vhost init...3

This commit is contained in:
최준흠 2024-05-15 16:30:58 +09:00
parent e54d0b72af
commit f2457ea0e8
25 changed files with 518 additions and 30 deletions

View File

@ -18,7 +18,7 @@ class BoardCell extends BaseCell
$viewDatas['currentCategory'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => __FUNCTION__]); $viewDatas['currentCategory'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => __FUNCTION__]);
$viewDatas['cellDatas'] = array(); $viewDatas['cellDatas'] = array();
$viewDatas['cellDatas']['entitys'] = $this->getBoardModel()->getEntitys([ $viewDatas['cellDatas']['entitys'] = $this->getBoardModel()->getEntitys([
'category_uid' => __FUNCTION__ 'category' => __FUNCTION__
]); ]);
return view( return view(
'Views/front/board/cell/' . __FUNCTION__, 'Views/front/board/cell/' . __FUNCTION__,

View File

@ -238,6 +238,7 @@ define('CLASS_ICONS', [
'SITEPAGE' => '<i class="bi bi-body-text"></i>', 'SITEPAGE' => '<i class="bi bi-body-text"></i>',
'CATEGORY' => '<i class="bi bi-boxes"></i>', 'CATEGORY' => '<i class="bi bi-boxes"></i>',
'PRODUCT' => '<i class="bi bi-box2"></i>', 'PRODUCT' => '<i class="bi bi-box2"></i>',
'DEVICE' => '<i class="bi bi-gear"></i>',
'ORDER' => '<i class="bi bi-clipboard-check"></i>', 'ORDER' => '<i class="bi bi-clipboard-check"></i>',
'BILLING' => '<i class="bi bi-clipboard-check"></i>', 'BILLING' => '<i class="bi bi-clipboard-check"></i>',
'CART' => '<i class="bi bi-cart4"></i>', 'CART' => '<i class="bi bi-cart4"></i>',

View File

@ -103,6 +103,18 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->get('toggle/(:num)/(:hash)', 'SitepageController::toggle/$1/$2'); $routes->get('toggle/(:num)/(:hash)', 'SitepageController::toggle/$1/$2');
$routes->post('batchjob', 'SitepageController::batchjob'); $routes->post('batchjob', 'SitepageController::batchjob');
}); });
$routes->group('device', static function ($routes) {
$routes->get('', 'DeviceController::index');
$routes->get('excel', 'DeviceController::excel');
$routes->get('insert', 'DeviceController::insert_form');
$routes->post('insert', 'DeviceController::insert');
$routes->get('update/(:uuid)', 'DeviceController::update_form/$1');
$routes->post('update/(:uuid)', 'DeviceController::update/$1');
$routes->get('view/(:uuid)', 'DeviceController::view/$1');
$routes->get('delete/(:uuid)', 'DeviceController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:uuid)/(:hash)', 'DeviceController::toggle/$1/$2');
$routes->post('batchjob', 'DeviceController::batchjob');
});
$routes->group('product', static function ($routes) { $routes->group('product', static function ($routes) {
$routes->get('', 'ProductController::index'); $routes->get('', 'ProductController::index');
$routes->get('excel', 'ProductController::excel'); $routes->get('excel', 'ProductController::excel');

View File

@ -25,14 +25,14 @@ class BoardController extends AdminController
public function getFields(string $action = ""): array public function getFields(string $action = ""): array
{ {
$fields = ["category_uid", 'title', "board_file", "passwd", "status", "content"]; $fields = ["category", 'title', "board_file", "passwd", "status", "content"];
switch ($action) { switch ($action) {
case "index": case "index":
case "excel": case "excel":
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"]; return ["category", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"];
break; break;
case "view": case "view":
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"]; return ["category", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"];
break; break;
default: default:
return $fields; return $fields;
@ -41,7 +41,7 @@ class BoardController extends AdminController
} }
public function getFieldFilters(): array public function getFieldFilters(): array
{ {
return ["category_uid", "user_uid", "status"]; return ["category", "user_uid", "status"];
} }
public function getFieldBatchFilters(): array public function getFieldBatchFilters(): array
{ {
@ -66,7 +66,7 @@ class BoardController extends AdminController
private function build_notice() private function build_notice()
{ {
$entitys = $this->_model->getEntitys(['category_uid' => $this->_category_notice, 'status' => DEFAULTS['STATUS']]); $entitys = $this->_model->getEntitys(['category' => $this->_category_notice, 'status' => DEFAULTS['STATUS']]);
$temps = array("<ul>"); $temps = array("<ul>");
foreach ($entitys as $entity) { foreach ($entitys as $entity) {
array_push($temps, sprintf( array_push($temps, sprintf(
@ -86,7 +86,7 @@ class BoardController extends AdminController
protected function insert_process() protected function insert_process()
{ {
$entity = parent::insert_process(); $entity = parent::insert_process();
if ($entity->category_uid == $this->_category_notice) { if ($entity->category == $this->_category_notice) {
$this->build_notice(); $this->build_notice();
} }
return $entity; return $entity;
@ -95,7 +95,7 @@ class BoardController extends AdminController
protected function update_process($entity) protected function update_process($entity)
{ {
$entity = parent::update_process($entity); $entity = parent::update_process($entity);
if ($entity->category_uid == $this->_category_notice) { if ($entity->category == $this->_category_notice) {
$this->build_notice(); $this->build_notice();
} }
return $entity; return $entity;
@ -104,7 +104,7 @@ class BoardController extends AdminController
protected function toggle_process($entity) protected function toggle_process($entity)
{ {
$entity = parent::toggle_process($entity); $entity = parent::toggle_process($entity);
if ($entity->category_uid == $this->_category_notice) { if ($entity->category == $this->_category_notice) {
$this->build_notice(); $this->build_notice();
} }
return $entity; return $entity;
@ -113,7 +113,7 @@ class BoardController extends AdminController
protected function delete_process($entity) protected function delete_process($entity)
{ {
$entity = parent::delete_process($entity); $entity = parent::delete_process($entity);
if ($entity->category_uid->$this->_category_notice) { if ($entity->category->$this->_category_notice) {
$this->build_notice(); $this->build_notice();
} }
return $entity; return $entity;

View File

@ -0,0 +1,47 @@
<?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->_model = 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 = ["type", "name", "cost", "price", "sale", "stock", "status", "content",];
switch ($action) {
case "index":
case "excel":
return ["type", "name", "cost", "price", "sale", "stock", "status", "created_at"];
break;
case "view":
return [...$fields, "created_at"];
break;
default:
return $fields;
break;
}
}
public function getFieldFilters(): array
{
return ["type", "status"];
}
public function getFieldBatchFilters(): array
{
return parent::getFieldBatchFilters();
}
}

View File

@ -22,14 +22,14 @@ class SitepageController extends AdminController
public function getFields(string $action = ""): array public function getFields(string $action = ""): array
{ {
$fields = ["category_uid", 'title', "status", "content"]; $fields = ["category", 'title', "status", "content"];
switch ($action) { switch ($action) {
case "index": case "index":
case "excel": case "excel":
return ["category_uid", "user_uid", 'title', "status", "created_at"]; return ["category", "user_uid", 'title', "status", "created_at"];
break; break;
case "view": case "view":
return ["category_uid", "user_uid", 'title', "status", "created_at", "content"]; return ["category", "user_uid", 'title', "status", "created_at", "content"];
break; break;
default: default:
return $fields; return $fields;
@ -38,7 +38,7 @@ class SitepageController extends AdminController
} }
public function getFieldFilters(): array public function getFieldFilters(): array
{ {
return ["category_uid", "user_uid", "status"]; return ["category", "user_uid", "status"];
} }
public function getFieldBatchFilters(): array public function getFieldBatchFilters(): array
{ {

View File

@ -42,7 +42,6 @@ DROP TABLE IF EXISTS vhost.tw_category;
CREATE TABLE vhost.tw_category ( CREATE TABLE vhost.tw_category (
uid varchar(50) NOT NULL, uid varchar(50) NOT NULL,
classname varchar(50) NOT NULL DEFAULT 'Sitepage',
grpno int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함', grpno int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함',
grporder int(5) unsigned NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작', grporder int(5) unsigned NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작',
grpdepth int(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요', grpdepth int(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요',
@ -77,7 +76,7 @@ CREATE TABLE vhost.tw_board (
grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작', grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작',
grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요', grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요',
parent int(10) UNSIGNED NULL COMMENT '부모UID', parent int(10) UNSIGNED NULL COMMENT '부모UID',
category_uid varchar(50) NOT NULL COMMENT '범주_UID', category varchar(20) NOT NULL COMMENT '구분',
user_uid varchar(36) NULL COMMENT '작성자 정보', user_uid varchar(36) NULL COMMENT '작성자 정보',
title varchar(255) NOT NULL COMMENT '제목', title varchar(255) NOT NULL COMMENT '제목',
content text NOT NULL COMMENT '내용', content text NOT NULL COMMENT '내용',
@ -89,15 +88,14 @@ CREATE TABLE vhost.tw_board (
created_at timestamp NOT NULL DEFAULT current_timestamp(), created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL, deleted_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (uid), PRIMARY KEY (uid),
CONSTRAINT FOREIGN KEY (category_uid) REFERENCES tw_category (uid), CONSTRAINT tw_board_ibfk_1 FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT = '게시물 정보'; ) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT = '게시물 정보';
DROP TABLE IF EXISTS vhost.tw_sitepage; DROP TABLE IF EXISTS vhost.tw_sitepage;
CREATE TABLE vhost.tw_sitepage ( CREATE TABLE vhost.tw_sitepage (
uid int(10) unsigned NOT NULL AUTO_INCREMENT, uid int(10) unsigned NOT NULL AUTO_INCREMENT,
category_uid varchar(50) NOT NULL COMMENT '범주_UID', category varchar(20) NOT NULL COMMENT '구분',
user_uid varchar(36) DEFAULT NULL COMMENT '작성자 정보', user_uid varchar(36) DEFAULT NULL COMMENT '작성자 정보',
title varchar(255) NOT NULL COMMENT '제목', title varchar(255) NOT NULL COMMENT '제목',
content text NOT NULL COMMENT '내용', content text NOT NULL COMMENT '내용',
@ -108,8 +106,7 @@ CREATE TABLE vhost.tw_sitepage (
PRIMARY KEY (uid), PRIMARY KEY (uid),
KEY category_uid (category_uid), KEY category_uid (category_uid),
KEY user_uid (user_uid), KEY user_uid (user_uid),
CONSTRAINT tw_sitepage_ibfk_1 FOREIGN KEY (category_uid) REFERENCES tw_category (uid), CONSTRAINT tw_sitepage_ibfk_1 FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
CONSTRAINT tw_sitepage_ibfk_2 FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT '사이트페이지'; ) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT '사이트페이지';
DROP TABLE IF EXISTS vhost.tw_product; DROP TABLE IF EXISTS vhost.tw_product;
@ -127,7 +124,7 @@ CREATE TABLE vhost.tw_product (
stock int(5) unsigned NOT NULL DEFAULT 1 COMMENT '재고수량', stock int(5) unsigned NOT NULL DEFAULT 1 COMMENT '재고수량',
view_cnt int(4) unsigned NOT NULL DEFAULT 1 COMMENT '조회수', view_cnt int(4) unsigned NOT NULL DEFAULT 1 COMMENT '조회수',
content text NOT NULL COMMENT '상품내용', content text NOT NULL COMMENT '상품내용',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매, unuse: 판매않함, soldout:상품부족 등등', status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매, unuse: 판매중지, soldout:매진, outofstock:재고부족 등등',
updated_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(), created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL, deleted_at timestamp NULL DEFAULT NULL,
@ -148,8 +145,8 @@ CREATE TABLE vhost.tw_device (
price int(10) unsigned NOT NULL DEFAULT 0 COMMENT '판매가', price int(10) unsigned NOT NULL DEFAULT 0 COMMENT '판매가',
sale int(10) unsigned NOT NULL DEFAULT 0 COMMENT '할인가', sale int(10) unsigned NOT NULL DEFAULT 0 COMMENT '할인가',
stock int(5) unsigned NOT NULL DEFAULT 1 COMMENT '재고수량', stock int(5) unsigned NOT NULL DEFAULT 1 COMMENT '재고수량',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매중 unuse: 판매않함, soldout:상품부족 등등',
content text NOT NULL COMMENT '장비내용', content text NOT NULL COMMENT '장비내용',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매중 unuse: 판매중지, soldout:매진, outofstock:재고부족 등등',
updated_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(), created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL, deleted_at timestamp NULL DEFAULT NULL,

Binary file not shown.

View File

@ -0,0 +1,17 @@
<?php
namespace App\Entities;
class DeviceEntity extends BaseEntity
{
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
//기본기능
public function getTitle(): string
{
return $this->attributes['name'];
}
//추가기능
}

View File

@ -45,6 +45,7 @@ function getFieldForm_BoardHelper($field, $value, array $viewDatas, array $attri
case 'view_cnt': case 'view_cnt':
return form_input($field, $value, ['type' => 'number']); return form_input($field, $value, ['type' => 'number']);
break; break;
case "category":
case "status": case "status":
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]]; $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes); return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);

View File

@ -0,0 +1,163 @@
<?php
function getFieldLabel_DeviceHelper($field, array $viewDatas): string
{
$attributes = [];
switch ($field) {
default:
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
$attributes = ['style="color:red";'];
}
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
break;
}
}
//header.php에서 getFieldForm_Helper사용
function getFieldForm_DeviceHelper($field, $value, array $viewDatas, array $attributes = array())
{
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'category_uid':
case 'user_uid':
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
// // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
// foreach ($viewDatas['fieldFormOptions'][$field] as $key => $label) {
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
// }
// return implode("&nbsp;", $checkboxs);
break;
case 'title':
case 'name':
return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
break;
case 'content':
case 'head':
case 'tail':
return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
break;
case "status":
case "type":
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
break;
case 'updated_at':
case 'created_at':
return form_input($field, $value, ['class' => 'calender']);
break;
default:
return form_input($field, $value);
break;
}
} //
function getFieldView_DeviceHelper($field, $entity, array $viewDatas)
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'category_uid':
foreach (array_values($viewDatas['fieldFormOptions'][$field]) as $category_2depths) {
foreach ($category_2depths as $key => $label) {
if ($key == $value) {
return $label;
}
}
}
return $value;
break;
case 'cost':
case 'price':
case 'sale':
return number_format(!$value ? 0 : $value) . "";
break;
case 'stock':
case 'view_cnt':
return number_format(!$value ? 0 : $value);
break;
case 'content':
return html_entity_decode($value);
break;
case 'updated_at':
case 'created_at':
return $value ? str_split($value, 10)[0] : "";
break;
default:
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
break;
}
} //
function getFieldFilter_DeviceHelper($field, $value, array $viewDatas)
{
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
} //
function getFieldIndex_Column_DeviceHelper($field, array $viewDatas)
{
$label = lang("{$viewDatas['className']}.label.{$field}");
if ($field == $viewDatas['order_field']) {
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
}
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
$viewDatas['uri']->addQuery('order_field', $field);
$viewDatas['uri']->addQuery('order_value', $value);
$columnData = anchor((string)$viewDatas['uri'], $label);
switch ($field) {
case 'title':
case 'name':
return sprintf("<th class='col-4'>%s</th>", $columnData);
break;
default:
return sprintf("<th>%s</th>", $columnData);
break;
}
} //
//Front용
function getFieldIndex_Row_DeviceHelper($field, $entity, array $viewDatas): string
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
//front는 table을 사용하지 않는 점 주의
switch ($field) {
case 'title':
case 'name':
return anchor(
current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['currentCategory']->getPrimaryKey(),
$value,
["target" => "_self"]
);
break;
default:
return getFieldView_DeviceHelper($field, $entity, $viewDatas);
break;
}
} //
//Admin용
function getFieldIndex_Row_DeviceHelper_Admin($field, $entity, array $viewDatas): string
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'title':
case 'name':
return anchor(
current_url() . '/view/' . $entity->getPrimaryKey(),
$value,
["target" => "_self"]
);
break;
default:
if (in_array($field, $viewDatas['fieldFilters'])) {
$attributes["onChange"] = sprintf(
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
current_url(),
$entity->getPrimaryKey(),
$field,
$field
);
return getFieldForm_DeviceHelper($field, $entity->$field, $viewDatas, $attributes);
}
//front는 table을 사용하지 않는 점 주의
return getFieldIndex_Row_DeviceHelper($field, $entity, $viewDatas);
break;
}
} //

View File

@ -45,6 +45,7 @@ function getFieldForm_SitepageHelper($field, $value, array $viewDatas, array $at
case 'view_cnt': case 'view_cnt':
return form_input($field, $value, ['type' => 'number']); return form_input($field, $value, ['type' => 'number']);
break; break;
case "category":
case "status": case "status":
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]]; $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes); return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);

View File

@ -6,7 +6,7 @@ return [
'grpno' => "그룹번호", 'grpno' => "그룹번호",
'grpord' => "부모번호", 'grpord' => "부모번호",
'grpdpt' => "그룸Depth", 'grpdpt' => "그룸Depth",
'category_uid' => "분류", 'category' => "분류",
'user_uid' => "작성자", 'user_uid' => "작성자",
'title' => "제목", 'title' => "제목",
'content' => "내용", 'content' => "내용",
@ -18,5 +18,9 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일" 'created_at' => "작성일"
], ],
"CATEGORY" => [
'information' => '공지사항',
'reference' => '자료실'
],
'STATUS' => ['use' => '사용', 'unuse' => '사용않함'], 'STATUS' => ['use' => '사용', 'unuse' => '사용않함'],
]; ];

View File

@ -0,0 +1,36 @@
<?php
return [
'title' => "장비 정보",
'label' => [
'uid' => "번호",
'type' => '형식',
'name' => "모델명",
'cost' => "판매원가",
'price' => "판매금액",
'sale' => "할인금액",
'stock' => "재고",
'content' => "장비정보",
'status' => "상태",
'updated_at' => "수정일",
'created_at' => "생성일"
],
"TYPE" => [
'beremetal' => '실서버',
'kvm' => '가상서버',
'container' => '콘테이너',
'cpu' => 'CPU',
'memory' => 'Memory',
'ssd' => 'SSD',
'nvme' => 'NVME',
'nic' => 'LANCARD',
'windows' => 'Windows',
'linux' => 'Linux',
'publicip' => '공인IP'
],
"STATUS" => [
"use" => "판매중",
"unuse" => "판매중지",
"soldout" => "매진",
"outofstock" => "재고부족",
]
];

View File

@ -24,7 +24,8 @@ return [
], ],
"STATUS" => [ "STATUS" => [
"use" => "판매중", "use" => "판매중",
"unuse" => "판매일시중지", "unuse" => "판매중지",
"soldout" => "매진",
"outofstock" => "재고부족", "outofstock" => "재고부족",
] ]
]; ];

View File

@ -3,7 +3,7 @@ return [
'title' => "사이트페이지 정보", 'title' => "사이트페이지 정보",
'label' => [ 'label' => [
'uid' => "번호", 'uid' => "번호",
'category_uid' => "분류", 'category' => "분류",
'user_uid' => "작성자", 'user_uid' => "작성자",
'title' => "제목", 'title' => "제목",
'content' => "내용", 'content' => "내용",
@ -11,5 +11,12 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일" 'created_at' => "작성일"
], ],
"CATEGORY" => [
'greeting' => '인사말',
'companyinfo' => '회사소개',
'beremetal' => '단독서버',
'line' => '회선',
'vpn' => '기타서비스'
],
'STATUS' => ['use' => '사용', 'unuse' => '사용않함'], 'STATUS' => ['use' => '사용', 'unuse' => '사용않함'],
]; ];

View File

@ -13,7 +13,7 @@ class BoardModel extends BaseHierarchyModel
parent::__construct('Board'); parent::__construct('Board');
$this->allowedFields = [ $this->allowedFields = [
...$this->allowedFields, ...$this->allowedFields,
"category_uid", "category",
"user_uid", 'title', "content", "user_uid", 'title', "content",
"passwd", "board_file", "view_cnt", "status" "passwd", "board_file", "view_cnt", "status"
]; ];
@ -30,7 +30,7 @@ class BoardModel extends BaseHierarchyModel
public function getFieldRule(string $field, array $rules, string $action = ""): array public function getFieldRule(string $field, array $rules, string $action = ""): array
{ {
switch ($field) { switch ($field) {
case "category_uid": case "category":
$rules[$field] = "required|string"; $rules[$field] = "required|string";
break; break;
case "user_uid": case "user_uid":

View File

@ -0,0 +1,82 @@
<?php
namespace App\Models;
use App\Entities\DeviceEntity;
class DeviceModel extends BaseModel
{
const STATUS_OUTOFSTOCK = "outofstock";
const STATUS_SOLDOUT = "soldout";
protected $table = "tw_device";
protected $useAutoIncrement = false;
protected $returnType = DeviceEntity::class;
protected $useSoftDeletes = true;
public function __construct()
{
parent::__construct('Device');
$this->allowedFields = [
...$this->allowedFields,
'type', 'name', "photo", "cost", "price", "sale",
"stock", "content", "status"
];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
}
public function getTitleField(): string
{
return 'name';
}
public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case $this->getTitleField():
$rules[$field] = "required|trim|string";
break;
case 'type':
$rules[$field] = "required|string";
break;
case 'photo':
$rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]";
break;
case 'cost':
case 'price':
case 'stock':
$rules[$field] = "required|numeric";
break;
case 'sale':
$rules[$field] = "if_exist|numeric";
break;
case "content":
$rules[$field] = "required|string";
break;
default:
$rules = parent::getFieldRule($field, $rules, $action);
break;
}
return $rules;
}
public function getEntity($conditions): DeviceEntity
{
return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다.");
}
public function create(array $formDatas): DeviceEntity
{
return $this->create_process(new DeviceEntity(), $formDatas);
}
public function modify(DeviceEntity $entity, array $formDatas): DeviceEntity
{
return $this->modify_process($entity, $formDatas);
}
//Index관련
public function setIndexWordFilter(string $word)
{
if ($word !== DEFAULTS['EMPTY']) {
parent::setIndexWordFilter($word);
$this->orLike($this->getTitleField(), $word, "both");
$this->orLike("content", $word, "both"); //befor , after , both
}
}
}

View File

@ -7,6 +7,7 @@ use App\Entities\ProductEntity;
class ProductModel extends BaseModel class ProductModel extends BaseModel
{ {
const STATUS_OUTOFSTOCK = "outofstock"; const STATUS_OUTOFSTOCK = "outofstock";
const STATUS_SOLDOUT = "soldout";
protected $table = "tw_product"; protected $table = "tw_product";
protected $useAutoIncrement = false; protected $useAutoIncrement = false;
protected $returnType = ProductEntity::class; protected $returnType = ProductEntity::class;

View File

@ -13,7 +13,7 @@ class SitepageModel extends BaseModel
parent::__construct('Sitepage'); parent::__construct('Sitepage');
$this->allowedFields = [ $this->allowedFields = [
...$this->allowedFields, ...$this->allowedFields,
"category_uid", "category",
"user_uid", 'title', "content", "user_uid", 'title', "content",
"status" "status"
]; ];
@ -30,7 +30,7 @@ class SitepageModel extends BaseModel
public function getFieldRule(string $field, array $rules, string $action = ""): array public function getFieldRule(string $field, array $rules, string $action = ""): array
{ {
switch ($field) { switch ($field) {
case "category_uid": case "category":
$rules[$field] = "required|string"; $rules[$field] = "required|string";
break; break;
case "user_uid": case "user_uid":

View File

@ -0,0 +1,48 @@
<?= $this->extend('layouts/admin') ?>
<?= $this->section('content') ?>
<link href="/css/admin/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<div class="top container-fluid">
<nav class="nav">
조건검색:<?php foreach ($viewDatas['fieldFilters'] as $field) : ?><?= getFieldFilter_DeviceHelper($field, $viewDatas[$field], $viewDatas) ?><?php endforeach ?>
</nav>
<?= $this->include('templates/admin/index_head') ?>
</div>
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<?php foreach ($viewDatas['fields'] as $field) : ?><?= getFieldIndex_Column_DeviceHelper($field, $viewDatas) ?><?php endforeach ?>
<th>@</th>
</tr>
</thead>
<tbody>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
<td nowarp>
<?= form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
<?= anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
</td>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<td><?= getFieldIndex_Row_DeviceHelper_Admin($field, $entity, $viewDatas) ?></td>
<?php endforeach ?>
<td><?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?></td>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
</tbody>
</table>
<div class="bottom">
<ul class="nav justify-content-center">
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
<?php foreach ($viewDatas['batchjobFilters'] as $field) : ?><?= getFieldFilter_DeviceHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?><?php endforeach ?>
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
<li class="nav-item"><?= anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?></li>
</ul>
<?= $viewDatas['pagination'] ?>
</div>
<?= form_close() ?>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,24 @@
<?= $this->extend('layouts/admin') ?>
<?= $this->section('content') ?>
<link href="/css/admin/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="form table table-bordered table-striped">
<tbody>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_DeviceHelper($field, $viewDatas) ?></td>
<td class="column">
<?= getFieldForm_DeviceHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td valign="bottom" colspan="2"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></td>
</tr>
</tbody>
<?= form_close(); ?>
</table>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,24 @@
<?= $this->extend('layouts/admin') ?>
<?= $this->section('content') ?>
<link href="/css/admin/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="form table table-bordered table-striped">
<tbody>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_DeviceHelper($field, $viewDatas) ?></td>
<td class="column">
<?= getFieldForm_DeviceHelper($field, $viewDatas['entity']->$field ?: DEFAULTS['EMPTY'], $viewDatas) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td valign="bottom" colspan="2"><?= form_submit('', '수정', array("class" => "btn btn-outline btn-primary")); ?></td>
</tr>
</tbody>
<?= form_close(); ?>
</table>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,19 @@
<?= $this->extend('layouts/admin') ?>
<?= $this->section('content') ?>
<link href="/css/admin/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<table class="form table table-bordered table-striped">
<tbody>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_DeviceHelper($field, $viewDatas) ?></td>
<td class="column">
<?= getFieldView_DeviceHelper($field, $viewDatas['entity'], $viewDatas) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?= $this->endSection() ?>

View File

@ -3,6 +3,9 @@
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-heading-Shoppingmall" aria-expanded="false" aria-controls="flush-heading-Shoppingmall"><b>상점관리</b></button> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-heading-Shoppingmall" aria-expanded="false" aria-controls="flush-heading-Shoppingmall"><b>상점관리</b></button>
</h2> </h2>
<div id="flush-heading-Shoppingmall" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-heading-Shoppingmall"> <div id="flush-heading-Shoppingmall" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-heading-Shoppingmall">
<div class="accordion-item">
<h2><a href="/admin/device"><?= CLASS_ICONS['DEVICE'] ?>장비 관리</a></h2>
</div>
<div class="accordion-item"> <div class="accordion-item">
<h2><a href="/admin/product"><?= CLASS_ICONS['PRODUCT'] ?>상품 관리</a></h2> <h2><a href="/admin/product"><?= CLASS_ICONS['PRODUCT'] ?>상품 관리</a></h2>
</div> </div>