dbms_init...1

This commit is contained in:
choi.jh 2025-06-16 17:10:16 +09:00
parent 5606f70905
commit e345424145
14 changed files with 171 additions and 156 deletions

View File

@ -377,4 +377,16 @@ define('LAYOUTS', [
define('DEFAULT_LIST_PERPAGE', $_ENV['LIST_PERPAGE'] ?? $_SERVER['LIST_PERPAGE'] ?? 20);
//서비스별 아이템 타입
define('SERVICE_ITEM_TYPES', $_ENV['SERVICEINFO_ITEM_TYPSS'] ?? $_SERVER['SERVICEINFO_ITEM_TYPSS'] ?? ['LINE', 'IP', 'SERVER', 'CPU', 'RAM', 'STORAGE', 'SOFTWARE', 'DEFENCE', 'DOMAIN']);
define('SERVICE_ITEM_TYPES', $_ENV['SERVICEINFO_ITEM_TYPES']
?? $_SERVER['SERVICEINFO_ITEM_TYPES']
?? [
"LINE" => "라인",
"IP" => "IP주소",
"SERVER" => "서버",
"CPU" => "CPU",
"RAM" => "메모리",
"STORAGE" => "저장장치",
"SOFTWARE" => "소프트웨어",
"DEFENCE" => "방어(CS)",
"DOMAIN" => "도메인",
]);

View File

@ -144,8 +144,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob', 'ServicePaymentController::batchjob');
$routes->post('batchjob_delete', 'ServicePaymentController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServicePaymentController::download/$1');
$routes->get('invoice_email', 'ServicePaymentController::invoice_email', []);
$routes->get('invoice_mobile', 'ServicePaymentController::invoice_mobile', []);
$routes->post('invoice', 'ServicePaymentController::invoice', []);
});
});
$routes->group('equipment', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {

View File

@ -29,7 +29,7 @@ abstract class CustomerController extends AdminController
final protected function initServiceItemOptions(): void
{
//$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용
foreach (SERVICE_ITEM_TYPES as $item_type) {
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$options = [];
foreach ($this->getService()->getEquipmentService($item_type)->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();

View File

@ -102,7 +102,7 @@ class ServiceController extends CustomerController
{
$entities = [];
foreach (parent::index_process() as $entity) {
foreach (SERVICE_ITEM_TYPES as $item_type) {
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$entity->setItemEntities(
$item_type,
$this->getServiceItemService()->getEntities(['serviceinfo_uid' => $entity->getPK(), 'item_type' => $item_type])

View File

@ -2,11 +2,14 @@
namespace App\Controllers\Admin\Customer;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Customer\ServicePaymentEntity;
use App\Helpers\Customer\ServicePaymentHelper;
use App\Libraries\LogCollector;
use App\Services\Customer\ServicePaymentService;
use App\Services\Customer\ServiceService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
@ -71,11 +74,16 @@ class ServicePaymentController extends CustomerController
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
switch ($this->getAction()) {
case 'invoice_email':
$result = parent::getResultSuccess($message, 'invoice_email');
break;
case 'invoice':
$result = parent::getResultSuccess($message, 'invoice');
$this->control = $this->getControlDatas();
$this->getHelper()->setViewDatas($this->getViewDatas());
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'payment';
if ($actionTemplate) {
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
} else {
$view_file = $this->view_path . $this->getAction();
}
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
break;
case 'index':
$result = parent::getResultSuccess($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'payment');
@ -87,14 +95,33 @@ class ServicePaymentController extends CustomerController
return $result;
}
//Index,FieldForm관련
private function setService(int $uid): void
private function getOwners(ClientEntity $ownerEntity): array
{
$this->getServiceService()->getEntity($uid);
$entity = $this->getServiceService()->getEntity($uid);
if (!$entity) {
throw new \Exception("서비스 정보가 존재하지 않습니다. uid: {$uid}");
}
$this->_services[$uid] = $entity;
$temps = [
'name' => $ownerEntity->getName(),
'total_amount' => 0,
'services' => []
];
return $temps;
}
private function getServices(ServiceEntity $serviceEntity): array
{
$temps = [
'serial' => $serviceEntity->getSerialCode(),
'billing_at' => $serviceEntity->getBillingAt(),
'items' => []
];
return $temps;
}
private function getItems(ServicePaymentEntity $entity): array
{
// dd($this->getFilterFieldOptions());
$temps = [
'item_type' => SERVICE_ITEM_TYPES[$entity->getItemType()],
'item_uid' => $this->getFilterFieldOption($entity->getItemType())[$entity->getItemUid()],
'amount' => $entity->getAmount()
];
return $temps;
}
private function invoice_process(): array
{
@ -104,6 +131,7 @@ class ServicePaymentController extends CustomerController
throw new \Exception("청구서에 적용될 리스트를 선택하셔야합니다.");
}
$this->item_fields = ['item_type', 'ammount', 'biiling_cycle'];
$owner_pk = false;
$entities = [];
foreach ($uids as $uid) {
//기존 Entity 가져오기
@ -111,26 +139,32 @@ class ServicePaymentController extends CustomerController
if (!$entity) {
LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 정보를 찾을수 없습니다.");
}
//서비스 정보 추가
$this->addService($entity->getServiceUid());
$entities[] = $entity;
//entities에 관리자 설정
$ownerEntity = $entity->getOwner();
if ($ownerEntity->getPK() !== $owner_pk) {
if (!array_key_exists($ownerEntity->getPK(), $entities)) {
$entities[$ownerEntity->getPK()] = $this->getOwners($ownerEntity);
}
$owner_pk = $ownerEntity->getPK();
}
//entities에 서비스 설정
$serviceEntity = $entity->getService();
if (!array_key_exists($serviceEntity->getPK(), $entities[$owner_pk]['services'])) {
$entities[$owner_pk]['services'][$serviceEntity->getPK()] = $this->getServices($serviceEntity);
}
//entities에 서비스 Item Type,Item 설정
if (!array_key_exists($entity->getPK(), $entities[$owner_pk]['services'][$serviceEntity->getPK()])) {
$entities[$owner_pk]['services'][$serviceEntity->getPK()]['items'][] = $this->getItems($entity);
}
$entities[$ownerEntity->getPK()]['total_amount'] += $entity->getAmount();
}
// dd($entities);
return $entities;
}
public function invoice_email(): RedirectResponse|string
public function invoice(): RedirectResponse|string
{
try {
$this->setAction(__FUNCTION__);
$this->entities = $this->invoice_process();
return $this->getResultSuccess();
} catch (\Exception $e) {
return $this->getResultFail($e->getMessage());
}
}
public function invoice_mobile(): RedirectResponse|string
{
try {
$this->setAction(__FUNCTION__);
$this->initAction(__FUNCTION__);
$this->entities = $this->invoice_process();
return $this->getResultSuccess();
} catch (\Exception $e) {

View File

@ -9,6 +9,14 @@ class ClientEntity extends CustomerEntity
const PK = ClientModel::PK;
const TITLE = ClientModel::TITLE;
//타 객체정의 부분
public function getSerialCode(): string
{
return "C" . $this->getPK();
}
public function getName(): string
{
return $this->attributes['name'];
}
public function getRole(): string
{
return $this->attributes['role'];

View File

@ -25,6 +25,11 @@ class ServiceEntity extends CustomerEntity
$this->_ownerEntity = $ownerEntity;
}
//타 객체정의 부분
public function getSerialCode(): string
{
return "S" . $this->getPK();
}
//서버코드
public function getCode(): string
{
return $this->attributes['code'];

View File

@ -13,19 +13,6 @@ class ServicePaymentEntity extends CustomerEntity
private ?ServiceEntity $_serviceEntity = null;
private ?ClientEntity $_ownerEntity = null;
//고객정보객체-상속
//서비스정보객체
final public function getServiceUid(): int
{
return intval($this->attributes['serviceinfo_uid']);
}
final public function getService(): ServiceEntity|null
{
return $this->_serviceEntity;
}
final public function setService(ServiceEntity $serviceEntity): void
{
$this->_serviceEntity = $serviceEntity;
}
//관리자정보객체
final public function getOwnerUID(): int
{
@ -39,6 +26,19 @@ class ServicePaymentEntity extends CustomerEntity
{
$this->_ownerEntity = $ownerEntity;
}
//서비스정보객체
final public function getServiceUid(): int
{
return intval($this->attributes['serviceinfo_uid']);
}
final public function getService(): ServiceEntity|null
{
return $this->_serviceEntity;
}
final public function setService(ServiceEntity $serviceEntity): void
{
$this->_serviceEntity = $serviceEntity;
}
//타 객체정의 부분
public function getItemType(): string
{

View File

@ -113,31 +113,12 @@ class ServicePaymentHelper extends CustomerHelper
]
);
break;
case 'invoice_email':
$extras = ["class" => "btn btn-outline btn-success btn-circle", "target" => "_self", ...$extras];
$action = form_label(
ICONS['MAIL'],
$action,
[
"data-src" => "/admin/customer/payment/invoice?ActionTemplate=email",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case 'invoice_mobile':
$extras = ["class" => "btn btn-outline btn-success btn-circle", "target" => "_self", ...$extras];
$action = form_label(
ICONS['PHONE'],
$action,
[
"data-src" => "/admin/customer/payment/invoice?ActionTemplate=mobile",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
case 'invoice':
$action = form_submit($action . "_submit", '청구서 발행', [
"formaction" => current_url() . '/' . $action,
"class" => "btn btn-outline btn-primary",
// "onclick" => "return submitBatchJob()"
]);
break;
default:
$action = parent::getListButton($action, $viewDatas, $extras);

View File

@ -20,17 +20,7 @@ return [
'type' => "default",
'status' => 'default'
],
"ITEM_TYPE" => [
"LINE" => "라인",
"IP" => "IP주소",
"SERVER" => "서버",
"CPU" => "CPU",
"RAM" => "메모리",
"STORAGE" => "저장장치",
"SOFTWARE" => "소프트웨어",
"DEFENCE" => "방어(CS)",
"DOMAIN" => "도메인",
],
"ITEM_TYPE" => SERVICE_ITEM_TYPES,
"BILLING_CYCLE" => [
"month" => "매월",
"onetime" => "일회성",

View File

@ -54,9 +54,7 @@
<?= $viewDatas['helper']->getFieldForm($field, null, $viewDatas, ['data-batchjob' => 'true']) ?>&nbsp;
<?php endforeach ?>
<li class="nav-item"><?= $viewDatas['helper']->getListButton('batchjob', $viewDatas) ?></li>
<li class="nav-item">청구서: </li>
<li class="nav-item"><?= $viewDatas['helper']->getListButton('invoice_email', $viewDatas) ?></li>
<li class="nav-item"><?= $viewDatas['helper']->getListButton('invoice_mobile', $viewDatas) ?></li>
<li class="nav-item"><?= $viewDatas['helper']->getListButton('invoice', $viewDatas) ?></li>
</ul>
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
</div>

View File

@ -0,0 +1,58 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<div class="action_form" style="width:1024px;">
<!-- 청구서 정보 -->
<table class=" table table-bordered">
<tbody>
<tr>
<th>메일 제목</th>
<td colspan="3">서비스 요금 청구서 </td>
</tr>
<tr>
<th>발신자</th>
<td>support@priem-idc.jp</td>
<th>발행일</th>
<td><?= date("Y-m-d") ?></td>
</tr>
</tbody>
</table>
<!-- 서비스 테이블 -->
<?php foreach ($viewDatas['entities'] as $entity): ?>
<table class="table table-bordered text-center">
<tr>
<th>관리자명</th>
<th> 결제 금액</th>
</tr>
<tr>
<td><?= $entity['name'] ?></td>
<td><?= number_format($entity['total_amount']) ?>원</td>
</tr>
<tr>
<td colspan="2">
<table class="table table-bordered text-center">
<?php foreach ($entity['services'] as $service): ?>
<tr>
<th>서비스: <?= $service['serial'] ?></th>
<th class="text-end">지급기한: <?= $service['billing_at'] ?></th>
</tr>
<tr>
<td>항목</td>
<td>
<ol>
<?php foreach ($service['items'] as $item): ?>
<li class="text-start"><?= $item['item_type'] ?> :<?= $item['item_uid'] ?> [<?= number_format($item['amount']) ?>원]</li>
<?php endforeach; ?>
</ol>
</td>
</tr>
<?php endforeach; ?>
</table>
</td>
</tr>
</table>
<?php endforeach; ?>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -1,70 +0,0 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<div class="action_form">
<!-- 청구서 정보 -->
<table class="table table-bordered">
<tbody>
<tr>
<th>메일 제목</th>
<td colspan="3">서비스 요금 청구서 </td>
</tr>
<tr>
<th>발신자</th>
<td><?= $viewDatas['helper']->getFieldView('site_email', $viewDatas) ?></td>
<th>발행일</th>
<td><?= date("Y-m-d") ?></td>
</tr>
</tbody>
</table>
<!-- 서비스 테이블 -->
<tr>
<th>고객코드</th>
<td><?= $viewDatas['helper']->getFieldView('ownerinfo_uid', $viewDatas) ?></td>
<th>고객명</th>
<td><?= $viewDatas['helper']->getFieldView('client_name', $viewDatas) ?></td>
</tr>
<table class="table table-bordered text-center align-middle">
<thead class="table-light">
<tr>
<th>서비스 코드</th>
<th>서비스 종류</th>
<th> 결제 금액</th>
<th>납부 기한</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= $viewDatas['helper']->getFieldView('service_title', $viewDatas) ?></td>
<td><?= $viewDatas['helper']->getFieldView('service_type', $viewDatas) ?></td>
<td class="fw-bold"><?= $viewDatas['helper']->getFieldView('total_amount', $viewDatas) ?>원</td>
<td><?= $viewDatas['helper']->getFieldView('billing_at', $viewDatas) ?></td>
</tr>
<tr>
<td colspan="4" class="text-start">
<table class="table table-bordered text-center align-middle">
<thead class="table-light">
<tr>
<?php foreach ($viewDatas['item_fields'] as $field): ?>
<th><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($viewDatas['entities'] as $entity): ?>
<?php $viewDatas['entity'] = $entity; ?>
<tr>
<?php foreach ($viewDatas['item_fields'] as $field): ?>
<td><?= $viewDatas['helper']->getFieldView($field, $viewDatas['entity']->$field, $viewDatas) ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</td>
</tr>
</table>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -48,12 +48,12 @@
<td colspan="<?= count($viewDatas['control']['index_fields']) + 2 ?>">
<table class="table table-bordered table-hover table-striped">
<tr>
<?php foreach (SERVICE_ITEM_TYPES as $item_type): ?>
<?php foreach (SERVICE_ITEM_TYPES as $item_type => $label): ?>
<th data-rtc-resizable="<?= $item_type ?>" nowrap><?= $viewDatas['helper']->getFieldLabel($item_type, $viewDatas) ?></th>
<?php endforeach ?>
</tr>
<tr>
<?php foreach (SERVICE_ITEM_TYPES as $item_type): ?>
<?php foreach (SERVICE_ITEM_TYPES as $item_type => $label): ?>
<td><?= $viewDatas['helper']->getFieldView($item_type, $entity->$item_type, $viewDatas) ?></td>
<?php endforeach ?>
</tr>