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 = [])
|
||||
{
|
||||
$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)) {
|
||||
foreach ($this->getProductDeviceModel()->getEntitys(
|
||||
['product_uid' => $cellDatas['entity']->getPrimaryKey()]
|
||||
) as $productDevieceEntity) {
|
||||
$cellDatas['defaults'][] = $productDevieceEntity->device_uid;
|
||||
$cellDatas['selecteds'][$cellDatas['deviceEntitys'][$productDevieceEntity->device_uid]->getCategory()][$productDevieceEntity->getPrimaryKey()] = $productDevieceEntity;
|
||||
}
|
||||
}
|
||||
$cellDatas['device'] = [];
|
||||
$cellDatas['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'];
|
||||
$cellDatas['device']['options'] = $this->getDeviceModel()->getOptions();
|
||||
//dd($cellDatas);
|
||||
return view(
|
||||
@ -42,10 +49,9 @@ class ProductCell extends BaseCell
|
||||
|
||||
public function device_calulator(array $cellDatas = []): string
|
||||
{
|
||||
$cellDatas['categorys'] = DEVICE['CATEGORYS'];
|
||||
$cellDatas['device'] = [];
|
||||
$cellDatas['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'];
|
||||
$cellDatas['device']['options'] = $this->getDeviceModel()->getOptions();
|
||||
|
||||
return view(
|
||||
'Views/cells/product/' . __FUNCTION__,
|
||||
['cellDatas' => $cellDatas]
|
||||
|
||||
@ -171,8 +171,6 @@ define('SESSION_NAMES', [
|
||||
'CART' => 'cart'
|
||||
]);
|
||||
define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']);
|
||||
//월이용권 상품의 Category번호
|
||||
define('RENTAL_PRODUCT_CATEGORYS', [5, 8]);
|
||||
//인증 관련
|
||||
define('AUTH_ADAPTERS', [
|
||||
'Local' => [
|
||||
@ -314,3 +312,8 @@ define('API', [
|
||||
'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",
|
||||
]);
|
||||
|
||||
//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) {
|
||||
$this->getProductDeviceModel()->delete($productDeviceEntity->getPrimaryKey());
|
||||
}
|
||||
//상품관련 tw_product_device 기존정보 생성처리
|
||||
foreach (['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'] as $field) {
|
||||
//상품관련 tw_product_device 생성처리
|
||||
foreach (DEVICE['CATEGORYS'] as $field) {
|
||||
$device_uids = $this->request->getPost($field) ?: [];
|
||||
// dd($device_uids);
|
||||
$productDeviceEntitys = [];
|
||||
foreach ($device_uids as $device_uid) {
|
||||
$formDatas = ['product_uid' => $entity->getPrimaryKey()];
|
||||
$formDatas['device_uid'] = $device_uid;
|
||||
$formDatas['device_cnt'] = $this->request->getPost($field . "_cnt") ?: 1;
|
||||
if ($formDatas['product_uid'] && $formDatas['device_uid']) {
|
||||
$this->getProductDeviceModel()->create($formDatas);
|
||||
}
|
||||
$productDeviceEntitys[] = $this->getProductDeviceModel()->create($formDatas);
|
||||
}
|
||||
//dd($productDeviceEntitys);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -153,7 +153,6 @@ CREATE TABLE vhost.tw_product_device (
|
||||
uid int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
product_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,
|
||||
created_at timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
deleted_at timestamp NULL DEFAULT NULL,
|
||||
|
||||
@ -16,11 +16,11 @@ abstract class BaseHierarchyModel extends BaseModel
|
||||
abstract public function getContentField();
|
||||
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("grporder ASC");
|
||||
return parent::getEntitys($conditions, $entitys);
|
||||
return parent::getEntitys($conditions);
|
||||
}
|
||||
public function getSiblingEntitys($entity)
|
||||
{
|
||||
|
||||
@ -266,10 +266,10 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
$entity = $this->save_process($entity);
|
||||
//primaryKey가 자동입력이면
|
||||
if ($this->useAutoIncrement) {
|
||||
$pk = $this->primaryKey;
|
||||
$entity->$pk = $this->insertID();
|
||||
}
|
||||
// if ($this->useAutoIncrement) {
|
||||
// $pk = $this->primaryKey;
|
||||
// $entity->$pk = $this->insertID();
|
||||
// }
|
||||
return $entity;
|
||||
}
|
||||
final protected function modify_process($entity, array $formDatas)
|
||||
|
||||
@ -69,11 +69,11 @@ class DeviceModel extends BaseModel
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getEntitys(array $conditions = array(), $entitys = array()): array
|
||||
public function getEntitys(array $conditions = array()): array
|
||||
{
|
||||
$this->orderBy("category ASC");
|
||||
$this->orderBY("price DESC");
|
||||
return parent::getEntitys($conditions, $entitys);
|
||||
return parent::getEntitys($conditions);
|
||||
}
|
||||
public function create(array $formDatas): DeviceEntity
|
||||
{
|
||||
|
||||
@ -12,7 +12,7 @@ class ProductDeviceModel extends BaseModel
|
||||
{
|
||||
parent::__construct('ProductDevice');
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields, "product_uid", "device_uid", "device_cnt"
|
||||
...$this->allowedFields, "product_uid", "device_uid",
|
||||
];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
@ -27,9 +27,6 @@ class ProductDeviceModel extends BaseModel
|
||||
case "device_uid":
|
||||
$rules[$field] = $this->getUUIDFieldRule('required');
|
||||
break;
|
||||
case 'device_cnt':
|
||||
$rules[$field] = "required|numeric";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
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;">
|
||||
<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>
|
||||
<?php endforeach ?>
|
||||
</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>
|
||||
<?= form_dropdown(
|
||||
$category . '[]',
|
||||
$cellDatas['device']['options'][$category],
|
||||
$cellDatas['defaults'],
|
||||
[
|
||||
'id' => $category,
|
||||
'size' => "6",
|
||||
'class' => 'vhost_cellDatas'
|
||||
]
|
||||
) ?>
|
||||
<?php foreach ($cellDatas['device']['options'][$category] as $key => $label) : ?>
|
||||
<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 ?>')">
|
||||
<?= $label ?>
|
||||
</button>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user