
<?php $__env->startPush('styles'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('backEnd/css/custom.css')); ?>"/>
<?php $__env->stopPush(); ?>
<?php $__env->startSection('mainContent'); ?>
    <div class="row justify-content-center">
        <div class="col-12">
            <div class="box_header common_table_header">
                <div class="main-title d-md-flex">
                    <h3 class="mb-0 mr-30 mb_xs_15px mb_sm_20px"><?php echo e(__('purchase.Purchase Orders')); ?> </h3>
                     <?php if(permissionCheck('purchase_order.store')): ?>
                    <ul class="d-flex">
                        <li><a class="primary-btn radius_30px mr-10 fix-gr-bg"
                               href="<?php echo e(route("purchase_order.create")); ?>"><i
                                    class="ti-plus"></i><?php echo e(__('purchase.New Order')); ?></a>
                        </li>
                    </ul>
                    <?php endif; ?>
                </div>
            </div>
        </div>
        <div class="col-lg-12">
            <div class="QA_section QA_section_heading_custom check_box_table">
                <div class="QA_table">
                    <!-- table-responsive -->
                    <div class="">
                        <table class="table Crm_table_active3">
                            <thead>
                            <tr>
                                <th scope="col"><?php echo e(__('common.No')); ?></th>
                                <th scope="col"><?php echo e(__('quotation.Date')); ?></th>
                                <th scope="col"><?php echo e(__('quotation.Supplier')); ?> <?php echo e(__('common.Name')); ?></th>
                                <th scope="col"><?php echo e(__('sale.Invoice No')); ?></th>
                                <th scope="col"><?php echo e(__('purchase.Total Amount')); ?></th>
                                <th scope="col"><?php echo e(__('purchase.Paid Amount')); ?></th>
                                <th scope="col"><?php echo e(__('purchase.Due Amount')); ?></th>
                                <th scope="col"><?php echo e(__('purchase.Is Approved')); ?></th>
                                <th scope="col"><?php echo e(__('common.Action')); ?></th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=> $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($key+1); ?></td>
                                    <td><?php echo e(date(app('general_setting')->dateFormat->format, strtotime($order->created_at))); ?></td>
                                    <td><?php echo e(@$order->supplier->name); ?></td>
                                    <td><a href="javascript:void(0)" onclick="getDetails(<?php echo e($order->id); ?>)"><?php echo e($order->invoice_no); ?></a></td>
                                    <td><?php echo e(single_price($order->payable_amount)); ?></td>
                                    <?php
                                    $paid = $order->payments->sum('amount') - $order->payments->sum('return_amount');
                                    ?>
                                    <td><?php echo e(single_price($paid)); ?></td>
                                    <td><?php echo e(single_price($order->payable_amount - $paid)); ?></td>
                                    <td>
                                        <?php if($order->status == 0): ?>
                                            <h6><span class="badge_4"><?php echo e(__('purchase.No')); ?></span></h6>
                                        <?php else: ?>
                                            <h6><span class="badge_1"><?php echo e(__('purchase.Yes')); ?></span></h6>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <div class="dropdown CRM_dropdown">
                                            <button class="btn btn-secondary dropdown-toggle" type="button"
                                                    id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true"
                                                    aria-expanded="false">
                                                <?php echo e(__('common.Select')); ?>

                                            </button>
                                            <div class="dropdown-menu dropdown-menu-right"
                                                 aria-labelledby="dropdownMenu2">
                                                <?php if($order->is_paid != 2 && $order->status == 1): ?>
                                                    <a href="<?php echo e(route('purchase.payment',$order->id)); ?>"
                                                       class="dropdown-item"
                                                       type="button"><?php echo e(__('pos.Payment')); ?></a>
                                                <?php endif; ?>
                                                <?php if($order->status == 0): ?>
                                                    <a onclick="approve_modal('<?php echo e(route('purchase.approve', $order->id)); ?>')"
                                                       class="dropdown-item edit_brand"><?php echo e(__('sale.Approve')); ?></a>
                                                    <?php if(permissionCheck('purchase_order.edit')): ?>
                                                    <a href="<?php echo e(route('purchase_order.edit',$order->id)); ?>"
                                                       class="dropdown-item" type="button"><?php echo e(__('common.Edit')); ?></a>
                                                    <?php endif; ?>
                                                <?php endif; ?>
                                                <?php if($order->return_status == 2 && $order->added_to_stock == 1): ?>
                                                    <a href="<?php echo e(route('purchase.order.return',$order->id)); ?>" class="dropdown-item"
                                                       type="button"><?php echo e(__('purchase.Purchase Return')); ?></a>
                                                <?php endif; ?>
                                                <?php if(permissionCheck('purchase_order.show')): ?>
                                                <a href="<?php echo e(route('purchase_order.show',$order->id)); ?>"
                                                   class="dropdown-item"
                                                   type="button"><?php echo e(__('purchase.Purchase Details')); ?></a>
                                                <?php endif; ?>

                                                <?php if(permissionCheck('purchase.order.destroy') && $order->status == 0): ?>
                                                <a onclick="confirm_modal('<?php echo e(route('purchase.order.destroy', $order->id)); ?>')"
                                                   class="dropdown-item edit_brand"><?php echo e(__('common.Delete')); ?></a>
                                                <?php endif; ?>

                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="getDetails">

    </div>
    <?php echo $__env->make('backEnd.partials.delete_modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('backEnd.partials.approve_modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startPush("scripts"); ?>
    <script type="text/javascript">
    function getDetails(el){
        $.post('<?php echo e(route('get_purchase_details')); ?>', {_token:'<?php echo e(csrf_token()); ?>', id:el}, function(data){
            $('#getDetails').html(data);
            $('#purchase_info_modal').modal('show');
            $('select').niceSelect();
        });
    }
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('backEnd.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/penastud/public_html/InfixBiz/Modules/Purchase/Resources/views/purchase_order/purchases.blade.php ENDPATH**/ ?>