dbmsv2 init...1
This commit is contained in:
parent
70e1ecec06
commit
5a3b04a0e9
@ -4,38 +4,60 @@ namespace App\Cells\Equipment;
|
||||
|
||||
|
||||
use App\Services\Equipment\ServerPartService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
|
||||
class ServerPartCell extends EquipmentCell
|
||||
{
|
||||
private ?ServerService $_serverService = null;
|
||||
public function __construct()
|
||||
{
|
||||
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
|
||||
{
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
$serverPartEntities = $this->getService()->getEntities(['serverinfo_uid' => $params['serverinfo_uid']]);
|
||||
$entities = [];
|
||||
foreach ($serverPartEntities as $entity) {
|
||||
if (!array_key_exists($entity->getType(), $entities)) {
|
||||
$entities[$entity->getType()] = [];
|
||||
$result = "";
|
||||
if (array_key_exists('serverinfo_uid', $params)) {
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
// dd($params);
|
||||
//서버정보
|
||||
$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 view('cells/serverpart/' . $template, [
|
||||
'serverPartCellDatas' => [
|
||||
'control' => $this->getService()->getControlDatas(),
|
||||
'service' => $this->getService(),
|
||||
'entities' => $entities,
|
||||
'serverinfo_uid' => $params['serverinfo_uid'],
|
||||
'types' => $params['types'],
|
||||
]
|
||||
]);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ class ServiceController extends CustomerController
|
||||
{
|
||||
switch ($this->getService()->getAction()) {
|
||||
case 'view':
|
||||
case 'index':
|
||||
$this->service = $this->getService();
|
||||
$this->control = $this->getService()->getControlDatas();
|
||||
$this->getService()->getHelper()->setViewDatas($this->getViewDatas());
|
||||
|
||||
@ -68,11 +68,6 @@ class ServiceHelper extends CustomerHelper
|
||||
case 'clientinfo_uid':
|
||||
$value = "<a href=\"/admin/customer/client/detail/{$value}\">" . $viewDatas['control']['field_optons'][$field][$value]->getTitle() . "</a>";
|
||||
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':
|
||||
if (array_key_exists('unPaids', $viewDatas)) {
|
||||
if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) {
|
||||
|
||||
@ -88,17 +88,21 @@ class ServerPartHelper extends EquipmentHelper
|
||||
$title = $entity->getTitle();
|
||||
$title .= $entity->getCnt() > 1 ? "*" . $entity->getCnt() . "개" : "";
|
||||
$title .= $entity->getExtra() !== "" ? "/" . $entity->getExtra() : "";
|
||||
$temps[] = form_label(
|
||||
$title,
|
||||
$field,
|
||||
[
|
||||
"data-src" => "/admin/equipment/serverpart/modify/{$entity->getPK()}?type={$entity->getType()}&ActionTemplate=popup",
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"class" => "btn btn-sm btn-outline btn-circle",
|
||||
"target" => "_self"
|
||||
]
|
||||
);
|
||||
if (array_key_exists('return_type', $extras) && $extras['return_type'] === 'text') {
|
||||
$temps[] = $title;
|
||||
} else {
|
||||
$temps[] = form_label(
|
||||
$title,
|
||||
$field,
|
||||
[
|
||||
"data-src" => "/admin/equipment/serverpart/modify/{$entity->getPK()}?type={$entity->getType()}&ActionTemplate=popup",
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"class" => "btn btn-sm btn-outline btn-circle",
|
||||
"target" => "_self"
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
$value = implode(",", $temps);
|
||||
break;
|
||||
|
||||
@ -11,7 +11,6 @@ use App\Services\Customer\ClientService;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use App\Services\UserService;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
abstract class EquipmentService extends CommonService
|
||||
{
|
||||
@ -80,7 +79,7 @@ abstract class EquipmentService extends CommonService
|
||||
{
|
||||
$entity = $this->getClientService()->getEntity($uid);
|
||||
if (!$entity) {
|
||||
throw new \Exception("{$uid}에 해당하는 고객정보가 존재하지 않습니다. uid: {$uid}");
|
||||
throw new \Exception("{$uid}에 해당하는 고객정보가 존재하지 않습니다.");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@ -73,7 +73,11 @@
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('title', $entity->getTitle(), $viewDatas) ?>
|
||||
</td>
|
||||
<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 nowrap>
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('price', $entity->price, $viewDatas) ?>
|
||||
|
||||
@ -24,7 +24,10 @@
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
</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>
|
||||
</table>
|
||||
<div class="text-center"><?= form_submit('', '수정', array("class" => "btn btn-outline btn-primary")); ?></div>
|
||||
|
||||
@ -47,9 +47,8 @@
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('clientinfo_uid', lang("{$viewDatas['class_path']}.label.clientinfo_uid"), $viewDatas) ?>
|
||||
</th>
|
||||
<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 class="index_head_short_column">부품정보</th>
|
||||
<th class="index_head_short_column">
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('billing_at', lang("{$viewDatas['class_path']}.label.billing_at"), $viewDatas) ?>
|
||||
</th>
|
||||
@ -84,10 +83,11 @@
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('clientinfo_uid', $entity->clientinfo_uid, $viewDatas) ?>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('serverinfo_uid', $entity->serverinfo_uid, $viewDatas) ?>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $entity->getServerEntity()->getPK(), 'types' => SERVERPART['SERVICE_PARTTYPES'], 'template' => 'part_service']) ?>
|
||||
<?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
|
||||
'serverinfo_uid' => $entity->getServerEntity()->getPK(),
|
||||
'types' => SERVERPART['SERVICE_PARTTYPES'],
|
||||
'template' => 'part_service'
|
||||
]) ?>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('billing_at', $entity->billing_at, $viewDatas) ?>
|
||||
@ -120,4 +120,35 @@
|
||||
</table>
|
||||
<!-- Layout Middle End -->
|
||||
<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() ?>
|
||||
@ -22,7 +22,10 @@
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</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>
|
||||
</table>
|
||||
<div class="form_bottom"><?= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?></div>
|
||||
|
||||
@ -27,7 +27,11 @@
|
||||
<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('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>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
<?php $temps = [] ?>
|
||||
<?php $htmls = $texts = [$serverPartCellDatas['serverEntity']->getCode()] ?>
|
||||
<?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 ?>
|
||||
<?= 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>
|
||||
@ -30,7 +30,11 @@
|
||||
<div><?= $serviceCellDatas['service']->getHelper()->getFieldView('location', $entity->getLocation(), $serviceCellDatas) ?></div>
|
||||
<div><?= $serviceCellDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $serviceCellDatas) ?></div>
|
||||
</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>
|
||||
<?= form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?>
|
||||
<div class="row align-items-center">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user