diff --git a/addons/default/visiosoft/advs-module/resources/js/edit_cats.js b/addons/default/visiosoft/advs-module/resources/js/edit_cats.js index 29a350703..8f736ab17 100644 --- a/addons/default/visiosoft/advs-module/resources/js/edit_cats.js +++ b/addons/default/visiosoft/advs-module/resources/js/edit_cats.js @@ -20,6 +20,11 @@ var promiseForCategory = new Promise(function (resolve) { }); promiseForCategory.then(function (categories_list) { + + categories_list = $.grep(Object.values(categories_list), function (e) { + return (e.length > 0) ? e : ''; + }); + level = 0; $.each(categories_list, function (index, value) { level++; diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/button.php b/addons/default/visiosoft/advs-module/resources/lang/en/button.php index 3781caa78..9285e73b8 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/button.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/button.php @@ -36,7 +36,7 @@ return [ 'new_productoption' => 'New Productoption', 'new_productoptions_value' => 'New Product option value', 'new_options_configuration' => 'New Option configuration', - 'new_option_configuration' => 'New Option configuration', 'new_option_configuration' => 'New Option configuration', 'create_configurations' => 'Create Configurations', + 'replicate' => 'Replicate', ]; diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index 44a7f571c..a51671c58 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php @@ -390,4 +390,9 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface { return $this->product_options_value; } + + public function status() + { + return $this->status; + } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php index 42968fa28..f3ae4a2be 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php @@ -83,4 +83,6 @@ interface AdvInterface extends EntryInterface public function expired(); public function getProductOptionsValues(); + + public function status(); } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php index f85f0db79..ecc68bbc4 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php @@ -1,16 +1,8 @@ [ - 'filter' => 'input', - 'placeholder' => 'visiosoft.module.advs::field.search', - 'query' => NameDescFilterQuery::class, - ], - 'country', - 'id' => [ - 'heading' => 'ID', - 'filter' => 'input' - ], - ]; - /** * The table columns. * diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableButtons.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableButtons.php new file mode 100644 index 000000000..1a8634916 --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableButtons.php @@ -0,0 +1,56 @@ +setButtons([ + 'status' => [ + 'text' => function (EntryInterface $entry) { + $text_type = ($entry->status() == 'approved') ? 'decline' : 'approve'; + return "" . trans('visiosoft.module.advs::button.' . $text_type) . ""; + + }, + 'icon' => function (EntryInterface $entry) { + return ($entry->status() == 'approved') ? "fa fa-eye-slash" : "fa fa-eye"; + }, + 'href' => function (EntryInterface $entry) { + $action_type = ($entry->status() == 'approved') ? 'declined' : 'approved'; + return "/admin/class/actions/{entry.id}/" . $action_type; + }, + 'type' => function (EntryInterface $entry) { + return ($entry->status() == 'approved') ? "danger" : "success"; + }, + ], + + 'edit' => [ + 'href' => function (EntryModel $entry) { + return route('visiosoft.module.advs::edit_adv', ['id' => $entry->getId()]); + }, + 'text' => "" . trans('streams::button.edit') . "" + ], + 'settings' => [ + 'text' => false, + 'href' => false, + 'dropdown' => [ + 'change_owner' => [ + 'data-toggle' => 'modal', + 'data-target' => '#modal', + 'text' => trans('visiosoft.module.advs::button.change_owner'), + 'href' => 'admin/advs-users/choose/{entry.id}' + ], + 'replicate' => [ + 'text' => 'visiosoft.module.advs::button.replicate' + ], + 'create_configration' => [ + 'text' => trans('visiosoft.module.advs::button.create_configurations'), + 'href' => route('visiosoft.module.advs::configrations.create') . "?ad={entry.id}"] + ] + ] + ]); + } + +} diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php new file mode 100644 index 000000000..dc9968af4 --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php @@ -0,0 +1,58 @@ +setColumns([ + 'cover_photo' => [ + 'value' => function (EntryInterface $entry) { + return ""; + }, + ], + + 'name' => [ + 'sort_column' => 'slug', + 'wrapper' => ' + #{value.id}{value.name} +
+ {value.finish_at} +
+ {value.category}', + 'value' => [ + 'id' => 'entry.id', + 'finish_at' => 'entry.finish_at', + 'name' => function (EntryInterface $entry) { + if ($entry->getTitle()) { + $value = " {entry.name} "; + } else { + $value = "" . trans("visiosoft.module.advs::view.unfinished") . ""; + } + return $value; + }, + 'category' => function (EntryInterface $entry, CategoryModel $categoryModel) { + $category = $categoryModel->getCat($entry->cat1); + if (!is_null($category)) + return $category->name; + } + ], + ], + 'price' => [ + 'wrapper' => '{{currency_format("{entry.price}","{entry.currency}")}}', + 'class' => 'advs-price', + ], + + 'country' => [ + 'class' => 'advs-country', + ], + 'created_by' => [ + 'value' => 'entry.created_by.name', + ], + ]); + } + +} diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableFilters.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableFilters.php new file mode 100644 index 000000000..5853abc50 --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableFilters.php @@ -0,0 +1,64 @@ +all()->pluck('name', 'id')->all(); + + $categories = $categoryRepository->all()->mainCategories()->pluck('name', 'id')->all(); + + $builder->setFilters( + [ + 'search' => [ + 'filter' => 'input', + 'placeholder' => 'visiosoft.module.advs::field.search', + 'query' => NameDescFilterQuery::class, + ], + 'country', + 'id' => [ + 'heading' => 'ID', + 'filter' => 'input' + ], + 'City' => [ + 'exact' => true, + 'filter' => 'select', + 'query' => CityFilterQuery::class, + 'options' => $cities, + ], + 'Category' => [ + 'exact' => true, + 'filter' => 'select', + 'query' => CategoryFilterQuery::class, + 'options' => $categories, + ], + 'User' => [ + 'exact' => true, + 'filter' => 'select', + 'query' => UserFilterQuery::class, + ], + 'status' => [ + 'filter' => 'select', + 'query' => StatusFilterQuery::class, + 'options' => [ + 'approved' => 'visiosoft.module.advs::field.status.option.approved', + 'expired' => 'visiosoft.module.advs::field.status.option.expired', + 'unpublished' => 'visiosoft.module.advs::field.status.option.unpublished', + 'pending_admin' => 'visiosoft.module.advs::field.status.option.pending_admin', + 'pending_user' => 'visiosoft.module.advs::field.status.option.pending_user', + ], + ] + ] + ); + } + +} diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php index d865a67dc..24ec7cc48 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php @@ -52,67 +52,11 @@ class AdvsController extends AdminController * @param AdvTableBuilder $table * @return \Symfony\Component\HttpFoundation\Response */ - public function index(AdvTableBuilder $table, \Anomaly\UsersModule\User\UserModel $userModel, CityModel $cityModel, CatsCategoryEntryModel $categoryModel) + public function index(AdvTableBuilder $table) { $table->addAsset("styles.css", "visiosoft.module.advs::css/custom.css"); $table->addAsset('scripts.js', 'visiosoft.module.advs::js/list.js'); - $table->addButtons([ - 'status' => [ - 'text' => function (EntryInterface $entry) { - if ($entry->status == 'approved') { - return "" . trans('visiosoft.module.advs::button.decline') . ""; - } else { - return "" . trans('visiosoft.module.advs::button.approve') . ""; - } - }, - 'icon' => function (EntryInterface $entry) { - if ($entry->status == 'approved') { - return "fa fa-eye-slash"; - } else { - return "fa fa-eye"; - } - }, - 'href' => function (EntryInterface $entry) { - if ($entry->status == 'approved') { - return "/admin/class/actions/{entry.id}/declined"; - } else { - return "/admin/class/actions/{entry.id}/approved"; - } - }, - 'type' => function (EntryInterface $entry) { - if ($entry->status == 'approved') { - return "danger"; - } else { - return "success"; - } - }, - ], - 'edit' => [ - 'href' => '/advs/edit_advs/{entry.id}', - 'text' => "" . trans('streams::button.edit') . "", - ], - 'settings' => [ - 'text' => false, - 'href' => false, - 'dropdown' => [ - 'change_owner' => [ - 'data-toggle' => 'modal', - 'data-target' => '#modal', - 'text' => trans('visiosoft.module.advs::button.change_owner'), - 'href' => 'admin/advs-users/choose/{entry.id}', - ], - 'replicate' => [ - 'text' => 'Replicate', - ], - 'create_configration' => [ - 'text' => trans('visiosoft.module.advs::button.create_configurations'), - 'href' => route('visiosoft.module.advs::configrations.create')."?ad={entry.id}" - ], - ], - ], - ]); - if ($this->model->is_enabled('recommendedads')) { $table->addButton('add_recommended', [ 'type' => 'default', @@ -122,87 +66,6 @@ class AdvsController extends AdminController ]); } - $table->setColumns([ - 'cover_photo' => [ - 'value' => function (EntryInterface $entry) { - return ""; - }, - ], - 'entry.id', - 'name' => [ - 'class' => 'advs-name', - 'sort_column' => 'slug', - 'value' => function (EntryInterface $entry) { - return (!is_null($entry->name)) ? " " . $entry->name . " " : "" . trans("visiosoft.module.advs::view.unfinished") . ""; - }, - ], - 'price' => [ - 'class' => 'advs-price', - ], - 'currency' => [ - 'class' => 'advs-currency', - ], - 'country' => [ - 'class' => 'advs-country', - ], - 'created_by' => [ - 'value' => function (EntryInterface $entry, UserModel $userModel) { - $user = $userModel->find($entry->created_by_id); - if (!is_null($user)) - return $user->first_name . " " . $user->last_name; - } - ], - 'category' => [ - 'sort_column' => 'cat1', - 'value' => function (EntryInterface $entry, CategoryModel $categoryModel) { - $category = $categoryModel->getCat($entry->cat1); - if (!is_null($category)) - return $category->name; - } - ], - 'finish_at', - ]); - - - $cities = $cityModel->all()->pluck('name', 'id')->all(); - $categories = $categoryModel::query()->where('parent_category_id', null) - ->leftJoin('cats_category_translations', 'cats_category.id', '=', 'cats_category_translations.entry_id') - ->where('locale', config('app.locale')) - ->select('cats_category.*', 'cats_category_translations.name') - ->pluck('t1.name', 'id')->all(); - $table->setFilters(array_merge($table->getFilters(), - [ - 'City' => [ - 'exact' => true, - 'filter' => 'select', - 'query' => CityFilterQuery::class, - 'options' => $cities, - ], - 'Category' => [ - 'exact' => true, - 'filter' => 'select', - 'query' => CategoryFilterQuery::class, - 'options' => $categories, - ], - 'User' => [ - 'exact' => true, - 'filter' => 'select', - 'query' => UserFilterQuery::class, - ], - 'status' => [ - 'filter' => 'select', - 'query' => StatusFilterQuery::class, - 'options' => [ - 'approved' => 'visiosoft.module.advs::field.status.option.approved', - 'expired' => 'visiosoft.module.advs::field.status.option.expired', - 'unpublished' => 'visiosoft.module.advs::field.status.option.unpublished', - 'pending_admin' => 'visiosoft.module.advs::field.status.option.pending_admin', - 'pending_user' => 'visiosoft.module.advs::field.status.option.pending_user', - ], - ] - ]) - ); - return $table->render(); } @@ -342,7 +205,8 @@ class AdvsController extends AdminController } - public function exportAdvs(){ - return Excel::download(new AdvsExport(), 'advs-' . time() . '.xlsx'); - } + public function exportAdvs() + { + return Excel::download(new AdvsExport(), 'advs-' . time() . '.xlsx'); + } }