
<?php $__env->startSection('title','Vaccination'); ?>
<?php $__env->startPush('styles'); ?>
    <style>
        .cm_grid {
            display: flex;
        }

        label {
            color: #1C274D;
            font-family: Mulish, sans-serif;
            font-size: 16px;
            font-style: normal;
            font-weight: 600;
            line-height: normal;
        }

        .cattle_info {
            height: 135px;
            overflow-y: scroll;
        }

        .farm_info span {
            color: #0050C9;
            font-size: 14px;
            font-style: normal;
            font-weight: 500;
            line-height: normal;
        }

        .farm_info strong {
            color: #1C274D;
            font-size: 14px;
            font-style: normal;
            font-weight: 500;
            line-height: normal;
        }

        .cattle_uid {
            color: #6E7796;
            font-size: 14px;
            font-style: normal;
            font-weight: 600;
            line-height: 24px; /* 171.429% */
        }
    </style>
<?php $__env->stopPush(); ?>
<?php
    $c_id = request()->get('tag');
    $v_id = request()->get('vaccine');
    $dose = request()->get('dose');
?>
<?php $__env->startSection('content'); ?>
    <h2 class="ms-2 mb-3 card-title">Vaccination List</h2>
    <div class="card mt-3 m-lg-2">
        <div class="card-body table_card mt-2">
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Vaccination.create')): ?>
                <div class="add-new-button-hidden">
                    <button class="btn add_new_btn" data-bs-toggle="modal" data-bs-target="#vaccination_add_modal"
                            ><i class="plus-ico"></i>Add Vaccination
                    </button>
                    <button class="btn add_new_btn" data-bs-toggle="modal" data-bs-target="#vaccination_bulk_modal"
                            ><i class="plus-ico"></i>Bulk Entry
                    </button>
                </div>
            <?php endif; ?>
            <table id="myTable" class="table table-bordered dt-responsive nowrap w-100">
                <thead>
                <tr>
                    <th><?php echo e(__('messages.sl')); ?></th>
                    <th>Tag ID</th>
                    <th>Vaccine Name</th>
                    <th>Vaccine Date</th>
                    <th>Type</th>
                    <th><?php echo e(__('messages.action')); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php $__currentLoopData = $vaccinations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e(++$key); ?></td>
                        <td><?php echo e(($item->cattle_id) ? $item->cattle->tag->uid : 'N/A'); ?></td>
                        <td><?php echo e(($item->vaccine_id) ? $item->vaccine->name : 'N/A'); ?></td>
                        <td><?php echo e(($item->vaccine_date) ? \Carbon\Carbon::createFromFormat('Y-m-d', $item->vaccine_date)->format('d-m-Y') : 'N/A'); ?></td>
                        <td><?php echo e(($item->dose) ?? 'N/A'); ?></td>
                        <td class="center">
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Vaccination.list')): ?>
                                <a view-id="<?php echo e($item->id); ?>" class="btn btn-sm view_btn" data-bs-toggle="offcanvas"
                                   data-bs-target="#offcanvasRight" aria-controls="offcanvasRight">
                                    <img src="<?php echo e(asset('assets/icons/svg/eye.svg')); ?>" alt="" srcset="">
                                </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Vaccination.edit')): ?>
                                <a data-id="<?php echo e($item->id); ?>" class="btn btn-sm edit-btn" data-bs-toggle="modal"
                                   data-bs-target="#vaccination_edit_modal">
                                    <img src="<?php echo e(asset('assets/icons/svg/edit.svg')); ?>" alt="" srcset="">
                                </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Vaccination.delete')): ?>
                                <a href="#" class="btn btn-sm" onclick="deletePost(<?php echo e($item->id); ?>)">
                                    <img src="<?php echo e(asset('assets/icons/svg/delete.svg')); ?>" alt="" srcset="">
                                    <form id="delete-form-<?php echo e($item->id); ?>"
                                          action="<?php echo e(route('vaccination.destroy', $item->id)); ?>" method="POST"
                                          style="display: none;">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                    </form>
                                </a>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
    </div>

    <div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasRight"
         aria-labelledby="offcanvasRightLabel">
        <div class="offcanvas-header">
            <button type="button" class="me-4" data-bs-dismiss="offcanvas" aria-label="Close"
                    style=" border: none;">
                <svg xmlns="http://www.w3.org/2000/svg" width="24"
                     height="24" viewBox="0 0 24 24" fill="none">
                    <path d="M20 11H7.83L13.42 5.41L12 4L4 12L12 20L13.41 18.59L7.83 13H20V11Z"
                          fill="black"/>
                </svg>
            </button>
            <h5 class="offcanvas-title" id="offcanvasRightLabel">Vaccination Details</h5>
        </div>
        <div class="offcanvas-body me-2 offcanva_data_view" style="width: 26rem;"></div>
    </div>

    
    <div class="modal fade" id="vaccination_add_modal" tabindex="-1" aria-labelledby="exampleModalLabel"
         aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content p-5">
                <h4 class="card-title">Add Vaccination Information</h4>
                <div class="modal-body p-0 mt-3">
                    <form action="<?php echo e(route('vaccination.store')); ?>" method="POST" autocomplete="off">
                        <?php echo csrf_field(); ?>
                        <div class="row mb-2">
                            <div class="col-md-6">
                                <label class="form-label" for="cattle_id">Tag ID <span
                                        class="text-danger">*</span></label> <br>
                                <select class="form-control add-modal <?php $__errorArgs = ['cattle_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                        name="cattle_id" id="cattle_id" style="width: 100%" required>
                                    <option value="">Select Tag Id</option>
                                    <?php $__currentLoopData = $cattles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option
                                            value="<?php echo e($value->id); ?>"><?php echo e($value->tag->uid); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label" for="disease_id">Disease Name <span
                                        class="text-danger">*</span></label>
                                <select class="form-control add-modal <?php $__errorArgs = ['disease_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                        name="disease_id" id="disease_id" style="width: 100%" required>
                                    <option value="">Select Disease</option>
                                    <?php $__currentLoopData = $diseases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($item->id); ?>"><?php echo e($item->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="vaccine_id">Vaccine Name <span
                                        class="text-danger">*</span></label>
                                <select class="form-control select2-multiple <?php $__errorArgs = ['vaccine_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                        name="vaccine_id" id="vaccine_id" required>
                                    <option value="">Select Vaccine</option>
                                    <?php $__currentLoopData = $vaccines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option
                                            value="<?php echo e($item->id); ?>" <?php echo e((($v_id) && ($v_id === $item->id)) ? 'selected' : ''); ?>><?php echo e($item->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="vaccine_date">Vaccine Date <span
                                        class="text-danger">*</span></label>
                                <input type="text"
                                       class="form-control custom-date-format <?php $__errorArgs = ['vaccine_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                       name="vaccine_date" id="vaccine_date" value="<?php echo e(old('vaccine_date')); ?>"
                                       placeholder="Pick vaccine date" required/>
                            </div>
                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="cost">Cost</label>
                                <input type="text" class="form-control" name="cost" id="cost" value="<?php echo e(old('cost')); ?>"
                                       placeholder="Enter cost"/>
                            </div>
                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="route">Route/Method</label>
                                <select class="form-control" name="route" id="route">
                                    <option value="">Select Route</option>
                                    <option value="Subcutaneous">Subcutaneous</option>
                                    <option value="Intramuscular">Intramuscular</option>
                                    <option value="Oral">Oral</option>
                                    <option value="IV">IV</option>
                                </select>
                            </div>
                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="dose">Type <span class="text-danger">*</span></label>
                                <select class="form-control" name="dose" id="dose" required>
                                    <option value="">Select Type</option>
                                    <option
                                        value="First Dose" <?php echo e((($dose==='First Dose')) ? 'selected' : ''); ?>>
                                        First Dose
                                    </option>
                                    <option
                                        value="Booster Dose" <?php echo e((($dose==='Booster Dose')) ? 'selected' : ''); ?>>
                                        Booster Dose
                                    </option>
                                    <option
                                        value="Regular Dose" <?php echo e((($dose==='Regular Dose')) ? 'selected' : ''); ?>>
                                        Regular Dose
                                    </option>
                                </select>
                            </div>

                            <div class="col-md-6 mt-2">
                                <div class="form-group">
                                    <label class="form-label" for="vaccinated_by">Vaccinated By</label>
                                    <select class="form-control" name="vaccinated_by" id="vaccinated_by">
                                        <option value="">Select Vaccinated By</option>
                                        <?php $__currentLoopData = $inseminators; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($item->id); ?>"><?php echo e($item->name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="mt-5 d-flex justify-content-end ">
                            <button type="button" class="btn  me-2" data-bs-dismiss="modal"
                                    style="background: #EAECF0;">
                                <?php echo e(__('messages.close')); ?>

                            </button>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Vaccination.create')): ?>
                                <button type="submit" class="btn btn-primary" >
                                    Save
                                </button>
                            <?php endif; ?>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>
    
    
    <div class="modal fade" id="vaccination_edit_modal" tabindex="-1" aria-labelledby="exampleModalLabel"
         aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content p-5">
                <h4 class="card-title">Add Vaccination Information</h4>
                <div class="modal-body p-0 mt-3">
                    <form action="<?php echo e(route('vaccinations_update')); ?>" method="POST" autocomplete="off">
                        <?php echo csrf_field(); ?>
                        <div class="row mb-2">
                            <div class="col-md-6">
                                <label class="form-label" for="cattle_id_edit">Tag ID <span class="text-danger">*</span></label>
                                <br>
                                <select class="form-control mySelect2 <?php $__errorArgs = ['cattle_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                        name="cattle_id" id="cattle_id_edit" style="width: 100%" required>

                                </select>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label" for="disease_id_edit">Disease Name <span
                                        class="text-danger">*</span></label>
                                <select class="form-control mySelect2 <?php $__errorArgs = ['disease_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                        name="disease_id" id="disease_id_edit" style="width: 100%" required>
                                </select>
                            </div>

                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="vaccine_id_edit">Vaccine Name <span
                                        class="text-danger">*</span></label>
                                <select class="form-control select2-multiple <?php $__errorArgs = ['vaccine_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                        name="vaccine_id" id="vaccine_id_edit" required>

                                </select>
                            </div>
                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="vaccine_date_edit">Vaccine Date <span
                                        class="text-danger">*</span></label>
                                <input type="text"
                                       class="form-control custom-date-format <?php $__errorArgs = ['vaccine_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                       name="vaccine_date" id="vaccine_date_edit" required/>
                            </div>

                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="cost_edit">Cost</label>
                                <input type="text" class="form-control" name="cost" id="cost_edit"/>
                            </div>

                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="route_edit">Route/Method</label>
                                <select class="form-control" name="route" id="route_edit">

                                </select>
                            </div>
                            <div class="col-md-6 mt-2">
                                <label class="form-label" for="dose_edit">Type <span
                                        class="text-danger">*</span></label>
                                <select class="form-control" name="dose" id="dose_edit" required></select>
                            </div>
                            <input type="hidden" name="vaccination_id" id="vaccination_id">
                            <div class="col-md-6 mt-2">
                                <div class="form-group">
                                    <label class="form-label" for="vaccinated_by_edit">Vaccinated By</label>
                                    <select class="form-control" name="vaccinated_by" id="vaccinated_by_edit"></select>
                                </div>
                            </div>
                        </div>
                        <div class="mt-5 d-flex justify-content-end ">
                            <button type="button" class="btn  me-2" data-bs-dismiss="modal"
                                    style="background: #EAECF0;">
                                <?php echo e(__('messages.close')); ?>

                            </button>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Vaccination.create')): ?>
                                <button type="submit" class="btn btn-primary" >
                                    Update
                                </button>
                            <?php endif; ?>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>
    

    
    <div class="modal fade" id="vaccination_bulk_modal" tabindex="-1" aria-labelledby="exampleModalLabel"
         aria-hidden="true">
        <div class="modal-dialog modal-xl modal-dialog-centered">
            <div class="modal-content p-5">
                <h4 class="card-title">Bulk Entry - Vaccination Information</h4>
                <div class="modal-body p-0 mt-3">
                    <div class="cm_row mt-2">
                        <div class="">
                            <div class="form-group">
                                <label class="form-label" for="farm">Farm Name</label>
                                <select class="form-control <?php $__errorArgs = ['farms'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="farm"
                                        id="farm">
                                    <?php if(count($farms) > 0): ?>
                                        <option selected value="">Select Farm</option>
                                        <?php $__currentLoopData = $farms; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($item->id); ?>"><?php echo e($item->name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="">
                            <div class="form-group">
                                <label class="form-label" for="herd">Herd Name</label>
                                <select class="form-control <?php $__errorArgs = ['herd'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="herd"
                                        id="herd">
                                </select>
                            </div>
                        </div>
                        <div class="">
                            <div class="form-group">
                                <label class="form-label" for="lot">Lot Name</label>
                                <select class="form-control <?php $__errorArgs = ['lots'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="lot"
                                        id="lot">
                                </select>
                            </div>
                        </div>
                        <div class="">
                            <div class="form-group pt-4" style="margin-top: 6px;">
                                <button type="button" id="get-data-btn"
                                        class="btn btn-primary" disabled="disabled" style="background-color: #009A75; color: #fff">
                                    Get Data
                                </button>
                            </div>
                        </div>
                    </div>

                    <form action="<?php echo e(route('vaccinations.bulk-entry-store')); ?>" method="POST" role="form" id="form1"
                          enctype="multipart/form-data" autocomplete="off">
                        <?php echo csrf_field(); ?>
                        <div class="no_data mt-5 w-100 text-center" hidden>
                            <h6>No Data Found</h6>
                        </div>
                        <div class="row mt-5" id="bulk_entry_field" hidden>
                            <div class="col-md-12">
                                <div class="cm_grid">
                                    <div>
                                        <h6 style="font-size: 14px; color: #6E7796;font-weight: 600;">Showing data for
                                            -</h6>
                                    </div>
                                    <div class="farm_info"></div>
                                </div>
                            </div>
                            <div class="col-md-12 mb-3">
                                <label class="form-label">Tag ID <span class="text-danger">*</span></label>
                                <div class="form-check">
                                    <label class="cattle_uid">
                                        <input type="checkbox" class="form-check-input" id="checkAll"> Select All
                                    </label>
                                </div>
                                <div class="row cattle_info" id="cattle_info"></div>
                            </div>
                            <div class="col-md-4 mt-2">
                                <label class="form-label" for="disease_id_bulk">Disease Name <span
                                        class="text-danger">*</span></label>
                                <select class="form-control select2-multiple <?php $__errorArgs = ['disease_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                        name="disease_id" id="disease_id_bulk" required>
                                    <option value="">Select Disease</option>
                                    <?php $__currentLoopData = $diseases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($item->id); ?>"><?php echo e($item->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-4 mt-2">
                                <label class="form-label" for="vaccine_id_bulk">Vaccine Name <span
                                        class="text-danger">*</span></label>
                                <select class="form-control select2-multiple <?php $__errorArgs = ['vaccine_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                        name="vaccine_id" id="vaccine_id_bulk" required>
                                    <option value="">Select Vaccine</option>
                                    <?php $__currentLoopData = $vaccines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option
                                            value="<?php echo e($item->id); ?>" <?php echo e((($v_id) && ($v_id === $item->id)) ? 'selected' : ''); ?>><?php echo e($item->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-4 mt-2">
                                <label class="form-label" for="vaccine_date_bulk">Vaccine Date <span
                                        class="text-danger">*</span></label>
                                <input type="text"
                                       class="form-control custom-date-format <?php $__errorArgs = ['vaccine_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                       name="vaccine_date" id="vaccine_date_bulk" value="<?php echo e(old('vaccine_date')); ?>"
                                       placeholder="Pick vaccine date" required/>
                            </div>
                            <div class="col-md-4 mt-2">
                                <label class="form-label" for="cost_bulk">Cost</label>
                                <input type="text" class="form-control" name="cost" id="cost_bulk"
                                       value="<?php echo e(old('cost')); ?>"
                                       placeholder="Enter cost"/>
                            </div>
                            <div class="col-md-4 mt-2">
                                <label class="form-label" for="route_bulk">Route/Method</label>
                                <select class="form-control" name="route" id="route_bulk">
                                    <option value="">Select Route</option>
                                    <option value="Subcutaneous">Subcutaneous</option>
                                    <option value="Intramuscular">Intramuscular</option>
                                    <option value="Oral">Oral</option>
                                    <option value="IV">IV</option>
                                </select>
                            </div>
                            <div class="col-md-4 mt-2">
                                <label class="form-label" for="dose_bulk">Type <span
                                        class="text-danger">*</span></label>
                                <select class="form-control" name="dose" id="dose_bulk" required>
                                    <option value="">Select Type</option>
                                    <option value="First Dose" <?php echo e((($dose === 'First Dose')) ? 'selected' : ''); ?>>
                                        First Dose
                                    </option>
                                    <option value="Booster Dose" <?php echo e((($dose === 'Booster Dose')) ? 'selected' : ''); ?>>
                                        Booster Dose
                                    </option>
                                    <option value="Regular Dose" <?php echo e((($dose === 'Regular Dose')) ? 'selected' : ''); ?>>
                                        Regular Dose
                                    </option>
                                </select>
                            </div>
                            <div class="form-group col-md-4 mt-2">
                                <label class="form-label" for="vaccinated_by_bulk">Vaccinated By</label>
                                <select class="form-control" name="vaccinated_by" id="vaccinated_by_bulk">
                                    <option value="">Select Vaccinated By</option>
                                    <?php $__currentLoopData = $inseminators; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($item->id); ?>"><?php echo e($item->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="mt-5 d-flex justify-content-end ">
                                <button type="button" class="btn  me-2" data-bs-dismiss="modal"
                                        style="background: #EAECF0;">Close
                                </button>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Vaccination.create')): ?>
                                    <button type="submit" class="btn btn-primary" >
                                        Save
                                    </button>
                                <?php endif; ?>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script type="text/javascript">
        $(document).ready(function ($) {
            $('.modal').on('hidden.bs.modal', function (e) {
                $(this).find("input,textarea,select").val('').end().find("input[type=checkbox], input[type=radio]").prop("checked", "").end();
                $('select').val("").trigger('change');
                $('#bulk_entry_field').prop('hidden', true);
                $('.no_data').prop('hidden', false);
            });

            $('.add-modal').select2({
                dropdownParent: $('#vaccination_add_modal'),
                width: 'resolve',
            });
            $('.mySelect2').select2({
                dropdownParent: $('#vaccination_edit_modal'),
                width: 'resolve',
            });

            $(document).on('click', '.view_btn', function () {
                let id = $(this).attr('view-id');
                $('.offcanva_data_view').empty();
                $.ajax({
                    type: "GET",
                    url: "<?php echo e(url('system/vaccination')); ?>/" + id,
                    success: function (res) {
                        $('.offcanva_data_view').append('<table class="table table-borderless w-100" style="border: none;">' +
                            ' <tr><th style="width: 30%;">Tag ID</th><td>' + res.uid + '</td></tr>' +
                            ' <tr><th style="width: 30%;">Animal Name</th><td></td></tr>' +
                            ' <tr><th style="width: 30%;">Disease Name</th><td>' + res.disease + '</td></tr>' +
                            ' <tr><th style="width: 30%;">Vaccine Name</th><td>' + res.vaccine_name + '</td></tr>' +
                            ' <tr><th style="width: 30%;">Vaccine Date</th><td>' + res.vaccine_date + '</td></tr>' +
                            '<tr><th style="width: 30%;">Route/Method</th><td>' + res.vaccine.route + '</td></tr>' +
                            '<tr><th style="width: 30%;">Dose</th><td>' + res.vaccine.dose + '</td></tr>' +
                            '<tr><th style="width: 30%;">Vaccinated By</th><td>' + (res.doctor === undefined ? 'null' : res.doctor) + '</td></tr>' +
                            '</table>')
                    },
                    error: function (response) {
                        console.log(response);
                    }
                });
            });

            $(document).on('click', '.edit-btn', function () {
                let id = $(this).attr('data-id');
                $('#cattle_id_edit').empty();
                $('#disease_id_edit').empty();
                $('#vaccine_id_edit').empty();
                $('#route_edit').empty();
                $('#dose_edit').empty();
                $('#vaccinated_by_edit').empty();
                $.ajax({
                    type: "GET",
                    url: "<?php echo e(url('system/vaccination')); ?>/" + id + "/edit",
                    success: function (res) {
                        $.each(res.cattles, function (index, value) {
                            $('#cattle_id_edit').append('<option value="' + value.id + '" ' + (value.id === res.vaccine.cattle_id ? 'selected' : '') + '>' + value.uid + '</option>');

                        });
                        $.each(res.diseases, function (index, value) {
                            $('#disease_id_edit').append('<option value="' + value.id + '" ' + (value.id === res.vaccine.disease_id ? 'selected' : '') + '>' + value.name + '</option>');
                        });
                        $.each(res.vaccines, function (index, value) {
                            $('#vaccine_id_edit').append('<option value="' + value.id + '" ' + (value.id === res.vaccine.vaccine_id ? 'selected' : '') + '>' + value.name + '</option>');
                        });
                        $('#vaccine_date_edit').val(res.vaccine_date);
                        $('#cost_edit').val(res.vaccine.cost);
                        $('#vaccination_id').val(res.vaccine.id);
                        $('#route_edit').append('<option value="" selected disabled>--Select Route--</option>' +
                            '<option value="Subcutaneous" ' + ("Subcutaneous" === res.vaccine.route ? 'selected' : '') + '>Subcutaneous</option>' +
                            '<option value="Intramuscular" ' + ("Intramuscular" === res.vaccine.route ? 'selected' : '') + '>Intramuscular</option>' +
                            ' <option value="Oral" ' + ("Oral" === res.vaccine.route ? 'selected' : '') + '>Oral</option>' +
                            '<option value="IV" ' + ("IV" === res.vaccine.route ? 'selected' : '') + '>IV</option>');

                        $('#dose_edit').append('<option value="">--Select Type--</option>' +
                            '<option value="First Dose" ' + ("First Dose" === res.vaccine.dose ? 'selected' : '') + '>First Dose</option>' +
                            '<option value="Booster Dose"' + ("Booster Dose" === res.vaccine.dose ? 'selected' : '') + '>Booster Dose</option>' +
                            ' <option value="Regular Dose"' + ("Regular Dose" === res.vaccine.dose ? 'selected' : '') + '>Regular Dose</option>')
                        $.each(res.inseminators, function (index, value) {
                            $('#vaccinated_by_edit').append('<option value="' + value.id + '" ' + (value.id === res.vaccine.vaccinated_by ? 'selected' : '') + '>' + value.name + '</option>');
                        })
                    },
                    error: function (response) {
                        console.log(response);
                    }
                });
            });

            $("#checkAll").click(function () {
                $(".check").prop('checked', $(this).prop('checked'));
            });

            $('#farm').change(function () {
                var farm_id = $(this).val();
                if (farm_id) {
                    $.ajax({
                        type: "GET",
                        url: "<?php echo e(url('system/milk-production/get-herd-list')); ?>?farm_id=" + farm_id,
                        success: function (res) {
                            if (res) {
                                $('#get-data-btn').prop("disabled", false);
                                $("#herd").empty().append('<option>Select Herd</option>');
                                $.each(res, function (key) {
                                    $("#herd").append('<option value="' + res[key].id + '">' + res[key].name + '</option>');
                                });

                            } else {
                                $("#herd").empty();
                            }
                        }
                    });
                } else {
                    $("#herd").empty();
                    $("#lot").empty();
                }
            });
            $('#herd').on('change', function () {
                var lot_id = $(this).val();
                if (lot_id) {
                    $.ajax({
                        type: "GET",
                        url: "<?php echo e(url('system/milk-production/get-lot-list')); ?>?lot_id=" + lot_id,
                        success: function (res) {
                            if (res) {
                                $("#lot").empty().append('<option>Select Lot</option>');
                                $.each(res, function (key, value) {
                                    $("#lot").append('<option value="' + res[key].id + '">' + res[key].name + '</option>');
                                });

                            } else {
                                $("#lot").empty();
                            }
                        }
                    });
                } else {
                    $("#lot").empty();
                }
            });
            // get data method
            $('.no_data').prop('hidden', false);
            $('#get-data-btn').on('click', function () {
                let farm = $('#farm').val();
                let herd = $('#herd').val();
                let lot = $('#lot').val();
                $('.farm_info').empty();
                $('#cattle_info').empty();
                if (lot) {
                    $.ajax({
                        type: "GET",
                        url: "<?php echo e(route('vaccinations.get-data')); ?>",
                        data: {
                            farm: farm,
                            herd: herd,
                            lot: lot,
                        },
                        success: function (res) {
                            $('.farm_info').append('<p><strong>Farm Name : </strong><span>' + res.farm_info.name + '</span><br>' +
                                '<strong>Hard Name : </strong><span>' + res.herd_info.name + '</span><br>' +
                                '<strong>Lot Name : </strong><span>' + res.lot_info.name + '</span></p>');
                            if (res.cattles.length > 0) {
                                $('.no_data').prop('hidden', true);
                                $('#bulk_entry_field').prop('hidden', false);
                                $.each(chunkArray(res.cattles, 5), function (index, value) {
                                    $.each(value, function (index, item) {
                                        $('#cattle_info').append(
                                            '<div class="col-lg-3 col-md-1 col-sm-1">' +
                                            '<div class="form-check"><label class="cattle_uid"><input type="checkbox" class="form-check-input check" name="cattle_id[]" value="' + item.id + '"> ' + item.uid + '</label></div>' +
                                            '</div>'
                                        );
                                    })

                                });
                            } else {
                                $('#bulk_entry_field').prop('hidden', true);
                                $('.no_data').prop('hidden', false);
                            }
                        }
                    });
                } else {
                    $("#lot").empty();
                }
            });

            function chunkArray(array, size) {
                var result = [];
                for (var i = 0; i < array.length; i += size) {
                    result.push(array.slice(i, i + size));
                }
                return result;
            }
        });
    </script>
<?php $__env->stopPush(); ?>

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