diff --git a/addons/default/visiosoft/advs-module/migrations/2021_03_31_100145_visiosoft.module.advs__add_index_table.php b/addons/default/visiosoft/advs-module/migrations/2021_03_31_100145_visiosoft.module.advs__add_index_table.php new file mode 100644 index 000000000..a43320c99 --- /dev/null +++ b/addons/default/visiosoft/advs-module/migrations/2021_03_31_100145_visiosoft.module.advs__add_index_table.php @@ -0,0 +1,21 @@ +index('deleted_at'); + $table->index('cat1'); + $table->index('country_id'); + $table->index('city'); + $table->index('finish_at'); + $table->index('status'); + $table->index('count_show_ad'); + }); + } +} diff --git a/addons/default/visiosoft/advs-module/resources/config/settings/sections.php b/addons/default/visiosoft/advs-module/resources/config/settings/sections.php index 1336af80b..2c4ab7f5a 100644 --- a/addons/default/visiosoft/advs-module/resources/config/settings/sections.php +++ b/addons/default/visiosoft/advs-module/resources/config/settings/sections.php @@ -23,6 +23,7 @@ return [ 'ads' => [ 'title' => 'visiosoft.module.advs::section.ads', 'fields' => [ + 'detailed_product_options', 'latest-limit', 'popular_ads_limit', 'ads_image_limit', @@ -55,6 +56,7 @@ return [ 'hide_options_field', 'hide_village_field', 'hide_configurations', + 'make_all_fields_required', 'make_map_required', 'show_breadcrumb_when_creating_ad', 'show_post_ad_agreement', diff --git a/addons/default/visiosoft/advs-module/resources/config/settings/settings.php b/addons/default/visiosoft/advs-module/resources/config/settings/settings.php index cf259dcd8..9ae81b704 100644 --- a/addons/default/visiosoft/advs-module/resources/config/settings/settings.php +++ b/addons/default/visiosoft/advs-module/resources/config/settings/settings.php @@ -147,6 +147,13 @@ return [ 'mode' => 'checkbox' ] ], + 'make_all_fields_required' => [ + 'type' => 'anomaly.field_type.boolean', + 'config' => [ + 'default_value' => false, + 'mode' => 'checkbox' + ] + ], 'make_map_required' => [ 'type' => 'anomaly.field_type.boolean', 'config' => [ @@ -424,4 +431,10 @@ return [ ] ], 'disable_sentry' => 'anomaly.field_type.boolean', + 'detailed_product_options' => [ + 'type' => 'anomaly.field_type.boolean', + 'config' => [ + 'default_value' => true, + ] + ], ]; diff --git a/addons/default/visiosoft/advs-module/resources/css/list.css b/addons/default/visiosoft/advs-module/resources/css/list.css index 9fdad75ab..0693c4ff8 100644 --- a/addons/default/visiosoft/advs-module/resources/css/list.css +++ b/addons/default/visiosoft/advs-module/resources/css/list.css @@ -24,6 +24,7 @@ .upper-list-banner { min-height: 300px; background-size: cover; + background-position: center; } .upper-list-banner img { diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/message.php b/addons/default/visiosoft/advs-module/resources/lang/en/message.php index 64e9a67a5..c60c9eeab 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/message.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/message.php @@ -31,4 +31,5 @@ return [ 'passive_status_change' => "Your Ad's Status Has Been Set to Passive!", 'sold_status_change' => "Your Ad's Status Has Been Set to Sold!", 'status_change' => "Your Ad's Status Has Been Set to :status!", + 'disabled_detailed_options_for_admin_role' => "Detailed product options are disabled.", ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/setting.php b/addons/default/visiosoft/advs-module/resources/lang/en/setting.php index 2bf5e9497..803e3403f 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/setting.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/setting.php @@ -111,6 +111,10 @@ return [ 'name' => 'Hide the Configurations Button', 'instructions' => 'Hide the Configurations Button in the Ad Preview Page', ], + 'make_all_fields_required' => [ + 'name' => 'Make All Fields Required', + 'instructions' => 'Require the user to fill the Price and Description fields when creating an ad', + ], 'make_map_required' => [ 'name' => 'Make Map Required', 'instructions' => 'Require the user to place a pin on the map when creating an ad', @@ -254,4 +258,8 @@ return [ 'name' => 'Watermark', 'instructions' => 'Is watermark active?' ], + 'detailed_product_options' => [ + 'name' => 'Detailed Product Options', + 'instructions' => 'Allows you to enter stock and price information for the product' + ], ]; 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 17e8aadd8..dd6532f7f 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 @@ -20,6 +20,8 @@
+ {% set requiredFields = setting_value('visiosoft.module.advs::make_all_fields_required') %} + {% set form = form('advs', 'advs').entry(id).actions({'update': { 'text': trans('visiosoft.module.advs::button.publish') }}).get() %} @@ -132,32 +134,42 @@
{% if not setting_value('visiosoft.module.advs::hide_options_field') %} -
- -
- + {% if not setting_value('visiosoft.module.advs::detailed_product_options') %} +
+ +
+ +
+ {% if auth_check() and auth_user().hasRole('admin') %} +
+

+ + {{ trans('visiosoft.module.advs::message.disabled_detailed_options_for_admin_role') }} +

+
+ {% endif %}
-
- -
- -
- {{ form.fields.product_options_value.configSet('cat1',adv.cat1).input|raw }} + {% else %} +
+ +
+ {{ form.fields.product_options_value.configSet('cat1',adv.cat1).input|raw }} +
-
+ {% endif %} {% endif %}
diff --git a/addons/default/visiosoft/advs-module/resources/views/new-ad/preview/preview.twig b/addons/default/visiosoft/advs-module/resources/views/new-ad/preview/preview.twig index e0ed36c0c..b2f6b6724 100644 --- a/addons/default/visiosoft/advs-module/resources/views/new-ad/preview/preview.twig +++ b/addons/default/visiosoft/advs-module/resources/views/new-ad/preview/preview.twig @@ -9,6 +9,12 @@
{{ trans('visiosoft.module.advs::field.preview_text.part_2') }}

+ {% if auth_check() and auth_user().hasRole('admin') %} +

+ + {{ trans('visiosoft.module.advs::message.disabled_detailed_options_for_admin_role') }} +

+ {% endif %}
{% if isActive('packages') and setting_value('visiosoft.module.packages::move_the_buy_package_to_the_end') and (auth_user().isAdmin or not auth_user().hasPermission('visiosoft.module.packages::packages.no_read')) %} @@ -19,10 +25,12 @@ {% set continueLink = url_route('adv_detail_seo', [adv.slug, adv.id]) %} {% endif %} {% if not setting_value('visiosoft.module.advs::hide_configurations') %} - - {{trans('visiosoft.module.advs::button.create_configurations')}} - + {% if setting_value('visiosoft.module.advs::detailed_product_options') %} + + {{ trans('visiosoft.module.advs::button.create_configurations') }} + + {% endif %} {% endif %} @@ -33,17 +41,18 @@
- {% include "visiosoft.module.advs::new-ad/preview/partials/preview-window" %} + {% include "visiosoft.module.advs::new-ad/preview/partials/preview-window" %}
{% if not setting_value('visiosoft.module.advs::hide_configurations') %} - {{trans('visiosoft.module.advs::button.create_configurations')}} + {{ trans('visiosoft.module.advs::button.create_configurations') }} {% endif %} - + {{ trans('visiosoft.module.advs::field.edit') }} diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index 5bc4373a0..8ff5c25d2 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php @@ -71,12 +71,8 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface public function userAdv($nullable_ad = false, $checkRole = true) { - if ($user = Auth::user() and $user->hasRole('admin') && $checkRole) { - return $this->getAdv(null, $nullable_ad); - } else { - return $this->getAdv(null, $nullable_ad) - ->where('advs_advs.created_by_id', Auth::id()); - } + return $this->getAdv(null, $nullable_ad) + ->where('advs_advs.created_by_id', Auth::id()); } public function getAdvByCat($cat_id) @@ -142,7 +138,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface $responseBodyAsString = $response->getBody()->getContents(); $response = json_decode($responseBodyAsString, true); if ($showMsg) { - $messages->error($response['error']); + $messages->error($response['error']); } } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php b/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php index 1f0aaa106..a7b3b3220 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php @@ -75,4 +75,9 @@ class AdvPresenter extends EntryPresenter $advModel = new AdvModel(); return $advModel->priceFormat($adv->getObject()); } + + public function detailUrl() + { + return $this->getObject()->getAdvDetailLinkByModel($this); + } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 5046f2f69..e80d6d00d 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -71,16 +71,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface if ($city) { $query = $query->where('city', $city->id); } elseif (isset($param['city']) and !empty(array_filter($param['city']))) { - $query = $query->whereIn('city', $param['city']); + $query = $query->whereIn('city', explode(',', array_first($param['city']))); } if (isset($param['district']) and !empty(array_filter($param['district']))) { - $query = $query->whereIn('district', $param['district']); + $query = $query->whereIn('district', explode(',',array_first($param['district']))); } if (isset($param['neighborhood']) and !empty(array_filter($param['neighborhood']))) { - $query = $query->whereIn('neighborhood', $param['neighborhood']); + $query = $query->whereIn('neighborhood', explode(',',array_first($param['neighborhood']))); } if (isset($param['village']) and !empty(array_filter($param['village']))) { - $query = $query->whereIn('village', $param['village']); + $query = $query->whereIn('village', explode(',',array_first($param['village']))); } } if ($category) { 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 99ff60fc1..7bcb93053 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Form/AdvFormBuilder.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Form/AdvFormBuilder.php @@ -1,63 +1,11 @@ [ - 'translatable' => true, - 'required' => true, - ], - 'slug' => [ - 'unique' => true, - 'required' => true, - ], - 'price' => [ - 'type' => 'anomaly.field_type.text' - ], - 'standard_price' => [ - 'type' => 'anomaly.field_type.text' - ], - 'advs_desc', - 'cat1', - 'cat2', - 'cat3', - 'cat4', - 'cat5', - 'cat6', - 'cat7', - 'cat8', - 'cat9', - 'cat10', - 'currency', - 'online_payment', - 'stock', - 'country' => [ - 'class' => 'form-control countryselect' - ], - 'city' => [ - 'class' => 'form-control cityselect' - ], - 'district' => [ - 'class' => 'form-control districtselect' - ], - 'neighborhood' => [ - 'class' => 'form-control neighborhoodselect' - ], - 'village' => [ - 'class' => 'form-control villageselect' - ], - 'map_Val' => [ - 'label' => false, - 'class' => 'hidden d-none mapVal' - ], - 'files', - 'doc_files', - 'popular_adv', - 'adv_day', - 'product_options_value' - ]; + protected $fields; protected $category = null; @@ -78,4 +26,73 @@ class AdvFormBuilder extends FormBuilder protected $sections = []; protected $assets = []; + + public function __construct(Form $form) + { + parent::__construct($form); + $this->fields = $this->settingFields(); + } + + private function settingFields() + { + $requiredFields = setting_value('visiosoft.module.advs::make_all_fields_required'); + + return [ + 'name' => [ + 'translatable' => true, + 'required' => true, + ], + 'slug' => [ + 'unique' => true, + 'required' => true, + ], + 'price' => [ + 'type' => 'anomaly.field_type.text', + 'required' => $requiredFields + ], + 'standard_price' => [ + 'type' => 'anomaly.field_type.text' + ], + 'advs_desc' => [ + 'required' => $requiredFields + ], + 'cat1', + 'cat2', + 'cat3', + 'cat4', + 'cat5', + 'cat6', + 'cat7', + 'cat8', + 'cat9', + 'cat10', + 'currency', + 'online_payment', + 'stock', + 'country' => [ + 'class' => 'form-control countryselect' + ], + 'city' => [ + 'class' => 'form-control cityselect' + ], + 'district' => [ + 'class' => 'form-control districtselect' + ], + 'neighborhood' => [ + 'class' => 'form-control neighborhoodselect' + ], + 'village' => [ + 'class' => 'form-control villageselect' + ], + 'map_Val' => [ + 'label' => false, + 'class' => 'hidden d-none mapVal' + ], + 'files', + 'doc_files', + 'popular_adv', + 'adv_day', + 'product_options_value' + ]; + } } 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 362696b60..b93f7472c 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php @@ -584,8 +584,7 @@ class AdvsController extends PublicController $configurations = $this->optionConfigurationRepository->getConf($adv->id); $foreign_currencies = json_decode($adv->foreign_currencies, true); - - if (isset($_COOKIE['currency']) && $adv->foreign_currencies && array_key_exists($_COOKIE['currency'], $foreign_currencies)) { + if (isset($_COOKIE['currency']) && $_COOKIE['currency'] && $adv->foreign_currencies && array_key_exists($_COOKIE['currency'], $foreign_currencies)) { $adv->currency = $_COOKIE['currency']; $adv->price = $foreign_currencies[$_COOKIE['currency']]; } @@ -615,6 +614,10 @@ class AdvsController extends PublicController $adv = $this->adv_repository->getListItemAdv($id); + if (!Auth::check() or ($adv['created_by_id'] != auth()->id() and !Auth::user()->isAdmin())) { + abort(403); + } + for ($i = 1; $i <= 10; $i++) { $cat = "cat" . $i; if ($adv->$cat != null) { @@ -1089,7 +1092,7 @@ class AdvsController extends PublicController $thisModel = new AdvModel(); $adv = $thisModel->isAdv($id); $response = array(); - if ($adv) { + if ($adv and $adv->getStatus() == "approved") { $cart = $thisModel->addCart($adv, $quantity, $name); $response['status'] = "success"; $count = $cart->getItems()->count; diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/OptionConfigurationController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/OptionConfigurationController.php index 14d1b456c..ca9c43aca 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/OptionConfigurationController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/OptionConfigurationController.php @@ -44,15 +44,20 @@ class OptionConfigurationController extends PublicController { if($conf = $this->optionConfigurationRepository->find($this->request->configuration)) { - $conf->name = $conf->getName(); + if($conf->parent_adv->getStatus() == "approved") + { + $conf->name = $conf->getName(); - if ($conf->stock < $this->request->quantity){ - return redirect()->back()->with('warning', [trans('visiosoft.module.carts::message.error1in2')]); - }else{ - $cart = $this->dispatch(new GetCart()); - $cart->add($conf, $this->request->quantity); - return $this->redirect->to(route('visiosoft.module.carts::cart')); - } + if ($conf->stock < $this->request->quantity){ + return redirect()->back()->with('warning', [trans('visiosoft.module.carts::message.error1in2')]); + }else{ + $cart = $this->dispatch(new GetCart()); + $cart->add($conf, $this->request->quantity); + return $this->redirect->to(route('visiosoft.module.carts::cart')); + } + } + $this->messages->info(trans('visiosoft.module.advs::message.error_added_cart')); + return back(); } } diff --git a/addons/default/visiosoft/base-theme/resources/views/addons/anomaly/users-module/partials/register-form.twig b/addons/default/visiosoft/base-theme/resources/views/addons/anomaly/users-module/partials/register-form.twig index 00e7c48d7..cc91e0c83 100644 --- a/addons/default/visiosoft/base-theme/resources/views/addons/anomaly/users-module/partials/register-form.twig +++ b/addons/default/visiosoft/base-theme/resources/views/addons/anomaly/users-module/partials/register-form.twig @@ -55,8 +55,10 @@
- {{ form.fields.phone.setValue(form.fields.phone.value).input|raw }} - + {{ form.fields.phone.setAttributes({'maxlength': 15}).setValue(form.fields.phone.value).input|raw }} +
diff --git a/addons/default/visiosoft/cats-module/migrations/2021_03_31_104729_visiosoft.module.cats__add_index_table.php b/addons/default/visiosoft/cats-module/migrations/2021_03_31_104729_visiosoft.module.cats__add_index_table.php new file mode 100644 index 000000000..6ecf73dd2 --- /dev/null +++ b/addons/default/visiosoft/cats-module/migrations/2021_03_31_104729_visiosoft.module.cats__add_index_table.php @@ -0,0 +1,19 @@ +index('deleted_at'); + $table->index('slug'); + $table->index('parent_category_id'); + $table->index('icon_id'); + $table->index('sort_order'); + }); + } +} diff --git a/addons/default/visiosoft/location-module/resources/views/new-ad/map.twig b/addons/default/visiosoft/location-module/resources/views/new-ad/map.twig index 9b94af55e..c1d32a90f 100644 --- a/addons/default/visiosoft/location-module/resources/views/new-ad/map.twig +++ b/addons/default/visiosoft/location-module/resources/views/new-ad/map.twig @@ -19,17 +19,26 @@
diff --git a/addons/default/visiosoft/profile-module/migrations/2021_03_31_121019_visiosoft.module.profile__add_index_table.php b/addons/default/visiosoft/profile-module/migrations/2021_03_31_121019_visiosoft.module.profile__add_index_table.php new file mode 100644 index 000000000..bfa9683c2 --- /dev/null +++ b/addons/default/visiosoft/profile-module/migrations/2021_03_31_121019_visiosoft.module.profile__add_index_table.php @@ -0,0 +1,18 @@ +index('deleted_at'); + $table->index('name'); + $table->index('folder_id'); + }); + + } +} diff --git a/addons/default/visiosoft/profile-module/resources/assets/css/profile-nav.scss b/addons/default/visiosoft/profile-module/resources/assets/css/profile-nav.scss index 23affb0bd..ee7d447f4 100644 --- a/addons/default/visiosoft/profile-module/resources/assets/css/profile-nav.scss +++ b/addons/default/visiosoft/profile-module/resources/assets/css/profile-nav.scss @@ -41,7 +41,7 @@ z-index: 1040; } - a { + a, span { display: flex; align-items: center; margin-bottom: 1.25rem; @@ -62,7 +62,7 @@ } } - svg { + svg, img { margin-right: .75rem; width: 1.5rem; height: 1.5rem; diff --git a/addons/default/visiosoft/profile-module/resources/views/address/list.twig b/addons/default/visiosoft/profile-module/resources/views/address/list.twig index 810140973..dca0d5c67 100644 --- a/addons/default/visiosoft/profile-module/resources/views/address/list.twig +++ b/addons/default/visiosoft/profile-module/resources/views/address/list.twig @@ -3,7 +3,7 @@ {% block content %} {% embed 'visiosoft.module.profile::profile/index' %} {% block detail %} - +
diff --git a/addons/default/visiosoft/profile-module/resources/views/profile/partials/navigation.twig b/addons/default/visiosoft/profile-module/resources/views/profile/partials/navigation.twig index 29b052248..6feed3884 100644 --- a/addons/default/visiosoft/profile-module/resources/views/profile/partials/navigation.twig +++ b/addons/default/visiosoft/profile-module/resources/views/profile/partials/navigation.twig @@ -3,10 +3,13 @@ class="ml-2">