¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -9,11 +9,13 @@ class BrandedProductsReport extends Report
{
protected $filters = [];
protected function view()
{
return 'report::admin.reports.branded_products_report.index';
}
protected function query()
{
return Brand::select('id')

View File

@@ -9,11 +9,13 @@ class CategorizedProductsReport extends Report
{
protected $filters = [];
protected function view()
{
return 'report::admin.reports.categorized_products_report.index';
}
protected function query()
{
return Category::withoutGlobalScope('active')

View File

@@ -8,11 +8,13 @@ class CouponsReport extends Report
{
protected $date = 'orders.created_at';
protected function view()
{
return 'report::admin.reports.coupons_report.index';
}
protected function query()
{
return Coupon::withoutGlobalScope('active')

View File

@@ -11,6 +11,7 @@ class CustomersOrderReport extends Report
return 'report::admin.reports.customers_order_report.index';
}
protected function query()
{
return Order::select('customer_id', 'customer_first_name', 'customer_last_name', 'customer_email')

View File

@@ -4,6 +4,7 @@ namespace Modules\Report\Http\Controllers\Admin;
use Illuminate\Http\Request;
use Modules\Report\TaxReport;
use Illuminate\Http\Response;
use Modules\Report\SalesReport;
use Modules\Report\SearchReport;
use Modules\Report\CouponsReport;
@@ -40,27 +41,31 @@ class ReportController
'tax_report' => TaxReport::class,
];
/**
* Display a listing of the resource.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
* @param Request $request
*
* @return Response
*/
public function index(Request $request)
{
$type = $request->query('type');
if (! $this->reportTypeExists($type)) {
if (!$this->reportTypeExists($type)) {
return redirect()->route('admin.reports.index', ['type' => 'coupons_report']);
}
return $this->report($type)->render($request);
}
/**
* Determine if the report type exists.
*
* @param string $type
*
* @return bool
*/
private function reportTypeExists($type)
@@ -68,10 +73,12 @@ class ReportController
return array_key_exists($type, $this->reports);
}
/**
* Returns a new instance of the given type of report.
*
* @param string $type
*
* @return mixed
*/
private function report($type)

View File

@@ -8,11 +8,13 @@ class ProductsPurchaseReport extends Report
{
protected $date = 'orders.created_at';
protected function view()
{
return 'report::admin.reports.products_purchase_report.index';
}
protected function query()
{
return Product::withoutGlobalScope('active')

View File

@@ -11,6 +11,7 @@ class ProductsStockReport extends Report
return 'report::admin.reports.products_stock_report.index';
}
protected function query()
{
return Product::select('id', 'qty', 'in_stock')

View File

@@ -8,11 +8,13 @@ class ProductsViewReport extends Report
{
protected $filters = [];
protected function view()
{
return 'report::admin.reports.products_view_report.index';
}
protected function query()
{
return Product::withoutGlobalScope('active')

View File

@@ -3,13 +3,10 @@
namespace Modules\Report\Providers;
use Illuminate\Support\Facades\View;
use Modules\Support\Traits\AddsAsset;
use Illuminate\Support\ServiceProvider;
class ReportServiceProvider extends ServiceProvider
{
use AddsAsset;
/**
* Bootstrap the application services.
*
@@ -20,7 +17,5 @@ class ReportServiceProvider extends ServiceProvider
View::composer('report::admin.reports.*', function ($view) {
$view->with('request', $this->app['request']);
});
$this->addAdminAssets('admin.reports.index', ['admin.report.css', 'admin.report.js']);
}
}

View File

@@ -11,14 +11,6 @@ abstract class Report
protected $groups = ['years', 'months', 'weeks', 'days'];
protected $date = 'created_at';
abstract protected function view();
abstract protected function query();
protected function data()
{
return [];
}
public function render($request)
{
@@ -30,6 +22,7 @@ abstract class Report
->with(array_merge(compact('report'), $this->data()));
}
public function report($request)
{
$this->query = $this->query();
@@ -41,28 +34,45 @@ abstract class Report
return $this->query;
}
abstract protected function query();
abstract protected function view();
protected function data()
{
return [];
}
private function filters($request)
{
return array_filter($request->query(), function ($value, $name) {
return ! is_null($value) && in_array($name, $this->filters);
return !is_null($value) && in_array($name, $this->filters);
}, ARRAY_FILTER_USE_BOTH);
}
private function from($date)
{
$this->query->whereDate($this->date, '>=', Carbon::parse($date));
}
private function to($date)
{
$this->query->whereDate($this->date, '<=', Carbon::parse($date));
}
private function status($status)
{
$this->query->where('orders.status', $status);
}
private function group($group)
{
if (in_array($group, $this->groups)) {
@@ -70,31 +80,12 @@ abstract class Report
}
}
private function groupByYears()
{
$this->groupAndOrderBy('YEAR');
}
private function groupByMonths()
{
$this->groupAndOrderBy('YEAR')
->groupAndOrderBy('MONTH');
}
private function groupByWeeks()
{
$this->groupAndOrderBy('YEAR')
->groupAndOrderBy('MONTH')
->groupAndOrderBy('WEEK');
}
private function groupByDays()
{
$this->groupAndOrderBy('YEAR')
->groupAndOrderBy('MONTH')
->groupAndOrderBy('WEEK')
->groupAndOrderBy('DAY');
}
private function groupAndOrderBy($part)
{
@@ -104,4 +95,28 @@ abstract class Report
return $this;
}
private function groupByMonths()
{
$this->groupAndOrderBy('YEAR')
->groupAndOrderBy('MONTH');
}
private function groupByWeeks()
{
$this->groupAndOrderBy('YEAR')
->groupAndOrderBy('MONTH')
->groupAndOrderBy('WEEK');
}
private function groupByDays()
{
$this->groupAndOrderBy('YEAR')
->groupAndOrderBy('MONTH')
->groupAndOrderBy('WEEK')
->groupAndOrderBy('DAY');
}
}

View File

@@ -0,0 +1,59 @@
.report-wrapper {
background: transparent;
box-shadow: none;
.box-body {
margin-left: -15px;
margin-right: -15px;
}
}
.report-result {
padding: 15px 15px 10px;
background: #ffffff;
border-radius: 3px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
.table-responsive {
margin-bottom: 0;
}
.table {
margin-top: 15px;
margin-bottom: 0;
td {
padding: 15px;
border: none;
&.empty {
text-align: center;
}
a {
color: #333;
}
}
}
}
.filter-report {
padding: 15px;
background: #ffffff;
border-radius: 3px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
form {
margin-top: 15px;
}
.form-group select {
width: 100%;
}
}
@media screen and (max-width: 991px) {
.filter-report {
margin-top: 30px;
}
}

View File

@@ -60,53 +60,53 @@ return [
'products_count' => 'Products Count',
'total' => 'Total',
// coupons_report
# coupons_report
'coupon_name' => 'Coupon Name',
'coupon_code' => 'Coupon Code',
// customer orders report
# customer orders report
'customer_name' => 'Customer Email',
'customer_email' => 'Customer Email',
'customer_group' => 'Customer Group',
'guest' => 'Guest',
'registered' => 'Registered',
// products purchase report
# products purchase report
'qty' => 'Qty',
// products stock report
# products stock report
'stock_availability' => 'Stock Availability',
// products view report
# products view report
'views' => 'Views',
// branded products report
# branded products report
'brand' => 'Brand',
// category products report
# category products report
'category' => 'Category',
// taxed products report
# taxed products report
'tax_class' => 'Tax Class',
// tagged products report
# tagged products report
'tag' => 'Tag',
// sales report
# sales report
'subtotal' => 'Subtotal',
'shipping' => 'Shipping',
'discount' => 'Discount',
'tax' => 'Tax',
// search report
# search report
'keyword' => 'Keyword',
'results' => 'Results',
'hits' => 'Hits',
// shipping report
# shipping report
'shipping_method' => 'Shipping Method',
// tax report
# tax report
'tax_name' => 'Tax Name',
],
];

View File

@@ -9,9 +9,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.branded_products_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -9,9 +9,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.categorized_products_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -13,9 +13,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.coupons_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -18,9 +18,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.customers_order_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -18,7 +18,7 @@
<div class="col-lg-3 col-md-4">
<div class="filter-report clearfix">
<h3 class="tab-content-title">{{ trans('report::admin.filter') }}</h3>
<h5 class="tab-content-title">{{ trans('report::admin.filter') }}</h5>
<form method="GET" action="{{ route('admin.reports.index') }}">
<div class="form-group">
@@ -45,3 +45,10 @@
</div>
</div>
@endsection
@push('globals')
@vite([
'Modules/Report/Resources/assets/admin/sass/main.scss',
'Modules/Report/Resources/assets/admin/js/main.js'
])
@endpush

View File

@@ -18,9 +18,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.products_purchase_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -29,9 +29,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.products_stock_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -13,9 +13,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.products_view_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -8,9 +8,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.sales_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -8,9 +8,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.search_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -22,9 +22,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.shipping_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -9,9 +9,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.tagged_products_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -13,9 +13,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.tax_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -17,9 +17,9 @@
@endsection
@section('report_result')
<h3 class="tab-content-title">
<h5 class="tab-content-title">
{{ trans('report::admin.filters.report_types.taxed_products_report') }}
</h3>
</h5>
<div class="table-responsive">
<table class="table">

View File

@@ -12,6 +12,7 @@ class SalesReport extends Report
return 'report::admin.reports.sales_report.index';
}
protected function query()
{
return Order::selectRaw('orders.id')

View File

@@ -8,10 +8,6 @@ class SearchReport extends Report
{
protected $filters = [];
protected function view()
{
return 'report::admin.reports.search_report.index';
}
public function query()
{
@@ -20,4 +16,10 @@ class SearchReport extends Report
$query->where('term', 'LIKE', request('keyword') . '%');
});
}
protected function view()
{
return 'report::admin.reports.search_report.index';
}
}

View File

@@ -7,18 +7,6 @@ use Modules\Shipping\Facades\ShippingMethod;
class ShippingReport extends Report
{
protected function view()
{
return 'report::admin.reports.shipping_report.index';
}
protected function data()
{
return [
'shippingMethods' => ShippingMethod::all(),
];
}
public function query()
{
return Order::select('shipping_method')
@@ -31,4 +19,18 @@ class ShippingReport extends Report
})
->groupBy('shipping_method');
}
protected function view()
{
return 'report::admin.reports.shipping_report.index';
}
protected function data()
{
return [
'shippingMethods' => ShippingMethod::all(),
];
}
}

View File

@@ -9,11 +9,13 @@ class TaggedProductsReport extends Report
{
protected $filters = [];
protected function view()
{
return 'report::admin.reports.tagged_products_report.index';
}
protected function query()
{
return Tag::select('id')

View File

@@ -8,10 +8,6 @@ class TaxReport extends Report
{
protected $date = 'orders.created_at';
protected function view()
{
return 'report::admin.reports.tax_report.index';
}
public function query()
{
@@ -27,4 +23,10 @@ class TaxReport extends Report
})
->groupBy('tax_rates.id');
}
protected function view()
{
return 'report::admin.reports.tax_report.index';
}
}

View File

@@ -9,16 +9,19 @@ class TaxedProductsReport extends Report
{
protected $filters = [];
protected function view()
{
return 'report::admin.reports.taxed_products_report.index';
}
protected function data()
{
return ['taxClasses' => TaxClass::list()];
}
protected function query()
{
return TaxClass::select('id')