+ {% 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() %}
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 ad1d276d8..eba332bd8 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
@@ -21,6 +21,7 @@ use Visiosoft\AdvsModule\Adv\Event\viewAd;
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
+use Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationModel;
use Visiosoft\AdvsModule\Productoption\Contract\ProductoptionRepositoryInterface;
use Visiosoft\AdvsModule\ProductoptionsValue\Contract\ProductoptionsValueRepositoryInterface;
use Visiosoft\AlgoliaModule\Search\SearchModel;
@@ -622,6 +623,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) {
@@ -1240,10 +1245,15 @@ class AdvsController extends PublicController
$quantity = $request->quantity;
$id = $request->id;
$type = $request->type;
- $advmodel = new AdvModel();
- $adv = $advmodel->getAdv($id);
-
- $status = $advmodel->stockControl($id, $quantity);
+ if ($request->dataType === 'ad-configuration') {
+ $optionConf = new OptionConfigurationModel();
+ $adv = $optionConf->newQuery()->find($id);
+ $status = $adv->stockControl($id, $quantity);
+ } else {
+ $advmodel = new AdvModel();
+ $adv = $advmodel->getAdv($id);
+ $status = $advmodel->stockControl($id, $quantity);
+ }
$response = array();
if ($status == 1) {
diff --git a/addons/default/visiosoft/advs-module/src/OptionConfiguration/OptionConfigurationModel.php b/addons/default/visiosoft/advs-module/src/OptionConfiguration/OptionConfigurationModel.php
index c7153d80d..9e54d6752 100644
--- a/addons/default/visiosoft/advs-module/src/OptionConfiguration/OptionConfigurationModel.php
+++ b/addons/default/visiosoft/advs-module/src/OptionConfiguration/OptionConfigurationModel.php
@@ -1,10 +1,8 @@
name . ' | ' . trim($option_group_value, ' ');
}
}
+
+ public function stockControl($id, $quantity)
+ {
+ $conf = $this->newQuery()->find($id);
+ $stock = $conf->stock;
+
+ if ($stock === NULL || $stock === 0) {
+ return 0;
+ }
+
+ if ($stock < $quantity) {
+ return 0;
+ }
+
+ return 1;
+ }
}
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..0f9518645 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 @@
- {{ form.fields.country.setOptions({})|raw }}
+ class="location-field country-data">
+ {{ form.fields.country.setAttributes({'required': true}).setOptions({})|raw }}
+
- {{ form.fields.city|raw }}
+ class="location-field city-data">
+ {{ form.fields.city.setAttributes({'required': true})|raw }}
+
- {{ form.fields.district|raw }}
+ class="location-field district-data">
+ {{ form.fields.district.setAttributes({'required': true})|raw }}
+
- {{ form.fields.neighborhood|raw }}
+ class="location-field neighborhood-data">
+ {{ form.fields.neighborhood.setAttributes({'required': true})|raw }}
+
{% if not setting_value('visiosoft.module.advs::hide_village_field') %}
- - {{ form.fields.village|raw }}
+ -
+ {{ form.fields.village.setAttributes({'required': true})|raw }}
+
{% endif %}
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..1fcbcb37a 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;
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">