<?php $__env->startSection('content'); ?>
    <div class="row gy-4">
        <!-- Filter Section -->
        <div class="col-12">
            <div class="show-filter text-end">
                <button type="button" class="btn btn--base showFilterBtn btn-sm">
                    <i class="las la-filter"></i> <?php echo app('translator')->get('Filter'); ?>
                </button>
            </div>
            <div class="card responsive-filter-card custom--card mt-4 mt-md-0">
                <div class="card-body p-3">
                    <form action="" method="GET">
                        <div class="d-flex flex-wrap row-gap-3 column-gap-4">
                            <!-- Search Filter (Order Number / Buyer/Seller) -->
                            <div class="flex-grow-1">
                                <label class="form-label form--label">
                                    <?php if(request()->routeIs('user.seller.sale.software.log')): ?>
                                        <?php echo app('translator')->get('Order Number / Buyer / Software Name'); ?>
                                    <?php else: ?>
                                        <?php echo app('translator')->get('Order Number / Seller / Software Name'); ?>
                                    <?php endif; ?>
                                </label>
                                <input class="form-control form--control" type="text" name="search"
                                    value="<?php echo e(request()->search); ?>">

                                <input type="hidden" name="type"
                                    value="<?php echo e(request()->routeIs('user.seller.sale.software.log') ? 'buyer' : 'seller'); ?>">
                            </div>

                            <!-- Sort By Filter (Price) -->
                            <div class="flex-grow-1 min-w-150">
                                <label class="form-label form--label"><?php echo app('translator')->get('Sort By'); ?></label>
                                <select class="form-select form--select select2-basic" name="sort_by">
                                    <option value=""><?php echo app('translator')->get('Default'); ?></option>
                                    <option value="price_asc" <?php if(request()->sort_by == 'price_asc'): echo 'selected'; endif; ?>>
                                        <?php echo app('translator')->get('Price: Low to High'); ?>
                                    </option>
                                    <option value="price_desc" <?php if(request()->sort_by == 'price_desc'): echo 'selected'; endif; ?>>
                                        <?php echo app('translator')->get('Price: High to Low'); ?>
                                    </option>
                                </select>
                            </div>

                            <!-- Filter Button -->
                            <div class="flex-grow-1 align-self-end">
                                <button class="btn btn--base w-100 h-100 h-50 ">
                                    <i class="las la-filter"></i> <?php echo app('translator')->get('Filter'); ?>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-12">
            <div class="table-section">
                <div class="table-area">
                    <table class="table table--custom table-responsive--xl">
                        <thead>
                            <tr>
                                <th><?php echo app('translator')->get('Software'); ?></th>
                                <th><?php echo app('translator')->get('Order Number'); ?></th>
                                <?php if(request()->routeIs('user.buyer.software.log')): ?>
                                    <th><?php echo app('translator')->get('Seller'); ?></th>
                                <?php else: ?>
                                    <th><?php echo app('translator')->get('Buyer'); ?></th>
                                <?php endif; ?>
                                <th><?php echo app('translator')->get('Price'); ?></th>
                                <th><?php echo app('translator')->get('Status'); ?></th>
                                <?php if(request()->routeIs('user.buyer.software.log')): ?>
                                    <th><?php echo app('translator')->get('Action'); ?></th>
                                <?php endif; ?>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $softwareLog; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td class="text-start">
                                        <div class="author-info">
                                            <div class="thumb">
                                                <img src="<?php echo e(poster(@$log->software->image ? getFilePath('software') . '/' . @$log->software->image : 'assets/images/default.png', false)); ?>"
                                                    alt="<?php echo app('translator')->get('Software Image'); ?>">
                                            </div>
                                            <div class="content">
                                                <a href="<?php echo e(route('software.details', [slug($log->software->name), $log->software->id])); ?>"
                                                    data-bs-toggle="tooltip" data-bs-placement="top"
                                                    title="<?php echo e(__($log->software->name)); ?>">
                                                    <span><?php echo e(__(strLimit($log->software->name, 30))); ?></span>
                                                </a>
                                            </div>
                                        </div>
                                    </td>
                                    <td><?php echo e(__($log->order_number)); ?></td>

                                    <?php if(request()->routeIs('user.buyer.software.log')): ?>
                                        <td>
                                            <div>
                                                <span class="fw-bold"><?php echo e(__($log->seller->fullname)); ?></span>
                                                <br>
                                                <span class="text--info">
                                                    <a href="<?php echo e(route('public.profile', $log->seller->username)); ?>">
                                                        <span>@</span><?php echo e($log->seller->username); ?>

                                                    </a>
                                                </span>
                                            </div>
                                        </td>
                                    <?php else: ?>
                                        <td>
                                            <div>
                                                <span class="fw-bold"><?php echo e(__($log->buyer->fullname)); ?></span>
                                                <br>
                                                <span class="text--info">
                                                    <a href="<?php echo e(route('public.profile', $log->buyer->username)); ?>">
                                                        <span>@</span><?php echo e($log->buyer->username); ?>

                                                    </a>
                                                </span>
                                            </div>
                                        </td>
                                    <?php endif; ?>

                                    <td class="text-md-center">
                                        <div>
                                            <?php if($log->discount > 0): ?>
                                                <span data-bs-toggle="tooltip" data-bs-placement="top"
                                                    title="<?php echo app('translator')->get('Price'); ?>"><?php echo e(showAmount($log->price)); ?></span>
                                                - <span class="text--danger" data-bs-toggle="tooltip"
                                                    data-bs-placement="top"
                                                    title="<?php echo app('translator')->get('Discount'); ?>"><?php echo e(showAmount($log->discount)); ?></span>
                                                <br>
                                                <strong data-bs-toggle="tooltip" data-bs-placement="top"
                                                    title="<?php echo app('translator')->get('Final Price'); ?>">
                                                    <?php echo e(showAmount($log->price - $log->discount)); ?>

                                                </strong>
                                            <?php else: ?>
                                                <strong data-bs-toggle="tooltip" data-bs-placement="top"
                                                    title="<?php echo app('translator')->get('Price'); ?>">
                                                    <?php echo e(showAmount($log->price)); ?>

                                                </strong>
                                            <?php endif; ?>
                                        </div>
                                    </td>

                                    <td>
                                        <?php if($log->status == Status::BOOKING_PAID): ?>
                                            <div>
                                                <span class="badge badge--success"><?php echo app('translator')->get('Paid'); ?></span>
                                                <br>
                                                <span><?php echo e(diffforhumans($log->updated_at)); ?></span>
                                            </div>
                                        <?php else: ?>
                                            <span class="badge badge--warning"><?php echo app('translator')->get('N/A'); ?></span>
                                        <?php endif; ?>
                                    </td>

                                    <?php if(request()->routeIs('user.buyer.software.log')): ?>
                                        <?php if($log->status == Status::BOOKING_PAID): ?>
                                            <td>
                                                <a href="<?php echo e(route('software.details', [slug($log->software->name), $log->software->id])); ?>?review=true"
                                                    class="btn btn--warning text-white btn-sm ms-1" data-bs-toggle="tooltip"
                                                    data-bs-placement="top" title="<?php echo app('translator')->get('Write a review'); ?>">
                                                    <i class="las la-star"></i>
                                                </a>
                                                <button class="btn btn--base text-white btn-sm ms-1 details-btn"
                                                    data-bs-toggle="tooltip" data-bs-placement="top"
                                                    data-url-software="<?php echo e(route('file.download', [encrypt($log->software->software_file), 'file'])); ?>"
                                                    data-url-documentation="<?php echo e(route('file.download', [encrypt($log->software->document_file), 'documentation'])); ?>"
                                                    title="<?php echo app('translator')->get('Download'); ?>">
                                                    <i class="las la-desktop"></i>
                                                </button>
                                            </td>
                                        <?php else: ?>
                                            <td><span class="badge badge--warning"><?php echo app('translator')->get('N/A'); ?></span></td>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="100%" class="text-center">
                                        <?php echo $__env->make('Template::partials.empty', [
                                            'message' => 'No software sales yet!',
                                        ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>

                    <!-- Pagination Links -->
                    <?php if($softwareLog->hasPages()): ?>
                        <?php echo e(paginateLinks($softwareLog)); ?>

                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>

    <?php if(request()->routeIs('user.buyer.software.log')): ?>
        <!-- Details Modal -->
        <div class="modal fade" id="detailsModal" tabindex="-1" aria-labelledby="detailsModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title"><?php echo app('translator')->get('Download'); ?></h5>
                        <span class="close" data-bs-dismiss="modal" aria-label="Close">
                            <i class="las la-times"></i>
                        </span>
                    </div>
                    <div class="modal-body">
                        <div id="detailsModalContent" class="row">
                            <!-- Software Section -->
                            <div class="col-md-6">
                                <div class="software-section mb-4">
                                    <h6 class="text--title mb-0"><?php echo app('translator')->get('Software'); ?></h6>
                                    <p class="small text-muted my-2"><?php echo app('translator')->get('Download the software you purchased.'); ?></p>
                                    <a href="#" id="softwareDownloadLink" class="btn btn--base btn--sm">
                                        <i class="las la-download"></i> <?php echo app('translator')->get('Download Software'); ?>
                                    </a>
                                </div>
                            </div>

                            <!-- Documentation Section -->
                            <div class="col-md-6">
                                <div class="documentation-section mb-4">
                                    <h6 class="text--title mb-0"><?php echo app('translator')->get('Documentation'); ?></h6>
                                    <p class="small text-muted my-2"><?php echo app('translator')->get('Get the documentation to understand usage and setup.'); ?></p>
                                    <a href="#" id="documentationDownloadLink" class="btn btn--base btn--sm">
                                        <i class="las la-download"></i> <?php echo app('translator')->get('Download Documentation'); ?>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?>


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

<?php $__env->startPush('script'); ?>
    <?php if(request()->routeIs('user.buyer.software.log')): ?>
        <script>
            (function($) {
                "use strict";

                $('.details-btn').on('click', function() {
                    // Get the URLs from data attributes
                    var urlSoftware = $(this).data('url-software');
                    var urlDocumentation = $(this).data('url-documentation');

                    // Populate the modal links
                    $('#softwareDownloadLink').attr('href', urlSoftware);
                    $('#documentationDownloadLink').attr('href', urlDocumentation);

                    // Show the modal
                    $('#detailsModal').modal('show');
                });
            })(jQuery);
        </script>
    <?php endif; ?>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('Template::layouts.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/mojibor/work.mojibor.com/core/resources/views/templates/basic/user/software_log.blade.php ENDPATH**/ ?>