
<?php $__env->startSection('title','Sold'); ?>

<?php $__env->startPush('styles'); ?>
    <style>
        .auc-sold {
            margin-right: 10px;
        }
        @media screen and (max-width: 460px) {
            .auc-sold {
                margin-right: 0;
                margin-top: 10px;
            }
        }
    </style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
    <h2 class="ms-2 card-title">Sold List</h2>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('cattle.list')): ?>
        <div class="add-new-button-hidden">
            <button class="btn add_new_btn disposal-add" data-bs-toggle="modal" data-type="regular"
                    data-bs-target="#disposalAddModal"
                    ><i class="plus-ico"></i> Add Regular Record
            </button>
            <button class="btn add_new_btn disposal-add" data-bs-toggle="modal" data-type="auction"
                    data-bs-target="#disposalAddModal"
                    ><i class="plus-ico"></i> Add Auction Record
            </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><?php echo e(__('messages.sl')); ?></th>
                    <th>Tag ID</th>
                    <th>Date</th>
                    <th>Price</th>
                    <th>Sold By</th>
                    <th><?php echo e(__('messages.action')); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php $__currentLoopData = $solds; $__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->tag->uid); ?>

                        </td>
                        <td><?php echo e(($item->date) ? \Carbon\Carbon::createFromFormat('Y-m-d', $item->date)->format('d-m-Y') : 'N/A'); ?></td>
                        <td><?php echo e(($item->price) ?? 'N/A'); ?></td>
                        <td><?php echo e(($item->sold_by) ? $item->solded_by->name : 'N/A'); ?></td>
                        <td class="center">
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('cattle.list')): ?>
                                <a role="button" data-url="<?php echo e(route('solds.edit',$item->id)); ?>"
                                   class="btn btn-sm edit-button">
                                    <i class="edit-ico"></i>
                                </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('cattle.list')): ?>
                                <a href="#" class="bt 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('solds.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="modal fade" id="disposalAddModal" 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">Add Sold Record</h1>
                <p style="font-size: 16px;color: #6E7796;">Fill all information to save sold Information </p>
                <div class="modal-body p-0 mt-3 addModal"></div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="disposalEditModal" 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">Update Sold Information</h1>
                <p style="font-size: 16px;color: #6E7796;">Fill all information to update sold Information </p>
                <div class="modal-body p-0 mt-3 editModal"></div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('scripts'); ?>
    <script>
        $('.disposal-add').click(function () {
            let type = $(this).data('type');
            axios.get("<?php echo e(url('system/disposal/solds/create?sold_type=')); ?>" + type).then(function (response) {
                $('.addModal').html(response.data);
            }).catch(function (error) {
                console.log(error)
            })
        })
        $('.edit-button').click(function () {
            let url = $(this).data('url');
            axios.get(url).then(function (response) {
                $('.editModal').html(response.data);
                $('#disposalEditModal').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\practice\ml_firm\resources\views/backend/disposal/sold/index.blade.php ENDPATH**/ ?>