%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/silvzytp/crm-dub-code/resources/views/backend/report/
Upload File :
Create Path :
Current File : //home/silvzytp/crm-dub-code/resources/views/backend/report/index.blade.php

@extends('layouts.backend')
@section('title', $siteTitle)
@section('action')
<button class="btn btn-sm btn-success printarea">Print</button>
<button type="button" class="btn btn-sm btn-primary export-btn">Export</button>
@endsection
@push('styles')
<style>
    .data-render{
        top: 10%;
        left: 50%;
        transform: translate(-10%, -50%);
    }
    .opacity-7{
        opacity: .4;
    }
</style>
@endpush

@section('content')
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <div class="row align-items-center">
                        <div class="col-4 col-md-8">
                            <h2 class="card-title mb-0">Monthly Report</h2>
                        </div>
                        <div class="col-8 col-md-4">
                            <form method="GET" id="filter-form">
                                <div class="d-flex align-items-center">
                                    <select name="year" class="form-control form-control-sm">
                                        <option value="">-- Select Year --</option>
                                        @php
                                            $current_year = Carbon\Carbon::now()->format('Y');
                                        @endphp
                                        @for ($i=2000;$i<=$current_year; $i++)
                                        <option value="{{ $i }}" {{ $i == $current_year ? 'selected' : '' }}>{{ $i }}</option>
                                        @endfor
                                    </select>

                                    <select name="month" class="form-control form-control-sm mx-2">
                                        <option value="">-- Select Month --</option>
                                        @foreach (MONTH as $key=>$value)
                                        <option value="{{ $key }}">{{ $value }}</option>
                                        @endforeach
                                    </select>

                                    <button type="button" class="btn btn-sm btn-primary filter-btn"><i class="fas fa-search"></i></button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="card-body px-0 position-relative">
                    <div class="data-render position-absolute d-none">
                        <img src="{{ asset('uploads/images/table-loading.svg') }}" alt="">
                    </div>
                    <div class="table-responsive d-flex" id="filter-table">
                        <div id="print-table">
                            <style>
                                @media screen {
                                    .no_screen {display: none;}
                                    .no_print {display: block;}
                                    body {margin: 0;}
                                }

                                @media print {
                                    body,
                                    html {
                                        -webkit-print-color-adjust: exact !important;
                                        font-family: sans-serif;
                                        margin-bottom: 100px !important;
                                    }
                                    table{
                                        width: 100%;
                                    }
                                    .table-responsive{
                                        overflow-x: inherit !important;
                                    }
                                }
                                @page {
                                    size: landscape;
                                    margin: 5mm 5mm;
                                }
                            </style>
                            <table class="table">
                                <thead>
                                    <th style="min-width: 200px;">Agent</th>
                                    @foreach (MONTH_DAY_DATA as $key=>$day)
                                    <th style="min-width: 80px;">{{ $day }}</th>
                                    @endforeach
                                    <th style="min-width: 80px;">Total</th>
                                </thead>
                                <tbody>
                                    @php
                                        foreach (MONTH_DAY_DATA as $key => $value) {
                                            $$key = 0;
                                        }
                                    @endphp
                                    @foreach ($agents as $agent)
                                    @php
                                        $total = 0;
                                    @endphp
                                    <tr>
                                        <td>{{ $agent->name }}</td>
                                        @foreach (MONTH_DAY_DATA as $key=>$day)
                                            @php
                                                $call_count = DB::table('fresh_leads')
                                                    ->where('agent_id',$agent->id)
                                                    ->whereYear('created_at',Carbon\Carbon::now()->format('Y'))
                                                    ->whereMonth('created_at',$month)
                                                    ->whereDay('created_at',$key)->count();
                                                $$key += $call_count;
                                                $total += $call_count;
                                            @endphp
                                        <td class="{{ $call_count == 0 ? 'opacity-7' : '' }}">{{ $call_count }}</td>
                                        @endforeach
                                        <td><strong>{{ $total }}</strong></td>
                                    </tr>
                                    @endforeach

                                    {{-- agent total call --}}
                                    <tr class="bg-success">
                                        <td style="min-width: 200px;"><strong>Total</strong></td>
                                        @php
                                            $in_total = 0;
                                        @endphp
                                        @foreach (MONTH_DAY_DATA as $key=>$day)
                                        @php
                                            $in_total += $$key;
                                        @endphp
                                        <td><strong>{{ $$key }}</strong></td>
                                        @endforeach
                                        <td><strong>{{ $in_total }}</strong></td>
                                    </tr>

                                    {{-- source --}}
                                    @php
                                        foreach (MONTH_DAY_DATA as $day_id => $day_name) {
                                            $$day_id = 0;
                                        }
                                    @endphp

                                    @foreach ($sources as $source)
                                    @php
                                        $source_column_total = 0;
                                    @endphp
                                    <tr>
                                        <td>{{ $source->name }}</td>
                                        @foreach (MONTH_DAY_DATA as $day_id=>$day_name)
                                            @php
                                                $source_count = DB::table('fresh_leads')
                                                    ->where(['marketing_source_id'=>$source->id])
                                                    ->whereYear('created_at',Carbon\Carbon::now()->format('Y'))
                                                    ->whereMonth('created_at',$month)
                                                    ->whereDay('created_at',$day_id)->count();
                                                $$day_id += $source_count;
                                                $source_column_total += $source_count;
                                            @endphp
                                        <td class="{{ $source_count == 0 ? 'opacity-7' : '' }}">{{ $source_count }}</td>
                                        @endforeach
                                        <td><strong>{{ $source_column_total }}</strong></td>
                                    </tr>
                                    @endforeach

                                    {{-- source column total --}}
                                    <tr class="bg-success">
                                        <td style="min-width: 200px;"><strong>Total</strong></td>
                                        @php
                                            $source_in_total = 0;
                                        @endphp
                                        @foreach (MONTH_DAY_DATA as $day_id=>$day_name)
                                        @php
                                            $source_in_total += $$day_id;
                                        @endphp
                                        <td><strong>{{ $$day_id }}</strong></td>
                                        @endforeach
                                        <td><strong>{{ $source_in_total }}</strong></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    @include('backend.report.export')
@endsection

@push('scripts')
<script src="{{ asset('assets/js/printarea.js') }}"></script>
<script>
    $(document).on('click','button.filter-btn', function(){
        var year = $('select[name="year"]').val();
        var month = $('select[name="month"]').val();
        if (year == '' || month == '') {
            alert('The year and month field is requried!')
        }else{
            $.ajax({
                type: "GET",
                url: "{{ route('super.report.filter') }}",
                data: {year:year,month:month},
                cache: false,
                dataType: "JSON",
                beforeSend: function(){
                    $('.data-render').removeClass('d-none');
                },
                complete: function(){
                    $('.data-render').addClass('d-none');
                },
                success: function (response) {
                    $('#filter-table').html('');
                    $('#filter-table').html(response);
                }
            });
        }
    });

    $(document).on('click','button.export-btn',function(){
        $('#export-form')[0].reset();
        $('#export-modal').modal({
            keyboard: false,
            backdrop: 'static'
        });
    });

    $(document).on('submit','form#export-form',function(){
        $('#export-modal').modal('hide');
    });

    // print area
    $(document).on('click','button.printarea',function(){
        var mode   = 'iframe';        //popup
        var close  = mode = 'popup';
        var options = {
            mode    : mode,
            popClose: close
        }

        $('#filter-table').printArea(options);
    });
</script>
@endpush

Zerion Mini Shell 1.0