diff --git a/plugins/tps/shops/controllers/RentalsAndSalesController.php b/plugins/tps/shops/controllers/RentalsAndSalesController.php new file mode 100644 index 0000000..bf4ad56 --- /dev/null +++ b/plugins/tps/shops/controllers/RentalsAndSalesController.php @@ -0,0 +1,19 @@ + + = e(trans('backend::lang.form.create')) ?> + = e(trans('backend::lang.reorder.default_title')) ?> + + diff --git a/plugins/tps/shops/controllers/rentalsandsalescontroller/_reorder_toolbar.htm b/plugins/tps/shops/controllers/rentalsandsalescontroller/_reorder_toolbar.htm new file mode 100644 index 0000000..a7156fb --- /dev/null +++ b/plugins/tps/shops/controllers/rentalsandsalescontroller/_reorder_toolbar.htm @@ -0,0 +1,3 @@ +
\ No newline at end of file diff --git a/plugins/tps/shops/controllers/rentalsandsalescontroller/config_form.yaml b/plugins/tps/shops/controllers/rentalsandsalescontroller/config_form.yaml new file mode 100644 index 0000000..f8f7553 --- /dev/null +++ b/plugins/tps/shops/controllers/rentalsandsalescontroller/config_form.yaml @@ -0,0 +1,10 @@ +name: RentalsAndSalesController +form: $/tps/shops/models/rentalsandsales/fields.yaml +modelClass: Tps\Shops\Models\RentalsAndSales +defaultRedirect: tps/shops/rentalsandsalescontroller +create: + redirect: 'tps/shops/rentalsandsalescontroller/update/:id' + redirectClose: tps/shops/rentalsandsalescontroller +update: + redirect: tps/shops/rentalsandsalescontroller + redirectClose: tps/shops/rentalsandsalescontroller diff --git a/plugins/tps/shops/controllers/rentalsandsalescontroller/config_list.yaml b/plugins/tps/shops/controllers/rentalsandsalescontroller/config_list.yaml new file mode 100644 index 0000000..0604a32 --- /dev/null +++ b/plugins/tps/shops/controllers/rentalsandsalescontroller/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/shops/models/rentalsandsales/columns.yaml +modelClass: Tps\Shops\Models\RentalsAndSales +title: RentalsAndSalesController +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'tps/shops/rentalsandsalescontroller/update/:id' diff --git a/plugins/tps/shops/controllers/rentalsandsalescontroller/config_reorder.yaml b/plugins/tps/shops/controllers/rentalsandsalescontroller/config_reorder.yaml new file mode 100644 index 0000000..1442b0d --- /dev/null +++ b/plugins/tps/shops/controllers/rentalsandsalescontroller/config_reorder.yaml @@ -0,0 +1,4 @@ +title: RentalsAndSalesController +modelClass: Tps\Shops\Models\RentalsAndSales +toolbar: + buttons: reorder_toolbar diff --git a/plugins/tps/shops/controllers/rentalsandsalescontroller/create.htm b/plugins/tps/shops/controllers/rentalsandsalescontroller/create.htm new file mode 100644 index 0000000..563c152 --- /dev/null +++ b/plugins/tps/shops/controllers/rentalsandsalescontroller/create.htm @@ -0,0 +1,46 @@ + += e(trans('backend::lang.form.return_to_list')) ?>
+ \ No newline at end of file diff --git a/plugins/tps/shops/controllers/rentalsandsalescontroller/index.htm b/plugins/tps/shops/controllers/rentalsandsalescontroller/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/tps/shops/controllers/rentalsandsalescontroller/index.htm @@ -0,0 +1 @@ += $this->listRender() ?> diff --git a/plugins/tps/shops/controllers/rentalsandsalescontroller/preview.htm b/plugins/tps/shops/controllers/rentalsandsalescontroller/preview.htm new file mode 100644 index 0000000..0f0f21e --- /dev/null +++ b/plugins/tps/shops/controllers/rentalsandsalescontroller/preview.htm @@ -0,0 +1,22 @@ + ++ + = e(trans('backend::lang.form.return_to_list')) ?> + +
\ No newline at end of file diff --git a/plugins/tps/shops/controllers/rentalsandsalescontroller/reorder.htm b/plugins/tps/shops/controllers/rentalsandsalescontroller/reorder.htm new file mode 100644 index 0000000..f8abc0f --- /dev/null +++ b/plugins/tps/shops/controllers/rentalsandsalescontroller/reorder.htm @@ -0,0 +1,8 @@ + += e(trans('backend::lang.form.return_to_list')) ?>
+ \ No newline at end of file diff --git a/plugins/tps/shops/models/RentalsAndSales.php b/plugins/tps/shops/models/RentalsAndSales.php new file mode 100644 index 0000000..e854290 --- /dev/null +++ b/plugins/tps/shops/models/RentalsAndSales.php @@ -0,0 +1,27 @@ + 'Tps\Shops\Classes\Attachment', + ]; +} diff --git a/plugins/tps/shops/models/rentalsandsales/columns.yaml b/plugins/tps/shops/models/rentalsandsales/columns.yaml new file mode 100644 index 0000000..8e2018f --- /dev/null +++ b/plugins/tps/shops/models/rentalsandsales/columns.yaml @@ -0,0 +1,22 @@ +columns: + id: + label: id + type: number + type: + label: type + type: text + name: + label: name + type: text + floor: + label: floor + type: number + sector: + label: sector + type: text + created_at: + label: created_at + type: datetime + updated_at: + label: updated_at + type: datetime diff --git a/plugins/tps/shops/models/rentalsandsales/fields.yaml b/plugins/tps/shops/models/rentalsandsales/fields.yaml new file mode 100644 index 0000000..da4debb --- /dev/null +++ b/plugins/tps/shops/models/rentalsandsales/fields.yaml @@ -0,0 +1,47 @@ +fields: + type: + label: Тип + options: + rental: Аренда + sale: Продажа + showSearch: true + span: auto + type: dropdown + name: + label: 'Указать аренда или продажа' + span: auto + type: text + number: + label: 'Номер арендатора' + span: auto + type: text + floor: + label: Этаж + options: + - '0' + - '1' + - '2' + - '3' + - '4' + - '5' + showSearch: true + span: auto + type: dropdown + sector: + label: Сектор + span: auto + type: text + description: + label: Описание + size: small + span: auto + type: textarea + images: + label: images + mode: image + useCaption: true + thumbOptions: + mode: crop + extension: auto + span: auto + type: fileupload diff --git a/plugins/tps/shops/plugin.yaml b/plugins/tps/shops/plugin.yaml index b20f4b7..0f2e2d9 100644 --- a/plugins/tps/shops/plugin.yaml +++ b/plugins/tps/shops/plugin.yaml @@ -42,3 +42,7 @@ navigation: label: Notification url: tps/shops/notification icon: icon-comments + side-menu-item9: + label: 'Аренда и продажа' + url: tps/shops/rentalsandsalescontroller + icon: icon-line-chart diff --git a/plugins/tps/shops/updates/builder_table_create_tps_shops_rentals_and_sales.php b/plugins/tps/shops/updates/builder_table_create_tps_shops_rentals_and_sales.php new file mode 100644 index 0000000..6af7dcc --- /dev/null +++ b/plugins/tps/shops/updates/builder_table_create_tps_shops_rentals_and_sales.php @@ -0,0 +1,29 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->string('type'); + $table->string('name')->nullable(); + $table->string('number')->nullable(); + $table->integer('floor'); + $table->string('sector')->nullable(); + $table->text('description')->nullable(); + $table->timestamp('created_at')->nullable(); + $table->timestamp('updated_at')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('tps_shops_rentals_and_sales'); + } +} diff --git a/plugins/tps/shops/updates/version.yaml b/plugins/tps/shops/updates/version.yaml index 3964178..c76f528 100644 --- a/plugins/tps/shops/updates/version.yaml +++ b/plugins/tps/shops/updates/version.yaml @@ -90,3 +90,6 @@ 1.0.31: - 'Created table tps_shops_notification' - builder_table_create_tps_shops_notification.php +1.0.32: + - 'Created table tps_shops_rentals_and_sales' + - builder_table_create_tps_shops_rentals_and_sales.php diff --git a/themes/berkarar/assets/js/customSelect.js b/themes/berkarar/assets/js/customSelect.js index 2f27de7..6fe47da 100644 --- a/themes/berkarar/assets/js/customSelect.js +++ b/themes/berkarar/assets/js/customSelect.js @@ -42,7 +42,8 @@ function initializeCustomSelect() { // } // s.options[i].setAttribute("selected", "selected"); // console.log(s.options[i]); - handleChange(s.selectedIndex); + // handleChange(s.selectedIndex, 'shops'); + handleChange(s.selectedIndex, s.name); @@ -111,18 +112,261 @@ document.addEventListener("click", closeAllSelect); initializeCustomSelect(); -function handleChange(selectElement) { - var floorID = selectElement; // Get the selected value of the dropdown - console.log("Selected Value:", floorID); - $.request('onUpdate', { - data: { floorID: floorID }, - update: { - 'home/shop_item': '#rest-all', - 'home/pagination': '#pagination-container' // Update this with the correct ID or selector - } - }); + + +// ************************************************** + + // function afterUpdate1() { + // console.log("runned my function"); + // var itemsPerPage = 1; + // var currentPage = 0; + // var items = document.querySelectorAll(".shops_item_data"); + // var totalPages = Math.ceil(items.length / itemsPerPage); + // var nextButton = document.querySelector(".next-button"); + // var prevButton = document.querySelector(".prev-button"); + // var pageInput = document.querySelector(".input_page"); + // var paginationBlock = document.querySelector("#all_pagination"); + + // // Initially hide all items except the first page + // for (var i = itemsPerPage; i < items.length; i++) { + // items[i].style.display = "none"; + // } + + // updatePagination(); + + // prevButton.addEventListener("click", function () { + // if (currentPage > 0) { + // currentPage--; + // updatePagination(); + // } + // }); + + // nextButton.addEventListener("click", function () { + // if (currentPage < totalPages - 1) { + // currentPage++; + // updatePagination(); + // } + // }); + + // function updatePagination() { + // var startIndex = currentPage * itemsPerPage; + // var endIndex = startIndex + itemsPerPage; + + // for (var i = 0; i < items.length; i++) { + // if (i >= startIndex && i < endIndex) { + // items[i].style.display = "block"; + // } else { + // items[i].style.display = "none"; + // } + // } + + // if(pageInput.value != null) + // { + // pageInput.value = currentPage + 1; // Update input field value + // } + + // } + // }; + + + + // function afterUpdate2() { + // var itemsPerPage = 9; + // var currentPage = 0; + // var items = document.querySelectorAll("#rentals .shops_item"); + // var totalPages = Math.ceil(items.length / itemsPerPage); + // var nextButton = document.querySelector("#rentals_pagination .next-button"); + // var prevButton = document.querySelector("#rentals_pagination .prev-button"); + // var pageInput = document.querySelector("#rentals_pagination .input_page"); + // var paginationBlock = document.querySelector("#rentals_pagination"); + + // // Initially hide all items except the first page + // for (var i = itemsPerPage; i < items.length; i++) { + // items[i].style.display = "none"; + // } + + // updatePagination(); + + // prevButton.addEventListener("click", function () { + // if (currentPage > 0) { + // currentPage--; + // updatePagination(); + // } + // }); + + // nextButton.addEventListener("click", function () { + // if (currentPage < totalPages - 1) { + // currentPage++; + // updatePagination(); + // } + // }); + + + // function updatePagination() { + // var startIndex = currentPage * itemsPerPage; + // var endIndex = startIndex + itemsPerPage; + + // for (var i = 0; i < items.length; i++) { + // if (i >= startIndex && i < endIndex) { + // items[i].style.display = "block"; + // } else { + // items[i].style.display = "none"; + // } + // } + + // console.log(items.length); + + // if(pageInput.value != null) + // { + // pageInput.value = currentPage + 1; // Update input field value + // } + + // } + // }; + + + // function afterUpdate3() { + // var itemsPerPage = 9; + // var currentPage = 0; + // var items = document.querySelectorAll("#sales .shops_item"); + // var totalPages = Math.ceil(items.length / itemsPerPage); + // var nextButton = document.querySelector("#sales_pagination .next-button"); + // var prevButton = document.querySelector("#sales_pagination .prev-button"); + // var pageInput = document.querySelector("#sales_pagination .input_page"); + // var paginationBlock = document.querySelector("#sales_pagination"); + + // // Initially hide all items except the first page + // for (var i = itemsPerPage; i < items.length; i++) { + // items[i].style.display = "none"; + // } + + // updatePagination(); + + // prevButton.addEventListener("click", function () { + // if (currentPage > 0) { + // currentPage--; + // updatePagination(); + // } + // }); + + // nextButton.addEventListener("click", function () { + // if (currentPage < totalPages - 1) { + // currentPage++; + // updatePagination(); + // } + // }); + + // function updatePagination() { + // var startIndex = currentPage * itemsPerPage; + // var endIndex = startIndex + itemsPerPage; + + // for (var i = 0; i < items.length; i++) { + // if (i >= startIndex && i < endIndex) { + // items[i].style.display = "block"; + // } else { + // items[i].style.display = "none"; + // } + // } + + // if(pageInput.value != null) + // { + // pageInput.value = currentPage + 1; // Update input field value + // } + + // } + // }; + + // function afterUpdate4() { + // // Initially hide all pagination buttons except the one for the active tab + // var allPagination = document.querySelector('.shops_block_all_pagination'); + // var rentalsPagination = document.querySelector('.shops_block_rentals_pagination'); + // var salesPagination = document.querySelector('.shops_block_sales_pagination'); + + // allPagination.style.display = "inline-flex"; + // rentalsPagination.style.display = "none"; + // salesPagination.style.display = "none"; + + // // Handle click events on tab links + // var tabLinks = document.querySelectorAll('.shops_tab-link'); + // // console.log(tabLinks); + // tabLinks.forEach(function(tabLink) { + // tabLink.addEventListener('click', function() { + // // Remove 'active' class from all tab links + // tabLinks.forEach(function(link) { + // link.classList.remove('active'); + // }); + // // Add 'active' class to the clicked tab link + // tabLink.classList.add('active'); + + // // Hide all pagination buttons + // allPagination.style.display = "none"; + // rentalsPagination.style.display = "none"; + // salesPagination.style.display = "none"; + + // // Get the data-tab attribute value of the clicked tab link + // var tabId = tabLink.getAttribute('data-tab'); + + // console.log(tabId + '_pagination'); + // document.querySelector(tabId + '_pagination').style.display = "inline-flex"; + // }); + // }); + // }; + + +// ********************************************************************************************** + + +function handleChange(selectElement,type) { + var floorID = selectElement; + + if(type == 'shops') + { + console.log("Selected type:", type); + $.request('onUpdate', { + data: { floorID: floorID }, + update: { + 'home/shop_item': '#rest-all', + 'home/pagination': '#pagination-container' + } + }); + } + + if(type == 'rentals_and_sales'){ + console.log("Selected type:", type); + + $.request('onUpdate', { + data: { floorID: floorID }, + update: { + 'home/rentals_and_sales/rentals_and_sales': '#all', + 'home/rentals_and_sales/rentals': '#rentals', + 'home/rentals_and_sales/sales': '#sales', + 'home/rentals_and_sales/js_code': '#js_code', + }, + complete: function(data) { + afterPartialUpdate(); + } + + }); + } + return false; } + + // complete: function(data) { + // // console.log("hi"); + // } + // complete: function(data) { + // // This code runs after the first AJAX request is completed + // $.request('refreshOtherPartial', { + // update: { + // 'other/partial': '#otherPartial' + // }, + // complete: function(data) { + // // This code runs after the second AJAX request is completed + // console.log("Other partial refreshed"); + // } + // }); + // } diff --git a/themes/berkarar/pages/rental_or_sale.htm b/themes/berkarar/pages/rental_or_sale.htm new file mode 100644 index 0000000..234aaa4 --- /dev/null +++ b/themes/berkarar/pages/rental_or_sale.htm @@ -0,0 +1,104 @@ +title = "rental_or_sale" +url = "/rental_or_sale/:id" +layout = "default" +is_hidden = 0 +== +param('id'); + + $this['sale'] = Tps\Shops\Models\RentalsAndSales::where("id", $id)->get()->first(); + +} +?> +== +