

<?php $__env->startSection('title'); ?>
MRR
<?php $__env->stopSection(); ?>

<?php $__env->startSection('report_title'); ?>
MRR
<?php $__env->stopSection(); ?>

<?php $__env->startSection('by'); ?>
Who prepared this
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <?php
        $chunckNumber = 10;
        $total = count($goods_in->products);
        $total_pages = ceil($total / $chunckNumber); 
        $page_no = 1;
        if(request('per_page_item') > 0){
            $chunckNumber = request('per_page_item');
        }
        
        $purchase_product = App\PurchaseProduct::where('purchase_id', $goods_in->purchase_id)->first();
        if($purchase_product){
            $supplier_id = $purchase_product->supplier_id;
            $supplier_name = App\Supplier::find($supplier_id)->name;
            $supplier_address = App\Supplier::find($supplier_id)->address;
        }else{
            $supplier_name = 'No Name';
            $supplier_address = 'No Address';
        }
    ?>

<?php $__currentLoopData = $goods_in->products->chunk($chunckNumber); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $products): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
  <section class="sheet padding-10mm">
     
    <div id="logo" style="float:right;">
      <img src="<?php echo e(asset('logo.png')); ?>" alt="Well Group" height="40" style="border-style: none;">
    </div>
    <div style="margin-left: 11%;float: center !important">
      <center><span style="font-weight: bold;font-size: 20px"><?php echo e(unit_name() ?? app_info()->company_name); ?></span></center>
      <center><span style="font-size: 12px"><?php echo e(auth_unit_address()); ?></span></center>
      <center><span style="font-weight: bold;font-size: 18px; margin-right:0 !important;">Material Receiving Report (MRR)</span></center>
      <div class="print-none" style="font-weight: normal !important; font-size: 18px !important">
        <center style="margin-right: 150px" >
            <?php if($loop->first): ?>
            <form action="" method="get">
                <select name="gap" onchange="this.form.submit()" >
                    <?php $__currentLoopData = gaps(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $gap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($key); ?>" <?php if(request('gap') == $key): ?> selected <?php endif; ?>><?php echo e($gap); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <select name="per_page_item" onchange="this.form.submit()">
                    <?php $__currentLoopData = perPageItem(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item_number): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($key); ?>" <?php if(request('per_page_item') == $key): ?> selected <?php endif; ?>><?php echo e($item_number); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </form>
            <?php endif; ?>
        </center>
      </div>
    </div>
    <br>
    <div style="margin-bottom: 5px;font-size: 10px;float: left">
        <table style="font-size: 13px;">
            <tr>
                <td><strong> MR No & Date </strong></td>
                <td>: <?php echo e($goods_in->mrr_no); ?> , <?php echo e(dateFormat($goods_in->bill_date)); ?></td>
            </tr>
            <tr>
                <td><strong> Client Name </strong></td>
                <td>: <?php echo e($supplier_name); ?></td>
            </tr>
            <tr>
                <td><strong>Address </strong></td>
                <td>: <?php echo e($supplier_address); ?></td>
            </tr>
            <tr>
                <td><strong> Bill No </strong></td>
                <td>: <?php echo e($goods_in->bill_no); ?></td>
            </tr>
            <?php if(($goods_in->bill_no != $goods_in->chalan) && ($goods_in->chalan != null)): ?>
            <tr>
                <td><strong> Delivery Challan </strong></td>
                <td>: <?php echo e($goods_in->chalan); ?></td>
            </tr>
            <?php endif; ?>
            <tr>
                <td><strong> Order No </strong></td>
                <td>: <?php echo e($goods_in->purchase->purchase_no); ?></td>
            </tr>
            <tr>
                
            </tr>
        </table>
      
    </div>
    <br><br>
    
      <div style="min-height: 320px">
          <table class="table" align="center" cellpadding="0" cellspacing="0" border="0" style="">
              <thead>
              <tr style="font-size: 13px;height: 30px; background-color: #e3e1dc;" class="text-center">
                  <td class="td"> #SL</td>
                  <td class="td"> Code</td>
                  <td class="td" width="30%"> Item Description</td>
                  <td class="td"> Unit</td>
                  <td class="td">Last Purchase</td>
                  <td class="td"> Qty Received</td>
                  <td class="td"> Unit Price</td>
                  <td class="td"> Total Value</td>
              </tr>
              </thead>
              <tbody style="font-size: 12px">
              <?php if(isset($goods_in->products[0]->id)): ?>
                  <?php $total = 0;
                  ?>
                   <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      
                      <?php if($product->qty > 0): ?>
                        <tr>
                            <td class="td" ><?php echo e($key + 1); ?></td>
                            <td class="td" ><?php echo e($product->product->item_code); ?></td>
                            <td class="td" ><?php echo e($product->product->name); ?></td>
                            <td class="td" ><?php echo e(optional($product->product->unit)->name); ?></td>
                            
                            <?php

                                $requisition = App\QuotationProduct::where('requisition_id',$product->requisition_id )->where('product_id', $product->product->id)->first();
                                $requisition_product = App\RequisitionProduct::where('product_id', $product->product->id)->where('requisition_id', $requisition->requisitionProduct->new_requisition->requisition->id)->first();
                                $last_purchase = App\GoodsinProduct::find($requisition_product->last_goodsin_id);
                            ?>
                        
                            <td class="td cs-td">
                            <?php if($last_purchase): ?>
                            Tk-<?php echo e($last_purchase->price); ?> /- Per <?php echo e(optional($last_purchase->product_unit)->name); ?><br> Date: <?php echo e($last_purchase->goodsin ? dateFormat($last_purchase->goodsin->bill_date) : null); ?>, PO-<?php echo e(optional($last_purchase->purchase)->purchase_no); ?>



                            <?php else: ?>
                            New
                            <?php endif; ?>

                            </td>
                            <td class="td text-right" ><?php echo e($product->qty); ?></td>
                            <td class="td text-right" ><?php echo e(number_format($product->price, 3)); ?></td>
                            <td class="td text-right" > <?php echo e(number_format($product->qty * $product->price, 2)); ?></td>
                        </tr>
                        <?php
                            $total += $product->qty * $product->price;
                        ?>
                      <?php endif; ?>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  <tr>
                      <td class="td text-right" colspan="7"><strong>Total Value</strong> </td>
                      <td class="td text-right"> <strong><?php echo e(number_format($total, 2)); ?></strong></td>
                  </tr>
              <?php endif; ?>
              </tbody>
          </table>
          <div style="font-size: 13px">
            <strong>Note: </strong> <i><?php echo e($goods_in->note); ?></i>
          </div>
      </div>

<div style="margin-top:130px" class="signature">
    <table class=" table"  align="center" cellpadding="0" cellspacing="0" style="width: 100%;border:none; float:left;">
      <tr>
        <td style="border-top: 1px solid black;width: 20%;text-align: center;font-size: 13px; margin-top:30px;" ><br><strong>PREPARED BY</strong></td>
        <td style="width: 8%;border:none;"></td>
        <td style="border-top: 1px solid black;width: 20%;text-align: center;font-size: 13px; margin-top:30px;" ><br> <strong>STORE OFFICER</strong></td>
        <td style="width: 8%;border:none;"></td>
        <td style="border-top: 1px solid black;width: 20%;text-align: center;font-size: 13px"><br>  <strong>ACCOUNTS OFFICER</strong></td>
        <td style="width: 7%;border:none;"></td>
        <td style="border-top: 1px solid black;width: 15%;text-align: center;font-size: 13px"><br><span class="strong"><strong>MANAGER/DIRECTOR</strong></span></td>
      </tr>
    </table>
</div>
<br><br><br>
<?php if($loop->last): ?>
<center><a id="print" class="btn-print print-none" onclick="window.print()" >Print</a></center>
<?php endif; ?>
</section>
<!--<div class="page_break"></div>-->
 <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

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

<?php echo $__env->make('report.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/welluugs/purchase.wellgrouperp.com/resources/views/inventory/goodsin/mr-report-print.blade.php ENDPATH**/ ?>