dbmsv2 init...1
This commit is contained in:
parent
8bd5a50748
commit
abdc53a693
@ -367,7 +367,7 @@ define('SERVICE_NEW_INTERVAL', $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVIC
|
||||
|
||||
//서버 PartType
|
||||
define("SERVER", [
|
||||
"PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS']
|
||||
"PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'SOFTWARE'],
|
||||
]);
|
||||
|
||||
//결제관련
|
||||
|
||||
@ -20,9 +20,7 @@ class ServerController extends EquipmentController
|
||||
$this->class_path .= $this->getService()->getClassName();
|
||||
$this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/';
|
||||
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
|
||||
|
||||
$this->serverinfopartinfo_cnt_range = array_combine(range(0, 10), range(0, 10));
|
||||
$this->serverinfopartinfo_extra_options = array_merge(["" => "RAID 선택"], lang("{$this->getService()->getClassName()}.EXTRAS"));
|
||||
$this->serverinfopartinfo_cnt_options = array_combine(range(1, 10), range(1, 10));
|
||||
}
|
||||
public function getService(): ServerService
|
||||
{
|
||||
|
||||
@ -14,21 +14,17 @@ class ServerPartEntity extends EquipmentEntity
|
||||
{
|
||||
$this->attributes['partEntity'] = $entity;
|
||||
}
|
||||
public function getPartEntity(): PartEntity
|
||||
public function getPartEntity(): PartEntity|null
|
||||
{
|
||||
return $this->attributes['partEntity'];
|
||||
}
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->getPartEntity()->getType() ?? "";
|
||||
return $this->attributes['partEntity'] ?? null;
|
||||
}
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->getPartEntity()->getTitle() ?? "";
|
||||
return $this->getPartEntity() === null ? "" : $this->getPartEntity()->getTitle();
|
||||
}
|
||||
public function getPrice(): int
|
||||
{
|
||||
return $this->getPartEntity()->getPrice() ?? 0;
|
||||
return $this->getPartEntity() === null ? 0 : $this->getPartEntity()->getPrice();
|
||||
}
|
||||
//기본기능용
|
||||
public function getPartInfoUID(): int
|
||||
@ -43,6 +39,10 @@ class ServerPartEntity extends EquipmentEntity
|
||||
{
|
||||
return $this->attributes['serviceinfo_uid'] ?? null;
|
||||
}
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->attributes['type'];
|
||||
}
|
||||
public function getBilling(): string
|
||||
{
|
||||
return $this->attributes['billing'];
|
||||
|
||||
@ -11,15 +11,17 @@ class ServerHelper extends EquipmentHelper
|
||||
parent::__construct();
|
||||
$this->setTitleField(field: ServerModel::TITLE);
|
||||
}
|
||||
private function getServerPartForm(string $field, mixed $value, array $viewDatas, array $extras, string $type): string
|
||||
private function getServerPartForm(string $field, mixed $value, array $viewDatas, array $extras, string $partType): string
|
||||
{
|
||||
//Type별로 부품연결정보가 있는지 확인
|
||||
$serverpartEntity = null;
|
||||
if (array_key_exists('entity', $viewDatas)) {
|
||||
$serverpartEntity = $viewDatas['entity']->getServerPartEntity($type);
|
||||
$serverpartEntity = $viewDatas['entity']->getServerPartEntity($partType);
|
||||
}
|
||||
$form = "";
|
||||
if ($serverpartEntity !== null) { //수정시 사용할 hidden uid
|
||||
$form = form_hidden("serverinfopartinfo_uid_{$type}", $serverpartEntity->getPK());
|
||||
//수정시 Type별 사용할 hidden serverinfopartinfo_uid
|
||||
if ($serverpartEntity !== null) {
|
||||
$form .= form_hidden("serverinfopartinfo_uid_{$partType}", $serverpartEntity->getPK());
|
||||
}
|
||||
//기존 입력화면에서 return 된것인지?
|
||||
if ($value === null && $serverpartEntity !== null) {
|
||||
@ -31,6 +33,10 @@ class ServerHelper extends EquipmentHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'code':
|
||||
// $extras['readonly'] = in_array($viewDatas['control']['action'], ['modify_form']) ? ' readonly' : '';
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
case 'manufactur_at':
|
||||
case 'format_at':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
|
||||
@ -39,21 +45,42 @@ class ServerHelper extends EquipmentHelper
|
||||
case 'partinfo_uid_CPU':
|
||||
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'CPU');
|
||||
break;
|
||||
case 'serverinfopartinfo_uid_CPU_cnt':
|
||||
$form = form_dropdown($field, $viewDatas['serverinfopartinfo_cnt_options'], $value, $extras) . "개";
|
||||
break;
|
||||
case 'partinfo_uid_RAM':
|
||||
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'RAM',);
|
||||
break;
|
||||
case 'serverinfopartinfo_uid_RAM_cnt':
|
||||
$form = form_dropdown($field, $viewDatas['serverinfopartinfo_cnt_options'], $value, $extras) . "개";
|
||||
break;
|
||||
case 'partinfo_uid_DISK':
|
||||
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'DISK');
|
||||
break;
|
||||
case 'serverinfopartinfo_uid_DISK_cnt':
|
||||
$form = form_dropdown($field, $viewDatas['serverinfopartinfo_cnt_options'], $value, $extras) . "개";
|
||||
break;
|
||||
case 'serverinfopartinfo_uid_DISK_extra':
|
||||
$form = $this->form_dropdown_custom($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
case 'partinfo_uid_OS':
|
||||
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'OS');
|
||||
break;
|
||||
case 'serverinfopartinfo_uid_OS_cnt':
|
||||
$form = form_dropdown($field, $viewDatas['serverinfopartinfo_cnt_options'], $value, $extras) . "개";
|
||||
break;
|
||||
case 'partinfo_uid_DB':
|
||||
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'DB');
|
||||
break;
|
||||
case 'serverinfopartinfo_uid_DB_cnt':
|
||||
$form = form_dropdown($field, $viewDatas['serverinfopartinfo_cnt_options'], $value, $extras) . "개";
|
||||
break;
|
||||
case 'partinfo_uid_SOFTWARE':
|
||||
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'SOFTWARE');
|
||||
break;
|
||||
case 'serverinfopartinfo_uid_SOFTWARE_cnt':
|
||||
$form = form_dropdown($field, $viewDatas['serverinfopartinfo_cnt_options'], $value, $extras) . "개";
|
||||
break;
|
||||
case 'ipinfo_uid':
|
||||
case 'csinfo_uid':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||
@ -65,6 +92,19 @@ class ServerHelper extends EquipmentHelper
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
private function getServerPartView(string $field, mixed $value, array $viewDatas, array $extras, string $partType): string
|
||||
{
|
||||
$serverPartEntity = $viewDatas['entity']->getServerPartEntity($partType);
|
||||
if ($serverPartEntity !== null) {
|
||||
$value .= sprintf(
|
||||
"<div>%s%s %s</div>",
|
||||
$serverPartEntity->getTitle(),
|
||||
$serverPartEntity->getCnt() >= 1 ? "*" . $serverPartEntity->getCnt() . "개" : "",
|
||||
$serverPartEntity->getExtra() ?? ""
|
||||
);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||
{
|
||||
switch ($field) {
|
||||
@ -72,18 +112,13 @@ class ServerHelper extends EquipmentHelper
|
||||
case 'format_at':
|
||||
$value = $value ? date("Y-m-d", strtotime($value)) : "";
|
||||
break;
|
||||
case 'serverpartinfo':
|
||||
$value = "";
|
||||
foreach (SERVER['PARTTYPES'] as $partType) {
|
||||
$serverPartEntity = $viewDatas['entity']->getServerPartEntity($partType);
|
||||
$value .= sprintf(
|
||||
"<div>%s : %s%s %s</div>",
|
||||
$serverPartEntity->getType(),
|
||||
$serverPartEntity->getTitle(),
|
||||
$serverPartEntity->getCnt() > 1 ? "*" . $serverPartEntity->getCnt() . "개" : "",
|
||||
$serverPartEntity->getExtra() ?? ""
|
||||
);
|
||||
}
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
case 'OS':
|
||||
case 'DB':
|
||||
case 'SOFTWARE':
|
||||
$value = $this->getServerPartView($field, $value, $viewDatas, $extras, $field);
|
||||
break;
|
||||
case 'ipinfo_uid':
|
||||
$value = "";
|
||||
|
||||
@ -19,11 +19,18 @@ return [
|
||||
"ipinfo_uid" => "IP정보",
|
||||
"csinfo_uid" => "CS정보",
|
||||
'partinfo_uid_CPU' => "CPU",
|
||||
'serverinfopartinfo_uid_CPU_cnt' => "CPU갯수",
|
||||
'partinfo_uid_RAM' => "RAM",
|
||||
'serverinfopartinfo_uid_RAM_cnt' => "RAM갯수",
|
||||
'partinfo_uid_DISK' => "DISK",
|
||||
'serverinfopartinfo_uid_DISK_cnt' => "DISK갯수",
|
||||
'serverinfopartinfo_uid_DISK_extra' => "RAID설정",
|
||||
'partinfo_uid_OS' => "OS",
|
||||
'serverinfopartinfo_uid_OS_cnt' => "OS갯수",
|
||||
'partinfo_uid_DB' => "DB",
|
||||
'serverinfopartinfo_uid_DB_cnt' => "DB갯수",
|
||||
'partinfo_uid_SOFTWARE' => "기타SW",
|
||||
'serverinfopartinfo_uid_SOFTWARE_cnt' => "SOFTWARE갯수",
|
||||
],
|
||||
"TITLE" => [
|
||||
'HP DL360 Gen6' => "HP DL360 Gen6",
|
||||
@ -43,7 +50,7 @@ return [
|
||||
'occupied' => "서비스중",
|
||||
'forbidden' => "사용불가",
|
||||
],
|
||||
"EXTRAS" => [
|
||||
"SERVERINFOPARTINFO_UID_DISK_EXTRA" => [
|
||||
'RAID0' => "RAID0",
|
||||
'RAID1' => "RAID1",
|
||||
'RAID5' => "RAID5",
|
||||
|
||||
@ -44,7 +44,6 @@ abstract class CommonModel extends Model
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
protected $isDebug = false;
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -149,7 +148,7 @@ abstract class CommonModel extends Model
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
public function create(array $formDatas, bool $isDebug = false): mixed
|
||||
public function create(array $formDatas): mixed
|
||||
{
|
||||
// LogCollector::debug("입력내용");
|
||||
// LogCollector::debug(var_export($formDatas, true));
|
||||
@ -164,9 +163,6 @@ abstract class CommonModel extends Model
|
||||
$convertedFormDatas[$field] = $value;
|
||||
}
|
||||
}
|
||||
if ($this->isDebug) {
|
||||
dd($convertedFormDatas);
|
||||
}
|
||||
// 최종 저장 시 오류 발생하면
|
||||
if (!$this->save($convertedFormDatas)) {
|
||||
$message = sprintf(
|
||||
@ -188,9 +184,14 @@ abstract class CommonModel extends Model
|
||||
$pkField = $this->getPKField();
|
||||
$entity->$pkField = $this->getInsertID();
|
||||
}
|
||||
$debug = sprintf("debug.%s.%s", str_replace("\\", ".", get_class($this)), __FUNCTION__);
|
||||
if (env($debug, false)) {
|
||||
echo var_dump($formDatas);
|
||||
dd($entity->toArray());
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
public function modify(mixed $entity, array $formDatas, bool $isDebug = false): mixed
|
||||
public function modify(mixed $entity, array $formDatas): mixed
|
||||
{
|
||||
// 저장하기 전에 데이터 값 변경이 필요한 Field
|
||||
// LogCollector::debug("[{$entity->getPK()}/{$entity->getTitle()}] 변경 전 내용");
|
||||
@ -207,9 +208,6 @@ abstract class CommonModel extends Model
|
||||
$entity->$field = $value;
|
||||
}
|
||||
}
|
||||
if ($this->isDebug) {
|
||||
dd($entity);
|
||||
}
|
||||
//수정일추가
|
||||
$entity->setUpdatedAt(date("Y-m-d H:i:s"));
|
||||
// 최종 저장 시 오류 발생하면
|
||||
@ -222,6 +220,11 @@ abstract class CommonModel extends Model
|
||||
LogCollector::debug($message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
$debug = sprintf("debug.%s.%s", str_replace("\\", ".", get_class($this)), __FUNCTION__);
|
||||
if (env($debug, false)) {
|
||||
echo var_dump($formDatas);
|
||||
dd($entity->toArray());
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,6 @@ abstract class CommonService
|
||||
private $_model = null;
|
||||
private $_classNames = [];
|
||||
private $_serviceDatas = [];
|
||||
protected $isDebug = false;
|
||||
protected function __construct(Model $model)
|
||||
{
|
||||
$this->_model = $model;
|
||||
@ -50,14 +49,15 @@ abstract class CommonService
|
||||
try {
|
||||
$entity = is_array($where) ? $this->getModel()->where($where)->first() : $this->getModel()->find($where);
|
||||
if (!$entity) {
|
||||
throw new \Exception($message ?? __METHOD__ . "에서 해당 정보가 존재하지 않습니다");
|
||||
return null;
|
||||
}
|
||||
return $this->getEntity_process($entity);
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf(
|
||||
"\n------%s SQL오류-----\n%s\n------------------------------\n",
|
||||
"\n------%s SQL오류-----<BR>\n%s<BR>\n%s<BR>\n------------------------------\n",
|
||||
__FUNCTION__,
|
||||
$this->getModel()->getLastQuery()
|
||||
$this->getModel()->getLastQuery(),
|
||||
$e->getMessage()
|
||||
);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
@ -65,17 +65,13 @@ abstract class CommonService
|
||||
final public function getEntities(mixed $where = null, array $columns = ['*']): array
|
||||
{
|
||||
try {
|
||||
$entities = $this->getEntities_process($where, $columns);
|
||||
$debug = sprintf("debug.%s.%s", $this->getClassName(), __FUNCTION__);
|
||||
if (env($debug, false)) {
|
||||
echo $debug . "=>" . $this->getModel()->getLastQuery() . "<BR>";
|
||||
}
|
||||
return $entities;
|
||||
return $this->getEntities_process($where, $columns);
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf(
|
||||
"\n------%s SQL오류-----\n%s\n------------------------------\n",
|
||||
"\n------%s SQL오류-----<BR>\n%s<BR>\n%s<BR>\n------------------------------\n",
|
||||
__FUNCTION__,
|
||||
$this->getModel()->getLastQuery()
|
||||
$this->getModel()->getLastQuery(),
|
||||
$e->getMessage()
|
||||
);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
@ -83,18 +79,23 @@ abstract class CommonService
|
||||
//삭제
|
||||
final public function delete(mixed $entity): mixed
|
||||
{
|
||||
$result = $this->getModel()->delete($entity->getPK());
|
||||
if (!$result) {
|
||||
try {
|
||||
$message = "[{$entity->getTitle()}]" . MESSAGES["DELETED"] . ":";
|
||||
$result = $this->getModel()->delete($entity->getPK());
|
||||
if (!$result) {
|
||||
throw new \Exception($message);
|
||||
}
|
||||
LogCollector::info($message);
|
||||
return $entity;
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf(
|
||||
"\n------%s SQL오류-----\n%s\n------------------------------\n",
|
||||
"\n------%s SQL오류-----<BR>\n%s<BR>\n%s<BR>\n------------------------------\n",
|
||||
__FUNCTION__,
|
||||
$this->getModel()->getLastQuery()
|
||||
$this->getModel()->getLastQuery(),
|
||||
$e->getMessage()
|
||||
);
|
||||
LogCollector::error($message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["DELETED"] . ":");
|
||||
return $entity;
|
||||
}
|
||||
//Index용
|
||||
final public function getTotalCount(): int
|
||||
@ -148,6 +149,10 @@ abstract class CommonService
|
||||
foreach ($this->getModel()->select(implode(',', $columns))->findAll() as $entity) {
|
||||
$entities[$entity->getPK()] = $this->getEntity_process($entity);
|
||||
}
|
||||
$debug = sprintf("debug.%s.%s", str_replace("\\", ".", get_class($this)), __FUNCTION__);
|
||||
if (env($debug, false)) {
|
||||
echo $debug . "=>" . $this->getModel()->getLastQuery() . "<BR>";
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
//FieldForm관련용
|
||||
@ -197,28 +202,14 @@ abstract class CommonService
|
||||
//생성
|
||||
public function create(array $formDatas): mixed
|
||||
{
|
||||
if ($this->isDebug) {
|
||||
echo $this->getClassName() . "=>" . __METHOD__;
|
||||
echo var_dump($formDatas);
|
||||
}
|
||||
$entity = $this->getModel()->create($formDatas);
|
||||
if ($this->isDebug) {
|
||||
dd($entity);
|
||||
}
|
||||
LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["CREATED"] . ":");
|
||||
return $entity;
|
||||
}
|
||||
//수정
|
||||
public function modify(mixed $entity, array $formDatas): mixed
|
||||
{
|
||||
if ($this->isDebug) {
|
||||
echo $this->getClassName() . "=>" . __METHOD__;
|
||||
echo var_dump($formDatas);
|
||||
}
|
||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
||||
if ($this->isDebug) {
|
||||
dd($entity);
|
||||
}
|
||||
LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["UPDATED"] . ":");
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ class ServerPartService extends EquipmentService
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new ServerPartModel());
|
||||
$this->addClassName('Server');
|
||||
$this->addClassName('ServerPart');
|
||||
}
|
||||
public function getFormFields(): array
|
||||
{
|
||||
@ -54,7 +54,11 @@ class ServerPartService extends EquipmentService
|
||||
//partEntity 정보 추가
|
||||
protected function getEntity_process(mixed $entity): ServerPartEntity
|
||||
{
|
||||
$entity->setPartEntity($this->getPartService()->getEntity($entity->getPartInfoUID()));
|
||||
//부품정보 정의
|
||||
$partEntity = $this->getPartService()->getEntity($entity->getPartInfoUID());
|
||||
if ($entity) {
|
||||
$entity->setPartEntity($partEntity);
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//기본 기능부분
|
||||
@ -90,33 +94,48 @@ class ServerPartService extends EquipmentService
|
||||
return $options;
|
||||
}
|
||||
|
||||
private function getFormDatasByServer(ServerEntity $serverEntity, string $partType, array $formDatas): array
|
||||
//서버별 부품연결정보 생성
|
||||
private function createByServer_process(ServerEntity $serverEntity, string $partType, array $formDatas): ServerPartEntity
|
||||
{
|
||||
$temps = [
|
||||
$serverPartFormDatas = [
|
||||
"partinfo_uid" => $formDatas["partinfo_uid_{$partType}"],
|
||||
"serverinfo_uid" => $serverEntity->getPK(),
|
||||
"serviceinfo_uid" => $serverEntity->getServiceInfoUID(),
|
||||
"type" => $partType,
|
||||
"billing" => $formDatas['billing'] ?? ServerPartENtity::DEFAULT_BILLING,
|
||||
"amount" => $formDatas["amount"] ?? 0,
|
||||
"cnt" => $formDatas["serverinfopartinfo_uid_{$partType}_cnt"] ?? 1,
|
||||
"extra" => $formDatas["serverinfopartinfo_uid_{$partType}_extra"] ?? ""
|
||||
"billing" => array_key_exists("serverinfopartinfo_uid_{$partType}_billing", $formDatas) ? $formDatas["serverinfopartinfo_uid_{$partType}_billing"] : null,
|
||||
"amount" => array_key_exists("serverinfopartinfo_uid_{$partType}_amount", $formDatas) ? $formDatas["serverinfopartinfo_uid_{$partType}_amount"] : 0,
|
||||
"cnt" => array_key_exists("serverinfopartinfo_uid_{$partType}_cnt", $formDatas) ? $formDatas["serverinfopartinfo_uid_{$partType}_cnt"] : null,
|
||||
"extra" => array_key_exists("serverinfopartinfo_uid_{$partType}_extra", $formDatas) ? $formDatas["serverinfopartinfo_uid_{$partType}_extra"] : null
|
||||
];
|
||||
return $temps;
|
||||
$entity = parent::create($serverPartFormDatas);
|
||||
//부품정보 정의
|
||||
$partEntity = $this->getPartService()->getEntity($entity->getPartInfoUID());
|
||||
if ($partEntity) {
|
||||
$entity->setPartEntity($partEntity);
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//생성
|
||||
public function createByServer(ServerEntity $serverEntity, array $formDatas): array
|
||||
{
|
||||
$entities = [];
|
||||
foreach (SERVER['PARTTYPES'] as $partType) {
|
||||
$serverPartFormDatas = $this->getFormDatasByServer(
|
||||
$serverEntity,
|
||||
$partType,
|
||||
$formDatas
|
||||
);
|
||||
$this->isDebug = true;
|
||||
$entities[] = parent::create($serverPartFormDatas);
|
||||
//파트정보 선택했는지 여부에따라 처리
|
||||
if (array_key_exists("partinfo_uid_{$partType}", $formDatas) && $formDatas["partinfo_uid_{$partType}"]) {
|
||||
$entities[] = $this->createByServer_process($serverEntity, $partType, $formDatas);
|
||||
}
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
//수정
|
||||
public function modifyByServer(ServerEntity $serverEntity, array $formDatas): array
|
||||
{
|
||||
//기존 서벼별 부품연결정보 삭제 후
|
||||
$entities = $this->getEntities(['serverinfo_uid' => $serverEntity->getPK()]);
|
||||
foreach ($entities as $entity) {
|
||||
$this->delete($entity);
|
||||
}
|
||||
//서버별 부품연결정보 생성
|
||||
return $this->createByServer($serverEntity, $formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,9 +28,16 @@ class ServerService extends EquipmentService
|
||||
"format_at",
|
||||
"status",
|
||||
"partinfo_uid_CPU",
|
||||
"serverinfopartinfo_uid_CPU_cnt",
|
||||
"partinfo_uid_RAM",
|
||||
"serverinfopartinfo_uid_RAM_cnt",
|
||||
"partinfo_uid_DISK",
|
||||
"serverinfopartinfo_uid_DISK_cnt",
|
||||
"serverinfopartinfo_uid_DISK_extra",
|
||||
"partinfo_uid_OS",
|
||||
"serverinfopartinfo_uid_OS_cnt",
|
||||
"partinfo_uid_SOFTWARE",
|
||||
"serverinfopartinfo_uid_SOFTWARE_cnt",
|
||||
"ipinfo_uid",
|
||||
"csinfo_uid",
|
||||
],
|
||||
@ -42,7 +49,9 @@ class ServerService extends EquipmentService
|
||||
"partinfo_uid_CPU",
|
||||
"partinfo_uid_RAM",
|
||||
"partinfo_uid_DISK",
|
||||
"serverinfopartinfo_uid_DISK_extra",
|
||||
"partinfo_uid_OS",
|
||||
"partinfo_uid_SOFTWARE",
|
||||
"ipinfo_uid",
|
||||
"csinfo_uid",
|
||||
"status"
|
||||
@ -59,9 +68,6 @@ class ServerService extends EquipmentService
|
||||
'title',
|
||||
'price',
|
||||
'amount',
|
||||
"serverpartinfo",
|
||||
"ipinfo_uid",
|
||||
"csinfo_uid",
|
||||
'manufactur_at',
|
||||
"format_at",
|
||||
'status'
|
||||
@ -72,6 +78,7 @@ class ServerService extends EquipmentService
|
||||
'type',
|
||||
"ipinfo_uid",
|
||||
"csinfo_uid",
|
||||
'partinfo_uid_SOFTWARE',
|
||||
'status'
|
||||
],
|
||||
];
|
||||
@ -104,18 +111,18 @@ class ServerService extends EquipmentService
|
||||
//partEntity 정보 추가
|
||||
protected function getEntity_process(mixed $entity): ServerEntity
|
||||
{
|
||||
//서버 부품정보 정의
|
||||
//부품연결정보 정의
|
||||
foreach (SERVER['PARTTYPES'] as $partType) {
|
||||
$serverPartEnty = $this->getServerPartService()->getEntity(['serverinfo_uid' => $entity->getPK(), 'type' => $partType]);
|
||||
if ($serverPartEnty) {
|
||||
$entity->addServerPartEntity($partType, $serverPartEnty);
|
||||
}
|
||||
}
|
||||
//서버 IP정보 정의
|
||||
//IP정보 정의
|
||||
foreach ($this->getIPService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $ipEntity) {
|
||||
$entity->addIPEntity($ipEntity);
|
||||
}
|
||||
//서버 CS정보 정의
|
||||
//CS정보 정의
|
||||
foreach ($this->getCSService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $csEntity) {
|
||||
$entity->addCSEntity($csEntity);
|
||||
}
|
||||
@ -183,19 +190,15 @@ class ServerService extends EquipmentService
|
||||
foreach ($this->getServerPartService()->createByServer($entity, $formDatas) as $serverPartEntity) {
|
||||
$entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity);
|
||||
};
|
||||
//IP정보 생성
|
||||
$entity->addIPEntity($this->getIPService()->createByServer($entity, $formDatas));
|
||||
return $entity;
|
||||
}
|
||||
public function modify(mixed $entity, array $formDatas): ServerEntity
|
||||
{
|
||||
$entity = parent::modify($entity, $formDatas);
|
||||
// //ServerPart정보 생성
|
||||
// foreach ($this->getServerPartService()->modifyByServer($entity, $formDatas) as $serverPartEntity) {
|
||||
// $entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity);
|
||||
// };
|
||||
// //IP정보 생성
|
||||
// $entity->addIPEntity($this->getIPService()->modifyByServer($entity, $formDatas));
|
||||
// ServerPart정보 수정
|
||||
foreach ($this->getServerPartService()->modifyByServer($entity, $formDatas) as $serverPartEntity) {
|
||||
$entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity);
|
||||
};
|
||||
return $entity;
|
||||
}
|
||||
|
||||
|
||||
@ -6,32 +6,54 @@
|
||||
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<div class="action_form">
|
||||
<table class="table table-bordered">
|
||||
<?php foreach (["code", "type", "title", "price", "amount", "manufactur_at", "format_at", "status",] as $field): ?>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['control']['field_default_values'][$field] ?? null), $viewDatas) ?>
|
||||
<span><?= validation_show_error($field); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>부품정보</td>
|
||||
<th>서버정보</th>
|
||||
<th>추가정보</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table class="table table-bordered">
|
||||
<?php foreach (SERVER['PARTTYPES'] as $type): ?>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("partinfo_uid_{$type}", lang("{$viewDatas['class_path']}.label.partinfo_uid_{$type}"), $viewDatas) ?></th>
|
||||
<tr>
|
||||
<?php foreach (["code", "type", "title", "price", "amount", "manufactur_at", "format_at", "status",] as $field): ?>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?= $viewDatas['helper']->getFieldForm("partinfo_uid_{$type}", old("partinfo_uid_{$type}") ?? ($viewDatas['control']['field_default_values']["partinfo_uid_{$type}"] ?? null), $viewDatas) ?>
|
||||
<?= form_dropdown("partinfo_uid_{$type}_cnt", $viewDatas['serverinfopartinfo_cnt_range'], old("partinfo_uid_{$type}_cnt") ?? 1) . "개" ?>
|
||||
<?php if ($type === "DISK"): ?>
|
||||
<?= form_dropdown("partinfo_uid_{$type}_extra", $viewDatas['serverinfopartinfo_extra_options'], old("partinfo_uid_{$type}_extra") ?? null) ?>
|
||||
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['control']['field_default_values'][$field] ?? null), $viewDatas) ?>
|
||||
<span><?= validation_show_error($field); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table class="table table-bordered">
|
||||
<?php foreach (SERVER['PARTTYPES'] as $partType): ?>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("partinfo_uid_{$partType}", lang("{$viewDatas['class_path']}.label.partinfo_uid_{$partType}"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?= $viewDatas['helper']->getFieldForm("partinfo_uid_{$partType}", old("partinfo_uid_{$partType}") ?? ($viewDatas['control']['field_default_values']["partinfo_uid_{$partType}"] ?? null), $viewDatas) ?>
|
||||
<?= $viewDatas['helper']->getFieldForm("serverinfopartinfo_uid_{$partType}_cnt", old("serverinfopartinfo_uid_{$partType}_cnt") ?? ($viewDatas['control']['field_default_values']["serverinfopartinfo_uid_{$partType}_cnt"] ?? null), $viewDatas) ?>
|
||||
<?php if ($partType === "DISK"): ?>
|
||||
<?= $viewDatas['helper']->getFieldForm("serverinfopartinfo_uid_{$partType}_extra", old("serverinfopartinfo_uid_{$partType}_extra") ?? ($viewDatas['control']['field_default_values']["serverinfopartinfo_uid_{$partType}_extra"] ?? null), $viewDatas) ?>
|
||||
<?php endif ?>
|
||||
<span><?= validation_show_error("partinfo_uid_{$type}"); ?></span>
|
||||
,금액 <?= $viewDatas['helper']->getFieldForm("serverinfopartinfo_uid_{$partType}_amount", old("serverinfopartinfo_uid_{$partType}_amount") ?? ($viewDatas['control']['field_default_values']["serverinfopartinfo_uid_{$partType}_amount"] ?? null), $viewDatas) ?>
|
||||
<span><?= validation_show_error("partinfo_uid_{$partType}"); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("ipinfo_uid", lang("{$viewDatas['class_path']}.label.ipinfo_uid"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?= $viewDatas['helper']->getFieldForm("ipinfo_uid", old("ipinfo_uid") ?? ($viewDatas['control']['field_default_values']["ipinfo_uid"] ?? null), $viewDatas) ?>
|
||||
,금액 <?= $viewDatas['helper']->getFieldForm("ipinfo_uid_amount", old("ipinfo_uid_amount") ?? ($viewDatas['control']['field_default_values']["ipinfo_uid_amount"] ?? null), $viewDatas) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("csinfo_uid", lang("{$viewDatas['class_path']}.label.csinfo_uid"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?= $viewDatas['helper']->getFieldForm("csinfo_uid", old("csinfo_uid") ?? ($viewDatas['control']['field_default_values']["csinfo_uid"] ?? null), $viewDatas) ?>
|
||||
,금액 <?= $viewDatas['helper']->getFieldForm("csinfo_uid_amount", old("csinfo_uid_amount") ?? ($viewDatas['control']['field_default_values']["csinfo_uid_amount"] ?? null), $viewDatas) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
<?php foreach ($viewDatas['control']['actionFields'] as $field): ?>
|
||||
<th data-rtc-resizable="<?= $field ?>"><?= $viewDatas['helper']->getListLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||
<?php endforeach ?>
|
||||
<th class="index_head_short_column">추가정보</th>
|
||||
<th class="index_head_short_column">작업</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -37,6 +38,13 @@
|
||||
<?php foreach ($viewDatas['control']['actionFields'] as $field): ?>
|
||||
<td><?= $viewDatas['helper']->getFieldView($field, $entity->$field, $viewDatas) ?></td>
|
||||
<?php endforeach ?>
|
||||
<td nowrap>
|
||||
<?php foreach (SERVER['PARTTYPES'] as $partType): ?>
|
||||
<div><?= $viewDatas['helper']->getFieldView($partType, "", $viewDatas) ?></div>
|
||||
<?php endforeach; ?>
|
||||
<div><?= $viewDatas['helper']->getFieldView("ipinfo_uid", "", $viewDatas) ?></div>
|
||||
<div><?= $viewDatas['helper']->getFieldView("csinfo_uid", "", $viewDatas) ?></div>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<?= $viewDatas['helper']->getListButton('view', '', $viewDatas) ?>
|
||||
<?= $viewDatas['helper']->getListButton('history', '', $viewDatas) ?>
|
||||
|
||||
@ -6,37 +6,63 @@
|
||||
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<div class="action_form">
|
||||
<table class="table table-bordered">
|
||||
<?php foreach (["code", "type", "title", "price", "amount", "manufactur_at", "format_at", "status",] as $field): ?>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['entity']->$field ?? null), $viewDatas) ?>
|
||||
<span><?= validation_show_error($field); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td>부품정보</td>
|
||||
<th>서버정보</th>
|
||||
<th>추가정보</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table class="table table-bordered">
|
||||
<?php foreach (SERVER['PARTTYPES'] as $type): ?>
|
||||
<?php foreach (["code", "type", "title", "price", "amount", "manufactur_at", "format_at", "status",] as $field): ?>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("partinfo_uid_{$type}", lang("{$viewDatas['class_path']}.label.partinfo_uid_{$type}"), $viewDatas) ?></th>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?= $viewDatas['helper']->getFieldForm("partinfo_uid_{$type}", old("partinfo_uid_{$type}") ?? ($viewDatas['entity']->getServerPartEntity($type)->getPartInfoUID()), $viewDatas) ?>
|
||||
<?= form_dropdown("partinfo_uid_{$type}_cnt", $viewDatas['serverinfopartinfo_cnt_range'], old("partinfo_uid_{$type}_cnt") ?? $viewDatas['entity']->getServerPartEntity($type)->getCnt()) . "개" ?>
|
||||
<?php if ($type === "DISK"): ?>
|
||||
<?= form_dropdown("partinfo_uid_{$type}_extra", $viewDatas['serverinfopartinfo_extra_options'], old("partinfo_uid_{$type}_extra") ?? $viewDatas['entity']->getServerPartEntity($type)->getExtra()) ?>
|
||||
<?php endif ?>
|
||||
<span><?= validation_show_error("partinfo_uid_{$type}"); ?></span>
|
||||
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['entity']->$field ?? null), $viewDatas) ?>
|
||||
<span><?= validation_show_error($field); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table class="table table-bordered">
|
||||
<?php foreach (SERVER['PARTTYPES'] as $partType): ?>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("partinfo_uid_{$partType}", lang("{$viewDatas['class_path']}.label.partinfo_uid_{$partType}"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?= $viewDatas['helper']->getFieldForm("partinfo_uid_{$partType}", old("partinfo_uid_{$partType}") ?? ($viewDatas['entity']->getServerPartEntity($partType) ? $viewDatas['entity']->getServerPartEntity($partType)->getPartInfoUID() : ($viewDatas['control']['field_default_values']["partinfo_uid_{$partType}"] ?? null)), $viewDatas) ?>
|
||||
<?= $viewDatas['helper']->getFieldForm("serverinfopartinfo_uid_{$partType}_cnt", old("serverinfopartinfo_uid_{$partType}_cnt") ?? ($viewDatas['entity']->getServerPartEntity($partType) ? $viewDatas['entity']->getServerPartEntity($partType)->getCnt() : ($viewDatas['control']['field_default_values']["serverinfopartinfo_uid_{$partType}_cnt"] ?? null)), $viewDatas) ?>
|
||||
<?php if ($partType === "DISK"): ?>
|
||||
<?= $viewDatas['helper']->getFieldForm("serverinfopartinfo_uid_{$partType}_extra", old("serverinfopartinfo_uid_{$partType}_extra") ?? ($viewDatas['entity']->getServerPartEntity($partType) ? $viewDatas['entity']->getServerPartEntity($partType)->getExtra() : ($viewDatas['control']['field_default_values']["serverinfopartinfo_uid_{$partType}_extra"] ?? null)), $viewDatas) ?>
|
||||
<?php endif ?>
|
||||
,금액 <?= $viewDatas['helper']->getFieldForm("serverinfopartinfo_uid_{$partType}_amount", ($viewDatas['entity']->getServerPartEntity($partType) ? $viewDatas['entity']->getServerPartEntity($partType)->getAmount() : ($viewDatas['control']['field_default_values']["serverinfopartinfo_uid_{$partType}_amount"] ?? null)), $viewDatas) ?>
|
||||
<span><?= validation_show_error("partinfo_uid_{$partType}"); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("ipinfo_uid", lang("{$viewDatas['class_path']}.label.ipinfo_uid"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?php foreach ($viewDatas['entity']->getIPEntities() as $entity): ?>
|
||||
<?= $viewDatas['helper']->getFieldForm("ipinfo_uid", old("ipinfo_uid") ?? ($viewDatas['control']['field_default_values']["ipinfo_uid"] ?? null), $viewDatas) ?>
|
||||
,금액 <?= $viewDatas['helper']->getFieldForm("ipinfo_uid_amount", ($ipEntity ? $ipEntity->getAmount() : ($viewDatas['control']['field_default_values']["ipinfo_amount"] ?? null)), $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("csinfo_uid", lang("{$viewDatas['class_path']}.label.csinfo_uid"), $viewDatas) ?></th>
|
||||
<td nowrap class="text-start">
|
||||
<?php foreach ($viewDatas['entity']->getCSEntities() as $entity): ?>
|
||||
<?= $viewDatas['helper']->getFieldForm("csinfo_uid", old("csinfo_uid") ?? ($viewDatas['control']['field_default_values']["csinfo_uid"] ?? null), $viewDatas) ?>
|
||||
,금액 <?= $viewDatas['helper']->getFieldForm("csinfo_uid_amount", ($entity ? $entity->getAmount() : ($viewDatas['control']['field_default_values']["csinfo_amount"] ?? null)), $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="text-center"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></div>
|
||||
<div class="text-center"><?= form_submit('', '수정', array("class" => "btn btn-outline btn-primary")); ?></div>
|
||||
<?= form_close(); ?>
|
||||
</div>
|
||||
<div class="form_bottom"><?= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?></div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user