dbmsv2 init...1

This commit is contained in:
choi.jh 2025-09-15 14:04:19 +09:00
parent 70e1ecec06
commit 5a3b04a0e9
12 changed files with 127 additions and 53 deletions

View File

@ -4,38 +4,60 @@ namespace App\Cells\Equipment;
use App\Services\Equipment\ServerPartService; use App\Services\Equipment\ServerPartService;
use App\Services\Equipment\ServerService;
class ServerPartCell extends EquipmentCell class ServerPartCell extends EquipmentCell
{ {
private ?ServerService $_serverService = null;
public function __construct() public function __construct()
{ {
parent::__construct(new ServerPartService()); parent::__construct(new ServerPartService());
} }
final public function getServerService(): ServerService
{
if (!$this->_serverService) {
$this->_serverService = new ServerService();
}
return $this->_serverService;
}
public function parttable(array $params): string public function parttable(array $params): string
{ {
$this->getService()->setAction(__FUNCTION__); $result = "";
$this->getService()->setFormFields(); if (array_key_exists('serverinfo_uid', $params)) {
$this->getService()->setFormFilters(); $this->getService()->setAction(__FUNCTION__);
$this->getService()->setFormRules(); $this->getService()->setFormFields();
$this->getService()->setFormOptions(); $this->getService()->setFormFilters();
$serverPartEntities = $this->getService()->getEntities(['serverinfo_uid' => $params['serverinfo_uid']]); $this->getService()->setFormRules();
$entities = []; $this->getService()->setFormOptions();
foreach ($serverPartEntities as $entity) { // dd($params);
if (!array_key_exists($entity->getType(), $entities)) { //서버정보
$entities[$entity->getType()] = []; $serverEntity = $this->getServerService()->getEntity($params['serverinfo_uid']);
if (!$serverEntity) {
return "[{$params['serverinfo_uid']}]에 해당하는 서버정보가 지정되지 않았거나 존재하지 않습니다.";
} }
$entities[$entity->getType()][] = $entity; //서버파트정보
$serverPartEntities = $this->getService()->getEntities(['serverinfo_uid' => $serverEntity->getPK(),]);
$entities = [];
foreach ($serverPartEntities as $entity) {
if (!array_key_exists($entity->getType(), $entities)) {
$entities[$entity->getType()] = [];
}
$entities[$entity->getType()][] = $entity;
}
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
$result = view('cells/serverpart/' . $template, [
'serverPartCellDatas' => [
'control' => $this->getService()->getControlDatas(),
'service' => $this->getService(),
'serverinfo_uid' => $params['serverinfo_uid'],
'entities' => $entities,
'serverEntity' => $serverEntity,
'types' => $params['types'],
],
]);
} }
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__; return $result;
return view('cells/serverpart/' . $template, [
'serverPartCellDatas' => [
'control' => $this->getService()->getControlDatas(),
'service' => $this->getService(),
'entities' => $entities,
'serverinfo_uid' => $params['serverinfo_uid'],
'types' => $params['types'],
]
]);
} }
} }

View File

@ -41,6 +41,7 @@ class ServiceController extends CustomerController
{ {
switch ($this->getService()->getAction()) { switch ($this->getService()->getAction()) {
case 'view': case 'view':
case 'index':
$this->service = $this->getService(); $this->service = $this->getService();
$this->control = $this->getService()->getControlDatas(); $this->control = $this->getService()->getControlDatas();
$this->getService()->getHelper()->setViewDatas($this->getViewDatas()); $this->getService()->getHelper()->setViewDatas($this->getViewDatas());

View File

@ -68,11 +68,6 @@ class ServiceHelper extends CustomerHelper
case 'clientinfo_uid': case 'clientinfo_uid':
$value = "<a href=\"/admin/customer/client/detail/{$value}\">" . $viewDatas['control']['field_optons'][$field][$value]->getTitle() . "</a>"; $value = "<a href=\"/admin/customer/client/detail/{$value}\">" . $viewDatas['control']['field_optons'][$field][$value]->getTitle() . "</a>";
break; break;
case 'serverinfo_uid':
$value = $viewDatas['entity']->getServerEntity()->getCode();
$value .= " /" . view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $viewDatas['entity']->getServerEntity()->getPK(), 'types' => SERVERPART['SERVICE_PARTTYPES'], 'template' => 'part_service']);
$value .= "<div class=\"float-end rounded border border-primary\" onClick=\"navigator.clipboard.writeText('복사할 텍스트'); alert('복사됨!')\">COPY</div>";
break;
case 'billing_at': case 'billing_at':
if (array_key_exists('unPaids', $viewDatas)) { if (array_key_exists('unPaids', $viewDatas)) {
if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) { if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) {

View File

@ -88,17 +88,21 @@ class ServerPartHelper extends EquipmentHelper
$title = $entity->getTitle(); $title = $entity->getTitle();
$title .= $entity->getCnt() > 1 ? "*" . $entity->getCnt() . "" : ""; $title .= $entity->getCnt() > 1 ? "*" . $entity->getCnt() . "" : "";
$title .= $entity->getExtra() !== "" ? "/" . $entity->getExtra() : ""; $title .= $entity->getExtra() !== "" ? "/" . $entity->getExtra() : "";
$temps[] = form_label( if (array_key_exists('return_type', $extras) && $extras['return_type'] === 'text') {
$title, $temps[] = $title;
$field, } else {
[ $temps[] = form_label(
"data-src" => "/admin/equipment/serverpart/modify/{$entity->getPK()}?type={$entity->getType()}&ActionTemplate=popup", $title,
"data-bs-toggle" => "modal", $field,
"data-bs-target" => "#index_action_form", [
"class" => "btn btn-sm btn-outline btn-circle", "data-src" => "/admin/equipment/serverpart/modify/{$entity->getPK()}?type={$entity->getType()}&ActionTemplate=popup",
"target" => "_self" "data-bs-toggle" => "modal",
] "data-bs-target" => "#index_action_form",
); "class" => "btn btn-sm btn-outline btn-circle",
"target" => "_self"
]
);
}
} }
$value = implode(",", $temps); $value = implode(",", $temps);
break; break;

View File

@ -11,7 +11,6 @@ use App\Services\Customer\ClientService;
use App\Services\Customer\ServiceService; use App\Services\Customer\ServiceService;
use App\Services\Equipment\ServerService; use App\Services\Equipment\ServerService;
use App\Services\UserService; use App\Services\UserService;
use CodeIgniter\Model;
abstract class EquipmentService extends CommonService abstract class EquipmentService extends CommonService
{ {
@ -80,7 +79,7 @@ abstract class EquipmentService extends CommonService
{ {
$entity = $this->getClientService()->getEntity($uid); $entity = $this->getClientService()->getEntity($uid);
if (!$entity) { if (!$entity) {
throw new \Exception("{$uid}에 해당하는 고객정보가 존재하지 않습니다. uid: {$uid}"); throw new \Exception("{$uid}에 해당하는 고객정보가 존재하지 않습니다.");
} }
return $entity; return $entity;
} }

View File

@ -73,7 +73,11 @@
<?= $viewDatas['service']->getHelper()->getFieldView('title', $entity->getTitle(), $viewDatas) ?> <?= $viewDatas['service']->getHelper()->getFieldView('title', $entity->getTitle(), $viewDatas) ?>
</td> </td>
<td nowrap> <td nowrap>
<?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $entity->getPK(), 'types' => SERVERPART['SERVER_PARTTYPES'], 'template' => 'part_server']) ?> <?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $entity->getPK(),
'types' => SERVERPART['SERVER_PARTTYPES'],
'template' => 'part_server'
]) ?>
</td> </td>
<td nowrap> <td nowrap>
<?= $viewDatas['service']->getHelper()->getFieldView('price', $entity->price, $viewDatas) ?> <?= $viewDatas['service']->getHelper()->getFieldView('price', $entity->price, $viewDatas) ?>

View File

@ -24,7 +24,10 @@
<?php endforeach ?> <?php endforeach ?>
</table> </table>
</td> </td>
<td><?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $viewDatas['entity']->getPK(), 'types' => SERVERPART['PARTTYPES']]) ?></td>> <td><?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $viewDatas['entity']->getPK(),
'types' => SERVERPART['PARTTYPES']
]) ?></td>>
</tr> </tr>
</table> </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>

View File

@ -47,9 +47,8 @@
<?= $viewDatas['service']->getHelper()->getListLabel('clientinfo_uid', lang("{$viewDatas['class_path']}.label.clientinfo_uid"), $viewDatas) ?> <?= $viewDatas['service']->getHelper()->getListLabel('clientinfo_uid', lang("{$viewDatas['class_path']}.label.clientinfo_uid"), $viewDatas) ?>
</th> </th>
<th class="index_head_short_column"> <th class="index_head_short_column">
<?= $viewDatas['service']->getHelper()->getListLabel('serverinfo_uid', lang("{$viewDatas['class_path']}.label.serverinfo_uid"), $viewDatas) ?> 서버정보<div class="float-end rounded border border-primary" style="cursor:pointer;" onclick="copyServerPartsToClipboard()">All COPY</div>
</th> </th>
<th class="index_head_short_column">부품정보</th>
<th class="index_head_short_column"> <th class="index_head_short_column">
<?= $viewDatas['service']->getHelper()->getListLabel('billing_at', lang("{$viewDatas['class_path']}.label.billing_at"), $viewDatas) ?> <?= $viewDatas['service']->getHelper()->getListLabel('billing_at', lang("{$viewDatas['class_path']}.label.billing_at"), $viewDatas) ?>
</th> </th>
@ -84,10 +83,11 @@
<?= $viewDatas['service']->getHelper()->getFieldView('clientinfo_uid', $entity->clientinfo_uid, $viewDatas) ?> <?= $viewDatas['service']->getHelper()->getFieldView('clientinfo_uid', $entity->clientinfo_uid, $viewDatas) ?>
</td> </td>
<td nowrap> <td nowrap>
<?= $viewDatas['service']->getHelper()->getFieldView('serverinfo_uid', $entity->serverinfo_uid, $viewDatas) ?> <?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
</td> 'serverinfo_uid' => $entity->getServerEntity()->getPK(),
<td nowrap> 'types' => SERVERPART['SERVICE_PARTTYPES'],
<?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $entity->getServerEntity()->getPK(), 'types' => SERVERPART['SERVICE_PARTTYPES'], 'template' => 'part_service']) ?> 'template' => 'part_service'
]) ?>
</td> </td>
<td nowrap> <td nowrap>
<?= $viewDatas['service']->getHelper()->getFieldView('billing_at', $entity->billing_at, $viewDatas) ?> <?= $viewDatas['service']->getHelper()->getFieldView('billing_at', $entity->billing_at, $viewDatas) ?>
@ -120,4 +120,35 @@
</table> </table>
<!-- Layout Middle End --> <!-- Layout Middle End -->
<div class="layout_bottom"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?></div> <div class="layout_bottom"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?></div>
<script>
function copyServerPartToClipboard(text) {
try {
if (navigator.clipboard && navigator.clipboard.writeText) {
// HTTPS 환경
navigator.clipboard.writeText(text)
.then(() => alert(text + " 복사되었습니다."))
.catch(err => alert("실패: " + err));
} else {
// HTTP 환경 fallback
const temp = document.createElement("textarea");
temp.value = text;
document.body.appendChild(temp);
temp.select();
document.execCommand("copy");
document.body.removeChild(temp);
alert(text + " 복사되었습니다.");
}
} catch (err) {
alert("복사 실패: " + err);
}
}
function copyServerPartsToClipboard() {
// 모든 .serverparts div에서 data-text 속성값 수집
const elements = document.querySelectorAll(".serverparts");
const texts = Array.from(elements).map(el => el.getAttribute("data-text") || "");
const combined = texts.join("\n");
copyServerPartToClipboard(combined);
}
</script>
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -22,7 +22,10 @@
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
</td> </td>
<td><?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $viewDatas['entity']->getServerEntity()->getPK(), 'types' => SERVERPART['PARTTYPES']]) ?></td> <td><?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $viewDatas['entity']->getServerEntity()->getPK(),
'types' => SERVERPART['PARTTYPES']
]) ?></td>
</tr> </tr>
</table> </table>
<div class="form_bottom"><?= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?></div> <div class="form_bottom"><?= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?></div>

View File

@ -27,7 +27,11 @@
<td><?= $viewDatas['service']->getHelper()->getFieldView('clientinfo_uid', $entity->getClientInfoUID(), $viewDatas) ?></td> <td><?= $viewDatas['service']->getHelper()->getFieldView('clientinfo_uid', $entity->getClientInfoUID(), $viewDatas) ?></td>
<td><?= $viewDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $viewDatas) ?></td> <td><?= $viewDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $viewDatas) ?></td>
<td><?= $viewDatas['service']->getHelper()->getFieldView('serveripinfo_uid', $entity->getServerEntity()->getCode(), $viewDatas) ?></td> <td><?= $viewDatas['service']->getHelper()->getFieldView('serveripinfo_uid', $entity->getServerEntity()->getCode(), $viewDatas) ?></td>
<td><?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $entity->getServerEntity()->getPK(), 'types' => SERVERPART['SERVICE_PARTTYPES'], 'template' => 'part_service']) ?></td> <td><?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $entity->getServerEntity()->getPK(),
'types' => SERVERPART['SERVICE_PARTTYPES'],
'template' => 'part_service'
]) ?></td>
<td><?= $viewDatas['service']->getHelper()->getFieldView('user_uid', $entity->getUserUID(), $viewDatas) ?></td> <td><?= $viewDatas['service']->getHelper()->getFieldView('user_uid', $entity->getUserUID(), $viewDatas) ?></td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>

View File

@ -1,5 +1,9 @@
<?php $temps = [] ?> <?php $htmls = $texts = [$serverPartCellDatas['serverEntity']->getCode()] ?>
<?php foreach (['SWITCH', 'IP', 'OS'] as $type): ?> <?php foreach (['SWITCH', 'IP', 'OS'] as $type): ?>
<?php $temps[] = $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) . $serverPartCellDatas['service']->getHelper()->getFieldView($type, "", $serverPartCellDatas) ?> <?php $texts[] = $serverPartCellDatas['service']->getHelper()->getFieldView($type, '', $serverPartCellDatas, ['return_type' => 'text']); ?>
<?php $button = $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) ?>
<?php $htmls[] = $button . $serverPartCellDatas['service']->getHelper()->getFieldView($type, '', $serverPartCellDatas) ?>
<?php endforeach ?> <?php endforeach ?>
<?= implode("/", $temps) ?> <?= implode(" /", $htmls) ?>
<?php $text = implode('/', $texts) ?>
<div class="serverparts float-end rounded border border-primary" style="cursor:pointer;" onclick="copyServerPartToClipboard('<?= $text ?>')" text-data="<?= $text ?>">COPY</div>

View File

@ -30,7 +30,11 @@
<div><?= $serviceCellDatas['service']->getHelper()->getFieldView('location', $entity->getLocation(), $serviceCellDatas) ?></div> <div><?= $serviceCellDatas['service']->getHelper()->getFieldView('location', $entity->getLocation(), $serviceCellDatas) ?></div>
<div><?= $serviceCellDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $serviceCellDatas) ?></div> <div><?= $serviceCellDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $serviceCellDatas) ?></div>
</td> </td>
<?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $entity->getServerEntity()->getPK(), 'types' => SERVERPART['SERVICE_PARTTYPES'], 'template' => 'part_detail']) ?> <?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $entity->getServerEntity()->getPK(),
'types' => SERVERPART['SERVICE_PARTTYPES'],
'template' => 'part_detail'
]) ?>
<td> <td>
<?= form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?> <?= form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?>
<div class="row align-items-center"> <div class="row align-items-center">