@include('layouts.head')
@if (isset( $supplier_list[0]->id) && $supplier_list[0]->id !='')
|
Supplier Name : {{ $supplier_list[0]->id }} - {{ $supplier_list[0]->name }}
|
|
Contact Person : {{ $supplier_list[0]->person_name }}
|
|
Address : {{ $supplier_list[0]->address }}
|
|
Mobile No. : {{ $supplier_list[0]->mobile }}
|
@else
Supplier Name : {{ isset($_GET['id']) && $_GET['id'] == "All" ? "All" : "Summary" }}
|
@endif
@php
$total = 0;
$g_torder_quantity = 0;
$g_r_torder_quantity = 0;
$actual_pur=0;
$avg_price=0;
$g_t_quantity = 0;
$g_t_total_price = 0;
@endphp
@if (request()->get('id') == 'All')
@foreach($department_info as $txn_date => $dept)
@php
$remove_dup_return=[];
$sub_grand_qty = 0;
$sub_grand_r_qty = 0;
$sub_grand_act_pur = 0;
$sub_grand_total = 0;
@endphp
| Date: {!! date('d-F-Y', strtotime($txn_date)) !!} |
@foreach($dept as $invoice_id => $catrow)
@php
unset($product_quantity);
$product_id = explode(',',$catrow->product_id);
$product_qty = explode(',',$catrow->product_qty);
$product_information = [];
foreach ($product_id as $k => $v)
{
$product_quantity[$v] = 0;
$product_information[$v] = $product_qty[$k];
}
foreach ($product_id as $k => $v)
{
$product_quantity[$v] += @$product_qty[$k];
}
@endphp
| PI#{{ $invoice_id }} {{'- - -'}}Supplier Name : {{ $catrow->name }} |
@php
$i = 1;
$torder_quantity = 0;
$r_torder_quantity = 0;
$act_pur = 0;
$t_quantity = 0;
$t_total_price = 0;
$products=[];
foreach($product_info as $row)
{
// print_r($product_information[$row->product_id]);
// print_r($row->product_id);
// exit();
$product_qty = isset($product_information[$row->product_id]) ? $product_information[$row->product_id] : 0;
//$product_qty = $product_information[$row->product_id];
$product_id = $row->product_id;
$product_name = $row->product_name;
$pack_type = $row->pack_type;
if(!isset($remove_dup_return[$txn_date][$catrow->name]))
$r_product_qty = $row->t_r_quantity;
else
$r_product_qty=null;
$rest_pur=$product_qty-$r_product_qty;
$dp_price = $row->dp_price;
$total = $product_qty;
$total_value = $product_qty * $dp_price;
// $total_value = $row->t_dp_price;
if($total >0){
$avg_price = $total_value / $total;
}else{
$avg_price = "";
}
if(isset($product_quantity[$product_id]) && $row->invoice_id == $catrow->invoice_id)
{
$torder_quantity += $product_qty;
$r_torder_quantity += $r_product_qty;
$act_pur += $rest_pur;
$t_quantity += $total;
$t_total_price += $total_value;
echo '';
echo '| '. $i++ .' | ';
echo ''. $product_id .' | ';
echo ''. $product_name .' | ';
echo ''. $pack_type .' | ';
echo ''. $product_qty .' | ';
// echo ''. $r_product_qty .' | ';
// echo ''. $rest_pur .' | ';
//echo ''. $dp_price .' | ';
echo ''. number_format($avg_price,2) .' | ';
echo ''. number_format($total_value,2) .' | ';
echo '
';
if(!isset($products[$product_id]))
$products[$product_id]=$product_id;
}
}
$g_torder_quantity += $torder_quantity;
$g_r_torder_quantity += $r_torder_quantity;
$g_t_quantity += $t_quantity;
$actual_pur += $act_pur;
$g_t_total_price += $t_total_price;
$sub_grand_qty += $torder_quantity;
$sub_grand_total += $t_total_price;
$sub_grand_r_qty += $r_torder_quantity;
$sub_grand_act_pur += $act_pur;
if(!isset($remove_dup_return[$txn_date][$catrow->name]))
$remove_dup_return[$txn_date][$catrow->name]=1;
@endphp
| Voucher Total = |
|
{!! number_format($torder_quantity) !!} |
{{-- {!! number_format($r_torder_quantity) !!} |
{!! number_format($act_pur) !!} | --}}
|
{!! number_format($t_total_price,2) !!} |
@endforeach
| Sub Total = |
|
{!! number_format($sub_grand_qty) !!} |
{{-- {!! number_format($sub_grand_r_qty) !!} |
{!! number_format($sub_grand_act_pur) !!} | --}}
|
{!! number_format($sub_grand_total,2) !!} |
@endforeach
| Grand Total = |
|
{!! number_format($g_torder_quantity) !!} |
{{-- {!! number_format($g_r_torder_quantity) !!} |
{!! number_format($actual_pur) !!} | --}}
|
{{ number_format($g_t_total_price,2) }} |
@elseif (isset($_GET['id']) && $_GET['id'] != "")
@php
$i = 1;
@endphp
@foreach($department_info as $invoice_id => $catrow)
@php
unset($product_quantity);
$product_id = explode(',',$catrow->product_id);
$product_qty = explode(',',$catrow->product_qty);
foreach ($product_id as $k => $v)
{
$product_quantity[$v] = 0;
}
foreach ($product_id as $k => $v)
{
$product_quantity[$v] += @$product_qty[$k];
}
@endphp
| PI#{{ $catrow->invoice_id }}--Date: {!! date('d-F-Y', strtotime($catrow->txn_date)) !!} |
@php
$remove_dup_return=[];
$torder_quantity = 0;
$r_torder_quantity = 0;
$act_pur=0;
$t_quantity = 0;
$t_total_price = 0;
//print_r($product_info);
foreach($product_info as $row)
{
$product_id = $row->product_id;
$product_name = $row->product_name;
$pack_type = $row->pack_type;
$product_qty = $row->t_quantity;
if(!isset($remove_dup_return[$catrow->txn_date]))
$r_product_qty = $row->t_r_quantity;
else
$r_product_qty = null;
$rest_pur=$product_qty-$r_product_qty;
$dp_price = $row->dp_price;
$total = $product_qty;
//$total_value = $product_qty * $dp_price;
$total_value = $row->t_dp_price;
if($total >0){
$avg_price = $total_value / $total;
}else{
$avg_price = "";
}
if(isset($product_quantity[$product_id]) && $catrow->invoice_id == $row->invoice_id )
{
$torder_quantity += $product_qty;
$r_torder_quantity += $r_product_qty;
$act_pur += $rest_pur;
$t_quantity += $total;
$t_total_price += $total_value;
echo '';
echo '| '. $i++ .' | ';
echo ''. $product_id .' | ';
echo ''. $product_name .' | ';
echo ''. $pack_type .' | ';
echo ''. $product_qty .' | ';
// echo ''. $r_product_qty .' | ';
// echo ''. $rest_pur .' | ';
// echo ''. $dp_price .' | ';
// echo ''. $total_value .' | ';
echo ''. number_format($avg_price,2) .' | ';
echo ''. number_format($total_value,2) .' | ';
echo '
';
}
if(!isset($remove_dup_return[$catrow->txn_date]))
$remove_dup_return[$catrow->txn_date] = 1;
}
$g_torder_quantity += $torder_quantity;
$g_r_torder_quantity += $r_torder_quantity;
$g_t_quantity += $t_quantity;
$actual_pur += $act_pur;
$g_t_total_price += $t_total_price;
@endphp
@if (isset($_GET['id']) && $_GET['id'] != "")
| Sub Total = |
|
{!! number_format($torder_quantity) !!} |
{{-- {!! number_format($r_torder_quantity) !!} |
{!! number_format($act_pur) !!} | --}}
|
{!! number_format($t_total_price,2) !!} |
@endif
@endforeach
| Grand Total = |
|
{!! number_format($g_torder_quantity) !!} |
{{-- {!! number_format($g_r_torder_quantity) !!} |
{!! number_format($actual_pur) !!} | --}}
|
{{ number_format($g_t_total_price,2) }} |
@else
@php
$i = 1;
$prod_information=[];
@endphp
@foreach($department_info as $invoice_id => $catrow)
@php
unset($product_quantity);
$product_id = explode(',',$catrow->product_id);
$product_qty = explode(',',$catrow->product_qty);
foreach ($product_id as $k => $v)
{
$product_quantity[$v] = 0;
}
foreach ($product_id as $k => $v)
{
if(isset($product_quantity[$k]))
$product_quantity[$v] += @$product_qty[$k];
}
$torder_quantity = 0;
$t_quantity = 0;
$t_total_price = 0;
//print_r($product_info);
foreach($product_info as $row)
{
$product_id = $row->product_id;
$product_name = $row->product_name;
$pack_type = $row->pack_type;
$product_qty = $row->t_quantity;
$r_product_qty = $row->t_r_quantity;
$dp_price = $row->dp_price;
$total = $product_qty;
//$total_value = $total * $dp_price;
$total_value_dp = $row->t_dp_price;
$total_value_dp_re = $row->t_r_dp_price;
$total_value = $total_value_dp - $total_value_dp_re;
if(isset($product_quantity[$product_id]) )
{
if(!isset($prod_information[$product_id]))
$prod_information[$product_id]=array('product_qty'=>$product_qty,'r_product_qty'=>$r_product_qty,'product_name'=>$product_name,'pack_type'=>$pack_type,'dp_price'=>$dp_price ,'total_value'=>$total_value);
else{
$prod_information[$product_id]['product_qty']+=$product_qty;
$prod_information[$product_id]['r_product_qty']+=$r_product_qty;
}
}
}
@endphp
@endforeach
@php
foreach($prod_information as $product_id => $prod){
$rest_pur = $prod['product_qty'] - $prod['r_product_qty'];
$actual_pur += $rest_pur;
//$total_value = $rest_pur * $prod['dp_price'];
$total_value = $prod['total_value'];
if($rest_pur > 0){
$avg_price = $total_value / $rest_pur;
}
else{
$avg_price = 0;
}
$g_torder_quantity += $prod['product_qty'];
$g_r_torder_quantity += $prod['r_product_qty'];
$g_t_total_price += $total_value;
echo '';
echo '| '. $i++ .' | ';
echo ''. $product_id .' | ';
echo ''. $prod['product_name'] .' | ';
echo ''. $prod['pack_type'] .' | ';
echo ''. $prod['product_qty'] .' | ';
echo ''. $prod['r_product_qty'] .' | ';
echo ''. $rest_pur .' | ';
//echo ''. $prod['dp_price'] .' | ';
echo ''. number_format($avg_price,2) .' | ';
echo ''. number_format($total_value,2) .' | ';
echo '
';
}
@endphp
| Grand Total = |
|
{!! number_format($g_torder_quantity) !!} |
{!! number_format($g_r_torder_quantity) !!} |
{!! number_format($actual_pur) !!} |
|
{{ number_format($g_t_total_price,2) }} |
@endif
| IN WORDS : {!! numberTowords($g_t_total_price) !!} |
@endsection