diff --git a/addons/default/visiosoft/advs-module/resources/views/ad-detail/detail.twig b/addons/default/visiosoft/advs-module/resources/views/ad-detail/detail.twig index b3e8195a8..386c2731a 100644 --- a/addons/default/visiosoft/advs-module/resources/views/ad-detail/detail.twig +++ b/addons/default/visiosoft/advs-module/resources/views/ad-detail/detail.twig @@ -18,10 +18,11 @@ {% include "visiosoft.module.advs::ad-detail/partials/author-button" %} - - {% include "visiosoft.module.advs::ad-detail/partials/breadcrumb" %} - - + {% if setting_value('visiosoft.theme.base::breadcrumbs') %} + + {% include "visiosoft.module.advs::ad-detail/partials/breadcrumb" %} + + {% endif %}

{{ adv.title }} {{ addBlock('ad-detail/title/action',{'adv_id':adv.id})|raw }} @@ -32,23 +33,25 @@
{% include "visiosoft.module.advs::ad-detail/partials/slider" %} -
- {% include "visiosoft.module.advs::ad-detail/partials/detail" %} + {% if setting_value('visiosoft.theme.base::ad_details') %} + {% include "visiosoft.module.advs::ad-detail/partials/detail" %} + {% endif %}
+ {% if setting_value('visiosoft.theme.base::ad_details_tab') %} - {% if blocks('ad-item-content-block-area') is null %} - {% include "visiosoft.module.advs::ad-detail/partials/content" %} - {% else %} - {{ blocks('ad-item-content-block-area') }} + {% if blocks('ad-item-content-block-area') is null %} + {% include "visiosoft.module.advs::ad-detail/partials/content" %} + {% else %} + {{ blocks('ad-item-content-block-area') }} + {% endif %} + + {{ addBlock('ad-detail/widget', {'price': adv.price, 'id': adv.id})|raw }} {% endif %} - - {{ addBlock('ad-detail/widget', {'price': adv.price, 'id': adv.id})|raw }} - diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 67ac7a901..d059b7659 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -74,7 +74,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface if (!empty($param['country'])) { $query = $query->where('country_id', $param['country']); } - if (!empty($param['city'])) { + if (isset($param['city']) and !empty(array_filter($param['city']))) { $query = $query->whereIn('city', $param['city']); } if (!empty($param['cat'])) { @@ -90,14 +90,14 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface if (!empty($param['user'])) { $query = $query->where('advs_advs.created_by_id', $param['user']); } - if (!empty($param['district'])) { - $query = $query->where('district', $param['district']); + if (isset($param['district']) and !empty(array_filter($param['district']))) { + $query = $query->whereIn('district', $param['district']); } - if (!empty($param['neighborhood'])) { - $query = $query->where('neighborhood', $param['neighborhood']); + if (isset($param['neighborhood']) and !empty(array_filter($param['neighborhood']))) { + $query = $query->whereIn('neighborhood', $param['neighborhood']); } - if (!empty($param['village'])) { - $query = $query->where('village', $param['village']); + if (isset($param['village']) and !empty(array_filter($param['village']))) { + $query = $query->whereIn('village', $param['village']); } if (!empty($param['min_price'])) { $num = $param['min_price']; diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index d515ed4d6..5aedb1d6f 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -146,27 +146,14 @@ class AdvsController extends PublicController $subCats = array(); $param = $this->requestHttp->toArray(); - if (!isset($param['country'])) { - if (is_null(Cookie::get('country'))) { - $param['country'] = setting_value('visiosoft.module.advs::default_country'); - } else { - $param['country'] = Cookie::get('country'); - } - } else { - if ($param['country'] != setting_value('visiosoft.module.advs::default_country')) { - Cookie::queue(Cookie::make('country', $param['country'], 84000)); - } - } - $searchedCountry = $param['country']; + $countries = $this->country_repository->viewAll(); $isActiveDopings = $this->adv_model->is_enabled('dopings'); $isActiveCustomFields = $this->adv_model->is_enabled('customfields'); - $advs = $this->adv_repository->searchAdvs('list', $param, $customParameters); - $advs = $this->adv_repository->addAttributes($advs); diff --git a/addons/default/visiosoft/base-theme/resources/config/settings/sections.php b/addons/default/visiosoft/base-theme/resources/config/settings/sections.php new file mode 100644 index 000000000..3b5b4426e --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/config/settings/sections.php @@ -0,0 +1,16 @@ + [ + 'stacked' => false, + 'tabs' => [ + 'catalog_mode' => [ + 'title' => 'visiosoft.theme.base::section.catalog_mode.name', + 'fields' => [ + 'navigation_title', 'navigation_action', 'date_fields', 'price_fields', + 'breadcrumbs', 'ad_details', 'ad_details_tab','latest_and_view_all_btn' + ], + ], + ], + ], +]; diff --git a/addons/default/visiosoft/base-theme/resources/config/settings/settings.php b/addons/default/visiosoft/base-theme/resources/config/settings/settings.php new file mode 100644 index 000000000..bd25805ef --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/config/settings/settings.php @@ -0,0 +1,53 @@ + [ + 'type' => 'anomaly.field_type.boolean', + "config" => [ + "default_value" => 1, + ] + ], + 'navigation_action' => [ + 'type' => 'anomaly.field_type.boolean', + "config" => [ + "default_value" => 1, + ] + ], + 'date_fields' => [ + 'type' => 'anomaly.field_type.boolean', + "config" => [ + "default_value" => 1, + ] + ], + 'price_fields' => [ + 'type' => 'anomaly.field_type.boolean', + "config" => [ + "default_value" => 1, + ] + ], + 'breadcrumbs' => [ + 'type' => 'anomaly.field_type.boolean', + "config" => [ + "default_value" => 1, + ] + ], + 'ad_details' => [ + 'type' => 'anomaly.field_type.boolean', + "config" => [ + "default_value" => 1, + ] + ], + 'ad_details_tab' => [ + 'type' => 'anomaly.field_type.boolean', + "config" => [ + "default_value" => 1, + ] + ], + 'latest_and_view_all_btn' => [ + 'type' => 'anomaly.field_type.boolean', + "config" => [ + "default_value" => 1, + ] + ], + +]; \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/css/theme.css b/addons/default/visiosoft/base-theme/resources/css/theme.css index 3ca4f04ee..e6eb89a55 100644 --- a/addons/default/visiosoft/base-theme/resources/css/theme.css +++ b/addons/default/visiosoft/base-theme/resources/css/theme.css @@ -8,4 +8,13 @@ .table-img-100 { max-width: 100px; +} + +.loading { + background-image: url("{{ img('visiosoft.theme.base::images/loading.gif').url }}"); + background-position: center; + background-size: 25px; + background-repeat: no-repeat; + height: 50px; + width: 100%; } \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/images/loading.gif b/addons/default/visiosoft/base-theme/resources/images/loading.gif new file mode 100644 index 000000000..9590093e9 Binary files /dev/null and b/addons/default/visiosoft/base-theme/resources/images/loading.gif differ diff --git a/addons/default/visiosoft/base-theme/resources/lang/en/field.php b/addons/default/visiosoft/base-theme/resources/lang/en/field.php index 5a0c813f2..35a74c2d8 100644 --- a/addons/default/visiosoft/base-theme/resources/lang/en/field.php +++ b/addons/default/visiosoft/base-theme/resources/lang/en/field.php @@ -7,4 +7,13 @@ return [ 'show_all' => [ 'name' => 'Show All', ], + 'login' => [ + 'name' => 'Login', + ], + 'logout' => [ + 'name' => 'Logout', + ], + 'profile' => [ + 'name' => 'Profile', + ], ]; \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/lang/en/section.php b/addons/default/visiosoft/base-theme/resources/lang/en/section.php new file mode 100644 index 000000000..3809465b4 --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/lang/en/section.php @@ -0,0 +1,7 @@ + [ + 'name' => 'Catalog Mode', + ], +]; \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/lang/en/setting.php b/addons/default/visiosoft/base-theme/resources/lang/en/setting.php new file mode 100644 index 000000000..076539921 --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/lang/en/setting.php @@ -0,0 +1,31 @@ + [ + 'name' => 'Navigation Title', + ], + 'navigation_action' => [ + 'name' => 'Navigation Action', + ], + 'country_fields' => [ + 'name' => 'Country Fields', + ], + 'date_fields' => [ + 'name' => 'Date Fields', + ], + 'price_fields' => [ + 'name' => 'Price Fields', + ], + 'breadcrumbs' => [ + 'name' => 'Breadcrumb', + ], + 'ad_details' => [ + 'name' => 'Ad Details', + ], + 'ad_details_tab' => [ + 'name' => 'Ad Details Tab', + ], + 'latest_and_view_all_btn' => [ + 'name' => 'Latest and View All Btn', + ], +]; \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/lang/tr/section.php b/addons/default/visiosoft/base-theme/resources/lang/tr/section.php new file mode 100644 index 000000000..11d971818 --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/lang/tr/section.php @@ -0,0 +1,7 @@ + [ + 'name' => 'Katalog Modu', + ], +]; \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/views/index/default.twig b/addons/default/visiosoft/base-theme/resources/views/index/default.twig index 316e5601a..a54dda9fc 100644 --- a/addons/default/visiosoft/base-theme/resources/views/index/default.twig +++ b/addons/default/visiosoft/base-theme/resources/views/index/default.twig @@ -1,13 +1,14 @@
-
-

{{ trans('theme::field.latest_ads.name') }}

-
- - + {% if setting_value('visiosoft.theme.base::latest_and_view_all_btn') %} +
+

{{ trans('theme::field.latest_ads.name') }}

+
+ + {% endif %}
@@ -25,28 +26,32 @@
-
- {{ latestAd.price }} {{ latestAd.currency }} -
+ {% if setting_value('visiosoft.theme.base::price_fields') %} +
+ {{ latestAd.price }} {{ latestAd.currency }} +
+ {% endif %} {% if setting_value('visiosoft.module.location::home_page_location') %} -
- - - {{ latestAd.city_name }}, {{ latestAd.country_name }} - -
+
+ + + {{ latestAd.city_name }}, {{ latestAd.country_name }} + +
+ {% endif %} + {% if setting_value('visiosoft.theme.base::date_fields') %} +
+ + + {{ latestAd.created_at|date('d/m/Y') }} + +
{% endif %} -
- - - {{ latestAd.created_at|date('d/m/Y') }} - -
diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/navigation.twig b/addons/default/visiosoft/base-theme/resources/views/partials/navigation.twig index 5830c8edd..3a00492ec 100644 --- a/addons/default/visiosoft/base-theme/resources/views/partials/navigation.twig +++ b/addons/default/visiosoft/base-theme/resources/views/partials/navigation.twig @@ -1,6 +1,9 @@ \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/resources/config/settings.php b/addons/default/visiosoft/location-module/resources/config/settings.php index 4a153a68c..6a8e70214 100644 --- a/addons/default/visiosoft/location-module/resources/config/settings.php +++ b/addons/default/visiosoft/location-module/resources/config/settings.php @@ -19,4 +19,11 @@ return [ 'default_value' => true, ], ], + 'default_country' => [ + 'type' => 'anomaly.field_type.relationship', + "config" => [ + "related" => \Visiosoft\LocationModule\Country\CountryModel::class, + 'default_value' => 212, + ] + ], ]; diff --git a/addons/default/visiosoft/location-module/resources/css/filterLocation.css b/addons/default/visiosoft/location-module/resources/css/filterLocation.css index a0b0bb095..a3cae9d8f 100644 --- a/addons/default/visiosoft/location-module/resources/css/filterLocation.css +++ b/addons/default/visiosoft/location-module/resources/css/filterLocation.css @@ -1,4 +1,29 @@ -#location .select2-selection__rendered { - display: inline-block; - padding-left: 4px; +.filter-location-back { + position: fixed; + width: 100%; + height: 100%; + left: 0; + top: 0; + z-index: 200; + background-color: #000; + opacity: .3; + -ms-filter: "alpha(opacity=30)"; + filter: alpha(opacity=30); + -ms-filter: "alpha(opacity=50)"; + +} + +.filter-location-body ul li:hover { + background: #227af3; + color: #fff; +} + +.filter-location-body .countries, +.filter-location-body .cities, +.filter-location-body .districts, +.filter-location-body .neighborhoods, +.filter-location-body .village { + height: 200px; + overflow: auto; + display: none } \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/resources/js/filterLocation.js b/addons/default/visiosoft/location-module/resources/js/filterLocation.js index 5d4e1ad62..589909e7b 100644 --- a/addons/default/visiosoft/location-module/resources/js/filterLocation.js +++ b/addons/default/visiosoft/location-module/resources/js/filterLocation.js @@ -1,155 +1,332 @@ -let searchParams = new URLSearchParams(window.location.search); +var countries; +var cities; +var districts; +var neighborhoods; +var village; -//Set Select2 Type for Location Fields -$('.cities, .countries, .districts, .neighborhoods, .village').select2({ - placeholder: select_trans +//Country +$('.filter-country-btn').on('click', function () { + if (countries == undefined) { + var promiseForCountries = new Promise(function (resolve, reject) { + crud('', '/ajax/getCountry', 'POST', beforeSend(), function (callback) { + countries = callback; + resetValue('country', true, false) + $.each(countries, function (index, value) { + $('.filter-location-modal .countries').append(item('country', value.id, value.name)); + }); + if (countries == "") + $('.filter-location-modal .countries').html(null_msg); + else if ($('input[name="country"]').val() != "") + $(".filter-location-body .countries li[data-id='" + $('input[name="country"]').val() + "'] input[type='checkbox']").prop('checked', true); + resolve(); + }) + }); + + promiseForCountries.then(function () { + SelectOnClick(); + }) + } + $('.filter-location-modal .countries').show(); + $('.filter-location-modal').show(); + $('.filter-location-back').show(); + scroolToModal() +}); + +//City +$('.filter-city-btn').on('click', function () { + var countries_value = $('input[name="country"]').val(); + var selected__city_request = $('input[name="city[]"]').val(); + if (cities == undefined || $(this).attr('data-parent') != countries_value) { + $(this).attr('data-parent', countries_value) + var promiseForCities = new Promise(function (resolve, reject) { + crud('id=' + countries_value, '/ajax/getCities', 'POST', beforeSend(), function (callback) { + cities = callback; + resetValue('city', true, false) + $.each(cities, function (index, value) { + $('.filter-location-modal .cities').append(item('city', value.id, value.name)); + }); + if (cities == "") + $('.filter-location-modal .cities').html(null_msg); + else if (selected__city_request != "") { + $.each(selected__city_request.split(','), function (index, value) { + $(".filter-location-body .cities li[data-id='" + value + "'] input[type='checkbox']").prop('checked', true); + }); + } + resolve(); + }) + }); + + promiseForCities.then(function () { + SelectOnClick(); + }) + } + $('.filter-location-modal .cities').show(); + $('.filter-location-modal').show(); + $('.filter-location-back').show(); + scroolToModal() +}); + +//District +$('.filter-district-btn').on('click', function () { + var city_value = $('input[name="city[]"]').val(); + var selected_district_request = $('input[name="district[]"]').val(); + if (districts == undefined || $(this).attr('data-parent') != city_value) { + $(this).attr('data-parent', city_value) + var promiseForDistricts = new Promise(function (resolve, reject) { + crud('id=' + city_value, '/ajax/getDistricts', 'POST', beforeSend(), function (callback) { + districts = callback; + resetValue('district', true, false) + $.each(districts, function (index, value) { + $('.filter-location-modal .districts').append(item('district', value.id, value.name)); + }); + if (districts == "") + $('.filter-location-modal .districts').html(null_msg); + else if (selected_district_request != "") { + $.each(selected_district_request.split(','), function (index, value) { + $(".filter-location-body .districts li[data-id='" + value + "'] input[type='checkbox']").prop('checked', true); + }); + } + resolve(); + }) + }); + + promiseForDistricts.then(function () { + SelectOnClick(); + }) + } + $('.filter-location-modal .districts').show(); + $('.filter-location-modal').show(); + $('.filter-location-back').show(); + scroolToModal() +}); + +//Neighborhood +$('.filter-neighborhood-btn').on('click', function () { + var district_value = $('input[name="district[]"]').val(); + var selected_neighborhood_request = $('input[name="neighborhood[]"]').val(); + if (neighborhoods == undefined || $(this).attr('data-parent') != district_value) { + $(this).attr('data-parent', district_value) + var promiseForNeighborhoods = new Promise(function (resolve, reject) { + crud('id=' + district_value, '/ajax/getNeighborhoods', 'POST', beforeSend(), function (callback) { + neighborhoods = callback; + resetValue('neighborhood', true, false) + $.each(neighborhoods, function (index, value) { + $('.filter-location-modal .neighborhoods').append(item('neighborhood', value.id, value.name)); + }); + if (neighborhoods == "") + $('.filter-location-modal .neighborhoods').html(null_msg); + else if (selected_neighborhood_request != "") { + $.each(selected_neighborhood_request.split(','), function (index, value) { + $(".filter-location-body .neighborhoods li[data-id='" + value + "'] input[type='checkbox']").prop('checked', true); + }); + } + resolve(); + }) + }); + + promiseForNeighborhoods.then(function () { + SelectOnClick(); + }) + } + $('.filter-location-modal .neighborhoods').show(); + $('.filter-location-modal').show(); + $('.filter-location-back').show(); + scroolToModal() +}); + +//Village +$('.filter-village-btn').on('click', function () { + var neighborhood_value = $('input[name="neighborhood[]"]').val(); + var selected_village_request = $('input[name="village[]"]').val(); + if (village == undefined || $(this).attr('data-parent') != neighborhood_value) { + $(this).attr('data-parent', neighborhood_value) + var promiseForVillage = new Promise(function (resolve, reject) { + crud('id=' + neighborhood_value, '/ajax/getVillage', 'POST', beforeSend(), function (callback) { + village = callback; + $('.filter-location-modal .village').html(""); + $.each(village, function (index, value) { + $('.filter-location-modal .village').append(item('village', value.id, value.name)); + }); + if (village == "") + $('.filter-location-modal .village').html(null_msg); + else if (selected_village_request != "") { + $.each(selected_village_request.split(','), function (index, value) { + $(".filter-location-body .village li[data-id='" + value + "'] input[type='checkbox']").prop('checked', true); + }); + } + resolve(); + }) + }); + + promiseForVillage.then(function () { + SelectOnClick(); + }) + } + $('.filter-location-modal .village').show(); + $('.filter-location-modal').show(); + $('.filter-location-back').show(); + scroolToModal() }); -FindLocations = (id, table, typeDb, divId, paramName = null) => { +$('.filter-modal-close , .filter-location-back').on('click', function () { + $('.filter-location-modal').hide(); + $('.filter-location-back').hide(); + $('.filter-location-modal .countries').hide(); + $('.filter-location-modal .cities').hide(); + $('.filter-location-modal .districts').hide(); + $('.filter-location-modal .neighborhoods').hide(); + $('.filter-location-modal .village').hide(); +}); + + +function SelectOnClick() { + + $(".filter-location-body input[type='checkbox']").unbind(); + searchLocationName() + $('.loading').hide(); + + return $(".filter-location-body input[type='checkbox']").change(function () { + + resetValue($(this).attr('data-field'), false, true) + + var input = $('input[name="' + $(this).attr('data-field') + '[]"]'); + var input_text = $(this).parent().find('small').html(); + var text_html = $('.selected-' + $(this).attr('data-field') + ' small'); + var text = ""; + var input_val = input.val(); + var id = $(this).attr('data-id'); + + if ($(this).attr('data-field') == "country") { + input.val(id) + text_html.html(input_text) + $(".filter-location-body input[type='checkbox']").prop('checked', false); + $(".filter-location-body li[data-id='" + id + "'] input[type='checkbox']").prop('checked', true); + + } else { + if (input_val != "") { + input_val = input_val.split(','); + text = text_html.html().split(','); + } else { + input_val = []; + text = []; + } + if (this.checked) { + input_val.push(id); + text.push(input_text) + } else { + input_val.splice($.inArray(id, input_val), 1); + text.splice($.inArray(input_text, text), 1); + } + input.val(input_val.join(',')) + text_html.html(text.join(',')) + } + }); +} + + +function crud(params, url, type, beforeSend, callback) { $.ajax({ - type: 'get', - url: '/getlocations', - data: { - id: id, - table: table, - typeDb: typeDb, + type: type, + data: params, + url: url, + beforeSend: function () { + beforeSend }, success: function (response) { - setLocations(response, id, table, typeDb, divId, paramName); - return response; + callback(response); }, - error: function (err) { - reject(Error("It broke")); - } }); -}; +} +function item(field_name, id, value) { + return '
  • \n' + + ' \n' + + '
  • '; +} -setLocations = (response, id, table, typeDb, divId, paramName) => { +function resetValue(location_type, reset_this, reset_parent) { + var list_class, inputs; + var selected_type = false; + + //For City + if (location_type == "country") { + inputs = ['city', 'district', 'neighborhood', 'village'] + list_class = ['cities', 'districts', 'neighborhoods', 'village'] + selected_type = true - //Add Options - if(divId != ".cities") - { - $(divId).append("") } - response.forEach(function (options) { - $(divId).append("") - }); - //Set Selected Option - if (paramName != null) { - if (divId == ".cities") { - $('.countries').val(searchParams.get('country')); - $('.countries').select2(); - $('.cities').val(findParam("city[]")); + //For City + if (location_type == "city") { + if (reset_this || selected_type) { + inputs = ['city', 'district', 'neighborhood', 'village'] + list_class = ['cities', 'districts', 'neighborhoods', 'village'] } else { - $(divId).val(searchParams.get(paramName)); + location_type = "district"; + selected_type = true } - $(divId).select2(); } -}; + //For District + if (location_type == "district") { + if (reset_this || selected_type) { + inputs = ['district', 'neighborhood', 'village'] + list_class = ['districts', 'neighborhoods', 'village'] + } else { + location_type = "neighborhood"; + selected_type = true + } -//Category Change -$('.countries').on('change', function () { - $('.cities').empty(); - var table = "cities"; - var typeDb = 'parent_country_id'; - var id = $(this).val(); - var divId = ".cities"; - - FindLocations(id, table, typeDb, divId); -}); - -//City Change -$('.cities, .select2-selection__choice__remove').on('change', function () { - $('.districts').empty(); - var table = "districts"; - var typeDb = 'parent_city_id'; - var id = $(this).val(); - var divId = ".districts"; - - FindLocations(id, table, typeDb, divId); -}); - -//Districts Change -$('.districts').on('change', function () { - var table = "neighborhoods"; - var typeDb = 'parent_district_id'; - var id = $(this).val(); - var divId = ".neighborhoods"; - - FindLocations(id, table, typeDb, divId); -}); - -//Neighborhoods Change -$('.neighborhoods').on('change', function () { - var table = "village"; - var typeDb = 'parent_neighborhood_id'; - var id = $(this).val(); - var divId = ".village"; - - FindLocations(id, table, typeDb, divId); -}); - - -jQuery(document).ready(function ($) { - -}).promise().done(function () { - - //Get City && Set Country - if (searchParams.get('country') != '') { - $('.cities').empty(); - var table = "cities"; - var typeDb = 'parent_country_id'; - var id = searchParams.get('country'); - var divId = ".cities"; - var paramName = 'city'; - - FindLocations(id, table, typeDb, divId, paramName); } -}).promise().done(function () { - - //get District && set city - if (findParam('city[]').length) { - $('.districts').empty(); - var table = "districts"; - var typeDb = 'parent_city_id'; - var id = findParam('city[]'); - var divId = ".districts"; - var paramName = 'district'; - - FindLocations(id, table, typeDb, divId, paramName); + //For Neighborhood + if (location_type == "neighborhood") { + if (reset_this || selected_type) { + inputs = ['neighborhood', 'village'] + list_class = ['neighborhoods', 'village'] + } else { + inputs = ['village'] + list_class = ['village'] + } } -}).promise().done(function () { + //Reset All List Class From list_class + $.each(list_class, function (index, value) { + $('.filter-location-modal .' + value).html(""); + }); - //get neighborhood && set districts - if (searchParams.get('district') != '') { - $('.neighborhoods').empty(); - var table = "neighborhoods"; - var typeDb = 'parent_district_id'; - var id = searchParams.get('district'); - var divId = ".neighborhoods"; - var paramName = 'neighborhood'; + //Reset All Input Value From inputs + $.each(inputs, function (index, value) { + $('input[name="' + value + '"]').val(""); + if (reset_parent) + $('.filter-' + value + '-btn').attr("data-parent", ""); + }); +} - FindLocations(id, table, typeDb, divId, paramName); - } +function scroolToModal() { + //Scrool Screen + $([document.documentElement, document.body]).animate({ + scrollTop: $('.filter-location-modal').offset().top - 250 + }, 1000); +} -}).promise().done(function () { +function searchLocationName() { + var searchField = $("#searchLocation"); + searchField.unbind(); + searchField.on("keyup", function () { + var value = this.value.toLowerCase().trim(); + $('.filter-location-modal li').show().filter(function () { + return $(this).text().toLowerCase().trim().indexOf(value) == -1; + }).hide(); + }); +} - //get village && set neighborhoods - if (searchParams.get('neighborhood') != '') { - $('.village').empty(); - var table = "village"; - var typeDb = 'parent_neighborhood_id'; - var id = searchParams.get('neighborhood'); - var divId = ".village"; - var paramName = 'village'; - - FindLocations(id, table, typeDb, divId, paramName); - } - -}); \ No newline at end of file +function beforeSend() { + $('.loading').show() + $('.filter-location-modal li').show(); + $("#searchLocation").val(''); +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/resources/lang/en/field.php b/addons/default/visiosoft/location-module/resources/lang/en/field.php index 20fdea2ba..b7efb4723 100644 --- a/addons/default/visiosoft/location-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/location-module/resources/lang/en/field.php @@ -31,4 +31,7 @@ return [ 'pick_option' => [ 'name' => 'Pick an option', ], + 'address' => [ + 'name' => 'Address', + ], ]; diff --git a/addons/default/visiosoft/location-module/resources/lang/en/message.php b/addons/default/visiosoft/location-module/resources/lang/en/message.php index b62512838..aacc0275b 100644 --- a/addons/default/visiosoft/location-module/resources/lang/en/message.php +++ b/addons/default/visiosoft/location-module/resources/lang/en/message.php @@ -1,4 +1,6 @@ 'Type here to search', + 'null_msg' => 'Not Found', ]; diff --git a/addons/default/visiosoft/location-module/resources/lang/en/setting.php b/addons/default/visiosoft/location-module/resources/lang/en/setting.php index 40603ccda..bdc74a511 100644 --- a/addons/default/visiosoft/location-module/resources/lang/en/setting.php +++ b/addons/default/visiosoft/location-module/resources/lang/en/setting.php @@ -13,4 +13,7 @@ return [ 'show_search_location_btn' => [ 'name' => 'Show Search Location Button', ], + 'default_country' => [ + 'name' => 'Default Country', + ], ]; diff --git a/addons/default/visiosoft/location-module/resources/lang/tr/addon.php b/addons/default/visiosoft/location-module/resources/lang/tr/addon.php index 1466a79f5..5621cea85 100644 --- a/addons/default/visiosoft/location-module/resources/lang/tr/addon.php +++ b/addons/default/visiosoft/location-module/resources/lang/tr/addon.php @@ -1,7 +1,7 @@ "Yer", - "name" =>"Yer Modülü", - "description" =>"Açıklama" + "title" =>"Bölge", + "name" =>"Bölge Modülü", + "description" =>"Bölge Modülü" ]; \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/resources/lang/tr/button.php b/addons/default/visiosoft/location-module/resources/lang/tr/button.php index 968651a6a..edbad7c93 100644 --- a/addons/default/visiosoft/location-module/resources/lang/tr/button.php +++ b/addons/default/visiosoft/location-module/resources/lang/tr/button.php @@ -2,8 +2,8 @@ return[ "new_country" =>"Yeni ülke", - "new_city" =>"Yeni şehir", - "new_district" =>"Yeni bölge", + "new_city" =>"Yeni İl", + "new_district" =>"Yeni İlçe", "new_neighborhood" =>"Yeni mahalle", "new_village" =>"Yeni köy", "sub_cities" =>"Alt Şehirler", diff --git a/addons/default/visiosoft/location-module/resources/lang/tr/field.php b/addons/default/visiosoft/location-module/resources/lang/tr/field.php index 3c8557b99..024fab207 100644 --- a/addons/default/visiosoft/location-module/resources/lang/tr/field.php +++ b/addons/default/visiosoft/location-module/resources/lang/tr/field.php @@ -10,11 +10,11 @@ return[ ], "city" => [ - "name" =>"Kent", + "name" =>"İl", ], "country" => [ - "name" =>"ülke", + "name" =>"Ülke", ], "district" => [ @@ -22,20 +22,23 @@ return[ ], "order" => [ - "name" =>"Sıralama düzeni", + "name" =>"Sıralama", ], "neighborhood" => [ - "name" =>"Komşuluk", + "name" =>"Mahalle", ], "village" => [ - "name" =>"köy", + "name" =>"Köy", ], "description" => [ "name" =>"Açıklama", ], + 'address' => [ + 'name' => 'Adres', + ], ]; \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/resources/lang/tr/message.php b/addons/default/visiosoft/location-module/resources/lang/tr/message.php index 6de81f2c1..2e30659db 100644 --- a/addons/default/visiosoft/location-module/resources/lang/tr/message.php +++ b/addons/default/visiosoft/location-module/resources/lang/tr/message.php @@ -1,5 +1,6 @@ 'Ara', + 'null_msg' => 'Bulunamadı', +]; diff --git a/addons/default/visiosoft/location-module/resources/lang/tr/permission.php b/addons/default/visiosoft/location-module/resources/lang/tr/permission.php deleted file mode 100644 index 848b62a8e..000000000 --- a/addons/default/visiosoft/location-module/resources/lang/tr/permission.php +++ /dev/null @@ -1,15 +0,0 @@ - [ - "name" =>"köy", - "option" => [ - "read" =>"Köy okuyabilir mi ", - "write" =>"Köy oluşturabilir / düzenleyebilir mi? ", - "delete" =>"Köyü silebilir mi?", - - ], - - ], - -]; \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/resources/lang/tr/section.php b/addons/default/visiosoft/location-module/resources/lang/tr/section.php index 67100fcc1..5f90ba31c 100644 --- a/addons/default/visiosoft/location-module/resources/lang/tr/section.php +++ b/addons/default/visiosoft/location-module/resources/lang/tr/section.php @@ -2,19 +2,19 @@ return[ "countries" => [ - "title" =>"Ülkeler", + "title" =>"Ülke", ], "cities" => [ - "title" =>"Şehirler", + "title" =>"İl", ], "districts" => [ - "title" =>"İlçeler", + "title" =>"İlçer", ], "neighborhoods" => [ - "title" =>"Çevredekiler", + "title" =>"Mahalle", ], "village" => [ diff --git a/addons/default/visiosoft/location-module/resources/views/ads-list/partials/location-fields.twig b/addons/default/visiosoft/location-module/resources/views/ads-list/partials/location-fields.twig index 0770eefb5..60561af34 100644 --- a/addons/default/visiosoft/location-module/resources/views/ads-list/partials/location-fields.twig +++ b/addons/default/visiosoft/location-module/resources/views/ads-list/partials/location-fields.twig @@ -1,42 +1,102 @@
    -
    - - +
    + + {{ trans('visiosoft.module.location::field.address.name') }} + + + {{ getCountry(setting_value('visiosoft.module.location::default_country')).name }} + + {% set country = setting_value('visiosoft.module.location::default_country') %} + {% if app.request.get('country') %} + {% set country = app.request.get('country') %} + {% endif %} +
    - - + + {% set selected_cities = app.request.get('city') %} + {% set selected_cities_name = [] %} + {% for selected_city in selected_cities[0]|split(',') %} + {% set selected_cities_name = selected_cities_name|merge([getCity(selected_city|trim(',')).name]) %} + {% endfor %} +
    + {{ selected_cities_name|join(',') }} +
    +
    - - + + {% set selected_districts = app.request.get('district') %} + {% set selected_districts_name = [] %} + {% for selected_district in selected_districts[0]|split(',') %} + {% set selected_districts_name = selected_districts_name|merge([getDistrict(selected_district|trim(',')).name]) %} + {% endfor %} +
    + {{ selected_districts_name|join(',') }} +
    +
    - - + + {% set selected_neighborhoods = app.request.get('neighborhood') %} + {% set selected_neighborhoods_name = [] %} + {% for selected_neighborhood in selected_neighborhoods[0]|split(',') %} + {% set selected_neighborhoods_name = selected_neighborhoods_name|merge([getNeighborhood(selected_neighborhood|trim(',')).name]) %} + {% endfor %} +
    + {{ selected_neighborhoods_name|join(',') }} +
    +
    - - + + {% set selected_villages = app.request.get('village') %} + {% set selected_villages_name = [] %} + {% for selected_village in selected_villages[0]|split(',') %} + {% set selected_villages_name = selected_villages_name|merge([getVillage(selected_village|trim(',')).name]) %} + {% endfor %} +
    + {{ selected_villages_name|join(',') }} +
    +
    -
    \ No newline at end of file +
    + + + + + diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php new file mode 100644 index 000000000..396af406e --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php @@ -0,0 +1,106 @@ +country_model = $countryModel; + $this->city_model = $cityModel; + $this->district_model = $districtModel; + $this->neighborhood_model = $neighborhoodModel; + $this->village_model = $villageModel; + parent::__construct(); + } + + /** + * @return mixed + */ + public function getCountries() + { + if ($this->request->id) + return $this->country_model->find($this->request->id); + else + return $this->country_model->get(); + } + + /** + * @return mixed + */ + public function getCities() + { + if ($this->request->id) { + $id = explode(',', $this->request->id); + return $this->city_model->whereIn('parent_country_id', $id)->get(); + } + } + + /** + * @return mixed + */ + public function getDistricts() + { + if ($this->request->id) { + $id = explode(',', $this->request->id); + return $this->district_model->whereIn('parent_city_id', $id)->get(); + } + } + + /** + * @return mixed + */ + public function getNeighborhoods() + { + if ($this->request->id) { + $id = explode(',', $this->request->id); + return $this->neighborhood_model->whereIn('parent_district_id', $id)->get(); + } + } + + /** + * @return mixed + */ + public function getVillage() + { + if ($this->request->id) { + $id = explode(',', $this->request->id); + return $this->village_model->whereIn('parent_neighborhood_id', $id)->get(); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/LocationModulePlugin.php b/addons/default/visiosoft/location-module/src/LocationModulePlugin.php index 9d9d16ff9..0b061185a 100644 --- a/addons/default/visiosoft/location-module/src/LocationModulePlugin.php +++ b/addons/default/visiosoft/location-module/src/LocationModulePlugin.php @@ -5,6 +5,7 @@ use Visiosoft\LocationModule\City\Command\GetCity; use Visiosoft\LocationModule\Country\Command\GetCountry; use Visiosoft\LocationModule\District\Command\GetDistrict; use Visiosoft\LocationModule\Neighborhood\Command\GetNeighborhood; +use Visiosoft\LocationModule\Village\Command\GetVillage; class LocationModulePlugin extends Plugin { @@ -56,6 +57,17 @@ class LocationModulePlugin extends Plugin return null; } + return $ad; + } + ), + new \Twig_SimpleFunction( + 'getVillage', + function ($id) { + + if (!$ad = $this->dispatch(new GetVillage($id))) { + return null; + } + return $ad; } ), diff --git a/addons/default/visiosoft/location-module/src/LocationModuleServiceProvider.php b/addons/default/visiosoft/location-module/src/LocationModuleServiceProvider.php index 260b09956..f7b3a8584 100644 --- a/addons/default/visiosoft/location-module/src/LocationModuleServiceProvider.php +++ b/addons/default/visiosoft/location-module/src/LocationModuleServiceProvider.php @@ -75,6 +75,27 @@ class LocationModuleServiceProvider extends AddonServiceProvider 'admin/location/neighborhoods' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@index', 'admin/location/neighborhoods/create' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@create', 'admin/location/neighborhoods/edit/{id}' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@edit', + + 'ajax/getCountry' => [ + 'as' => 'location::getCountry', + 'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getCountries' + ], + 'ajax/getCities' => [ + 'as' => 'location::getCities', + 'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getCities' + ], + 'ajax/getDistricts' => [ + 'as' => 'location::getDistricts', + 'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getDistricts' + ], + 'ajax/getNeighborhoods' => [ + 'as' => 'location::getNeighborhoods', + 'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getNeighborhoods' + ], + 'ajax/getVillage' => [ + 'as' => 'location::getVillage', + 'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getVillage' + ], ]; /** diff --git a/addons/default/visiosoft/location-module/src/Village/Command/GetVillage.php b/addons/default/visiosoft/location-module/src/Village/Command/GetVillage.php new file mode 100644 index 000000000..d29900321 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Village/Command/GetVillage.php @@ -0,0 +1,34 @@ +id = $id; + } + + /** + * @param VillageModel $groups + * @return |null + */ + public function handle(VillageModel $groups) + { + if ($this->id) { + return $groups->find($this->id); + } + return null; + } +}