Merge pull request #1178 from openclassify/dia

#2480 Sales Reports
This commit is contained in:
Muammer Top 2021-10-01 12:38:03 +03:00 committed by GitHub
commit 6237355bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 169 additions and 2 deletions

View File

@ -56,4 +56,20 @@ $(document).ready( function () {
},
],
});
$('#metaPageReport').DataTable({
ajax: '/admin/api/classified/report/page',
columns: [
{
data: 'name',
render: function ( data, type, row, meta ) {
return `
<a href="/admin/pages/edit/${row.id}" class="text-info">
${data ?? productsReportTrans.undefined_page}
</a>
`;
}
},
],
});
} );

View File

@ -392,4 +392,7 @@ return [
'product' => 'Product',
'count' => 'Count',
'undefined_product' => 'Undefined Product',
'pages_without_meta_information_report' => 'Pages Without Meta Information Report',
'page' => 'Page',
'undefined_page' => 'Undefined Page',
];

View File

@ -30,6 +30,13 @@
trans('visiosoft.module.advs::field.product'),
],
},
{
'title': trans('visiosoft.module.advs::field.pages_without_meta_information_report'),
'id': 'metaPageReport',
'columns': [
trans('visiosoft.module.advs::field.page'),
],
},
] %}
{% for report in reports %}
@ -58,6 +65,7 @@
<script>
const productsReportTrans = {
undefined_product: `{{ trans('visiosoft.module.advs::field.undefined_product') }}`,
undefined_page: `{{ trans('visiosoft.module.advs::field.undefined_page') }}`,
}
</script>

View File

@ -1,6 +1,5 @@
<?php namespace Visiosoft\AdvsModule\Adv\Event;
class PriceChange
{
public function __construct($request)

View File

@ -254,6 +254,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'admin/api/classified/report/status' => 'Visiosoft\AdvsModule\Http\Controller\Admin\ReportController@status',
'admin/api/classified/report/unexplained' => 'Visiosoft\AdvsModule\Http\Controller\Admin\ReportController@unexplained',
'admin/api/classified/report/no-image' => 'Visiosoft\AdvsModule\Http\Controller\Admin\ReportController@noImage',
'admin/api/classified/report/page' => 'Visiosoft\AdvsModule\Http\Controller\Admin\ReportController@page',
];
protected $middleware = [

View File

@ -1,5 +1,6 @@
<?php namespace Visiosoft\AdvsModule\Http\Controller\Admin;
use Anomaly\PagesModule\Page\Contract\PageRepositoryInterface;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
@ -52,4 +53,23 @@ class ReportController extends AdminController
'data' => $this->advRepository->getNoImageClassifiedsReport()
];
}
public function page(PageRepositoryInterface $pageRepository)
{
$pages = $pageRepository->newQuery()
->select('title as name', 'pages_pages.id')
->where(function ($q) {
$q->whereNull('meta_title')
->orWhereNull('meta_description');
})
->leftJoin('pages_pages_translations as pages_trans', function ($join) {
$join->on('pages_pages.id', '=', 'pages_trans.entry_id');
$join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);
})
->get();
return [
'data' => $pages
];
}
}

View File

@ -0,0 +1,27 @@
$(document).ready( function () {
$('#metaCategoryReport').DataTable({
ajax: {
url: '/admin/api/cats/report/category',
dataSrc( json ) {
json.recordsTotal = json.total;
json.recordsFiltered = json.total;
return json.data;
}
},
processing: true,
serverSide: true,
columns: [
{
data: 'name',
render: function ( data, type, row, meta ) {
return `
<a href="/admin/cats/edit/${row.id}" class="text-info">
${data ? data : categoryReportTrans.undefined_category}
</a>
`;
}
},
],
});
} );

View File

@ -37,5 +37,10 @@ return [
'please_wait' => 'Please wait.Deleting Sub Categories',
'category_selection' => 'Category Selection',
'go_to_parent' => 'Go To Parent',
'preview' => 'Preview'
'preview' => 'Preview',
// Report
'undefined_category' => 'Undefined Category',
'categories_with_no_meta_report' => 'Categories with No Meta Report',
'category' => 'Category',
];

View File

@ -0,0 +1,41 @@
<div class="row">
{% set reports = [
{
'title': trans('visiosoft.module.cats::field.categories_with_no_meta_report'),
'id': 'metaCategoryReport',
'columns': [
trans('visiosoft.module.cats::field.category'),
],
},
] %}
{% for report in reports %}
<div class="col-md-12">
<div class="card">
<div class="card-header bg-danger">
<h5 class="card-title text-white">{{ report.title }}</h5>
</div>
<div class="card-block">
<table id="{{ report.id }}" class="display">
<thead>
<tr>
{% for column in report.columns %}
<th>{{ column }}</th>
{% endfor %}
</tr>
</thead>
</table>
</div>
</div>
</div>
{% endfor %}
</div>
<script>
const categoryReportTrans = {
undefined_category: `{{ trans('visiosoft.module.cats::field.undefined_category') }}`,
};
</script>
{{ asset_add('scripts.js', 'visiosoft.module.cats::js/admin/dashboard/report.js') }}

View File

@ -184,4 +184,34 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
$cats->maincats = $catsDB->unique('id');
return $cats;
}
public function noMetaReport()
{
$categories = $this->newQuery()
->select('name as category', 'cats_category.id')
->where(function ($q) {
$q->whereNull('seo_keyword')
->orWhereNull('seo_description');
})
->leftJoin('cats_category_translations as cats_trans', function ($join) {
$join->on('cats_category.id', '=', 'cats_trans.entry_id');
$join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);
});
if ($search = request('search.value')) {
$categories = $categories->where('name', 'LIKE', "%$search%");
}
if ($orderDir = request('order.0.dir')) {
$categories = $categories->orderBy('category', $orderDir);
}
$start = request('start');
$limit = request('length') ?: 10;
$page = $start ? $start / $limit + 1 : 1;
$categories = $categories->paginate($limit, ['*'], 'page', $page);
return $categories;
}
}

View File

@ -23,4 +23,6 @@ interface CategoryRepositoryInterface extends EntryRepositoryInterface
public function getDeletedCategories();
public function getMainAndSubCats();
public function noMetaReport();
}

View File

@ -49,6 +49,9 @@ class CatsModuleServiceProvider extends AddonServiceProvider
'uses' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@all',
],
// Admin ReportController
'admin/api/cats/report/category' => 'Visiosoft\CatsModule\Http\Controller\Admin\ReportController@category',
// Sitemap
'sitemap.xml' => 'Visiosoft\CatsModule\Http\Controller\SitemapController@index',
'sitemap.xml/categories' => 'Visiosoft\CatsModule\Http\Controller\SitemapController@categories',

View File

@ -0,0 +1,12 @@
<?php namespace Visiosoft\CatsModule\Http\Controller\Admin;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
class ReportController extends AdminController
{
public function category(CategoryRepositoryInterface $categoryRepository)
{
return $categoryRepository->noMetaReport();
}
}