diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index cbe685212..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']); } } } @@ -225,17 +221,17 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface } - public function getAdvDetailLinkByModel($object, $type = null) - { - if ($type != null) { - $id = $object->id; - $seo = $object->slug; - return \route('adv_detail_seo', [$seo, $id]); - } - $id = $object->getObject()->id; - $seo = $object->getObject()->slug; - return \route('adv_detail_seo', [$seo, $id]); - } + public function getAdvDetailLinkByModel($object, $type = null) + { + if ($type != null) { + $id = $object->id; + $seo = $object->slug; + return \route('adv_detail_seo', [$seo, $id]); + } + $id = $object->getObject()->id; + $seo = $object->getObject()->slug; + return \route('adv_detail_seo', [$seo, $id]); + } public function getAdvDetailLinkByAdId($id) { @@ -396,7 +392,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface public function getProductOptionsValues() { - return $this->product_options_value; + return $this->product_options_value; } public function getStatus() 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/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index 1854f1bd6..c37fdc695 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -1229,7 +1229,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;