<div id="print_div">
    <div class="pathology-bill">
<div class="row">
<div class="col-2" style="width: 20%">
    <p>Date : {!! formatedDate(date('Y-m-d')) !!}</p>
</div>
<div class="col-7" style="text-align: center;">
    <p style="color:#0b5ed7;font-size:18px;margin-bottom: -4px !important"><b>{!! $company->name ?? '' !!}</b></p>
    <p style="font-size: 14px;"><b>{!! $productData->name ?? '' !!} STOCK STATEMENT</b></p>
    <!-- <p style="padding-bottom: 5px;font-size: 11px;"><b><span style="color: #698aff;">Stock</span> List</b> -->
    {{--<b>From <span style="color:#698aff;" id="">{{$from_date?formatedDate($from_date):formatedDate(date('Y-m-d H:i:s'))}}</span> TO <span style="color:#698aff;" id="">{{$to_date?formatedDate($to_date):formatedDate(date('Y-m-d H:i:s')) }}</span>
            </b>--}}</p>
</div>
<div class="col-2" style="text-align: right; width:20%">
    <p>Time : {!! formatedTime(date('H:i:s')) !!}</p>
</div>
</div>

<div>
    <table class="table table-borderless report-container">
        <tbody class="report-content">
            <tr>
                <td class="report-content-cell">
                    <div class="row">
                        <div class="col-12">

                            <table class="table table-bordered-print w-100 table-only-header-full-width mb-1" id="quotation_products">
                                <thead>
                                  <tr class="text-uppercase">
                                    <th style="text-align: left;" class="thbutton">Sl No</th>
                                    <th>Date Time</th>
                                    <th>Voucher Number</th>
                                    <th>Account Name</th>
                                    <th>Stock Type</th>
                                    <th class="text-end">STOCK IN</th>
                                    <th class="text-end">STOCK Out</th>
                                    <th style="text-align: left;" class="text-end">CURRENT STOCK</th>
                                    <th class="text-end">STOCK Value</th>
                                    
                                   
                                  </tr>
                                </thead>
                                <tbody>
                                  @if(isset($invoices) && count($invoices) > 0)
                                    @php
                                      $i                 = 1;
                                      $stockIn = 0;
                                      $stockOut = 0;
                                      $currentStock = 0;
                                    @endphp
                                    @foreach($invoices as $list)
                                    @php  $stockIn+=($list->pack_qty_in);
                                          $stockOut+=$list->pack_qty_out;

                                          $currentStock = $stockIn - $stockOut + $list->free_qty;
                                    @endphp
                                      <tr>
                                        <td class="text-center">{{$i}}</td>
                                        <td>{{ formatedDateTime($list->entry_date)??'' }}</td>
                                        <td>
                                          @if($list->voucher_type=='SALES' || $list->voucher_type=='IPD_INVOICE')
                                              {!! $list->voucherSaleType->voucher_type_invoice_no??'' !!}
                                          @elseif($list->voucher_type=='PURCHASE')
                                              {!! $list->voucherPurchaseType->main_invoice_no??'' !!}
                                          @elseif($list->voucher_type=='SALE_RETURN')
                                              {!! $list->voucherReturnType->main_invoice_no??'' !!}
                                          @elseif($list->voucher_type=='STOCK_IN')
                                              {!! $list->voucherStockIn->main_invoice_no??'' !!}
                                          @elseif($list->voucher_type=='STOCK_OUT')
                                              {!!   $list->voucherStockOut->main_invoice_no??'' !!}
                                          @endif
                                       
                                        </td>
                                        <td>
                                          @if($list->voucher_type=='SALES' || $list->voucher_type=='IPD_INVOICE')
                                              {!! $list->voucherSaleType->getPatient->name??'' !!}
                                          @elseif($list->voucher_type=='PURCHASE')
                                              {!! $list->voucherPurchaseType->getPatient->name??'' !!}
                                          @elseif($list->voucher_type=='SALE_RETURN')
                                              {!! $list->voucherReturnType->getPatient->name??'' !!}
                                          @endif

                                            @if(isset($list->getCreatedBy) && $list->getCreatedBy->prepared_by!='')
                                            <br>
                                            <div style="color:#aaa">By: {!! $list->getCreatedBy->prepared_by??'' !!}</div>
                                            @endif
                                        </td>
                                        <td>
                                          @if(isset($list->getMovementType))
                                            {{$list->getMovementType->name??'' }}
                                          @else
                                            {!! $list->stock_type??'' !!}
                                          @endif
                                        </td>
                                        <td class="text-end">{{ convertDecimelPoint($list->pack_qty_in + $list->free_qty) ?? ''}}</td>
                                        <td class="text-end">{{ convertDecimelPoint($list->pack_qty_out) }}</td>
                                        <td class="text-end">{{ convertDecimelPoint($currentStock)??0 }}</td>
                                        <td class="text-end">{{ convertDecimelPoint($list->taxable_unit_price) }}</td>
                                      </tr>
                                      @php
                                        $i += 1;
                                      @endphp
                                    @endforeach
                                  @else
                                    <tr>
                                      <td colspan="14" style="text-align: center;">Stock Not Available</td>
                                    </tr>
                                  @endif
                                </tbody>
                            </table>
                        </div>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</div>
</div>
</div>
@if(count($invoices)>0)
<div class="row">
  <div class="col-md-6" style="text-align: right;">
      <button id="btn_print" type="button" class="btn btn-primary btn-lg"><i class="bi bi-printer text-white"></i> Print Statement </button>
  </div>

  <div class="col-md-6" style="text-align: left;">
      <a href="javascript:;" class="btn btn-outline-primary export-statement"><i class="bi bi-download"></i> Export</a>
  </div>
</div>
@endif
