@extends('layouts.app') @section('title') {{'Sample 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 .= " TAKA "; 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??' PAISA ONLY.'; } else{ $words .= "ONLY."; } return $words; } if(isset($_GET["s_type"])) { $s_type = @$_GET['s_type']; } else{ $s_type = "In"; } @endphp
Sample Report Back
@if (Session::has('msg'))
{{ Session::get('msg') }}
@endif
Type
Search Customer
Start Date
End Date

 

@include('layouts.head')

Sample Report - {!! $s_type !!}

{!! 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

Customer 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 }}
Customer Name : {{ isset($_GET['id']) && $_GET['id'] == "All" ? "All" : "Summary" }}
{{-- --}} @if (isset($_GET['id']) && $_GET['id'] == '') @else @endif @php $grand_torder_quantity = 0; $grand_total_value = 0; @endphp @if (isset($_GET['id']) && $_GET['id'] == 'All') @foreach($department_info as $txn_date => $dept) @php $sub_grand_qty = 0; $sub_grand_total = 0; $sub_grand_total_value = 0; @endphp @foreach($dept as $so_id => $catrow) @php unset($product_quantity); $product_id = isset($catrow->product_id) ? explode(',',$catrow->product_id) : []; $product_qty = isset($catrow->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 @php $i = 1; $sub_torder_quantity = 0; $sub_total_price = 0; $sub_total_value = 0; 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; $dp_price = $row->dp_price; $total = $product_qty; $total_value = $row->t_price; if($total >0){ $avg_price = $total_value / $total; }else{ $avg_price = ""; } if(isset($product_quantity[$product_id]) && $catrow->so_id == $row->so_id) { $product_id = $row->product_id; $product_name = $row->product_name; $pack_type = $row->pack_type; $product_qty = $row->quantity; $dp_price = $row->dp_price; $total = $product_qty; $sub_torder_quantity += $product_qty; $sub_total_value += $total_value; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; } } $sub_grand_qty += $sub_torder_quantity; $sub_grand_total_value += $sub_total_value; $grand_torder_quantity += $sub_torder_quantity; $grand_total_value += $sub_total_value; @endphp {{-- --}} @endforeach {{-- --}} @endforeach @elseif (isset($_GET['id']) && $_GET['id'] != "") @foreach($department_info as $so_id => $catrow) @php unset($product_quantity); $product_id = isset($catrow->product_id) ? explode(',',$catrow->product_id) : []; $product_qty = isset($catrow->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 $i = 1; $sub_torder_quantity = 0; $sub_total_price = 0; $sub_total_value = 0; 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; $total = $product_qty; $total_value = $row->t_price; if($total >0){ $avg_price = $total_value / $total; }else{ $avg_price = ""; } if(isset($product_quantity[$product_id]) && $catrow->so_id == $row->so_id) { $sub_torder_quantity += $product_qty; $sub_total_value += $total_value; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; } } $grand_torder_quantity += $sub_torder_quantity; $grand_total_value += $sub_total_value; @endphp @if (isset($_GET['id']) && $_GET['id'] != "") {{-- --}} @endif @endforeach @else @php $product_information = []; @endphp @foreach($department_info as $return_id => $catrow) @php unset($product_quantity); $product_id = isset($catrow->product_id) ? explode(',',$catrow->product_id) : []; $product_qty = isset($catrow->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]; } $sub_torder_quantity = 0; $sub_total_price = 0; $sub_total_value = 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; $total = $product_qty; $total_value = $row->t_price; if($total >0){ $avg_price = $total_value / $total; }else{ $avg_price = ""; } if(isset($product_quantity[$product_id]) && $catrow->so_id == $row->so_id) { // print_r ($product_id .'='.$avg_price .'='.$total_value .'---'); $sub_torder_quantity += $product_qty; $sub_total_value += $total_value; if(!isset($product_information[$product_id])) $product_information[$product_id] = array('product_id'=>$product_id,'product_name'=>$product_name,'pack_type'=>$pack_type); $product_information[$product_id]['product_qty'] = ($product_information[$product_id]['product_qty'] ?? 0) + $product_qty; $product_information[$product_id]['avg_price'] = ($product_information[$product_id]['avg_price'] ?? $avg_price); $product_information[$product_id]['total_value'] = ($product_information[$product_id]['total_value'] ?? 0) + $total_value; } } //dd($product_information); $grand_torder_quantity += $sub_torder_quantity; $grand_total_value += $sub_total_value; @endphp @endforeach @php $i=1; foreach($product_information as $info){ echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; } @endphp @endif {{-- --}}
S.L. ID Item Name Unit QuantitySales PriceAvg. PricePriceTotal
Date: {!! date('d-F-Y', strtotime($txn_date)) !!}
PI#{{ $so_id }} {{'- - -'}}Customer Name : {{ $catrow->id }} - {{ $catrow->name }}
'. $i++ .''. $product_id .''. $product_name .''. $pack_type .''. $product_qty .''. number_format($avg_price,2) .''. number_format($total_value,2) .'
Sub Total = {!! number_format($sub_torder_quantity) !!} {!! number_format($sub_total_value,2) !!}
Sub Grand Total = {!! number_format($sub_grand_qty) !!} {!! number_format($sub_grand_total_value,2) !!}
PI#{{ $catrow->so_id }} - - - Date: {!! date('d-F-Y', strtotime($catrow->txn_date)) !!}
'. $i++ .''. $product_id .''. $product_name .''. $pack_type .''. $product_qty .''. number_format($avg_price,2) .''. number_format($total_value,2) .'
Sub Total = {!! number_format($sub_torder_quantity) !!} {!! number_format($sub_total_value,2) !!}
'. $i++ .''. $info['product_id'] .''. $info['product_name'] .''. $info['pack_type'] .''. $info['product_qty'] .''. number_format($info['total_value']/$info['product_qty'],2) .''. number_format($info['total_value'],2) .'
Grand Total = {!! number_format($grand_torder_quantity) !!} {{ number_format($grand_total_value,2) }}
IN WORDS : {!! numberTowords($grand_total_value) !!}
@endsection