#2480 Sales Reports

This commit is contained in:
diashalabi 2021-09-28 16:45:45 +03:00
parent 420a25f801
commit e239937e5c
3 changed files with 124 additions and 0 deletions

View File

@ -592,4 +592,63 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return false; return false;
} }
public function getStockReport()
{
return $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();
}
public function getAllClassifiedsCount()
{
return $this->newQuery()
->count();
}
public function getCurrentClassifiedsCount()
{
return $this->newQuery()
->current()
->count();
}
public function getUnexplainedClassifiedsReport()
{
return $this->newQuery()
->current()
->select('name', 'advs_advs.id', 'slug')
->where(function ($query) {
$query->where('advs_desc', '=', '')
->orWhereNull('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();
}
public function getNoImageClassifiedsReport()
{
return $this->newQuery()
->current()
->select('name', 'advs_advs.id', 'slug')
->where(function ($query) {
$query->where('cover_photo', '=', '')
->orWhereNull('cover_photo');
})
->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();
}
} }

View File

@ -60,4 +60,14 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function findByCFJSON($key, $value); public function findByCFJSON($key, $value);
public function uploadImage(); public function uploadImage();
public function getStockReport();
public function getAllClassifiedsCount();
public function getCurrentClassifiedsCount();
public function getUnexplainedClassifiedsReport();
public function getNoImageClassifiedsReport();
} }

View File

@ -0,0 +1,55 @@
<?php namespace Visiosoft\AdvsModule\Http\Controller\Admin;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
class ReportController extends AdminController
{
protected $advRepository;
public function __construct(AdvRepositoryInterface $advRepository)
{
parent::__construct();
$this->advRepository = $advRepository;
}
public function stock()
{
return [
'data' => $this->advRepository->getStockReport()
];
}
public function status()
{
$all = $this->advRepository->getAllClassifiedsCount();
$active = $this->advRepository->getCurrentClassifiedsCount();
return [
'data' => [
[
'status' => 'Active',
'count' => $active,
],
[
'status' => 'Passive',
'count' => $all - $active,
],
]
];
}
public function unexplained()
{
return [
'data' => $this->advRepository->getUnexplainedClassifiedsReport()
];
}
public function noImage()
{
return [
'data' => $this->advRepository->getNoImageClassifiedsReport()
];
}
}