From 654b27782317dfdf33c3d5ca1045d388f3042556 Mon Sep 17 00:00:00 2001 From: diashalabi Date: Fri, 24 Sep 2021 11:04:59 +0300 Subject: [PATCH 1/4] #3857 pusher error --- app/Providers/BroadcastServiceProvider.php | 2 +- config/broadcasting.php | 16 ++++++---------- routes/channels.php | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 1670987c1..395c518bc 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -18,4 +18,4 @@ class BroadcastServiceProvider extends ServiceProvider require base_path('routes/channels.php'); } -} \ No newline at end of file +} diff --git a/config/broadcasting.php b/config/broadcasting.php index 47a8db467..ec25f0541 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -32,19 +32,15 @@ return [ 'pusher' => [ 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY', '12345'), - 'secret' => env('PUSHER_APP_SECRET', '12345'), - 'app_id' => env('PUSHER_APP_ID', '12345'), + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - 'cluster' => env('PUSHER_APP_CLUSTER', 'mt1'), - 'encrypted' => env('BROADCAST_SSL', false), + 'cluster' => env('PUSHER_APP_CLUSTER'), + 'encrypted' => false, 'host' => '127.0.0.1', 'port' => 6001, - 'scheme' => env('BROADCAST_SSL', false) ? 'https' : 'http', - 'curl_options' => [ - CURLOPT_SSL_VERIFYHOST => 0, - CURLOPT_SSL_VERIFYPEER => 0, - ] + 'scheme' => 'http' ], ], diff --git a/routes/channels.php b/routes/channels.php index 5d451e1fa..9c586faf0 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -13,6 +13,6 @@ use Illuminate\Support\Facades\Broadcast; | */ -Broadcast::channel('App.Models.User.{id}', function ($user, $id) { +Broadcast::channel('Anomaly.UsersModule.User.UserModel.{id}', function ($user, $id) { return (int) $user->id === (int) $id; }); From f4064fa221301c96f671b8001da4e5a8167ad822 Mon Sep 17 00:00:00 2001 From: diashalabi Date: Mon, 27 Sep 2021 09:19:23 +0300 Subject: [PATCH 2/4] #3857 pusher error --- .../default/visiosoft/base-theme/resources/js/script.js | 6 +++--- config/broadcasting.php | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/default/visiosoft/base-theme/resources/js/script.js b/addons/default/visiosoft/base-theme/resources/js/script.js index 70565b5ed..7c62c80c7 100644 --- a/addons/default/visiosoft/base-theme/resources/js/script.js +++ b/addons/default/visiosoft/base-theme/resources/js/script.js @@ -1,4 +1,4 @@ $('.categories-list .show-all').on('click', function () { - $(this).siblings('.hidden-category').toggleClass('hidden') - $(this).find('a span').toggleClass('hidden') -}) + $(this).siblings('.hidden-category').toggleClass('hidden'); + $(this).find('a span').toggleClass('hidden'); +}); diff --git a/config/broadcasting.php b/config/broadcasting.php index ec25f0541..8b5ba4b16 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -37,10 +37,14 @@ return [ 'app_id' => env('PUSHER_APP_ID'), 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), - 'encrypted' => false, + 'encrypted' => true, 'host' => '127.0.0.1', 'port' => 6001, - 'scheme' => 'http' + 'scheme' => 'https', + 'curl_options' => [ + CURLOPT_SSL_VERIFYHOST => 0, + CURLOPT_SSL_VERIFYPEER => 0, + ] ], ], From 420a25f801e93557b3b20b1413eb6a5046df96b9 Mon Sep 17 00:00:00 2001 From: diashalabi Date: Tue, 28 Sep 2021 15:37:15 +0300 Subject: [PATCH 3/4] #2480 Sales Reports --- .../resources/js/admin/dashboard/report.js | 59 +++++++++++++++++ .../advs-module/resources/lang/en/field.php | 9 +++ .../views/admin/dashboard/report.twig | 64 +++++++++++++++++++ .../advs-module/src/Adv/AdvModel.php | 9 +++ .../src/Adv/Contract/AdvInterface.php | 2 + .../src/AdvsModuleServiceProvider.php | 6 ++ .../assets/js/admin/dashboard/report.js | 19 ++++++ .../resources/lang/en/field.php | 8 +++ .../views/admin/dashboard/report.twig | 50 +++++++++++++++ .../Controller/Admin/ReportController.php | 41 ++++++++++++ .../src/ProfileModuleServiceProvider.php | 4 ++ 11 files changed, 271 insertions(+) create mode 100644 addons/default/visiosoft/advs-module/resources/js/admin/dashboard/report.js create mode 100644 addons/default/visiosoft/advs-module/resources/views/admin/dashboard/report.twig create mode 100644 addons/default/visiosoft/profile-module/resources/assets/js/admin/dashboard/report.js create mode 100644 addons/default/visiosoft/profile-module/resources/views/admin/dashboard/report.twig create mode 100644 addons/default/visiosoft/profile-module/src/Http/Controller/Admin/ReportController.php diff --git a/addons/default/visiosoft/advs-module/resources/js/admin/dashboard/report.js b/addons/default/visiosoft/advs-module/resources/js/admin/dashboard/report.js new file mode 100644 index 000000000..92522a569 --- /dev/null +++ b/addons/default/visiosoft/advs-module/resources/js/admin/dashboard/report.js @@ -0,0 +1,59 @@ +$(document).ready( function () { + $('#stockReport').DataTable({ + ajax: '/admin/api/classified/report/stock', + order: [[ 1, "asc" ]], + columns: [ + { + data: 'name', + render: function ( data, type, row, meta ) { + return ` + + ${data ?? productsReportTrans.undefined_product} + + `; + } + }, + { data: 'stock' }, + ], + }); + + $('#activePassiveReport').DataTable({ + ajax: '/admin/api/classified/report/status', + columns: [ + { data: 'status' }, + { data: 'count' }, + ], + }); + + $('#unexplainedReport').DataTable({ + ajax: '/admin/api/classified/report/unexplained', + columns: [ + { + data: 'name', + render: function ( data, type, row, meta ) { + return ` + + ${data ?? productsReportTrans.undefined_product} + + `; + } + }, + ], + }); + + $('#noImageReport').DataTable({ + ajax: '/admin/api/classified/report/no-image', + columns: [ + { + data: 'name', + render: function ( data, type, row, meta ) { + return ` + + ${data ?? productsReportTrans.undefined_product} + + `; + } + }, + ], + }); +} ); diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/field.php b/addons/default/visiosoft/advs-module/resources/lang/en/field.php index b26c57483..f1ecaee86 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/field.php @@ -383,4 +383,13 @@ return [ 'name_a_z' => 'Name (A to Z)', 'name_z_a' => 'Name (Z to A)', 'select_lang_ads' => 'select the language of the ads', + + // Report + 'product_stock_report' => 'Product Stock Report', + 'active_passive_products_report' => 'Active-Passive Products Report', + 'unexplained_products_report' => 'Unexplained Products Report', + 'non_image_products_report' => 'Non-Image Products Report', + 'product' => 'Product', + 'count' => 'Count', + 'undefined_product' => 'Undefined Product', ]; diff --git a/addons/default/visiosoft/advs-module/resources/views/admin/dashboard/report.twig b/addons/default/visiosoft/advs-module/resources/views/admin/dashboard/report.twig new file mode 100644 index 000000000..9f7e14ae4 --- /dev/null +++ b/addons/default/visiosoft/advs-module/resources/views/admin/dashboard/report.twig @@ -0,0 +1,64 @@ +
+ {% set reports = [ + { + 'title': trans('visiosoft.module.advs::field.product_stock_report'), + 'id': 'stockReport', + 'columns': [ + trans('visiosoft.module.advs::field.product'), + trans('visiosoft.module.advs::field.stock.name'), + ], + }, + { + 'title': trans('visiosoft.module.advs::field.active_passive_products_report'), + 'id': 'activePassiveReport', + 'columns': [ + trans('visiosoft.module.advs::field.status.name'), + trans('visiosoft.module.advs::field.count'), + ], + }, + { + 'title': trans('visiosoft.module.advs::field.unexplained_products_report'), + 'id': 'unexplainedReport', + 'columns': [ + trans('visiosoft.module.advs::field.product'), + ], + }, + { + 'title': trans('visiosoft.module.advs::field.non_image_products_report'), + 'id': 'noImageReport', + 'columns': [ + trans('visiosoft.module.advs::field.product'), + ], + }, + ] %} + + {% for report in reports %} +
+
+
+
{{ report.title }}
+
+ +
+ + + + {% for column in report.columns %} + + {% endfor %} + + +
{{ column }}
+
+
+
+ {% endfor %} +
+ + + +{{ asset_add('scripts.js', 'visiosoft.module.advs::js/admin/dashboard/report.js') }} diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index 6f7377f07..4bc41fee4 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php @@ -543,4 +543,13 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface return $lastCat; } + + public function scopeCurrent($query) + { + return $query + ->whereDate('finish_at', '>=', date("Y-m-d H:i:s")) + ->where('status', '=', 'approved') + ->where('slug', '!=', '') + ->orderBy('publish_at', 'desc'); + } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php index 87702de18..8d7913146 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php @@ -97,4 +97,6 @@ interface AdvInterface extends EntryInterface public function getCatsIDs(); public function lastCategory(); + + public function scopeCurrent($query); } diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php index 8b96de2d9..b92a5472f 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php @@ -248,6 +248,12 @@ class AdvsModuleServiceProvider extends AddonServiceProvider 'as' => 'visiosoft.module.advs::ad.change.status', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\StatusController@change' ], + + // Admin ReportController + 'admin/api/classified/report/stock' => 'Visiosoft\AdvsModule\Http\Controller\Admin\ReportController@stock', + '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', ]; protected $middleware = [ diff --git a/addons/default/visiosoft/profile-module/resources/assets/js/admin/dashboard/report.js b/addons/default/visiosoft/profile-module/resources/assets/js/admin/dashboard/report.js new file mode 100644 index 000000000..bd649e8d1 --- /dev/null +++ b/addons/default/visiosoft/profile-module/resources/assets/js/admin/dashboard/report.js @@ -0,0 +1,19 @@ +$(document).ready( function () { + $('#newMemberReport').DataTable({ + ajax: '/admin/api/profile/report/latest', + order: [[ 1, "desc" ]], + columns: [ + { data: 'member', defaultContent: usersReportTrans.undefined_member }, + { data: 'date' }, + ], + }); + + $('#loginMemberReport').DataTable({ + ajax: '/admin/api/profile/report/login', + order: [[ 1, "desc" ]], + columns: [ + { data: 'member', defaultContent: usersReportTrans.undefined_member }, + { data: 'date' }, + ], + }); +} ); diff --git a/addons/default/visiosoft/profile-module/resources/lang/en/field.php b/addons/default/visiosoft/profile-module/resources/lang/en/field.php index 62a8abf0d..1f8b23fc6 100644 --- a/addons/default/visiosoft/profile-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/profile-module/resources/lang/en/field.php @@ -496,4 +496,12 @@ return [ 'receive_messages_email' => [ 'name' => 'Receive Messages Email', ], + + // Report + 'member' => 'Member', + 'registered_at' => 'Registered At', + 'login_at' => 'Login At', + 'undefined_member' => 'Undefined Member', + 'new_membership_report' => 'New Membership Report', + 'member_login_reports' => 'Member Login Reports', ]; diff --git a/addons/default/visiosoft/profile-module/resources/views/admin/dashboard/report.twig b/addons/default/visiosoft/profile-module/resources/views/admin/dashboard/report.twig new file mode 100644 index 000000000..63fe3e20d --- /dev/null +++ b/addons/default/visiosoft/profile-module/resources/views/admin/dashboard/report.twig @@ -0,0 +1,50 @@ +
+ {% set reports = [ + { + 'title': trans('visiosoft.module.profile::field.new_membership_report'), + 'id': 'newMemberReport', + 'columns': [ + trans('visiosoft.module.profile::field.member'), + trans('visiosoft.module.profile::field.registered_at'), + ], + }, + { + 'title': trans('visiosoft.module.profile::field.member_login_reports'), + 'id': 'loginMemberReport', + 'columns': [ + trans('visiosoft.module.profile::field.member'), + trans('visiosoft.module.profile::field.login_at'), + ], + }, + ] %} + + {% for report in reports %} +
+
+
+
{{ report.title }}
+
+ +
+ + + + {% for column in report.columns %} + + {% endfor %} + + +
{{ column }}
+
+
+
+ {% endfor %} +
+ + + +{{ asset_add('scripts.js', 'visiosoft.module.profile::assets/js/admin/dashboard/report.js') }} diff --git a/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/ReportController.php b/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/ReportController.php new file mode 100644 index 000000000..cb27c4684 --- /dev/null +++ b/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/ReportController.php @@ -0,0 +1,41 @@ +userRepository = $userRepository; + } + + public function latest() + { + $members = $this->userRepository->newQuery() + ->selectRaw("DATE_FORMAT(created_at, '%d.%m.%Y %H:%i') as date, CONCAT_WS('', first_name, ' ', last_name) AS member") + ->where('created_at', '>=', Carbon::today()->subWeek()) + ->get(); + + return [ + 'data' => $members + ]; + } + + public function login() + { + $members = $this->userRepository->newQuery() + ->selectRaw("DATE_FORMAT(last_login_at, '%d.%m.%Y %H:%i') as date, CONCAT_WS('', first_name, ' ', last_name) AS member") + ->whereNotNull('last_login_at') + ->where('last_login_at', '>=', Carbon::today()->subWeek()) + ->get(); + + return [ + 'data' => $members + ]; + } +} diff --git a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php index b43cd7ceb..3cb843f31 100644 --- a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php +++ b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php @@ -124,6 +124,10 @@ class ProfileModuleServiceProvider extends AddonServiceProvider // CacheController 'ajax/get-user-info' => 'Visiosoft\ProfileModule\Http\Controller\CacheController@getUserInfo', + + // Admin ReportController + 'admin/api/profile/report/latest' => 'Visiosoft\ProfileModule\Http\Controller\Admin\ReportController@latest', + 'admin/api/profile/report/login' => 'Visiosoft\ProfileModule\Http\Controller\Admin\ReportController@login', ]; protected $aliases = [ From e239937e5ced6216880118288585ff3f4b0bb0e9 Mon Sep 17 00:00:00 2001 From: diashalabi Date: Tue, 28 Sep 2021 16:45:45 +0300 Subject: [PATCH 4/4] #2480 Sales Reports --- .../advs-module/src/Adv/AdvRepository.php | 59 +++++++++++++++++++ .../Adv/Contract/AdvRepositoryInterface.php | 10 ++++ .../Controller/Admin/ReportController.php | 55 +++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 addons/default/visiosoft/advs-module/src/Http/Controller/Admin/ReportController.php diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index c34007876..cea08a2ce 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -592,4 +592,63 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface 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(); + } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php index 53e667867..4856c3bd3 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php @@ -60,4 +60,14 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface public function findByCFJSON($key, $value); public function uploadImage(); + + public function getStockReport(); + + public function getAllClassifiedsCount(); + + public function getCurrentClassifiedsCount(); + + public function getUnexplainedClassifiedsReport(); + + public function getNoImageClassifiedsReport(); } diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/ReportController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/ReportController.php new file mode 100644 index 000000000..8acc6ac6b --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/ReportController.php @@ -0,0 +1,55 @@ +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() + ]; + } +}