@extends('layouts.app')

@section('content')
<!-- Content wrapper scroll start -->
<div class="content-wrapper-scroll">

<!-- Content wrapper start -->
<div class="content-wrapper">

<div>
    <h4><strong>{{request()->branch}}:</strong> REPORT FOR {{request()->date}}</h4>
</div>

        <!-- Row start -->
        <div class="row gutters">
            <div class="col-xl-4 col-lg-4 col-md-4 col-sm-6 col-12">
                <div class="stats-tile">
                    <div class="sale-icon">
                        <i class="icon-credit-card"></i>
                    </div>
                    <div class="sale-details">
                        <h2>{{empty($app->currency) ? "GHS" : $app->currency}}@convert($branch_total_general - $total_deliveries)</h2>
                        <p>Total Net Sales</p>
                    </div>
                </div>
            </div>
            <div class="col-xl-4 col-lg-4 col-md-4 col-sm-6 col-12">
                <div class="stats-tile">
                    <div class="sale-icon">
                        <i class="icon-shopping-bag1"></i>
                    </div>
                    <div class="sale-details">
                        <h2>{{empty($app->currency) ? "GHS" : $app->currency}}@convert($branch_total_house)</h2>
                        <p><a href="">No Charge</a></p>
                    </div>
                </div>
            </div>
            <div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-12">
                <div class="stats-tile">
                    <div class="sale-icon">
                        <i class="icon-check-circle"></i>
                    </div>
                    <div class="sale-details">
                        <h2>{{empty($app->currency) ? "GHS" : $app->currency}}@convert($branch_total_reject)</h2>
                        <p><a href="#">Rejected Items</a></p>
                    </div>
                </div>
            </div>
        </div>


    <!-- Row start -->
    <div class="row gutters">
        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
        <div class="card">
            <div class="card-header">
                <form action="{{route('allDepartmentSummaryBranch')}}">
                    <input type="text" value="{{request()->date}}" hidden name="date">
                    <input type="text" value="{{request()->branch}}" hidden name="branch">
                    <button class="btn btn-outline-primary rounded-pill">Category Report</button>
                </form>
                <form action="{{route('allItemSummaryBranches')}}">
                    <input type="text" value="{{request()->date}}" name="date" hidden>
                    <input type="text" value="{{request()->branch}}" hidden name="branch">
                    <button class="btn btn-outline-primary rounded-pill">Product Report</button>
                </form>
                </div>

                <div class="card-body">
                    <div class="table-responsive">
                    <table id="copy-print-csv" class="table v-middle">
                                <thead>
                                    <tr>
                                        <th>Order No.</th>
                                        <th>Ordered Date</th>
                                        <th>Product</th>
                                        <th>Quantity</th>												
                                        <th> Unit Price</th>
                                        <th>Discount</th>
                                        <th>Total Price</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($sales_today_branch as $list)
                                    <tr>
                                        <td>#{{$list->invoice_number}}</td>
                                        <td>{{$list->created_at}}</td>
                                        <td>
                                        {{$list->invoice_product_name}}
                                        </td>
                                        <td>
                                            {{$list->invoice_quantity}}
                                        </td>
                                        <td>{{empty($app->currency) ? "GHS" : $app->currency}}{{$list->invoice_unit_price}}</td>
                                        <td>None</td>
                                        <td>{{empty($app->currency) ? "GHS" : $app->currency}}{{$list->invoice_total_price}}</td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                    </div>

                </div>
            </div>

        </div>
    </div>
    <!-- Row end -->




    <!-- on the house sales and rejected orders -->

        <!-- Row start -->
        <div class="row gutters">
        <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">

            <!-- Card start -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title">No Charge</div>
                </div>
                <div class="card-body">
                    
                    <!-- Row start -->
                    <div class="row gutters">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">        
                        <table id="apiCallbacks" class="table custom-table">

                                <thead>
                                    <tr>
                                        <th>Product</th>
                                        <th>Quantity</th>												
                                        <th> Unit Price</th>
                                        <th>Total Price</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($branch_total_house_list as $list)
                                    <tr>
                                        <td>
                                        {{$list->invoice_product_name}}
                                        </td>
                                        <td>
                                            {{$list->invoice_quantity}}
                                        </td>
                                        <td>{{empty($app->currency) ? "GHS" : $app->currency}}{{$list->invoice_unit_price}}</td>
                                        <td>{{empty($app->currency) ? "GHS" : $app->currency}}{{$list->invoice_total_price}}</td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>

                        </div>
                    </div>
                    <!-- Row end -->

                </div>
            </div>
            <!-- Card end -->

        </div>
        <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">

            <!-- Card start -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title">Rejected Items</div>
                </div>
                <div class="card-body">
                    
                    <!-- Row start -->
                    <div class="row gutters">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                        <div class="table-responsive">
                        <table id="copy-print-csv" class="table v-middle">
                                <thead>
                                    <tr>
                                        <th>Order No.</th>
                                        <th>Product</th>
                                        <th>Quantity</th>												
                                        <th> Unit Price</th>
                                        <th>Total Price</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($branch_total_reject_list as $list)
                                    <tr>
                                        <td>#{{$list->invoice_number}}</td>
                                        <td>
                                        {{$list->invoice_product_name}}
                                        </td>
                                        <td>
                                            {{$list->invoice_quantity}}
                                        </td>
                                        <td>{{empty($app->currency) ? "GHS" : $app->currency}}{{$list->invoice_unit_price}}</td>
                                        <td>{{empty($app->currency) ? "GHS" : $app->currency}}{{$list->invoice_total_price}}</td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                            </div>
                        
                    </div>
                    <!-- Row end -->

                </div>
            </div>
            <!-- Card end -->

        </div>
    </div>
    <!-- Row end -->

    <!-- Row start -->
    <div class="row gutters">
        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
        <div class="card-header">
                    <div class="card-title">Report on Sales Person Category</div>
                </div>
            <div class="card">
                <div class="card-body">
                    <div class="table-responsive">
                    <table class="table table-bordered table-striped m-0">
                            <thead>
                                <tr>
                                  <th>Sales Type</th>
                                  <th>Description</th>
                                  <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>												  
                                  <td>Counter [Walk In Customer] Transactions</td>
                                  <td>View report and transaction for counter sales or walk in customers</td>
                                  <td>
                                  <form action="{{route('getDeliveryReportRouteDate')}}" method="get">
                                        @csrf
                                        <input type="text" name="branch" hidden value="{{request()->branch}}">
                                        <input type="text" name="category" hidden value="Counter">
                                        <input type="text" readonly hidden name="date" value="{{request()->date}}">
                                        <button type="submit" class="btn btn-outline-primary rounded-pill btn-sm"> 
                                        View Report
                                        </button>
                                    </form>
                                  </td>
                                </tr>
                         @if(request()->branch == "DAKODWOM BRANCH")
                         <tr>												  
                            <td>Drive Thru</td>
                            <td>View Report of Drive-Thru Transactions</td>
                            <td>
                            <form action="{{route('getDeliveryReportRouteDate')}}" method="get">
                                @csrf
                                <input type="text" name="branch" hidden value="{{request()->branch}}">
                                <input type="text" name="category" hidden value="Drive Thru">
                                <input type="text" readonly hidden name="date" value="{{request()->date}}">
                                <button type="submit" class="btn btn-outline-primary rounded-pill btn-sm">
                                View Report
                                </button>
                            </form>
                            </td>
                        </tr>
                                    
                            @else
                            <tr>												  
                                  <td>Delivery [ Call Center Orders ] Transactions</td>
                                  <td>View report for Call Center or Delivery transaction</td>
                                  <td>
                                  <form action="{{route('getDeliveryReportRouteDate')}}" method="get">
                                        @csrf
                                        <input type="text" name="branch" hidden value="{{request()->branch}}">
                                        <input type="text" name="category" hidden value="Delivery">
                                        <input type="text" readonly hidden name="date" value="{{request()->date}}">
                                        <button type="submit" class="btn btn-outline-primary rounded-pill btn-sm">
                                        View Report
                                        </button>
                                    </form>
                                  </td>
                                </tr>
                                @endif
                            </tbody>
                    </table>
                    </div>

                </div>
            </div>


            <!-- users and sales person category -->

             <!-- Row start -->
      <div class="row gutters">
        <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">

            <!-- Card start -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title">Invoice List</div>
                </div>
                <div class="card-body">
                    
                    <!-- Row start -->
                    <div class="row gutters">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">        
                        <table id="scrollVertical" class="table custom-table">

                                <thead>
                                    <tr>
                                        <th>Order ID</th>
                                        <th>Transaction By</th>												
                                        <th> Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($all_orders as $list)
                                    <tr>
                                        <td>
                                        #{{$list->order_id}}
                                        </td>
                                        <td>
                                        {{@strtoupper($list->name)}}
                                        </td>
                                        <td><a href="{{route('orderTransaction',$list->order_id)}}" class="text-primary" style="text-decoration:underline">view</a></td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>

                        </div>
                    </div>
                    <!-- Row end -->

                </div>
            </div>
            <!-- Card end -->

        </div>
        <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">

            <!-- Card start -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title">User Report</div>
                </div>
                <div class="card-body">
                    
                    <!-- Row start -->
                    <div class="row gutters">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            
                        <table class="table table-bordered table-striped m-0">
                                <thead>
                                    <tr>
                                        <th>Name</th>
                                        <th>Branch</th>		
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($users_all as $list)
                                    <tr>
                                        <td>
                                        {{@strtoupper($list->name)}}
                                        </td>
                                        <td>{{$list->branch}}</td>
                                        <td>
                                            <form action="{{route('dateReportByUser')}}" method="get">
                                                @csrf
                                                <input type="text" name="user_id" hidden value="{{$list->id}}">
                                                <input type="text" readonly hidden name="date" value="{{request()->date}}">
                                                <button type="submit" class="btn btn-primary btn-sm"> 
                                                Transaction
                                                </button>
                                            </form>
                                        </td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                           
                        
                    </div>
                    <!-- Row end -->

                </div>
            </div>
        </div>
    </div>
</div>
            <!-- Card end -->


            
            </div>
        </div>
    </div>
    <!-- Row end -->



    


</div>
<!-- Content wrapper end -->




@endsection