

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

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

<?php $__env->startSection('by'); ?>
Who prepared this
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<style type="text/css">
  .invoice {
    border-right: 1px solid #2e2d2d;
    border-bottom: 1px solid #2e2d2d;
    padding: 3px;
  }
  .th{
      border-bottom: 1px solid #2e2d2d;border-right: 1px solid #2e2d2d;
  }
</style>
   <?php
        $chunckNumber = 20;
        if(request('per_page_item') > 0){
            $chunckNumber = request('per_page_item');
        }
    ?>
  <?php $__currentLoopData = $requisition->requisition_products ->chunk($chunckNumber); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__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: 10%;float: center !important">
      <center>
        <span style="font-size: 30px"><strong><?php echo e(unit_name() ?? app_info()->company_name); ?></strong></span>
        <br>
        <span style="font-size: 24px"><strong>Purchase Requisition</strong></span>
        
        
        <div class="print-none" style="font-weight: normal !important; font-size: 18px !important">
                <?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; ?>

            </div>  
      </center>
    </div>
    <br>
    <div style="margin-bottom: 5px;font-size: 16px;float: left">
      <strong>
          Requisition No : <?php echo e($requisition->requisition_id); ?>

      </strong>
    </div>
    <div style="margin-bottom: 5px;font-size: 16px;float: right">
      <strong>
          Requisition Date : <?php echo e(dateFormat($requisition->created_at)); ?>

      </strong>
    </div>
<table class="table" align="center" cellpadding="0" cellspacing="0" border="0" style="margin-top:20px;">

    <thead>
        <tr style="font-size: 12px;height: 20px; background-color: #e3e1dc;" class="text-center">
            <!--<td class="th" rowspan="2"> #SL</td>-->
            <td class="th" rowspan="2"> Group Name</td>
            <td class="th" width="6%" rowspan="2"> Code</td>
            <td class="th" width="20%" rowspan="2"> Item Name</td>
            <td class="th" rowspan="2" width="3%"> Unit</td>
            <td class="th" width="5%" rowspan="2"> Cur Stock</td>
            <td class="th" width="5%" rowspan="2"> 2 Monts Consum.</td>
            
            <td class="th"  width="7%"  rowspan="2"> Present Req. Qty</td>
            <td class="th" colspan="4"> Last Purchase </td>
            <td class="th"  width="17%" rowspan="2"> Remarks</td>
      </tr>
      <tr style="font-size: 12px;height: 20px; background-color: #e3e1dc;" class="text-center">
        <td class="th" width="5%" > Ord No</td>
        <td class="th" width="7%" > Date</td>
        <td class="th" width="5%" > Qty</td>
        <td class="th" width="5%" > Rate</td>
    </tr>
    </thead>
    <tbody style="font-size: 10px">
        <?php $i=0; ?>
        <?php if($requisition->count()>0): ?>
            <?php echo e(Form::open(['route'=>['inventory.requisition-item.checking-approval',$requisition->id],'method'=>'post'])); ?>


            <?php $__currentLoopData = $product; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php if($product->disabled == 0): ?>
            <?php
                $last_purchase = App\GoodsinProduct::find($product->last_goodsin_id);
                // $last_purchase = App\Product::find($product->id);

                $curr_stock = App\GoodsinProduct::where(get_where())->where('product_id',$product->product_id)->sum('qty') - App\GoodsIssueProduct::where(get_where())->where('product_id',$product->product_id)->sum('qty');
                $date_today = date('Y-m-d H:i:s');
                $date_two_months = date("Y-m-d H:i:s", strtotime("-2 months"));
                $two_months_consume = App\GoodsinProduct::where(get_where())->where('product_id',$product->product_id)->where('created_at', '<=', $date_today)->where('created_at', '>=', $date_two_months)->sum('qty');
            ?>
                <tr>
                    
                    <!--<td class="invoice" ><?php echo e(++$i); ?></td>-->
                    
                    
                    
                    <td class="invoice" ><?php echo e($product->product->group ? $product->product->group->name : " N/A "); ?></td>
                    <td class="invoice text-center" ><?php echo e($product->product ? $product->product->item_code : " N/A "); ?></td>
                    <td class="invoice text-left" ><?php echo e($product->product ? $product->product->name  : " N/A "); ?></td>


                    <td class="invoice text-center" ><?php echo e($product->product->unit ? $product->product->unit->name : " N/A "); ?></td>
                    <td class="invoice text-right" > <?php echo e(number_format($curr_stock)); ?></td>
                    <td class="invoice text-right" > <?php echo e(number_format($two_months_consume)); ?></td>
                    
                    <td class="invoice text-right" ><?php echo e($product->qty > 0? number_format(floatval($product->qty),2) : ''); ?></td>
                    <td class="invoice text-right" >
                      <?php if(isset($last_purchase->id)): ?>
                        <?php echo e(optional(optional($last_purchase->goodsin)->purchase)->purchase_no); ?> 
                        <?php else: ?>
                        
                      <?php endif; ?>
                      
                    </td>
                    <td class="invoice text-center" >
                      <?php $new_goods_in = false; ?>
                      <?php if(isset($last_purchase->id)): ?>
                        <?php if(optional($last_purchase->goodsin)->bill_date != null): ?>
                          <?php $new_goods_in = true; ?>
                          <?php echo e(date('d-m-Y',strtotime(optional($last_purchase->goodsin)->bill_date))); ?>

                        
                        <?php endif; ?>
                        
                      <?php endif; ?>
                      
                    </td>
                    <td class="invoice text-right" >
                      <?php if(isset($last_purchase->id) && $new_goods_in): ?>
                        <?php echo e($last_purchase->qty > 0? number_format(floatval($last_purchase->qty),2) : ''); ?> 
                      <?php endif; ?>
                    </td>
                    <td class="invoice text-right" >
                       <?php if(isset($last_purchase->id) && $new_goods_in): ?>
                      <?php echo e($last_purchase->price); ?>

                      
                      <?php endif; ?>
                      
                    </td>
                    <td class="invoice text-center" >
                        
                       <br>
                       <?php $new_goods_in = false; ?>
                      <?php if(isset($last_purchase->id)): ?>
                        <?php if(optional($last_purchase->goodsin)->bill_date != null): ?>
                          <?php $new_goods_in = true; ?>
                         
                        
                        <?php endif; ?>
                        <?php else: ?>
                        
                        
                      <?php endif; ?>
                       
                     </td>
                    
                </tr>
            <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php endif; ?>
    </tbody>
</table>

<div style="font-size: 12px">
  <strong>Note: </strong> <i><?php echo $requisition->note; ?></i>

<div class="signature signature-gap">
            <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>ENTRY BY</td>
                    <td style="width: 20%;border:none;"></td>
                    <td style="border-top: 1px solid black;width: 20%;text-align: center;font-size: 13px; margin-top:30px;" ><br> STORE MANAGER</td>
                    <td style="width: 20%;border:none;"></td>
                    <td style="border-top: 1px solid black;width: 20%;text-align: center;font-size: 13px"><br>APPROVE BY</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/requisition/invoice-requisition-print.blade.php ENDPATH**/ ?>