mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#2480 Sales Reports
This commit is contained in:
parent
10c0ad2361
commit
abe3218fea
@ -1,6 +1,16 @@
|
||||
$(document).ready( function () {
|
||||
$('#stockReport').DataTable({
|
||||
ajax: '/admin/api/classified/report/stock',
|
||||
ajax: {
|
||||
url: '/admin/api/classified/report/stock',
|
||||
dataSrc( json ) {
|
||||
json.recordsTotal = json.total;
|
||||
json.recordsFiltered = json.total;
|
||||
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
order: [[ 1, "asc" ]],
|
||||
columns: [
|
||||
{
|
||||
@ -26,7 +36,17 @@ $(document).ready( function () {
|
||||
});
|
||||
|
||||
$('#unexplainedReport').DataTable({
|
||||
ajax: '/admin/api/classified/report/unexplained',
|
||||
ajax: {
|
||||
url: '/admin/api/classified/report/unexplained',
|
||||
dataSrc( json ) {
|
||||
json.recordsTotal = json.total;
|
||||
json.recordsFiltered = json.total;
|
||||
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
columns: [
|
||||
{
|
||||
data: 'name',
|
||||
@ -42,7 +62,17 @@ $(document).ready( function () {
|
||||
});
|
||||
|
||||
$('#noImageReport').DataTable({
|
||||
ajax: '/admin/api/classified/report/no-image',
|
||||
ajax: {
|
||||
url: '/admin/api/classified/report/no-image',
|
||||
dataSrc( json ) {
|
||||
json.recordsTotal = json.total;
|
||||
json.recordsFiltered = json.total;
|
||||
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
columns: [
|
||||
{
|
||||
data: 'name',
|
||||
@ -58,7 +88,17 @@ $(document).ready( function () {
|
||||
});
|
||||
|
||||
$('#metaPageReport').DataTable({
|
||||
ajax: '/admin/api/classified/report/page',
|
||||
ajax: {
|
||||
url: '/admin/api/classified/report/page',
|
||||
dataSrc( json ) {
|
||||
json.recordsTotal = json.total;
|
||||
json.recordsFiltered = json.total;
|
||||
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
columns: [
|
||||
{
|
||||
data: 'name',
|
||||
|
||||
@ -549,7 +549,6 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
return $query
|
||||
->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
|
||||
->where('status', '=', 'approved')
|
||||
->where('slug', '!=', '')
|
||||
->orderBy('publish_at', 'desc');
|
||||
->where('slug', '!=', '');
|
||||
}
|
||||
}
|
||||
|
||||
@ -595,16 +595,28 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
|
||||
public function getStockReport()
|
||||
{
|
||||
return $this->newQuery()
|
||||
$classifieds = $this->newQuery()
|
||||
->current()
|
||||
->select('stock', 'name', 'advs_advs.id', 'slug')
|
||||
->where('is_get_adv', true)
|
||||
->where('stock', '<=', 10)
|
||||
->leftJoin('advs_advs_translations as classified_trans', function ($join) {
|
||||
$join->on('advs_advs.id', '=', 'classified_trans.entry_id');
|
||||
$join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);
|
||||
})
|
||||
->get();
|
||||
});
|
||||
|
||||
if ($search = request('search.value')) {
|
||||
$classifieds = $classifieds->where('name', 'LIKE', "%$search%");
|
||||
}
|
||||
|
||||
if ($orderDir = request('order.0.dir')) {
|
||||
$classifieds = $classifieds->orderBy(request('order.0.column') == 1 ? 'stock' : 'name', $orderDir);
|
||||
}
|
||||
|
||||
$start = request('start');
|
||||
$limit = request('length') ?: 10;
|
||||
$page = $start ? $start / $limit + 1 : 1;
|
||||
|
||||
return $classifieds->paginate($limit, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
public function getAllClassifiedsCount()
|
||||
@ -622,25 +634,38 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
|
||||
public function getUnexplainedClassifiedsReport()
|
||||
{
|
||||
return $this->newQuery()
|
||||
$classifieds = $this->newQuery()
|
||||
->current()
|
||||
->select('name', 'advs_advs.id', 'slug')
|
||||
->select('classified_trans.name', 'advs_advs.id', 'slug')
|
||||
->where(function ($query) {
|
||||
$query->where('advs_desc', '=', '')
|
||||
->orWhereNull('advs_desc');
|
||||
$query->where('classified_trans.advs_desc', '=', '')
|
||||
->orWhereNull('classified_trans.advs_desc');
|
||||
})
|
||||
->leftJoin('advs_advs_translations as classified_trans', function ($join) {
|
||||
$join->on('advs_advs.id', '=', 'classified_trans.entry_id');
|
||||
$join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);
|
||||
})
|
||||
->get();
|
||||
});
|
||||
|
||||
if ($search = request('search.value')) {
|
||||
$classifieds = $classifieds->where('classified_trans.name', 'LIKE', "%$search%");
|
||||
}
|
||||
|
||||
if ($orderDir = request('order.0.dir')) {
|
||||
$classifieds = $classifieds->orderBy('name', $orderDir);
|
||||
}
|
||||
|
||||
$start = request('start');
|
||||
$limit = request('length') ?: 10;
|
||||
$page = $start ? $start / $limit + 1 : 1;
|
||||
|
||||
return $classifieds->paginate($limit, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
public function getNoImageClassifiedsReport()
|
||||
{
|
||||
return $this->newQuery()
|
||||
$classifieds = $this->newQuery()
|
||||
->current()
|
||||
->select('name', 'advs_advs.id', 'slug')
|
||||
->select('classified_trans.name', 'advs_advs.id', 'slug')
|
||||
->where(function ($query) {
|
||||
$query->where('cover_photo', '=', '')
|
||||
->orWhereNull('cover_photo');
|
||||
@ -648,7 +673,20 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
->leftJoin('advs_advs_translations as classified_trans', function ($join) {
|
||||
$join->on('advs_advs.id', '=', 'classified_trans.entry_id');
|
||||
$join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);
|
||||
})
|
||||
->get();
|
||||
});
|
||||
|
||||
if ($search = request('search.value')) {
|
||||
$classifieds = $classifieds->where('classified_trans.name', 'LIKE', "%$search%");
|
||||
}
|
||||
|
||||
if ($orderDir = request('order.0.dir')) {
|
||||
$classifieds = $classifieds->orderBy('name', $orderDir);
|
||||
}
|
||||
|
||||
$start = request('start');
|
||||
$limit = request('length') ?: 10;
|
||||
$page = $start ? $start / $limit + 1 : 1;
|
||||
|
||||
return $classifieds->paginate($limit, ['*'], 'page', $page);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,9 +16,7 @@ class ReportController extends AdminController
|
||||
|
||||
public function stock()
|
||||
{
|
||||
return [
|
||||
'data' => $this->advRepository->getStockReport()
|
||||
];
|
||||
return $this->advRepository->getStockReport();
|
||||
}
|
||||
|
||||
public function status()
|
||||
@ -42,16 +40,12 @@ class ReportController extends AdminController
|
||||
|
||||
public function unexplained()
|
||||
{
|
||||
return [
|
||||
'data' => $this->advRepository->getUnexplainedClassifiedsReport()
|
||||
];
|
||||
return $this->advRepository->getUnexplainedClassifiedsReport();
|
||||
}
|
||||
|
||||
public function noImage()
|
||||
{
|
||||
return [
|
||||
'data' => $this->advRepository->getNoImageClassifiedsReport()
|
||||
];
|
||||
return $this->advRepository->getNoImageClassifiedsReport();
|
||||
}
|
||||
|
||||
public function page(PageRepositoryInterface $pageRepository)
|
||||
@ -65,11 +59,20 @@ class ReportController extends AdminController
|
||||
->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
|
||||
];
|
||||
if ($search = request('search.value')) {
|
||||
$pages = $pages->where('title', 'LIKE', "%$search%");
|
||||
}
|
||||
|
||||
if ($orderDir = request('order.0.dir')) {
|
||||
$pages = $pages->orderBy('title', $orderDir);
|
||||
}
|
||||
|
||||
$start = request('start');
|
||||
$limit = request('length') ?: 10;
|
||||
$page = $start ? $start / $limit + 1 : 1;
|
||||
|
||||
return $pages->paginate($limit, ['*'], 'page', $page);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user