
<?php $__env->startSection('title','Report Generate'); ?>
<?php $__env->startPush('styles'); ?>
    <style>
        .accordion-button:not(.collapsed) {
            color: var(--bs-accordion-active-color);
            background-color: #fff !important;
            box-shadow: none;
        }



        .accordion-item label {
            font-size: 14px !important;
        }

        .disease-select, .disease-select option {
            font-size: 14px;
        }

        .accordion-button {
            padding: 5px !important;
        }

        .accordion-body {
            padding: 5px !important;
        }

        li {
            list-style-type: none;
        }

        .cm_grid {
            display: flex;
        }

        .full_report {
            position: relative;
        }

        .print-button {
            position: absolute;
            top: 7vh;
            right: 16px;
        }

        #printsection strong {
            color: #6E7796;
            font-size: 14px;
            font-style: normal;
            font-weight: 600;
            line-height: normal;
        }

        #printsection span {
            color: #0050C9;
            font-size: 14px;
            font-style: normal;
            font-weight: 400;
            line-height: normal;
        }

        .report-status {
            color: #000;
            font-size: 14px;
            font-style: normal;
            font-weight: 700;
            margin: 0;
            line-height: 20px; /* 142.857% */
        }

        .mini_hight {
            min-height: 65px;
        }
    </style>
<?php $__env->stopPush(); ?>

<?php
    $farm_id = request()->get('farmCheck');
    $herd_id = request()->get('herdCheck');
    $lot_id = request()->get('lotCheck');
    $sex = request()->get('sex');
    $status = request()->get('status');
    $adult_status = request()->get('adult_status');
    $start_date = request()->get('start_date');
    $end_date = request()->get('end_date');
    $calving_interval = \App\Models\ActionPerameter::get('expected_calving');
?>

<?php $__env->startSection('content'); ?>
    <div class="row mb-4">
        <div class="col-12">
            <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                <h4 class="mb-sm-0 font-size-18">All Report Generate</h4>
            </div>
        </div>
    </div>
    <div class="d-xl-flex">
        <div class="w-100">
            <div class="d-md-flex">
                <div class="card filemanager-sidebar me-md-2">
                    <div class="card-body table_card">
                        <div class="d-flex flex-column h-100">
                            <div class="mb-4">
                                <form action="<?php echo e(route('general.report')); ?>" method="GET" role="form" id="form1"
                                      enctype="multipart/form-data" autocomplete="off">
                                    <div class="accordion accordion-flush" id="accordionPanelsStayOpenExample">
                                        <div class="accordion-item p-2">
                                            <h2 class="accordion-header">
                                                <button class="accordion-button" type="button" data-bs-toggle="collapse"
                                                        data-bs-target="#panelsStayOpen-collapseOne"
                                                        aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
                                                    Farms
                                                </button>
                                            </h2>
                                            <div id="panelsStayOpen-collapseOne"
                                                 class="accordion-collapse collapse show">
                                                <div class="accordion-body">
                                                    <div class="form-check">
                                                        <input class="form-check-input" type="checkbox"
                                                               id="farmCheckAll">
                                                        <label class="form-check-label" for="farmCheckAll"> All</label>
                                                    </div>
                                                    <?php $__currentLoopData = $farms; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $farm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <div class="form-check">
                                                            <input class="form-check-input farm-list" type="checkbox"
                                                                   name="farmCheck[]" id="farmCheck<?php echo e($farm->id); ?>"
                                                                   value="<?php echo e($farm->id); ?>" onChange="getHerd();">
                                                            <label class="form-check-label"
                                                                   for="farmCheck<?php echo e($farm->id); ?>"> <?php echo e($farm->name); ?></label>
                                                        </div>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="accordion-item p-2 ">
                                            <h2 class="accordion-header">
                                                <button class="accordion-button " type="button"
                                                        data-bs-toggle="collapse"
                                                        data-bs-target="#panelsStayOpen-collapseTwo"
                                                        aria-expanded="false"
                                                        aria-controls="panelsStayOpen-collapseTwo">
                                                    Herds
                                                </button>
                                            </h2>
                                            <div id="panelsStayOpen-collapseTwo"
                                                 class="accordion-collapse collapse show">
                                                <div class="accordion-body" id="herd">
                                                    <div class="form-check">
                                                        <input class="form-check-input" type="checkbox"
                                                               id="herdCheckAll">
                                                        <label class="form-check-label" for="herdCheckAll"> All</label>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="accordion-item p-2">
                                            <h2 class="accordion-header">
                                                <button class="accordion-button " type="button"
                                                        data-bs-toggle="collapse"
                                                        data-bs-target="#panelsStayOpen-collapseThree"
                                                        aria-expanded="false"
                                                        aria-controls="panelsStayOpen-collapseThree">
                                                    Lots
                                                </button>
                                            </h2>
                                            <div id="panelsStayOpen-collapseThree"
                                                 class="accordion-collapse collapse show">
                                                <div class="accordion-body" id="lot">
                                                    <div class="form-check">
                                                        <input class="form-check-input" type="checkbox"
                                                               id="lotCheckAll">
                                                        <label class="form-check-label" for="lotCheckAll"> All</label>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <ul class="list-unstyled categories-list">
                                        <li class="mt-2  border-top pt-3">
                                            <div style="margin-left:12px">
                                                <label class="form-label" style="margin-right:15px"><input
                                                        class="form-check-input" type="radio" name="sex" checked
                                                        value="female"> Female</label>
                                                <label class="form-label">
                                                    <input class="form-check-input" type="radio" name="sex"
                                                           value="male"> Male
                                                </label>
                                            </div>
                                        </li>

                                        <li class="mt-2 border-top pt-3">
                                            <div style="margin-left:12px">
                                                <span id="adult_span">
                                                    <label class="form-label" style="margin-right:10px"><input
                                                            class="form-check-input" type="radio" name="status" checked
                                                            value="adult" id='adult'> Adult</label>
                                                </span>
                                                <span id="reproduction_stage_span">
                                                    <label class="form-label" style="margin-right:10px"><input
                                                            class="form-check-input" type="radio" name="status"
                                                            value="reproduction_stage" id='reproduction_stage' required> Reproduction Stage</label>
                                                </span>
                                                <span id="heifer_span">
                                                      <label class="form-label" style="margin-right:15px"><input
                                                              class="form-check-input" type="radio" name="status"
                                                              value="heifer" id="heifer"> Heifer</label>
                                                </span>
                                                <span id="bull_span">
                                                    <label class="form-label" style="margin-right:10px"><input
                                                            class="form-check-input" type="radio" name="status"
                                                            value="bull" id='bull'> Bull</label>
                                                </span>
                                                <label class="form-label">
                                                    <input class="form-check-input" type="radio" name="status"
                                                           value="calf">Calf</label>
                                            </div>
                                        </li>

                                        <li class="mt-2 border-top pt-3 option_hide">
                                            <div style="margin-left:12px">
                                                <label class="form-label">
                                                    <input class="form-check-input male_selected"
                                                           type="radio" name="adult_status"
                                                           value="open_unbred" required> Open Unbreed</label><br>
                                                <label class="form-label">
                                                    <input class="form-check-input male_selected"
                                                           type="radio" name="adult_status"
                                                           value="open_bred"> Open Breed</label><br>
                                                <label class="form-label">
                                                    <input class="form-check-input male_selected"
                                                           type="radio" name="adult_status"
                                                           value="pregnant"> Pregnant</label><br>
                                                <label class="form-label">
                                                    <input class="form-check-input male_selected"
                                                           type="radio" name="adult_status"
                                                           value="calving"> Calving</label><br>
                                                <label class="form-label">
                                                    <input class="form-check-input male_selected"
                                                           type="radio" name="adult_status"
                                                           value="milking"> Milking</label><br>
                                                <label class="form-label">
                                                    <input class="form-check-input male_selected"
                                                           type="radio" name="adult_status"
                                                           value="dry"> Dry</label><br>
                                            </div>
                                        </li>
                                        <li class="mt-2 border-top pt-3 date_hide">
                                            <div class="col-12 p-3">
                                                <div class="input-daterange input-group" id="project-date-inputgroup"
                                                     data-provide="datepicker" data-date-format="dd/mm/yyyy"
                                                     data-date-container='#project-date-inputgroup'
                                                     data-date-autoclose="true">
                                                    <input type="text" class="form-control custom-date-format"
                                                           placeholder="Start Date" name="start_date" id="start_date"/>
                                                    <input type="text" class="form-control custom-date-format"
                                                           placeholder="End Date" name="end_date" id="end_date"/>
                                                </div>
                                            </div>
                                        </li>
                                        <li class="mt-4 p-3">
                                            <button type="submit" class="btn btn-primary"
                                                    style="background-color: #009A75; font-size: 0.9vw; color: #fff;">
                                                Search
                                            </button>
                                        </li>
                                    </ul>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="w-100">
                    <div class="card">
                        <div class="card-body table_card">
                            <div class="full_report">
                                <div class="">
                                    <div class="print-button">
                                        <button class="button print_btn" style="height: 45px;"><i class="print-ico"></i>
                                            Print
                                        </button>
                                    </div>
                                </div>
                                <?php if( $status === 'adult' && $adult_status === 'all'): ?>
                                    <div class="table-responsive">
                                        <div id="printsection">
                                            <div class="pb-2">
                                                <h5 class="font-size-16 me-3">All Report</h5>
                                                <p class="font-size-14 me-3"><strong
                                                        style="font-weight: 600;color: black">Date: <?php echo e(date('d-m-Y')); ?></strong>
                                                </p>
                                            </div>
                                            <?php if($farmSelected || $herdSelected || $lotSelected || $sex || $status): ?>
                                                <div class="p-2 ">
                                                    <div class="row mb-2  ">
                                                        <div class="col-sm">
                                                            <?php if(!empty($farmSelected)): ?>
                                                                <strong>Farm Name: </strong>
                                                                <?php $__currentLoopData = $farmSelected; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $f_select): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <?php $myArray[] = ucfirst($f_select->name); ?>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                <span style="color: #0050C9">
                                                                <?php echo e(implode( ',', $myArray )); ?>

                                                            </span>
                                                            <?php else: ?>
                                                                <strong>Farm Name: </strong>All Farms
                                                            <?php endif; ?>
                                                            <br>
                                                            <?php if(!empty($herdSelected)): ?>
                                                                <strong>Herd Name: </strong>
                                                                <?php $__currentLoopData = $herdSelected; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $h_select): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <?php $myArray1[] = ucfirst($h_select->name); ?>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                <span style="color: #0050C9">
                                                                <?php echo e(implode( ',', $myArray1 )); ?>

                                                                </span>
                                                            <?php else: ?>
                                                                <strong>Herd Name: </strong>All Herds
                                                            <?php endif; ?>
                                                            <br>
                                                            <?php if(!empty($lotSelected)): ?>
                                                                <strong>Lot Name: </strong>
                                                                <?php $__currentLoopData = $lotSelected; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $l_select): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <?php $myArray2[] = ucfirst($l_select->name); ?>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                <span style="color: #0050C9">
                                                                <?php echo e(implode( ',', $myArray2 )); ?>

                                                                </span>
                                                            <?php else: ?>
                                                                <strong>Lot Name: </strong>All Lots
                                                            <?php endif; ?>
                                                        </div>
                                                        <div class="col-sm text-center">
                                                            <?php if($sex): ?>
                                                                <strong>Sex: </strong>
                                                                <span
                                                                    style="text-transform: capitalize;color: #0050C9;"><?php echo e($sex); ?></span>
                                                            <?php endif; ?>
                                                            <br>
                                                            <?php if($status): ?>
                                                                <strong>Status: </strong>
                                                                <span
                                                                    style="text-transform: capitalize;color: #0050C9;"><?php echo e($status); ?></span>
                                                            <?php endif; ?>
                                                            <br>
                                                            <?php if($adult_status): ?>
                                                                <strong>Adult Status: </strong>
                                                                <span
                                                                    style="text-transform: capitalize;color: #0050C9;"><?php echo e($adult_status); ?></span>
                                                            <?php endif; ?>
                                                        </div>
                                                        <div class="col-sm">
                                                            <div style="float: right">
                                                                <?php if($start_date): ?>
                                                                    <strong>Start Date: </strong>
                                                                    <?php echo e(\Carbon\Carbon::createFromFormat('d-m-Y', $start_date)->format('d-m-Y')); ?>

                                                                <?php endif; ?>
                                                                <br>
                                                                <?php if($end_date): ?>
                                                                    <strong>End Date: </strong>
                                                                    <?php echo e(\Carbon\Carbon::createFromFormat('d-m-Y', $end_date)->format('d-m-Y')); ?>

                                                                <?php endif; ?>
                                                                <br>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php endif; ?>
                                            <?php echo $__env->make('backend.report.general_component.open_unbred', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                            <?php echo $__env->make('backend.report.general_component.open_bred', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                            <?php echo $__env->make('backend.report.general_component.pregnant', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                            <?php echo $__env->make('backend.report.general_component.calving', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                            <?php echo $__env->make('backend.report.general_component.milking', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                            <?php echo $__env->make('backend.report.general_component.dry', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                        </div>
                                    </div>
                                <?php else: ?>
                                    <div class="table-responsive">
                                        <div id="printsection">
                                            <div class="p-3">
                                                <h5 class=" report-status me-3">
                                                    <?php if($adult_status ==='pregnant'): ?>
                                                        Pregnant
                                                    <?php elseif($adult_status ==='milking'): ?>
                                                        Milking
                                                    <?php elseif($adult_status ==='open'): ?>
                                                        Open
                                                    <?php elseif($adult_status ==='calving'): ?>
                                                        Calving
                                                    <?php elseif($adult_status ==='dry'): ?>
                                                        Dry
                                                    <?php elseif($adult_status ==='open_unbred'): ?>
                                                        Open Unbred
                                                    <?php elseif($adult_status ==='open_bred'): ?>
                                                        Open Bred
                                                    <?php else: ?>
                                                        All
                                                    <?php endif; ?> Report</h5>
                                                <p class="font-size-14 me-3"><strong
                                                        style="font-weight: 600;color: black">Date: <?php echo e(date('d-m-Y')); ?></strong>
                                                </p>
                                            </div>
                                            <div class="mini_hight">
                                                <?php if($farmSelected || $herdSelected || $lotSelected || $sex || $status): ?>
                                                    <div class="p-3 ">
                                                        <div class="cm_grid mb-2">
                                                            <div>
                                                                <strong>Showing data for -</strong>
                                                            </div>
                                                            <div>
                                                                <?php if(!empty($farmSelected)): ?>
                                                                    <strong>Farm Name: </strong>
                                                                    <?php $__currentLoopData = $farmSelected; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $f_select): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <?php $myArray[] = ucfirst($f_select->name); ?>
                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                    <span style="color: #0050C9">
                                                                <?php echo e(implode( ',', $myArray )); ?>

                                                            </span>
                                                                <?php else: ?>
                                                                    <strong>Farm Name: </strong>All Farms
                                                                <?php endif; ?>
                                                                <br>
                                                                <?php if(!empty($herdSelected)): ?>
                                                                    <strong>Herd Name: </strong>
                                                                    <?php $__currentLoopData = $herdSelected; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $h_select): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <?php $myArray1[] = ucfirst($h_select->name); ?>
                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                    <span style="color: #0050C9">
                                                                <?php echo e(implode( ',', $myArray1 )); ?>

                                                                </span>
                                                                <?php else: ?>
                                                                    <strong>Herd Name: </strong>All Herds
                                                                <?php endif; ?>
                                                                <br>
                                                                <?php if(!empty($lotSelected)): ?>
                                                                    <strong>Lot Name: </strong>
                                                                    <?php $__currentLoopData = $lotSelected; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $l_select): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <?php $myArray2[] = ucfirst($l_select->name); ?>
                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                    <span style="color: #0050C9">
                                                                <?php echo e(implode( ',', $myArray2 )); ?>

                                                                </span>
                                                                <?php else: ?>
                                                                    <strong>Lot Name: </strong>All Lots
                                                                <?php endif; ?>
                                                            </div>
                                                            <div class="col-sm">
                                                                <div style="float: right">
                                                                    <?php if($start_date): ?>
                                                                        <strong>Start Date: </strong>
                                                                        <?php echo e($start_date); ?>

                                                                    <?php endif; ?>
                                                                    <br>
                                                                    <?php if($end_date): ?>
                                                                        <strong>End Date: </strong>
                                                                        <?php echo e($end_date); ?>

                                                                    <?php endif; ?>
                                                                    <br>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm mt-3 mb-3">
                                                                <?php if($sex): ?>
                                                                    <strong>Sex: </strong>
                                                                    <span
                                                                        style="text-transform: capitalize;color: #0050C9;"><?php echo e($sex); ?></span>
                                                                <?php endif; ?>
                                                                <br>
                                                                <?php if($status): ?>
                                                                    <strong>Status: </strong>
                                                                    <span
                                                                        style="text-transform: capitalize;color: #0050C9;"><?php echo e($status); ?></span>
                                                                <?php endif; ?>
                                                                <br>
                                                                <?php if($adult_status): ?>
                                                                    <strong>Breeding Status: </strong>
                                                                    <span
                                                                        style="text-transform: capitalize;color: #0050C9;"><?php echo e($adult_status); ?></span>
                                                                <?php endif; ?>
                                                            </div>
                                                        </div>
                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                            <table class="table table-bordered dt-responsive nowrap w-100"
                                                   data-table="simpleReportTable">
                                                <thead>
                                                <tr>
                                                    <th scope="col">No</th>
                                                    <th scope="col">Tag ID</th>
                                                    <th scope="col">Age</th>
                                                    <?php if( $status === 'adult' && $adult_status === 'pregnant'): ?>
                                                        <th scope="col">Total Pregnancy</th>
                                                        <th scope="col">Expected Calving Date</th>
                                                    <?php endif; ?>
                                                    <?php if( $status === 'adult' && $adult_status === 'milking'): ?>
                                                        <th scope="col">Lactaion Period</th>
                                                        <th scope="col">Total Lactaion Yield(L.)</th>
                                                        <th scope="col">Avg Lactaion Yield(L.)</th>
                                                    <?php endif; ?>
                                                    <?php if( $status === 'adult' && $adult_status === 'dry'): ?>
                                                        <th scope="col">Total Dry</th>
                                                        <th scope="col">Last Dry Date</th>
                                                    <?php endif; ?>
                                                    <?php if( $status === 'adult' && $adult_status === 'calving'): ?>
                                                        <th scope="col">Gender</th>
                                                        <th scope="col">Last Calving Status</th>
                                                        <th scope="col">Total Calving</th>
                                                        <th scope="col">Last Calving Date</th>
                                                    <?php endif; ?>
                                                    <?php if( $status === 'adult' && $adult_status === 'open_bred'): ?>
                                                        <th scope="col">Total AI</th>
                                                        <th scope="col">Last AI Date</th>
                                                    <?php endif; ?>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <?php $__empty_1 = true; $__currentLoopData = $cattles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                                    <tr>
                                                        <td><?php echo e($key+1); ?></td>
                                                        <td><?php echo e($item->tag->uid); ?></td>
                                                        <td><?php echo e(($item->birth_date) ? \Carbon\Carbon::parse($item->birth_date)->diff(\Carbon\Carbon::now())->format('%y Y, %m M, %d D') : 'N/A'); ?></td>
                                                        <?php if( $status === 'adult' && $adult_status === 'pregnant'): ?>
                                                            <td><?php echo e(($item->total_pregnant) ?? '0'); ?></td>
                                                            <?php
                                                                $expected_calving = null;
                                                                if ($item['id']) {
                                                                    $ai_cattle = \App\Models\ArtificialInsemination::where('cattle_id', $item['id'])->get()->last();
                                                                    if($ai_cattle) {
                                                                       $expected_calving =  \Carbon\Carbon::parse($ai_cattle['heat_date'])->addDays($calving_interval)->format('d-m-Y');
                                                                    }else {
                                                                        $expected_calving =  \Carbon\Carbon::parse($item['ai_date'])->addDays($calving_interval)->format('d-m-Y');
                                                                    }
                                                                }
                                                            ?>
                                                            <td><?php echo e(($expected_calving) ?? 'N/A'); ?></td>
                                                        <?php endif; ?>
                                                        <?php if( $status === 'adult' && $adult_status === 'milking'): ?>
                                                            <td><?php echo e(($item->total_day) ?? '0'); ?></td>
                                                            <td><?php echo e(($item->total_milk) ? number_format($item->total_milk, 2) : '0'); ?></td>
                                                            <td><?php echo e(($item->total_milk && $item->total_day) ? number_format((float)($item->total_milk/$item->total_day), 2) : '0'); ?></td>
                                                        <?php endif; ?>
                                                        <?php if( $status === 'adult' && $adult_status === 'dry'): ?>
                                                            <td><?php echo e(($item->total_dry) ?? '0'); ?></td>
                                                            <td><?php echo e(($item->dry_date) ? \Carbon\Carbon::createFromFormat('Y-m-d', $item->dry_date)->format('d-m-Y') : 'N/A'); ?></td>
                                                        <?php endif; ?>
                                                        <?php if( $status === 'adult' && $adult_status === 'calving'): ?>
                                                            <td><?php echo e(($item->calf_sex) ?? 'N/A'); ?></td>
                                                            <td><?php echo e(($item->last_calving_status) ?? 'N/A'); ?></td>
                                                            <td><?php echo e(($item->total_calving) ? $item->total_calving + ($item->no_of_calving ?? 0) : (($item->no_of_calving) ?? '0')); ?></td>
                                                            <td><?php echo e(($item->calving_date) ? \Carbon\Carbon::createFromFormat('Y-m-d', $item->calving_date)->format('d-m-Y') : 'N/A'); ?></td>
                                                        <?php endif; ?>
                                                        <?php if( $status === 'adult' && $adult_status === 'open_bred'): ?>
                                                            <td><?php echo e(($item->total_heat) ?? '0'); ?></td>
                                                            <td><?php echo e(($item->heat_date) ? \Carbon\Carbon::createFromFormat('Y-m-d', $item->heat_date)->format('d-m-Y') : 'N/A'); ?></td>
                                                        <?php endif; ?>
                                                    </tr>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                                    <tr>
                                                        <td colspan="6" class="text-center">No Cattles Found</td>
                                                    </tr>
                                                <?php endif; ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('scripts'); ?>
    <script type="text/javascript">
        $(document).ready(function ($) {
            $('.print_btn').click(function (e) {
                e.preventDefault();
                $("#printsection").print();
            });
            var sex = $(this).val();
            if (sex === 'male') {
                $('#adult').prop('checked', false);
                $('#heifer').prop('checked', false);
                document.getElementById('adult_span').style.display = "none";
                document.getElementById('heifer_span').style.display = "none";
                document.getElementById('reproduction_stage_span').style.display = "inline";
                document.getElementById('bull_span').style.display = "inline";
                $('.option_hide').addClass("d-none");
            } else {
                $('#bull').prop('checked', false);
                $('#reproduction_stage').prop('checked', false);
                document.getElementById('reproduction_stage_span').style.display = "none";
                document.getElementById('bull_span').style.display = "none";
                document.getElementById('adult_span').style.display = "inline";
                document.getElementById('heifer_span').style.display = "inline";
                $('.male_selected').attr("disabled", false);
                $('.option_hide').removeClass("d-none");
            }

            $('#farmCheckAll').click(function () {
                if ($(this).is(':checked')) {
                    $('input[name="farmCheck[]"]').prop('checked', true);
                } else {
                    $('input[name="farmCheck[]"]').prop('checked', false);
                }
            });

            $('#herdCheckAll').click(function () {
                if ($(this).is(':checked')) {
                    $('input[name="herdCheck[]"]').prop('checked', true);
                } else {
                    $('input[name="herdCheck[]"]').prop('checked', false);
                }
            });

            $('#lotCheckAll').click(function () {
                if ($(this).is(':checked')) {
                    $('input[name="lotCheck[]"]').prop('checked', true);
                } else {
                    $('input[name="lotCheck[]"]').prop('checked', false);
                }
            });

            $("input[name$='sex']").click(function () {
                var sex = $(this).val();
                if (sex === 'male') {
                    $('#adult').prop('checked', false);
                    $('#heifer').prop('checked', false);
                    document.getElementById('adult_span').style.display = "none";
                    document.getElementById('heifer_span').style.display = "none";
                    document.getElementById('reproduction_stage_span').style.display = "inline";
                    document.getElementById('bull_span').style.display = "inline";
                    $('.option_hide').addClass("d-none");
                } else {
                    $('#bull').prop('checked', false);
                    $('#reproduction_stage').prop('checked', false);
                    document.getElementById('reproduction_stage_span').style.display = "none";
                    document.getElementById('bull_span').style.display = "none";
                    document.getElementById('adult_span').style.display = "inline";
                    document.getElementById('heifer_span').style.display = "inline";
                    $('.male_selected').attr("disabled", false);
                    $('.option_hide').removeClass("d-none");
                }
            });

            $("input[name$='status']").click(function () {
                var status = $(this).val();

                if (status === 'heifer' || status === 'calf' || status === 'bull' || status === 'reproduction_stage') {
                    $('.male_selected').attr("disabled", true);
                    $('.option_hide').addClass("d-none");
                } else {
                    $('.male_selected').attr("disabled", false);
                    $('.option_hide').removeClass("d-none");
                }
            });

            $("input[name$='adult_status']").click(function () {
                var adult_status = $(this).val();
                if (adult_status === 'open_unbred') {
                    $('.date_hide').addClass("d-none");
                } else {
                    $('.date_hide').removeClass("d-none");
                }
            });

        });

        function getHerd() {
            var str = '';
            var val = document.getElementsByClassName('farm-list');
            for (i = 0; i < val.length; i++) {
                if (val[i].checked) {
                    str += val[i].value + ',';
                }
            }

            $.ajax({
                type: "GET",
                url: "<?php echo e(url('system/report/general/get-herd-list')); ?>",
                data: 'farm_id=' + str,
                success: function (res) {
                    console.log(res);
                    if (res) {
                        $("#herd").empty().html(res.herdoutput);
                        $("#lot").empty().html(res.lotoutput);
                    } else {
                        $("#herd").empty();
                        $("#lot").empty();
                    }
                }
            });
        }

        function getLot() {
            var str = '';
            var val = document.getElementsByClassName('herd-list');
            for (i = 0; i < val.length; i++) {
                if (val[i].checked) {
                    str += val[i].value + ',';
                }
            }
            $.ajax({
                type: "GET",
                url: "<?php echo e(url('system/report/general/get-lot-list')); ?>",
                data: 'herd_id=' + str,
                success: function (res) {
                    if (res) {
                        $("#lot").empty().html(res.lotoutput);
                    } else {
                        $("#lot").empty();
                    }
                }
            });
        }

        $("#print").click(function () {
            var printContents = document.getElementById("generalReportPdf").innerHTML;
            var printStyle = '<style>@page {size: auto;margin: 0mm;}</style>';
            var printDiv = '<div id="order-details-wrapper" style="padding: 20px;">' + printStyle + printContents + '</div>';
            document.body.innerHTML = printDiv;
            var originalContents = document.body.innerHTML;
            window.print();
            document.body.innerHTML = originalContents;
            location.reload();
        });
    </script>
<?php $__env->stopPush(); ?>

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