<style>.woocommerce-product-gallery{ opacity: 1 !important; }</style>

MODULES

Reports Generator


What does it do?

This module allows you to generate simpla date-based reports from your existing CRUDs data without coding.

You generate reports online - as many as you want, and then you download them as part of your generated code.

Notice: Reports can be generated only online, downloaded panel doesn't have function to create new reports.

To view the data in a chart form, we use Chart.js library.


How does the result look in QuickAdminPanel code?

We create one ReportsController file which stores separate methods for each report.

class ReportsController extends Controller
{
    public function registeredUsers()
    {
        $reportTitle = 'Registered Users';
        $reportLabel = 'COUNT';
        $chartType   = 'line';

        $results = User::get()->sortBy('created_at')->groupBy(function ($entry) {
            if ($entry->created_at instanceof \Carbon\Carbon) {
                return \Carbon\Carbon::parse($entry->created_at)->format('Y-m-d');
            }

            return \Carbon\Carbon::createFromFormat(config('app.date_format'), $entry->created_at)->format('Y-m-d');
        })->map(function ($entries, $group) {
            return $entries->sum('id');
        });

        return view('admin.reports', compact('reportTitle', 'results', 'chartType', 'reportLabel'));
    }

}
And View file admin/reports.blade.php looks like this:
<div class="row">
    <div class="col-md-10">
        <h2 style="margin-top: 0;">{{ $reportTitle }}</h2>

        <canvas id="myChart"></canvas>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
        <script>
            var ctx = document.getElementById("myChart");
            var myChart = new Chart(ctx, {
                type: '{{ $chartType }}',
                data: {
                    labels: [
                        @foreach ($results as $group => $result)
                            "{{ $group }}",
                        @endforeach
                    ],

                    datasets: [{
                        label: '{{ $reportLabel }}',
                        data: [
                            @foreach ($results as $group => $result)
                                {!! $result !!},
                            @endforeach
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    scales: {
                        yAxes: [{
                            ticks: {
                                beginAtZero:true
                            }
                        }]
                    }
                }
            });
        </script>
    </div>
</div>

You can easily customize each of the reports after download by adding more logic in the files above.


How to install/use the module?

First, go to your panel's Modules menu item, find the module in the list and click Install.

Then you will see a new menu item Reports on the left, where you can add your reports.

After creating reports, you will see another new menu item Generated Reports with the list of the reports - you can check the results there.

As soon as you're happy with your panel, download the files, and reports will be among them.


More information