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 %} + +
+ + {{ view("streams::table/partials/filters", {'table': table}) }} + {{ view("streams::table/partials/views", {'table': table}) }} + + {{ view(table.options.heading ?: "streams::table/partials/heading", {'table': table}) }} + + {% if not table.rows.empty() %} + {% block card %} +
+ + {{ form_open({ 'url': url_full() }) }} +
+ + + {{ view("streams::table/partials/header", {'table': table}) }} + + {% block body %} + + {% for row in table.rows %} + + + {% if table.options.sortable %} + + {% endif %} + + {% if not table.actions.empty() %} + + {% endif %} + + {% for column in row.columns %} + + {% endfor %} + + + + + {% endfor %} + + + {% endblock %} + + {{ view("streams::table/partials/footer", {'table': table}) }} + +
+ {{ icon('fa fa-arrows handle') }} + + + + + {{ (column.attributes.html) ? column.attributes.html|raw : column.value|raw }} + + {{ buttons(row.buttons)|raw }} +
+
+ {{ form_close() }} + +
+ {% endblock %} + {% else %} + + {% block no_results %} +
+
+ {{ trans(table.options.get('no_results_message', 'streams::message.no_results')) }} +
+
+ {% endblock %} + {% 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 ""; - }, + } ], 'name' => [ @@ -59,7 +60,36 @@ class AdvTableColumns 'created_by' => [ 'value' => 'entry.created_by.name', ], - ]); + ]; + + if ($builder->isActiveView('advanced')) { + + unset($columns['created_by'], $columns['country']); + $columns['is_get_adv'] = [ + 'attributes' => [ + 'html' => function (EntryModel $entry) { + $checked = ($entry->is_get_adv) ? 'checked' : ''; + return ''; + } + ], + 'class' => 'advs-price', + ]; + $columns['standard_price'] = [ + 'attributes' => [ + 'html' => function (EntryModel $entry) { + return ''; + } + ], + 'class' => 'advs-price', + ]; + $columns['price']['attributes'] = [ + 'html' => function (EntryModel $entry) { + return ''; + } + ]; + } + + $builder->setColumns($columns); } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/Views/Advanced.php b/addons/default/visiosoft/advs-module/src/Adv/Table/Views/Advanced.php new file mode 100644 index 000000000..f32c3e23e --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/Views/Advanced.php @@ -0,0 +1,21 @@ +where('slug', ""); + } + +} diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php index 88f672aa8..304b2f03a 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php @@ -46,6 +46,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider 'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@assetsClear', ], 'admin/advs-users/choose/{advId}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@choose', + 'admin/advs/ajax/advanced/advanced-update' => [ + 'as' => 'visiosoft.module.advs::ajax_advanced_update', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@advancedUpdate', + ], 'admin/class/actions/{id}/{type}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@actions', diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php index 2cf4c14a2..6962e2e4c 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php @@ -204,4 +204,17 @@ class AdvsController extends AdminController { return Excel::download(new AdvsExport(), 'advs-' . time() . '.xlsx'); } + + public function advancedUpdate() + { + if ($this->request->has('advanced_column') and $this->request->has('advanced_entry_id') and $this->request->has('advanced_value')) { + $entry_id = $this->request->get('advanced_entry_id'); + $column = $this->request->get('advanced_column'); + $value = $this->request->get('advanced_value'); + if ($entry = $this->advRepository->find($entry_id)) { + $entry->setAttribute($column, $value); + $entry->save(); + } + } + } } diff --git a/app/Listeners/EnableMaintenanceMode.php b/app/Listeners/EnableMaintenanceMode.php index 9aa9fb8ba..0baa89f1b 100755 --- a/app/Listeners/EnableMaintenanceMode.php +++ b/app/Listeners/EnableMaintenanceMode.php @@ -11,8 +11,12 @@ class EnableMaintenanceMode { $builder = $event->getBuilder(); if (get_class($builder->getRepository()) === SettingFormRepository::class) { - if ($builder->getFormValues()->has('maintenance') and $builder->getFormValues()->get('maintenance')) { - Artisan::call('down'); + if ($builder->getFormValues()->has('maintenance')) { + if ($builder->getFormValues()->get('maintenance')) { + Artisan::call('down'); + } elseif (config('streams::maintenance.enabled')) { + Artisan::call('up'); + } } } }