<?php $__env->startSection('title','Pending Requisition Product'); ?>

<?php $__env->startSection('content'); ?>

    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1>Pending Requisition Product</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="#">Home</a></li>
                        <li class="breadcrumb-item active">Pending Requisition</li>
                    </ol>
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                </div>
                <div class="col-sm-6 text-right">

                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>

    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <!-- Main content -->
                    <div class="invoice p-3 mb-3">
                        <div class="row">
                            <div class="col-12">
                                <h4>
                                    <i class="fas fa-globe"></i> Requisition No : <?php echo e($requisition->requisition_id); ?>

                                    <small class="float-right"> Date: <label class="label-success" style="padding: 5px 15px"> <?php echo e(\Carbon\Carbon::parse($requisition->created_at)->format('D-d-M-Y')); ?></label> </small>
                                </h4>
                                <br>
                            </div>
                            <!-- /.col -->
                        </div>
                        <!-- Table row -->
                        <div class="row">
                            <div class="col-12 table-responsive">
                                <table class="table table-striped table-bordered text-center">
                                    <thead>
                                        <tr class="bg-info">
                                            <th> #SL</th>
                                            <th> Approval</th>
                                            <th>Group</th>
                                            <th>Item Name</th>
                                            <th> Unit </th>
                                            <th> Total Qty</th>
                                            <th> Approved Qty</th>
                                            <th> Approve Qty</th>
                                            <th> Cur Stock</th>
                                            <th> Last Purchase</th>
                                        </tr>
                                    </thead>
                                    <tbody>


                                    <?php $i=0; ?>
                                    <?php if($requisition->count()>0): ?>
                                        <?php echo e(Form::open(['route'=>['approve.pending.requisition',$requisition->id],'method'=>'post'])); ?>


                                        <?php $__currentLoopData = $requisition->requisition_products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php
                                              $total_qty = $product->qty;


                                             //$approved_total_qty = $product->new_requisition !=null ? $product->new_requisition->new_requisition_products->where('product_id',$product->product_id)->sum('qty') : 0;
                                             $approved_total_qty = $product->calculate_approve_qty($requisition,$product);

                                            $last_purchase = $product->product->find($product->product_id);
                                            $last_purchase_date = $last_purchase->last_purchase_date !=null ?  "Date: ". $last_purchase->last_purchase_date : "";
                                            $last_purchase_price = $last_purchase->last_purchase_price !=null ? "Price: ". $last_purchase->last_purchase_price : "";
                                            ?>
                                            <?php if($total_qty - $approved_total_qty >0): ?>
                                            <tr>
                                                <input type="hidden" name="requisition_qty[]" value="<?php echo e($product->qty); ?>" class="form-control form-control-sm" />

                                                <td><?php echo e(++$i); ?></td>
                                                <td><input type="checkbox" name="requisition_product_id[]" value="<?php echo e($product->id); ?>" class="form-control">
                                                </td>
                                                <td><?php echo e($product->product->group ? $product->product->group->name : " N/A "); ?></td>
                                                <td><?php echo e($product->product ? $product->product->name  : " N/A "); ?></td>
                                                <td><?php echo e($product->product->unit ? $product->product->unit->name : " N/A "); ?></td>
                                                <td><?php echo e($product->qty); ?></td>
                                                <td><?php echo e($approved_total_qty); ?></td>
                                                <td>
                                                    <input type="text" name="qty[]" value="" class="form-control form-control" />
                                                </td>

                                                <td> N/A</td>
                                                <td><?php echo e($last_purchase_price); ?> <br/> <?php echo e($last_purchase_date); ?> </td>

                                            </tr>
                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php endif; ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.col -->
                        </div>
                        <!-- /.row -->

                        <div class="row">
                            <div class="col-lg-4">
                                <label for="sent_for">Sent For: <span style="color: red"> *</span></label>
                                <select id="sent_for" name="sent_for" class="form-control">
                                    <option  value="1">Quotation</option>
                                    <option  value="2">Without Quotation</option>
                                    
                                </select>
                            </div>

                            <div class="col-lg-12">
                                <br>
                                <?php echo e(Form::textarea('checking_note',null,['class'=>'form-control','rows'=>5,'cols'=>5,'placeholder'=>'Approval Note....'])); ?>

                            </div>
                            <div class="col-lg-12">
                                <br>
                                <?php echo e(Form::submit('Approved',['class'=>'btn btn-info'])); ?>

                            </div>


                        </div>

                    </div>
                    <!-- /.invoice -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->

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

<?php $__env->startSection('plugin'); ?>
    <!-- DataTables -->
    <script src="<?php echo e(asset('plugins/datatables/jquery.dataTables.js')); ?>"></script>
    <script src="<?php echo e(asset('plugins/datatables/dataTables.bootstrap4.js')); ?>"></script>

    <!-- page script -->
    <script type="text/javascript">
        function toggleSupplier(){
            var sent_for = $('#sent_for').val();
            if(sent_for == 1){
                $('#suppliers').hide();
            }else{
                $('#suppliers').show();
            }
        }

    </script>
    <!-- Script -->
    <script src='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js'></script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.fixed', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/welluugs/purchase.wellgrouperp.com/resources/views/requisition/pending-requisition-product.blade.php ENDPATH**/ ?>