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 af1425b79..c9b56fdce 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/field.php @@ -73,18 +73,6 @@ return [ 'status' => [ 'name' => 'Status' ], - 'next_add_advs_title' => [ - 'name' => 'Post an Ad in just 30 seconds' - ], - 'next_add_advs_msg' => [ - 'name' => 'Please DO NOT post multiple ads for the same items or service. All duplicate, spam and wrongly categorized ads will be deleted.' - ], - 'next_add_advs_btn' => [ - 'name' => 'Next' - ], - 'cancel_add_advs_btn' => [ - 'name' => 'or Cancel' - ], 'pending_adv' => [ 'name' => 'Pending Ads' ], 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 656aa5f8e..081e8c9a2 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/message.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/message.php @@ -8,5 +8,18 @@ return [ 'agreement' => 'By clicking Post, you agree to our Terms of Use and Privacy Policy acknowledge that you are the rightful owner of this item.', 'update_category_msg' => 'The classified category will be updated.', 'updated_category_msg' => 'Category successfully edited.', - + 'max_ad_limit' => [ + 'title' => "Your Free Ad Limit is Out.", + 'msg' => "You have reached your free ad limit.", + 'nextBtn' => "Show Ads", + 'cancelBtn' => "or Cancel", + 'link' => "/profile", + ], + 'create_ad_with_post_cat' => [ + 'title' => "Post an Ad in just 30 seconds", + 'msg' => "Please DO NOT post multiple ads for the same items or service. All duplicate, spam and wrongly categorized ads will be deleted.", + 'nextBtn' => "Next", + 'cancelBtn' => "or Cancel", + 'link' => "", + ], ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/tr/field.php b/addons/default/visiosoft/advs-module/resources/lang/tr/field.php index 26d7da2ec..afdb8c5aa 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/tr/field.php +++ b/addons/default/visiosoft/advs-module/resources/lang/tr/field.php @@ -96,23 +96,6 @@ return [ "status" => [ "name" => "durum", - ], - "next_add_advs_title" => [ - "name" => "Sadece 30 saniyede bir İlan ver", - - ], - "next_add_advs_msg" => [ - "name" => "Lütfen aynı ürün veya hizmet için birden fazla İlan yayınlamayın. Tüm yinelenen, - spam ve yanlış sınıflandırılmış İlanlar silinecek.", - - ], - "next_add_advs_btn" => [ - "name" => "Sonraki", - - ], - "cancel_add_advs_btn" => [ - "name" => "ya da iptal", - ], "pending_adv" => [ "name" => "Bekleyen İlanlar", diff --git a/addons/default/visiosoft/advs-module/resources/lang/tr/message.php b/addons/default/visiosoft/advs-module/resources/lang/tr/message.php index 50ac01074..091b44747 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/tr/message.php +++ b/addons/default/visiosoft/advs-module/resources/lang/tr/message.php @@ -8,4 +8,18 @@ return [ 'agreement' => 'Yayınla\'yı tıkladığınızda, Kullanım Koşulları ve Gizlilik Politikasını kabul etmiş olursunuz, bu öğenin hak sahibi olduğunuzu kabul edersiniz.', 'update_category_msg' => 'İlan kategorisi güncellenecektir.', 'updated_category_msg' => 'Kategori başarıyla güncellendi.', + 'max_ad_limit' => [ + 'title' => "Ücretsiz İlan Limitiniz Bitmiştir.", + 'msg' => "Size verilen ücretsiz ilan limitine ulaştınız.", + 'nextBtn' => "İlanlarım", + 'cancelBtn' => "ve ya İptal", + 'link' => "/profile", + ], + 'create_ad_with_post_cat' => [ + 'title' => "Sadece 30 saniyede İlan ver", + 'msg' => "Lütfen aynı ürün veya hizmet için birden fazla İlan yayınlamayın. Tüm yinelenen, spam ve yanlış sınıflandırılmış İlanlar silinecek.", + 'nextBtn' => "Devam Et", + 'cancelBtn' => "ve ya İptal", + 'link' => "", + ], ]; \ No newline at end of file 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 f71a76e5d..07ea7cdea 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -345,26 +345,30 @@ class AdvsController extends PublicController public function getCatsForNewAd($id) { - $adv = $this->getCats($id); + $cats = $this->getCats($id); + $count_user_ads = count($this->adv_model->userAdv()->get()); - if (empty($adv->toArray())) { + if (empty($cats->toArray())) { - $adv['title'] = trans('visiosoft.module.advs::field.next_add_advs_title.name'); - $adv['msg'] = trans('visiosoft.module.advs::field.next_add_advs_msg.name'); - $adv['nextBtn'] = trans('visiosoft.module.advs::field.next_add_advs_btn.name'); - $adv['cancelBtn'] = trans('visiosoft.module.advs::field.cancel_add_advs_btn.name'); - $adv['link'] = ""; + $cats = trans('visiosoft.module.advs::message.create_ad_with_post_cat'); - if ($this->adv_model->is_enabled('packages')) { - $packageModel = new PackageModel(); - $parent_cat = $this->category_model->getParentCats($id, 'parent_id'); - $package = $packageModel->reduceLimit($parent_cat); - if ($package != null) { - return $package; + if (setting_value('visiosoft.module.advs::default_adv_limit') <= $count_user_ads) { + if ($this->adv_model->is_enabled('packages')) { + $packageModel = new PackageModel(); + $parent_cat = $this->category_model->getParentCats($id, 'parent_id'); + $package = $packageModel->reduceLimit($parent_cat); + if ($package != null) { + return $package; + } + } else { + $msg = trans('visiosoft.module.advs::message.max_ad_limit'); + return $msg; } } + + } - return $adv; + return $cats; } public function create(Request $request, AdvFormBuilder $formBuilder, CategoryRepositoryInterface $repository) @@ -422,13 +426,20 @@ class AdvsController extends PublicController /* Update Adv */ $adv = AdvsAdvsEntryModel::find($request->update_id); - if ($advModel->is_enabled('packages') and $adv->slug == "") { - $parent_cat = $categoryModel->getParentCats($request->cat1, 'parent_id'); - $packageModel = new PackageModel(); - $package = $packageModel->reduceLimit($parent_cat, 'reduce'); - if ($package != null) { - return redirect('/')->with('error', trans('visiosoft.module.advs::message.please_buy_package')); - } + $count_user_ads = count($this->adv_model->userAdv()->get()); + + if (setting_value('visiosoft.module.advs::default_adv_limit') < $count_user_ads) { + if ($advModel->is_enabled('packages') and $adv->slug == "") { + $parent_cat = $categoryModel->getParentCats($request->cat1, 'parent_id'); + $packageModel = new PackageModel(); + $package = $packageModel->reduceLimit($parent_cat, 'reduce'); + if ($package != null) + $this->messages->error(trans('visiosoft.module.advs::message.please_buy_package')); + + } else + $this->messages->error(trans('visiosoft.module.advs::message.max_ad_limit.title')); + + return redirect('/'); } if ($advModel->is_enabled('store')) {