diff --git a/app/Config/Constants.php b/app/Config/Constants.php
index 5cda487..b9e4cdb 100644
--- a/app/Config/Constants.php
+++ b/app/Config/Constants.php
@@ -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" => "도메인",
+ ]);
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 4e85489..0d8d60f 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -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) {
diff --git a/app/Controllers/Admin/Customer/CustomerController.php b/app/Controllers/Admin/Customer/CustomerController.php
index eb97231..a61753c 100644
--- a/app/Controllers/Admin/Customer/CustomerController.php
+++ b/app/Controllers/Admin/Customer/CustomerController.php
@@ -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();
diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php
index 0413f56..530f349 100644
--- a/app/Controllers/Admin/Customer/ServiceController.php
+++ b/app/Controllers/Admin/Customer/ServiceController.php
@@ -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])
diff --git a/app/Controllers/Admin/Customer/ServicePaymentController.php b/app/Controllers/Admin/Customer/ServicePaymentController.php
index 20ccca6..d1b2ccd 100644
--- a/app/Controllers/Admin/Customer/ServicePaymentController.php
+++ b/app/Controllers/Admin/Customer/ServicePaymentController.php
@@ -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) {
diff --git a/app/Entities/Customer/ClientEntity.php b/app/Entities/Customer/ClientEntity.php
index eb65302..cd28567 100644
--- a/app/Entities/Customer/ClientEntity.php
+++ b/app/Entities/Customer/ClientEntity.php
@@ -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'];
diff --git a/app/Entities/Customer/ServiceEntity.php b/app/Entities/Customer/ServiceEntity.php
index 3501068..7ce45c8 100644
--- a/app/Entities/Customer/ServiceEntity.php
+++ b/app/Entities/Customer/ServiceEntity.php
@@ -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'];
diff --git a/app/Entities/Customer/ServicePaymentEntity.php b/app/Entities/Customer/ServicePaymentEntity.php
index 4e3640d..cd6f2bb 100644
--- a/app/Entities/Customer/ServicePaymentEntity.php
+++ b/app/Entities/Customer/ServicePaymentEntity.php
@@ -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
{
diff --git a/app/Helpers/Customer/ServicePaymentHelper.php b/app/Helpers/Customer/ServicePaymentHelper.php
index e426333..6053b39 100644
--- a/app/Helpers/Customer/ServicePaymentHelper.php
+++ b/app/Helpers/Customer/ServicePaymentHelper.php
@@ -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);
diff --git a/app/Language/en/Customer/ServiceItem.php b/app/Language/en/Customer/ServiceItem.php
index 035bdb5..fac453a 100644
--- a/app/Language/en/Customer/ServiceItem.php
+++ b/app/Language/en/Customer/ServiceItem.php
@@ -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" => "일회성",
diff --git a/app/Views/admin/payment/index.php b/app/Views/admin/payment/index.php
index acdef2e..3f801b2 100644
--- a/app/Views/admin/payment/index.php
+++ b/app/Views/admin/payment/index.php
@@ -54,9 +54,7 @@
= $viewDatas['helper']->getFieldForm($field, null, $viewDatas, ['data-batchjob' => 'true']) ?>
= $viewDatas['helper']->getListButton('batchjob', $viewDatas) ?>
- 청구서:
- = $viewDatas['helper']->getListButton('invoice_email', $viewDatas) ?>
- = $viewDatas['helper']->getListButton('invoice_mobile', $viewDatas) ?>
+ = $viewDatas['helper']->getListButton('invoice', $viewDatas) ?>
diff --git a/app/Views/admin/payment/invoice.php b/app/Views/admin/payment/invoice.php
new file mode 100644
index 0000000..fadcb68
--- /dev/null
+++ b/app/Views/admin/payment/invoice.php
@@ -0,0 +1,58 @@
+= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
+= $this->section('content') ?>
+
+= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/payment/invoice_email.php b/app/Views/admin/payment/invoice_email.php
deleted file mode 100644
index 362333c..0000000
--- a/app/Views/admin/payment/invoice_email.php
+++ /dev/null
@@ -1,70 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/service/index.php b/app/Views/admin/service/index.php
index e461929..da3bded 100644
--- a/app/Views/admin/service/index.php
+++ b/app/Views/admin/service/index.php
@@ -48,12 +48,12 @@
-
+ $label): ?>
| = $viewDatas['helper']->getFieldLabel($item_type, $viewDatas) ?> |
-
+ $label): ?>
| = $viewDatas['helper']->getFieldView($item_type, $entity->$item_type, $viewDatas) ?> |
|