diff --git a/addons/default/visiosoft/advs-module/resources/config/permissions.php b/addons/default/visiosoft/advs-module/resources/config/permissions.php index cead467e5..282f8d0ba 100644 --- a/addons/default/visiosoft/advs-module/resources/config/permissions.php +++ b/addons/default/visiosoft/advs-module/resources/config/permissions.php @@ -46,4 +46,9 @@ return [ 'write', 'delete', ], + 'status' => [ + 'read', + 'write', + 'delete', + ], ]; diff --git a/addons/default/visiosoft/advs-module/resources/js/admin/advanced.js b/addons/default/visiosoft/advs-module/resources/js/admin/advanced.js new file mode 100644 index 000000000..c94938966 --- /dev/null +++ b/addons/default/visiosoft/advs-module/resources/js/admin/advanced.js @@ -0,0 +1,32 @@ +function getUrlParameter(sParam) { + var sPageURL = window.location.search.substring(1), + sURLVariables = sPageURL.split('&'), + sParameterName, + i; + + for (i = 0; i < sURLVariables.length; i++) { + sParameterName = sURLVariables[i].split('='); + + if (sParameterName[0] === sParam) { + return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); + } + } +}; + + +if (getUrlParameter('view') === "advanced") { + $('.fast-update').on('change', function () { + var advanced_value = $(this).val(), advanced_entry_id = $(this).data('entry_id'), + advanced_column = $(this).data('column'), advanced_type = $(this).attr('type'); + + if (advanced_type === "checkbox") { + advanced_value = ($(this).prop('checked')) ? 1 : 0; + } + + crudAjax({ + 'advanced_column': advanced_column, + 'advanced_entry_id': advanced_entry_id, + 'advanced_value': advanced_value + }, advanced_update_url, 'POST') + }) +} \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/button.php b/addons/default/visiosoft/advs-module/resources/lang/en/button.php index 777bc94d0..88b42946a 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/button.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/button.php @@ -43,4 +43,5 @@ return [ 'fast_create' => 'Fast create', 'publish' => 'Publish', 'import' => 'Import', + 'new_status' => 'New Status', ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/permission.php b/addons/default/visiosoft/advs-module/resources/lang/en/permission.php index 0a094c9f1..1c540e8b2 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/permission.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/permission.php @@ -97,4 +97,12 @@ return [ 'delete' => 'Can delete option configuration?', ], ], + 'status' => [ + 'name' => 'Status', + 'option' => [ + 'read' => 'Can read status?', + 'write' => 'Can create/edit status?', + 'delete' => 'Can delete status?', + ], + ], ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/section.php b/addons/default/visiosoft/advs-module/resources/lang/en/section.php index 6e1310527..d7f9f96a1 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/section.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/section.php @@ -56,4 +56,7 @@ return [ 'title' => 'Configuration', ], 'translations' => 'Translations', + 'status' => [ + 'title' => 'Status', + ], ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/stream.php b/addons/default/visiosoft/advs-module/resources/lang/en/stream.php index 761fa569d..d94ccdc24 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/stream.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/stream.php @@ -31,4 +31,7 @@ return [ 'option_configuration' => [ 'name' => 'Configuration', ], + 'status' => [ + 'name' => 'Status', + ], ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/view.php b/addons/default/visiosoft/advs-module/resources/lang/en/view.php index 0a174882a..0ba4fe99f 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/view.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/view.php @@ -2,4 +2,5 @@ return [ 'unfinished' => 'Unfinished', + 'advanced' => 'Advanced', ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/tr/view.php b/addons/default/visiosoft/advs-module/resources/lang/tr/view.php index 3f1464b90..b5a71395d 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/tr/view.php +++ b/addons/default/visiosoft/advs-module/resources/lang/tr/view.php @@ -2,4 +2,5 @@ return [ 'unfinished' => 'Bitmemiş', + 'advanced' => 'Gelişmiş', ]; diff --git a/addons/default/visiosoft/advs-module/resources/views/admin/table/table.twig b/addons/default/visiosoft/advs-module/resources/views/admin/table/table.twig new file mode 100644 index 000000000..c600670e8 --- /dev/null +++ b/addons/default/visiosoft/advs-module/resources/views/admin/table/table.twig @@ -0,0 +1,90 @@ +{{ asset_add("scripts.js", "streams::js/table/table.js") }} + +{% if not actions.empty() %} + {{ asset_add("scripts.js", "streams::js/table/actions.js") }} +{% endif %} + +{% if table.options.sortable %} + {{ asset_add("scripts.js", "streams::js/table/sortable.js") }} +{% endif %} + +
+ diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvCollection.php b/addons/default/visiosoft/advs-module/src/Adv/AdvCollection.php index 7d4729887..855fa19c0 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvCollection.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvCollection.php @@ -1,8 +1,29 @@ count(); + + return self::paginator($this->forPage($page, $pageSize), $total, $pageSize, $page, [ + 'path' => Paginator::resolveCurrentPath(), + 'pageName' => 'page', + ]); + } + + protected static function paginator($items, $total, $perPage, $currentPage, $options) + { + return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact( + 'items', 'total', 'perPage', 'currentPage', 'options' + )); + } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 72f9efe81..b39827ea4 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -11,6 +11,7 @@ use Anomaly\Streams\Platform\Entry\EntryRepository; use Visiosoft\CatsModule\Category\CategoryModel; use Visiosoft\LocationModule\City\CityModel; use Visiosoft\LocationModule\Country\CountryModel; +use Visiosoft\LocationModule\District\DistrictModel; class AdvRepository extends EntryRepository implements AdvRepositoryInterface { @@ -215,12 +216,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface { $country = CountryModel::query()->where('location_countries.id', $adv->country_id)->first(); $city = CityModel::query()->where('location_cities.id', $adv->city)->first(); + $district = DistrictModel::query()->where('location_districts.id', $adv->district)->first(); if ($country != null) { $adv->setAttribute('country_name', $country->name); } if ($city != null) { $adv->setAttribute('city_name', $city->name); } + if ($district != null) { + $adv->setAttribute('district_name', $district->name); + } return $adv; } @@ -460,14 +465,22 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface return $advs->update(['finish_at' => $newDate]); } - public function getByUsersIDs($usersIDs) + public function getByUsersIDs($usersIDs, $status = 'approved', $withDraft = false) { - return $this + $ads = $this ->newQuery() ->whereIn('advs_advs.created_by_id', $usersIDs) - ->where('advs_advs.slug', '!=', "") - ->where('advs_advs.status', 'approved') ->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s')); + + if ($status) { + $ads = $ads->where('advs_advs.status', 'approved'); + } + + if (!$withDraft) { + $ads = $ads->where('advs_advs.slug', '!=', ""); + } + + return $ads; } public function getPopular() 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 16984415e..1eaac9dac 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php @@ -45,7 +45,7 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface public function extendAds($allAds, $isAdmin = false); - public function getByUsersIDs($usersIDs); + public function getByUsersIDs($usersIDs, $status = 'approved', $withDraft = false); public function getPopular(); diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php index ecc68bbc4..45466ee3b 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php @@ -19,6 +19,11 @@ class AdvTableBuilder extends TableBuilder 'slug' => 'all', 'text' => 'streams::view.all', ], + 'advanced' => [ + 'view' => All::class, + 'slug' => 'advanced', + 'text' => 'module::view.advanced', + ], 'trash', 'unfinished' => [ 'view' => unfinished::class @@ -74,6 +79,7 @@ class AdvTableBuilder extends TableBuilder 'order_by' => [ 'id' => 'DESC', ], + 'table_view' => 'visiosoft.module.advs::admin/table/table' ]; /** @@ -81,6 +87,10 @@ class AdvTableBuilder extends TableBuilder * * @var array */ - protected $assets = []; + protected $assets = [ + 'scripts.js' => [ + 'visiosoft.module.advs::js/admin/advanced.js' + ], + ]; } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php index 2854914eb..64f303c65 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php @@ -1,6 +1,7 @@ setColumns([ + $columns = [ 'cover_photo' => [ 'value' => function (EntryInterface $entry) { return "