@extends('layouts.app') @section('title') {{'Foreign Purchase Report'}} @endsection @section('content') @php function numberTowords($num) { $ones = array( 1 => "ONE", 2 => "TWO", 3 => "THREE", 4 => "FOUR", 5 => "FIVE", 6 => "SIX", 7 => "SEVEN", 8 => "EIGHT", 9 => "NINE", 10 => "TEN", 11 => "ELEVEN", 12 => "TWELVE", 13 => "THIRTEEN", 14 => "FOURTEEN", 15 => "FIFTEEN", 16 => "SIXTEEN", 17 => "SEVENTEEN", 18 => "EIGHTEEN", 19 => "NINETEEN" ); $tens = array( 1 => "TEN", 2 => "TWENTY", 3 => "THIRTY", 4 => "FORTY", 5 => "FIFTY", 6 => "SIXTY", 7 => "SEVENTY", 8 => "EIGHTY", 9 => "NINETY" ); $hundreds = array( "HUNDRED", "THOUSAND", "MILLION", "BILLION", "TRILLION", "QUARDRILLION" ); $num = number_format($num,2,".",","); $num_arr = explode(".",$num); $wholenum = $num_arr[0]; $decnum = $num_arr[1]; $whole_arr = array_reverse(explode(",",$wholenum)); krsort($whole_arr); $words = ""; foreach($whole_arr as $key => $i) { if($i == 0) { continue; } if($i < 20) { $words .= $ones[intval($i)]; } elseif($i < 100) { if(substr($i,0,1) == 0 && strlen($i) == 3) { $words .= $tens[substr($i,1,1)]; if(substr($i,2,1) != 0) { $words .= " ".$ones[substr($i,2,1)]; } } else { $words .= $tens[substr($i,0,1)]; if(substr($i,1,1) != 0) { $words .= " ".$ones[substr($i,1,1)]; } } } else { // $words .= $ones[substr($i,0,1)]." ".$hundreds[0]; if(substr($i,1,1) != 0 || substr($i,2,1) != 0) { $words .= $ones[substr($i,0,1)]." ".$hundreds[0]; } else { $words .= $ones[substr($i,0,1)]." ".$hundreds[0]; } if(substr($i,1,2) < 20 && substr($i,1,1) != 0) { $words .= " ".$ones[(substr($i,1,2))]; } else { if(substr($i,1,1) != 0) { $words .= " ".$tens[substr($i,1,1)]; } if(substr($i,2,1) != 0) { $words .= " ".$ones[substr($i,2,1)]; } } } if($key > 0) { $words .= " ".$hundreds[$key]." "; } } $words .= " DOLLAR "; if($decnum > 0) { $words .= " AND "; if($decnum < 20) { $words .= $ones[intval($decnum)]; } elseif($decnum < 100) { $words .= $tens[substr($decnum,0,1)]; if(substr($decnum,1,1) != 0) { $words .= " ".$ones[substr($decnum,1,1)]; } } $words .= $subunit??' CENT ONLY.'; } else{ $words .= "ONLY."; } return $words; } @endphp
Foreign Purchase Report Back
@if (Session::has('msg'))
{{ Session::get('msg') }}
@endif
Search Supplier
Search Group
Search Sub Group
Start Date
End Date

 

@include('layouts.head')

Foreign Purchase Report

{!! date('d-F-Y', strtotime($start_date)) !!} to {!! date('d-F-Y', strtotime($end_date)) !!}

@if (isset( $supplier_list[0]->id) && $supplier_list[0]->id !='') @else @endif

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 }}
@if (isset($_GET['group_id']) && $_GET['group_id'] != "") @php $selected_group = null; foreach ($group_info as $val) { if ($val->id == $_GET['group_id']) { $selected_group = $val; break; } } @endphp @if ($selected_group)
Group Name: {{ $selected_group->values }}
@endif @elseif (isset($_GET['sub_group_id']) && $_GET['sub_group_id'] != "") @php $selected_sub_group = null; foreach ($sub_group_info as $val) { if ($val->id == $_GET['sub_group_id']) { $selected_sub_group = $val; break; } } @endphp @if ($selected_sub_group)
Sub Group Name: {{ $selected_sub_group->department_name }}
@endif @else
Supplier Name : {{ isset($_GET['id']) && $_GET['id'] == "All" ? "All" : "Summary" }}
@endif
@php $i = 1; $total = 0; $g_torder_quantity = 0; $g_t_quantity = 0; $g_t_total_price = 0; @endphp @if (isset($_GET['id']) && $_GET['id'] == 'All') @foreach($department_info as $supp_name => $dept) @php $sub_grand_qty = 0; $sub_grand_total = 0; @endphp @foreach($dept as $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 @php $torder_quantity = 0; $t_quantity = 0; $t_total_price = 0; foreach($product_info as $row) { $product_id = $row->product_id; $product_name = $row->product_name; $pack_type = $row->pack_type; $product_qty = $row->quantity; $dp_price = $row->dp_price; $dollar = $row->dollar; $total = $product_qty; $total_value = $total * $dollar; if(isset($product_quantity[$product_id])) { $torder_quantity += $product_qty; $t_quantity += $total; $t_total_price += $total_value; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; } } $g_torder_quantity += $torder_quantity; $g_t_quantity += $t_quantity; $g_t_total_price += $t_total_price; $sub_grand_qty += $torder_quantity; $sub_grand_total += $t_total_price; @endphp @endforeach @endforeach @else @foreach($department_info as $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 @php $torder_quantity = 0; $t_quantity = 0; $t_total_price = 0; foreach($product_info as $row) { $product_id = $row->product_id; $product_name = $row->product_name; $pack_type = $row->pack_type; $product_qty = $row->quantity; $dp_price = $row->dp_price; $dollar = $row->dollar; $total = $product_qty; $total_value = $total * $dollar; if(isset($product_quantity[$product_id])) { $torder_quantity += $product_qty; $t_quantity += $total; $t_total_price += $total_value; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; } } $g_torder_quantity += $torder_quantity; $g_t_quantity += $t_quantity; $g_t_total_price += $t_total_price; @endphp @endforeach @endif
S.L. ID Item Name Unit Purchase Quantity Purchase $ Price Total $
Supplier Name: {{ $supp_name }}
{{ $catrow->department_name }}
'. $i++ .''. $product_id .''. $product_name .''. $pack_type .''. $product_qty .''. $dollar .''. $total_value .'
Sub Total = {!! number_format($torder_quantity) !!} {!! number_format($t_total_price,2) !!}
Sub Grand Total = {!! number_format($sub_grand_qty) !!} {!! number_format($sub_grand_total,2) !!}
{{ $catrow->department_name }}
'. $i++ .''. $product_id .''. $product_name .''. $pack_type .''. $product_qty .''. $dollar .''. $total_value .'
Sub Total = {!! number_format($torder_quantity) !!} {!! number_format($t_total_price,2) !!}
Grand Total = {!! number_format($g_torder_quantity) !!} {{ number_format($g_t_total_price,2) }}
IN WORDS : {!! numberTowords($g_t_total_price) !!}
@endsection