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

<?php $__env->startPush('css'); ?>
    <link  href="<?php echo e(asset('backend/plugins/datepicker/datepicker.css')); ?>" rel="stylesheet">
<?php $__env->stopPush(); ?>
<!-- page content -->
<?php $__env->startSection('content'); ?>
    <div class="right_col" role="main">
        <div class="">
            <!--<div class="page-title">
                <div class="title_left">
                    <h3>Purchase Management</h3>
                </div>
                <div class="title_right">
                    <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
                        <div class="col-md-5 col-sm-5 col-xs-12 form-group top_search" style="padding-left: 110px;">
                            <div class="input-group">
                                <a href="<?php echo e(route('purchase.create')); ?>" class="btn btn-primary">New Purchase</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>-->
            <div class="clearfix"></div>
            <?php if(Session::has('success')): ?>
                <div class="alert alert-success">
                    <?php echo e(Session::get('success')); ?>

                </div>
            <?php endif; ?>
            <?php if(Session::has('error')): ?>
                <div class="alert alert-danger">
                    <?php echo e(Session::get('error')); ?>

                </div>
            <?php endif; ?>
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>Due Purchase</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
                            <table width="100%" class="table table-condensed table-bordered table-hover" id="categorytable">
                                <thead>
                                <tr class="bg-primary">
                                    <th>SL</th>
                                    <th>Purchase Date</th>
                                    <th>Purchase By</th>
                                    <th>Supplier</th>
                                    <th>Chalan No</th>
                                    <th>Total Amount</th>
                                    <th>Paid Amount</th>
                                    <th>Due Amount</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $__currentLoopData = $rempurchase; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i=>$pc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <th> <?php echo e($i+1); ?></th>
                                        <td> <?php echo e(date('d-m-Y',strtotime($pc->created_at))); ?></td>
                                        <td> <?php echo e($pc->user->name); ?></td>
                                        <td> <?php echo e($pc->supplier->name); ?></td>
                                        <td> <?php echo e($pc->chalan_no); ?></td>
                                        <td> <?php echo e($pc->grand_total); ?></td>
                                        <td> <?php echo e($pc->paid_amount); ?></td>
                                        <td> <?php echo e($pc->due_amount); ?></td>
                                       <td>
                                            <a href="<?php echo e(route('account.spi')); ?>" class=" btn-xs btn-primary" ><i class="fa fa-check-circle"></i> Pay</a>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td colspan="5">Total </td>
                                    <td><?php echo e($rempurchase->sum('grand_total')); ?></td>
                                    <td><?php echo e($rempurchase->sum('paid_amount')); ?></td>
                                    <td><?php echo e($rempurchase->sum('due_amount')); ?></td>
                                    <td></td>
                                </tr>
                                </tbody>
                            </table>
                             <div class="text-center">
                                <?php echo e($rempurchase->links()); ?>

                            </div>
                        </div>
                        <!--<div class="row">
                            <form action="<?php echo e(route('purchase.report')); ?>" method="post">
                                <?php echo e(csrf_field()); ?>

                                <div class="col-md-3">
                                    <input class="form-control" data-toggle="start" type="text" name="start" placeholder="pick Start Date">
                                </div>
                                <div class="col-md-3">
                                    <input class="form-control" data-toggle="end" type="text" name="end" placeholder="pick End Date">
                                </div>
                                <div class="col-md-3">
                                    <select class="form-control" name="status">
                                        <option value="">--Select Purchase Type---</option>
                                        <option value="all"> ALl Purchase Report</option>
                                    </select>
                                </div>
                                <div class="col-md-3">
                                    <button name="" class="btn btn-primary">Export Report</button>
                                </div>
                            </form>
                        </div>-->
                        <br>
                        <h2>Paid Purchase</h2>
                        <hr>
                        <div class="x_content">
                            <table width="100%" class="table table-condensed table-bordered table-hover" id="categorytable">
                                <thead>
                                <tr class="bg-primary">
                                    <th>SL</th>
                                    <th>Purchase Date</th>
                                    <!--<th>Purchase By</th>-->
                                    <th>Supplier</th>
                                    <th>Chalan NO</th>
                                    <th>Total Amount</th>
                                    <th>Paid Amount</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $__currentLoopData = $paidpurchase; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p=>$paid): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <th> <?php echo e($p+1); ?></th>
                                        <td> <?php echo e(date('d-m-Y',strtotime($paid->created_at))); ?></td>
                                        <!--<td> <?php echo e($paid->user->name); ?></td>-->
                                        <td> <?php echo e($paid->supplier->name); ?></td>
                                        <td> <?php echo e($paid->chalan_no); ?></td>
                                        <td> <?php echo e($paid->grand_total); ?></td>
                                        <td> <?php echo e($paid->paid_amount); ?></td>
                                        <td>
                                            <!--<a href="<?php echo e(route('sales.print',$paid->id)); ?>" class="btn-xs btn-primary" target="_blank"><i class="fa fa-print fa-x"></i></a>  -->
                                            <a href="<?php echo e(route('purchase.show',$paid->id)); ?>" class="btn-xs btn-primary"><i class="fa fa-eye fa-x"></i></a>  
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td colspan="4">Total </td>
                                    <td><?php echo e($paidpurchase->sum('grand_total')); ?></td>
                                    <td><?php echo e($paidpurchase->sum('paid_amount')); ?></td>
                                    <td></td>
                                </tr>
                                </tbody>
                            </table>
                            <div class="text-center">
                                <?php echo e($paidpurchase->links()); ?>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /page content -->
<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>

    <script src="<?php echo e(asset('backend/plugins/datepicker/datepicker.js')); ?>"></script>
    <script type="text/javascript">
        $('[data-toggle="start"]').datepicker({
            format: 'yyyy-mm-dd'
        });

    $('[data-toggle="end"]').datepicker({
        format: 'yyyy-mm-dd'
    });
    </script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('backend.layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>