58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Models\DeviceModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class DeviceController extends AdminController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->initModel(new DeviceModel());
|
|
$this->_viewDatas["className"] = "Device";
|
|
$this->_viewPath .= strtolower($this->_viewDatas["className"]);
|
|
$this->_viewDatas["title"] = lang($this->_viewDatas["className"] . ".title");
|
|
$this->_viewDatas["class_icon"] = CLASS_ICONS[strtoupper($this->_viewDatas["className"])];
|
|
helper($this->_viewDatas["className"]);
|
|
}
|
|
|
|
public function getFields(string $action = ""): array
|
|
{
|
|
$fields = ["category", "name", "cost", "price", "status",];
|
|
switch ($action) {
|
|
case "index":
|
|
case "excel":
|
|
return ["category", "name", "cost", "price", "status", "created_at"];
|
|
break;
|
|
case "view":
|
|
return [...$fields, "created_at"];
|
|
break;
|
|
default:
|
|
return $fields;
|
|
break;
|
|
}
|
|
}
|
|
public function getFieldFilters(): array
|
|
{
|
|
return ["category", "status"];
|
|
}
|
|
public function getFieldBatchFilters(): array
|
|
{
|
|
return parent::getFieldBatchFilters();
|
|
}
|
|
|
|
public function parts($category)
|
|
{
|
|
helper('form');
|
|
$viewDatas = [];
|
|
$viewDatas['device'] = [];
|
|
$viewDatas['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'];
|
|
$viewDatas['device']['options'] = $this->getModel()->getOptions(['category' => $category]);
|
|
return view($this->_viewPath . '/' . $category, ['cellDatas' => $viewDatas]);
|
|
}
|
|
}
|