<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="{{ asset('vendor/bootstrap/dist/css/bootstrap.min.css') }}">
        <style type="text/css">
            @import url("https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800");
            @import url("https://fonts.googleapis.com/css?family=Open+Sans:400,600,700");
            @import url("https://fonts.googleapis.com/css?family=Montserrat:400,500,600,700");
            @import url("https://fonts.googleapis.com/css?family=Roboto:400,500,700");
            @import url("https://fonts.googleapis.com/css?family=Nunito:400,600,700");
        </style>
    </head>
    <body>
        @php
            $ticket_date_crt = date("d-M-Y", strtotime($ticket_date));
        @endphp
        <span style="text-align: center;"><u><b>{{$org_name}}</b></u><br></span>
        <span style="text-align: center;"><u><b>COUNTER COLLECTION REPORT FOR THE INVOICE DATE {{$ticket_date_crt}}</b></u><br></span>
        <table width="100%" class="table" style="font-size: 70%;" border="1">
            <thead class="thead-info">
                <tr>
                    <th>#</th>
                    <th>Invoice #</th>
                    <th>Invoice Date</th>
                    <th>Show Date</th>
                    <th>Ticket #</th>
                    <th>Facility</th>
                    <th>Adults</th>
                    <th>Child</th>
                    <th>Method</th>
                    <th>Amount</th>
                    <th>User</th>
                    <th>Cash</th>
                    <th>Card</th>
                    <th>UPI</th>
                    <th>Cancelled(Cash)</th>
                </tr>
            </thead>
            <tbody>
                @php
                    $n = 0;
                    $total_amount = 0;
                    $total_child_count = 0;
                    $total_adult_count = 0;
                    $total_cash_count = 0;
                    $total_card_count = 0;
                    $total_upi_count = 0;
                    $total_refund_amount = 0;
                @endphp
                @foreach($ticket_arr as $ticket_id)
                    @if(isset($invoice_array[$ticket_id]['invoice_number']))
                        @php
                            $n++;
                        @endphp
                        <tr>
                            <td>{{$n}}</td>
                            <td>{{$invoice_array[$ticket_id]['invoice_number']}}</td>
                            <td>{{$invoice_array[$ticket_id]['invoice_date']}}</td>
                            <td>{{$invoice_array[$ticket_id]['show_date']}}</td>
                            <td>{{$invoice_array[$ticket_id]['ticket_no']}}</td>
                            <td>{{$invoice_array[$ticket_id]['facility_name']}}</td>
                            <td style="text-align: center;">
                                {{$invoice_array[$ticket_id]['noofadult']}}
                                @if(isset($invoice_array[$ticket_id]['noofadult']))
                                    @php
                                        $total_adult_count += $invoice_array[$ticket_id]['noofadult'];
                                    @endphp
                                @endif
                            </td>
                            <td style="text-align: center;">
                                {{$invoice_array[$ticket_id]['noofchild']}}
                                @if(isset($invoice_array[$ticket_id]['noofchild']))
                                    @php
                                        $total_child_count += $invoice_array[$ticket_id]['noofchild'];
                                    @endphp
                                @endif
                            </td>
                            <td style="text-align: center;">{{$invoice_array[$ticket_id]['payment_method']}}</td>
                            <td style="text-align: right;">
                                {{$invoice_array[$ticket_id]['amount']}}
                                @if(isset($invoice_array[$ticket_id]['amount']))
                                    @php
                                        $total_amount += $invoice_array[$ticket_id]['amount'];
                                    @endphp
                                @endif
                            </td>
                            <td>{{$invoice_array[$ticket_id]['counter_user']}}</td>
                            <td>
                                @if($invoice_array[$ticket_id]['payment_method']=="Cash")
                                    {{$invoice_array[$ticket_id]['amount']}}
                                    @if(isset($invoice_array[$ticket_id]['amount']))
                                    @php
                                        $total_cash_count += $invoice_array[$ticket_id]['amount'];
                                    @endphp
                                    @endif
                                @endif
                            </td>
                            <td>
                                @if($invoice_array[$ticket_id]['payment_method']=="Card")
                                    {{$invoice_array[$ticket_id]['amount']}}
                                    @if(isset($invoice_array[$ticket_id]['amount']))
                                    @php
                                        $total_card_count += $invoice_array[$ticket_id]['amount'];
                                    @endphp
                                    @endif
                                @endif
                            </td>
                            <td>
                                @if($invoice_array[$ticket_id]['payment_method']=="UPI")
                                    {{$invoice_array[$ticket_id]['amount']}}
                                    @if(isset($invoice_array[$ticket_id]['amount']))
                                    @php
                                        $total_upi_count += $invoice_array[$ticket_id]['amount'];
                                    @endphp
                                    @endif
                                @endif
                            </td>
                            <td>
                                
                            </td>
                        </tr>
                    @endif
                    @if(isset($cancelled_array[$ticket_id]['invoice_number']))
                        @php
                            $n++;
                        @endphp
                        <tr>
                            <td>{{$n}}</td>
                            <td>{{$cancelled_array[$ticket_id]['invoice_number']}}</td>
                            <td>{{$cancelled_array[$ticket_id]['invoice_date']}}</td>
                            <td>{{$cancelled_array[$ticket_id]['show_date']}}</td>
                            <td>{{$cancelled_array[$ticket_id]['ticket_no']}}</td>
                            <td>{{$cancelled_array[$ticket_id]['facility_name']}}</td>
                            <td style="text-align: center;">
                                {{$cancelled_array[$ticket_id]['noofadult']}}
                                @if(isset($invoice_array[$ticket_id]['noofadult']))
                                @php
                                    $total_adult_count += $cancelled_array[$ticket_id]['noofadult'];
                                @endphp
                                @endif
                            </td>
                            <td style="text-align: center;">
                                {{$cancelled_array[$ticket_id]['noofchild']}}
                                @if(isset($invoice_array[$ticket_id]['noofchild']))
                                @php
                                    $total_child_count += $cancelled_array[$ticket_id]['noofchild'];
                                @endphp
                                @endif
                            </td>
                            <td style="text-align: center;">{{$cancelled_array[$ticket_id]['payment_method']}}</td>
                            <td style="text-align: right;">
                                {{$cancelled_array[$ticket_id]['amount']}}
                                @if(isset($cancelled_array[$ticket_id]['amount']))
                                    @php
                                        $total_amount += $cancelled_array[$ticket_id]['amount'];
                                    @endphp
                                @endif
                            </td>
                            <td>{{$cancelled_array[$ticket_id]['counter_user']}}</td>
                            <td>
                                
                            </td>
                            <td>
                                
                            </td>
                            <td>
                                
                            </td>
                            <td>
                                @if($cancelled_array[$ticket_id]['payment_method']=="Cash")
                                    {{$cancelled_array[$ticket_id]['refund_amount']}}
                                    @if(isset($invoice_array[$ticket_id]['refund_amount']))
                                    @php
                                        $total_refund_amount += $cancelled_array[$ticket_id]['refund_amount'];
                                    @endphp
                                    @endif
                                @endif
                            </td>
                        </tr>
                    @endif
                @endforeach
            </tbody>
            <tfoot class="tfoot-info">
                <tr>
                    <th>&nbsp;</th>
                    <th>&nbsp;</th>
                    <th>&nbsp;</th>
                    <th>&nbsp;</th>
                    <th>&nbsp;</th>
                    <th>&nbsp;</th>
                    <th align="right">{{$total_adult_count}}</th>
                    <th align="right">{{$total_child_count}}</th>
                    <th>&nbsp;</th>
                    <th align="right">{{$total_amount}}</th>
                    <th>&nbsp;</th>
                    <th align="right">{{$total_cash_count}}</th>
                    <th align="right">{{$total_card_count}}</th>
                    <th align="right">{{$total_upi_count}}</th>
                    <th align="right">{{$total_refund_amount}}</th>
                </tr>
            </tfoot>
        </table>
    </body>
</html>
                                    