vhost init...4
This commit is contained in:
parent
f9bb28c62c
commit
3a8ed66c16
@ -22,16 +22,23 @@ class ProductCell extends BaseCell
|
|||||||
|
|
||||||
public function device(array $cellDatas = [])
|
public function device(array $cellDatas = [])
|
||||||
{
|
{
|
||||||
$cellDatas['defaults'] = [];
|
$cellDatas['deviceEntitys'] = [];
|
||||||
|
foreach ($this->getDeviceModel()->getEntitys() as $deviceEntity) {
|
||||||
|
$cellDatas['deviceEntitys'][$deviceEntity->getPrimaryKey()] = $deviceEntity;
|
||||||
|
}
|
||||||
|
$cellDatas['categorys'] = DEVICE['CATEGORYS'];
|
||||||
|
$cellDatas['selecteds'] = [];
|
||||||
|
foreach ($cellDatas['categorys'] as $category) {
|
||||||
|
$cellDatas['selecteds'][$category] = [];
|
||||||
|
}
|
||||||
if (array_key_exists('entity', $cellDatas)) {
|
if (array_key_exists('entity', $cellDatas)) {
|
||||||
foreach ($this->getProductDeviceModel()->getEntitys(
|
foreach ($this->getProductDeviceModel()->getEntitys(
|
||||||
['product_uid' => $cellDatas['entity']->getPrimaryKey()]
|
['product_uid' => $cellDatas['entity']->getPrimaryKey()]
|
||||||
) as $productDevieceEntity) {
|
) as $productDevieceEntity) {
|
||||||
$cellDatas['defaults'][] = $productDevieceEntity->device_uid;
|
$cellDatas['selecteds'][$cellDatas['deviceEntitys'][$productDevieceEntity->device_uid]->getCategory()][$productDevieceEntity->getPrimaryKey()] = $productDevieceEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$cellDatas['device'] = [];
|
$cellDatas['device'] = [];
|
||||||
$cellDatas['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'];
|
|
||||||
$cellDatas['device']['options'] = $this->getDeviceModel()->getOptions();
|
$cellDatas['device']['options'] = $this->getDeviceModel()->getOptions();
|
||||||
//dd($cellDatas);
|
//dd($cellDatas);
|
||||||
return view(
|
return view(
|
||||||
@ -42,10 +49,9 @@ class ProductCell extends BaseCell
|
|||||||
|
|
||||||
public function device_calulator(array $cellDatas = []): string
|
public function device_calulator(array $cellDatas = []): string
|
||||||
{
|
{
|
||||||
|
$cellDatas['categorys'] = DEVICE['CATEGORYS'];
|
||||||
$cellDatas['device'] = [];
|
$cellDatas['device'] = [];
|
||||||
$cellDatas['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'];
|
|
||||||
$cellDatas['device']['options'] = $this->getDeviceModel()->getOptions();
|
$cellDatas['device']['options'] = $this->getDeviceModel()->getOptions();
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'Views/cells/product/' . __FUNCTION__,
|
'Views/cells/product/' . __FUNCTION__,
|
||||||
['cellDatas' => $cellDatas]
|
['cellDatas' => $cellDatas]
|
||||||
|
|||||||
@ -171,8 +171,6 @@ define('SESSION_NAMES', [
|
|||||||
'CART' => 'cart'
|
'CART' => 'cart'
|
||||||
]);
|
]);
|
||||||
define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']);
|
define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']);
|
||||||
//월이용권 상품의 Category번호
|
|
||||||
define('RENTAL_PRODUCT_CATEGORYS', [5, 8]);
|
|
||||||
//인증 관련
|
//인증 관련
|
||||||
define('AUTH_ADAPTERS', [
|
define('AUTH_ADAPTERS', [
|
||||||
'Local' => [
|
'Local' => [
|
||||||
@ -314,3 +312,8 @@ define('API', [
|
|||||||
'COOKIE_FILE' => PATHS['API'] . getenv('api.cookie.file') ?: "api-cookie_" . date("Ymd") . ".log",
|
'COOKIE_FILE' => PATHS['API'] . getenv('api.cookie.file') ?: "api-cookie_" . date("Ymd") . ".log",
|
||||||
'DEBUG_FILE' => PATHS['API'] . getenv('api.debug.file') ?: "api-debug_" . date("Ymd") . ".log",
|
'DEBUG_FILE' => PATHS['API'] . getenv('api.debug.file') ?: "api-debug_" . date("Ymd") . ".log",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
//Device Categorys
|
||||||
|
define('DEVICE', [
|
||||||
|
'CATEGORYS' => getenv('device.categorys') ?: ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'],
|
||||||
|
]);
|
||||||
|
|||||||
@ -144,18 +144,16 @@ class ProductController extends AdminController
|
|||||||
foreach ($productDeviceEntitys as $productDeviceEntity) {
|
foreach ($productDeviceEntitys as $productDeviceEntity) {
|
||||||
$this->getProductDeviceModel()->delete($productDeviceEntity->getPrimaryKey());
|
$this->getProductDeviceModel()->delete($productDeviceEntity->getPrimaryKey());
|
||||||
}
|
}
|
||||||
//상품관련 tw_product_device 기존정보 생성처리
|
//상품관련 tw_product_device 생성처리
|
||||||
foreach (['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'] as $field) {
|
foreach (DEVICE['CATEGORYS'] as $field) {
|
||||||
$device_uids = $this->request->getPost($field) ?: [];
|
$device_uids = $this->request->getPost($field) ?: [];
|
||||||
// dd($device_uids);
|
$productDeviceEntitys = [];
|
||||||
foreach ($device_uids as $device_uid) {
|
foreach ($device_uids as $device_uid) {
|
||||||
$formDatas = ['product_uid' => $entity->getPrimaryKey()];
|
$formDatas = ['product_uid' => $entity->getPrimaryKey()];
|
||||||
$formDatas['device_uid'] = $device_uid;
|
$formDatas['device_uid'] = $device_uid;
|
||||||
$formDatas['device_cnt'] = $this->request->getPost($field . "_cnt") ?: 1;
|
$productDeviceEntitys[] = $this->getProductDeviceModel()->create($formDatas);
|
||||||
if ($formDatas['product_uid'] && $formDatas['device_uid']) {
|
|
||||||
$this->getProductDeviceModel()->create($formDatas);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//dd($productDeviceEntitys);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -153,7 +153,6 @@ CREATE TABLE vhost.tw_product_device (
|
|||||||
uid int(10) unsigned NOT NULL AUTO_INCREMENT,
|
uid int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
product_uid varchar(36) NOT NULL COMMENT '상품 정보',
|
product_uid varchar(36) NOT NULL COMMENT '상품 정보',
|
||||||
device_uid varchar(36) NOT NULL COMMENT '장비 정보',
|
device_uid varchar(36) NOT NULL COMMENT '장비 정보',
|
||||||
device_cnt int(3) unsigned NOT NULL DEFAULT 1 COMMENT '장비 갯수',
|
|
||||||
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,
|
||||||
|
|||||||
@ -16,11 +16,11 @@ abstract class BaseHierarchyModel extends BaseModel
|
|||||||
abstract public function getContentField();
|
abstract public function getContentField();
|
||||||
abstract public function reply($parent_entity, array $formDatas): BaseEntity;
|
abstract public function reply($parent_entity, array $formDatas): BaseEntity;
|
||||||
|
|
||||||
public function getEntitys(array $conditions = [], array $entitys = []): array
|
public function getEntitys(array $conditions = []): array
|
||||||
{
|
{
|
||||||
$this->orderBy("grpno DESC");
|
$this->orderBy("grpno DESC");
|
||||||
$this->orderBY("grporder ASC");
|
$this->orderBY("grporder ASC");
|
||||||
return parent::getEntitys($conditions, $entitys);
|
return parent::getEntitys($conditions);
|
||||||
}
|
}
|
||||||
public function getSiblingEntitys($entity)
|
public function getSiblingEntitys($entity)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -266,10 +266,10 @@ abstract class BaseModel extends Model
|
|||||||
}
|
}
|
||||||
$entity = $this->save_process($entity);
|
$entity = $this->save_process($entity);
|
||||||
//primaryKey가 자동입력이면
|
//primaryKey가 자동입력이면
|
||||||
if ($this->useAutoIncrement) {
|
// if ($this->useAutoIncrement) {
|
||||||
$pk = $this->primaryKey;
|
// $pk = $this->primaryKey;
|
||||||
$entity->$pk = $this->insertID();
|
// $entity->$pk = $this->insertID();
|
||||||
}
|
// }
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
final protected function modify_process($entity, array $formDatas)
|
final protected function modify_process($entity, array $formDatas)
|
||||||
|
|||||||
@ -69,11 +69,11 @@ class DeviceModel extends BaseModel
|
|||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEntitys(array $conditions = array(), $entitys = array()): array
|
public function getEntitys(array $conditions = array()): array
|
||||||
{
|
{
|
||||||
$this->orderBy("category ASC");
|
$this->orderBy("category ASC");
|
||||||
$this->orderBY("price DESC");
|
$this->orderBY("price DESC");
|
||||||
return parent::getEntitys($conditions, $entitys);
|
return parent::getEntitys($conditions);
|
||||||
}
|
}
|
||||||
public function create(array $formDatas): DeviceEntity
|
public function create(array $formDatas): DeviceEntity
|
||||||
{
|
{
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class ProductDeviceModel extends BaseModel
|
|||||||
{
|
{
|
||||||
parent::__construct('ProductDevice');
|
parent::__construct('ProductDevice');
|
||||||
$this->allowedFields = [
|
$this->allowedFields = [
|
||||||
...$this->allowedFields, "product_uid", "device_uid", "device_cnt"
|
...$this->allowedFields, "product_uid", "device_uid",
|
||||||
];
|
];
|
||||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||||
}
|
}
|
||||||
@ -27,9 +27,6 @@ class ProductDeviceModel extends BaseModel
|
|||||||
case "device_uid":
|
case "device_uid":
|
||||||
$rules[$field] = $this->getUUIDFieldRule('required');
|
$rules[$field] = $this->getUUIDFieldRule('required');
|
||||||
break;
|
break;
|
||||||
case 'device_cnt':
|
|
||||||
$rules[$field] = "required|numeric";
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$rules = parent::getFieldRule($field, $rules, $action);
|
$rules = parent::getFieldRule($field, $rules, $action);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,22 +1,42 @@
|
|||||||
|
<script>
|
||||||
|
function addDevice(category, key, label) {
|
||||||
|
var categoryBox = document.getElementById(category + "Box");
|
||||||
|
var div = document.createElement("div");
|
||||||
|
var checkbox = document.createElement("input");
|
||||||
|
checkbox.setAttribute("type", "checkbox");
|
||||||
|
checkbox.setAttribute("name", category + '[]');
|
||||||
|
checkbox.setAttribute("value", key);
|
||||||
|
checkbox.setAttribute("checked", true);
|
||||||
|
checkbox.setAttribute("class", 'device');
|
||||||
|
div.appendChild(checkbox);
|
||||||
|
div.appendChild(document.createTextNode(label));
|
||||||
|
// console.log(div);
|
||||||
|
categoryBox.appendChild(div);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<table class="table table-bordered" style="width: auto;">
|
<table class="table table-bordered" style="width: auto;">
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ($cellDatas['device']['categorys'] as $category) : ?>
|
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
||||||
<th style="background-color:silver; text-align:center;"><?= lang('Device.CATEGORY.' . $category) . " 선택" ?></th>
|
<th style="background-color:silver; text-align:center;"><?= lang('Device.CATEGORY.' . $category) . " 선택" ?></th>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ($cellDatas['device']['categorys'] as $category) : ?>
|
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
||||||
|
<td id="<?= $category ?>Box">
|
||||||
|
<?php foreach ($cellDatas['selecteds'][$category] as $key => $productDevieceEntity) : ?>
|
||||||
|
<div><input type="checkbox" id="<?= $key ?>" name="<?= $category ?>[]" value="<?= $productDevieceEntity->device_uid ?>" checked class="device"><?= $cellDatas['deviceEntitys'][$productDevieceEntity->device_uid]->getTitle() ?></div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</td>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
||||||
<td>
|
<td>
|
||||||
<?= form_dropdown(
|
<?php foreach ($cellDatas['device']['options'][$category] as $key => $label) : ?>
|
||||||
$category . '[]',
|
<button type="button" class="device btn btn-light" data-bs-toggle="tooltip" data-bs-placement="bottom" title="<?= number_format($cellDatas['deviceEntitys'][$key]->getPrice()) ?>원" onClick="addDevice('<?= $category ?>','<?= $key ?>','<?= $label ?>')">
|
||||||
$cellDatas['device']['options'][$category],
|
<?= $label ?>
|
||||||
$cellDatas['defaults'],
|
</button>
|
||||||
[
|
<?php endforeach ?>
|
||||||
'id' => $category,
|
|
||||||
'size' => "6",
|
|
||||||
'class' => 'vhost_cellDatas'
|
|
||||||
]
|
|
||||||
) ?>
|
|
||||||
</td>
|
</td>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user