<?php use Carbon\Carbon; ?>

<?php $__env->startSection('title',__('messages.milk_production')); ?>
<?php $__env->startSection('content'); ?>
    <!-- end page title -->
    <h2 class="ms-2 mb-3 card-title"> <?php echo e(__('messages.parlour_milk_production_list')); ?> </h2>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Milk Production.create')): ?>
        <div class="add-new-button-hidden">
            <button class="btn add_new_btn addMilk" data-bs-toggle="modal" data-bs-target="#parlourMilk">
                <i class="plus-ico"></i> <?php echo e(__('messages.add_milk')); ?>

            </button>
            <button class="btn add_new_btn addBulk" data-bs-toggle="modal" data-bs-target="#parlourMilkBulk">
                <i class="plus-ico"></i> <?php echo e(__('messages.bulk_entry')); ?>

            </button>
        </div>
    <?php endif; ?>
    <div class="card mt-3 m-lg-2">
        <div class="card-body mt-2 table_card">
            <table id="datatable-buttons" class="table table-bordered dt-responsive nowrap w-100"
                   data-table="dataTables">
                <thead>
                <tr>
                    <th rowspan="2"> <?php echo e(__('messages.sl')); ?></th>
                    <th rowspan="2"><?php echo e(__('messages.tag_id')); ?> </th>
                    <th rowspan="2"><?php echo e(__('messages.date')); ?></th>
                    <th colspan="3" class="text-center"><?php echo e(__('messages.morning')); ?></th>
                    <th colspan="3" class="text-center"><?php echo e(__('messages.evening')); ?></th>
                    <th rowspan="2"><?php echo e(__('messages.action')); ?></th>
                </tr>
                <tr>
                    <th><?php echo e(__('messages.milk_l')); ?></th>
                    <th><?php echo e(__('messages.fat')); ?></th>
                    <th> <?php echo e(__('messages.snf')); ?></th>
                    <th><?php echo e(__('messages.milk_l')); ?></th>
                    <th><?php echo e(__('messages.fat')); ?></th>
                    <th style="border-right: 1px solid var(--border-color)"><?php echo e(__('messages.snf')); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $productions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <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->date) ? Carbon::createFromFormat('Y-m-d', $item->date)->format('d-m-Y') : 'N/A'); ?></td>
                        <td><?php echo e(($item->morning) ?? 'N/A'); ?></td>
                        <td><?php echo e(($item->morning_fat) ?? 'N/A'); ?></td>
                        <td><?php echo e(($item->morning_snf) ?? 'N/A'); ?></td>
                        <td><?php echo e(($item->evening) ?? 'N/A'); ?></td>
                        <td><?php echo e(($item->evening_fat) ?? 'N/A'); ?></td>
                        <td><?php echo e(($item->evening_snf) ?? 'N/A'); ?></td>
                        <td class="center">
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Milk Production.edit')): ?>
                                <a data-url="<?php echo e(route('parlour-milk-productions.edit',$item->id)); ?>" role="button"
                                   class="btn btn-sm editButton">
                                    <i class="edit-ico"></i>
                                </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Milk Production.delete')): ?>
                                <a href="#" class="btn btn-sm"
                                   onclick="deletePost(<?php echo e($item->id); ?>)">
                                    <i class="delete-ico"></i>
                                    <form id="delete-form-<?php echo e($item->id); ?>"
                                          action="<?php echo e(route('parlour-milk-productions.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(); if ($__empty_1): ?>
                <?php endif; ?>

                </tbody>
            </table>
        </div>
    </div>
    <div class="modal fade" id="parlourMilk" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content p-5">
                <h1 class="modal-title fs-5"
                    id="exampleModalLabel"><?php echo e(__('messages.add_parlour_milk_production')); ?></h1>
                <p style="font-size: 16px;color: #6E7796;"> <?php echo e(__('messages.fill_all_information_below')); ?> </p>
                <div class="modal-body p-0 mt-3 createModal"></div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="parlourMilkEdit" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content p-5">
                <h1 class="modal-title fs-5"
                    id="exampleModalLabel"> <?php echo e(__('messages.edit_parlour_milk_production')); ?></h1>
                <p style="font-size: 16px;color: #6E7796;"> <?php echo e(__('messages.fill_all_information_below')); ?> </p>
                <div class="modal-body p-0 mt-3 modalEdit"></div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="parlourMilkBulk" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-xl modal-dialog-centered">
            <div class="modal-content p-5">
                <h1 class="modal-title fs-5"
                    id="exampleModalLabel"> <?php echo e(__('messages.add_parlour_milk_production')); ?></h1>
                <p style="font-size: 16px;color: #6E7796;"><?php echo e(__('messages.fill_all_information_below')); ?> </p>
                <div class="modal-body p-0 mt-3 createModalBulk"></div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script type="text/javascript">
        let morningValue = <?php echo e(config('perameters.daily_milk_production_morning')); ?>,
            eveningValue = <?php echo e(config('perameters.daily_milk_production_evening')); ?>;
        $('.addMilk').click(function () {
            axios.get("<?php echo e(url('system/parlour-milk-productions/create')); ?>").then(function (response) {
                $('.createModal').html(response.data);
            }).catch(function (error) {
                console.log(error)
            })
        })
        $('.addBulk').click(function () {
            axios.get("<?php echo e(route('parlour-milk-production.bulk-entry')); ?>").then(function (response) {
                $('.createModalBulk').html(response.data);
            }).catch(function (error) {
                console.log(error)
            })
        })
        $('.editButton').click(function () {
            let url = $(this).data('url');
            axios.get(url).then(function (response) {
                $('.modalEdit').html(response.data);
                $('#parlourMilkEdit').modal('show');
            }).catch(function (error) {
                console.log(error)
            })
        })
    </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/milk/parlour-milk/index.blade.php ENDPATH**/ ?>