backend/kernel/modules/module_shop_client/views/index.php

82 lines
2.2 KiB
PHP
Raw Normal View History

2024-10-29 14:53:52 +03:00
<?php
/**
* @var array $modules_info
* @var int $module_count
* @var int $page_number
* @var int $per_page
2024-10-31 16:12:02 +03:00
* @var \kernel\services\ModuleService $moduleService
2024-10-29 14:53:52 +03:00
*/
use Itguild\Tables\ListJsonTable;
2024-11-19 14:55:25 +03:00
use kernel\widgets\ActionButtonWidget;
2024-10-29 14:53:52 +03:00
$meta = [];
$meta['columns'] = [
"name" => "Название",
"author" => "Автор",
"version" => "Версия",
"description" => "Описание",
"installations" => "Установки",
"views" => "Просмотры"
];
$meta['params'] = ["class" => "table table-bordered"];
$meta['perPage'] = $per_page;
$meta['baseUrl'] = "/admin/module_shop_client";
$meta['currentPage'] = $page_number;
$meta['total'] = $module_count;
$info_to_table['meta'] = $meta;
$info_to_table['data'] = $modules_info;
$table = new ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
2024-11-19 14:55:25 +03:00
$table->addAction(function ($row, $url) use ($moduleService) {
$id = $row['id'];
return ActionButtonWidget::create([
'btn_type' => "primary",
'label' => "<i class='fa-regular fa-eye'></i>",
'url' => "$url/view/$id",
])->run();
});
2024-10-29 14:53:52 +03:00
2024-10-31 16:12:02 +03:00
$table->addAction(function ($row, $url) use ($moduleService){
$slug = $row['slug'];
$id = $row['id'];
if ($moduleService->isInstall($slug)){
2024-11-19 14:55:25 +03:00
return ActionButtonWidget::create([
'btn_type' => "danger",
'label' => "<i class='fa-regular fa-trash-can'></i>",
'url' => "$url/delete/?slug=$slug",
])->run();
2024-10-31 16:12:02 +03:00
}
else {
2024-11-19 14:55:25 +03:00
return ActionButtonWidget::create([
'btn_type' => "success",
'label' => "<i class='fa-solid fa-download'></i>",
'url' => "$url/install/?id=$id",
])->run();
2024-10-31 16:12:02 +03:00
}
});
2024-10-29 14:53:52 +03:00
2024-11-14 01:55:04 +03:00
$table->addAction(function ($row, $url) use ($moduleService){
$slug = $row['slug'];
if ($moduleService->isInstall($slug)){
if (!$moduleService->isLastVersion($slug)) {
2024-11-19 14:55:25 +03:00
return ActionButtonWidget::create([
'btn_type' => "info",
'label' => "<i class='fa-regular fa-pen-to-square'></i>",
'url' => "$url/update/?slug=$slug",
])->run();
2024-11-14 01:55:04 +03:00
}
}
return false;
2024-11-14 01:55:04 +03:00
});
2024-10-29 14:53:52 +03:00
$table->create();
2024-11-05 15:36:46 +03:00
\kernel\widgets\ModuleTabsWidget::create()->run();
2024-10-29 14:53:52 +03:00
$table->render();