diff --git a/addons/default/visiosoft/advs-module/migrations/2020_07_20_112724_visiosoft.module.advs__create_standard_price_field.php b/addons/default/visiosoft/advs-module/migrations/2020_07_20_112724_visiosoft.module.advs__create_standard_price_field.php new file mode 100644 index 000000000..2b8c22332 --- /dev/null +++ b/addons/default/visiosoft/advs-module/migrations/2020_07_20_112724_visiosoft.module.advs__create_standard_price_field.php @@ -0,0 +1,52 @@ + 'advs', + ]; + + /** + * The addon fields. + * + * @var array + */ + protected $fields = [ + 'standard_price' => [ + 'type' => 'visiosoft.field_type.decimal', + 'config' => [ + 'decimal' => 2, + 'separator' => '.', + 'point' => ',' + ], + ], + ]; + + /** + * The field's assignment. + * + * @var array + */ + protected $assignments = [ + 'standard_price' => [ + 'required' => true + ], + ]; + +} diff --git a/addons/default/visiosoft/advs-module/resources/css/detail.css b/addons/default/visiosoft/advs-module/resources/css/detail.css index ff8130448..7a3247d9a 100644 --- a/addons/default/visiosoft/advs-module/resources/css/detail.css +++ b/addons/default/visiosoft/advs-module/resources/css/detail.css @@ -3,6 +3,16 @@ border-color: #ffc107 #ffc107 #ffc107; } +.ad-price-standard { + color: #f00; + text-decoration: line-through; +} + +.ad-price-standard-percentage { + background-color: #f00; + font-size: 16px; +} + /* Pending screen */ .pending-screen { background-color: #f2f2f2; @@ -13,4 +23,4 @@ } .pending-screen p { font-weight: 500; -} \ No newline at end of file +} diff --git a/addons/default/visiosoft/advs-module/resources/js/new-create.js b/addons/default/visiosoft/advs-module/resources/js/new-create.js index d19fcca5a..368260725 100644 --- a/addons/default/visiosoft/advs-module/resources/js/new-create.js +++ b/addons/default/visiosoft/advs-module/resources/js/new-create.js @@ -187,7 +187,7 @@ $(document).ready(function () { }); $(document).ready(function () { - $(".priceField").inputmask('currency', { + $(".priceField, .standard-price-field").inputmask('currency', { rightAlign: true, prefix: "", 'groupSeparator': '.', @@ -200,7 +200,7 @@ $(document).ready(function () { }); - $(".priceDecimalField").inputmask('99', { + $(".priceDecimalField, .standard-price-decimal-field").inputmask('99', { rightAlign: true, prefix: "", autoUnmask: true, @@ -210,11 +210,13 @@ $(document).ready(function () { }); - $(".priceField, .priceDecimalField").on('change', function () { - let price = $(".priceField").val() === "" ? '0' : $(".priceField").val(); + $(".decimal-price, .whole-price").on('change', function (e) { + const parent = e.target.closest('.select-price') + let price = $(parent).find('.whole-price').val() === "" ? '0' : $(parent).find('.whole-price').val(); price = parseInt(price.replace(/\./g, '')); - let decimal = parseInt($(".priceDecimalField").val()); - $('.priceHidden').find('input').val(parseFloat(price + "." + decimal)); + let decimal = parseInt($(parent).find('.decimal-price').val()); + + $(parent).find('input[type=number]').val(parseFloat(price + "." + decimal)); }); // Add dynamic option creation 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 cdb991641..2b46853c5 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/field.php @@ -19,6 +19,9 @@ return [ 'price' => [ 'name' => 'Price' ], + 'standard_price' => [ + 'name' => 'Standard Price' + ], 'date' => [ 'name' => 'Date' ], 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 5b7b06c34..761abb50b 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 @@ -4,6 +4,10 @@ {% include "visiosoft.module.advs::ad-detail/partials/ogdata" %} {% endblock %} +{% block styles %} + {{ asset_style("visiosoft.module.advs::css/detail.css") }} +{% endblock %} + {% block content %}
@@ -52,6 +56,5 @@
{{ asset_add("scripts.js", "visiosoft.module.advs::js/viewed.js") }} - {{ asset_add("styles.css", "visiosoft.module.advs::css/detail.css") }} {% endblock %} \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig b/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig index 5a5c3e1b7..efd963ad9 100644 --- a/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig +++ b/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig @@ -1,5 +1,16 @@
+ {% set standardPrice = adv.standard_price.value %} + {% if standardPrice %} +
+

+ {{ adv.standard_price.currency(null,'currency') }} +

+

+ %{{ (100 - ((100 * adv.price.value) / adv.standard_price.value))|round(0, 'common') }} +

+
+ {% endif %}

{{ adv.price.currency(null,'currency') }} diff --git a/addons/default/visiosoft/advs-module/resources/views/list/partials/display-mode.twig b/addons/default/visiosoft/advs-module/resources/views/list/partials/display-mode.twig index e50d02321..0c67cf183 100644 --- a/addons/default/visiosoft/advs-module/resources/views/list/partials/display-mode.twig +++ b/addons/default/visiosoft/advs-module/resources/views/list/partials/display-mode.twig @@ -23,7 +23,7 @@

- class="text-dark d-flex align-items-center justify-content-center"> gallery icon {{ trans('visiosoft.module.advs::field.gallery') }} diff --git a/addons/default/visiosoft/advs-module/resources/views/list/partials/price-filter.twig b/addons/default/visiosoft/advs-module/resources/views/list/partials/price-filter.twig index f411f6b22..ecc9f995c 100644 --- a/addons/default/visiosoft/advs-module/resources/views/list/partials/price-filter.twig +++ b/addons/default/visiosoft/advs-module/resources/views/list/partials/price-filter.twig @@ -29,9 +29,9 @@
diff --git a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig index 5f36bdd84..e5ee80ee4 100644 --- a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig +++ b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig @@ -59,6 +59,27 @@
{{ addBlock('new-ad/fields',{'adv':adv})|raw }} + +
+ +
+ {{ form.fields.standard_price.setAttributes({ + 'required' :true + }).input|raw }} +
+ {% set standardPriceValue = form.fields.standard_price.value|split('.') %} +
+ +
+
+ +
+
+
{% set PriceValue = form.fields.price.value|split('.') %}
- +
-
diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 3eb0e3e06..c1a714f3e 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -91,8 +91,10 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface }); } } - if (!empty($param['country'])) { - $query = $query->where('country_id', $param['country']); + $country = isset($param['country']) ? + $param['country'] : setting_value('visiosoft.module.location::default_country'); + if ($country) { + $query = $query->where('country_id', $country); } if ($city) { $query = $query->where('city', $city->id); diff --git a/addons/default/visiosoft/advs-module/src/Adv/Form/AdvFormBuilder.php b/addons/default/visiosoft/advs-module/src/Adv/Form/AdvFormBuilder.php index 538d0b4e7..0623c5ca6 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Form/AdvFormBuilder.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Form/AdvFormBuilder.php @@ -22,6 +22,9 @@ class AdvFormBuilder extends FormBuilder 'price' => [ 'type' => 'anomaly.field_type.text' ], + 'standard_price' => [ + 'type' => 'anomaly.field_type.text' + ], 'advs_desc', 'cat1', 'cat2', diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig b/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig index 9758f1cec..7e42a34fb 100644 --- a/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig +++ b/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig @@ -12,7 +12,7 @@ {% set title = trans(template.meta_title) %} {% set showTitle = template.showTitle is same as(false) ? false : true %} {% if showTitle %} - {% set title = setting_value('streams::name', config_get('streams::distribution.name'))~"|"~trans(template.meta_title) %} + {% set title = setting_value('streams::name', config_get('streams::distribution.name'))~" | "~trans(template.meta_title) %} {% endif %} {{ title|slice(0,60) }} diff --git a/addons/default/visiosoft/cats-module/resources/config/settings.php b/addons/default/visiosoft/cats-module/resources/config/settings.php new file mode 100644 index 000000000..642d1000f --- /dev/null +++ b/addons/default/visiosoft/cats-module/resources/config/settings.php @@ -0,0 +1,10 @@ + [ + "type" => "anomaly.field_type.integer", + "config" => [ + "default_value" => 5000, + ] + ], +]; diff --git a/addons/default/visiosoft/cats-module/resources/lang/en/setting.php b/addons/default/visiosoft/cats-module/resources/lang/en/setting.php new file mode 100644 index 000000000..ab795c85d --- /dev/null +++ b/addons/default/visiosoft/cats-module/resources/lang/en/setting.php @@ -0,0 +1,7 @@ + [ + 'name' => 'Sitemap Dividing Number', + ], +]; diff --git a/addons/default/visiosoft/cats-module/resources/views/sitemap/categories.twig b/addons/default/visiosoft/cats-module/resources/views/sitemap/categories.twig index 3cf9a85c2..7a2050821 100644 --- a/addons/default/visiosoft/cats-module/resources/views/sitemap/categories.twig +++ b/addons/default/visiosoft/cats-module/resources/views/sitemap/categories.twig @@ -1,9 +1,8 @@ - {% for category in categories %} + {% for link in sitemapLinks %} - {{ url_route('adv_list_seo', [category.slug]) }} - {{ category.created_at.tz('UTC').toAtomString() }} + {{ link }} weekly {% endfor %} diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php b/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php index 685ffde42..a403f9cbd 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php @@ -50,14 +50,8 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn public function getSubCatById($id) { - $orderBy = $this->model->getParentsCount($id) >= 1 ? 'name' : 'sort_order'; return $this->model->newQuery() - ->join('cats_category_translations', 'cats_category.id', '=', 'cats_category_translations.entry_id') - ->where('cats_category_translations.locale', config('app.locale')) ->where('parent_category_id', $id) - ->where('deleted_at', null) - ->select('cats_category.*') - ->orderBy($orderBy) ->get(); } diff --git a/addons/default/visiosoft/cats-module/src/Http/Controller/SitemapController.php b/addons/default/visiosoft/cats-module/src/Http/Controller/SitemapController.php index b7aa34d9a..8c1ab5f1e 100644 --- a/addons/default/visiosoft/cats-module/src/Http/Controller/SitemapController.php +++ b/addons/default/visiosoft/cats-module/src/Http/Controller/SitemapController.php @@ -2,22 +2,31 @@ use Anomaly\Streams\Platform\Http\Controller\PublicController; use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface; +use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface; class SitemapController extends PublicController { private $categoryRepository; + private $cityRepository; - public function __construct(CategoryRepositoryInterface $categoryRepository) + public function __construct( + CategoryRepositoryInterface $categoryRepository, + CityRepositoryInterface $cityRepository + ) { parent::__construct(); $this->categoryRepository = $categoryRepository; + $this->cityRepository = $cityRepository; } public function index() { $categoriesCount = $this->categoryRepository->count(); - $pagesCount = ceil($categoriesCount / 5000); + $citiesCount = $this->cityRepository->count(); + + $pagesCount = $citiesCount ? $categoriesCount * $citiesCount : $categoriesCount; + $pagesCount = ceil($pagesCount / setting_value('visiosoft.module.cats::sitemap_dividing_number')); return response()->view('visiosoft.module.cats::sitemap.index', [ 'pagesCount' => $pagesCount, @@ -26,13 +35,44 @@ class SitemapController extends PublicController public function categories() { + $sitemapDividingNumber = setting_value('visiosoft.module.cats::sitemap_dividing_number'); $page = request()->page ?: 1; $skip = $page - 1; - $categories = $this->categoryRepository->newQuery()->skip(5000 * $skip)->take(5000)->get(); + $citiesCount = $this->cityRepository->count(); + if ($citiesCount) { + $categoriesCount = $this->categoryRepository->count(); + + $takeCategories = $categoriesCount / ($categoriesCount * $citiesCount / $sitemapDividingNumber); + + $categories = $this->categoryRepository + ->newQuery() + ->skip($takeCategories * $skip) + ->take($takeCategories) + ->get(); + + $sitemapLinks = array(); + $cities = $this->cityRepository->all(); + foreach ($categories as $category) { + foreach ($cities as $city) { + $sitemapLinks[] = route('adv_list_seo', [$category->slug, $city->slug]); + } + } + } else { + $categories = $this->categoryRepository + ->newQuery() + ->skip($sitemapDividingNumber * $skip) + ->take($sitemapDividingNumber) + ->get(); + + $sitemapLinks = array(); + foreach ($categories as $category) { + $sitemapLinks[] = route('adv_list_seo', [$category->slug]); + } + } return response()->view('visiosoft.module.cats::sitemap.categories', [ - 'categories' => $categories, + 'sitemapLinks' => $sitemapLinks, ])->header('Content-Type', 'text/xml'); } } 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 7681901a8..683f018e9 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 @@ -3,14 +3,21 @@ {{ trans('visiosoft.module.location::field.address.name') }} - {% set country = setting_value('visiosoft.module.location::default_country') %} - {% if app.request.get('country') %} - {% set country = app.request.get('country') %} - {% endif %} + {% set defaultCountry = setting_value('visiosoft.module.location::default_country') %} + {% set selectedCountry = app.request.get('country') %} - {{ getCountry(country).name }} + {% set countryValue = '' %} + {% if selectedCountry %} + {% set countryName = getCountry(selectedCountry).name %} + {% set countryValue = defaultCountry == selectedCountry ? '' : selectedCountry %} + {% elseif defaultCountry %} + {% set countryName = getCountry(defaultCountry).name %} + {% else %} + {% set countryName = trans("visiosoft.module.location::field.country.name") %} + {% endif %} + {{ countryName }} - +