diff --git a/app/Config/Constants.php b/app/Config/Constants.php index b9e4cdb..79867b5 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -190,6 +190,7 @@ define('ICONS', [ 'CANCEL' => '', 'CLOSE' => '', 'CLIENT' => '', + 'CHART' => '', 'CHECK' => '', 'CHECK_OFF' => '', 'CHECK_ON' => '', @@ -390,3 +391,8 @@ define('SERVICE_ITEM_TYPES', $_ENV['SERVICEINFO_ITEM_TYPES'] "DEFENCE" => "방어(CS)", "DOMAIN" => "도메인", ]); + +//신규서비스 Interval +define('SERVICE_NEW_INTERVAL', $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVICE_NEW_INTERVAL'] ?? 7); +//미지급 Item_type +define('SERVICE_UNPAID_ITEM_TYPE', $_ENV['SERVICE_UNPAID_ITEM_TYPE'] ?? $_SERVER['SERVICE_UNPAID_ITEM_TYPE'] ?? "SERVER"); diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php index fc46825..0160810 100644 --- a/app/Controllers/Admin/Customer/ServiceController.php +++ b/app/Controllers/Admin/Customer/ServiceController.php @@ -8,7 +8,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -use App\Helpers\Customer\ServiceHelper; +use App\Helpers\Customer\ServicePaymentHelper; use App\Services\Customer\ServiceService; use App\Services\Customer\ServiceItemService; use App\Services\Equipment\CodeService; @@ -33,10 +33,10 @@ class ServiceController extends CustomerController } return $this->_service; } - public function getHelper(): ServiceHelper + public function getHelper(): ServicePaymentHelper { if (!$this->_helper) { - $this->_helper = new ServiceHelper($this->request); + $this->_helper = new ServicePaymentHelper($this->request); } return $this->_helper; } diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index a45b54a..c11351b 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -2,8 +2,9 @@ namespace App\Controllers\Admin; -use App\Helpers\UserHelper; -use App\Services\UserService; +use App\Helpers\HomeHelper; +use App\Services\Customer\ServiceService; +use App\Services\Customer\ServicePaymentService; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; @@ -12,30 +13,76 @@ use Psr\Log\LoggerInterface; class Home extends AdminController { private $_service = null; + private ?ServiceService $_serviceService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); + $this->content_title = lang("{$this->getService()->getClassName()}.title"); + $this->class_path .= $this->getService()->getClassName(); + $this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/'; + // $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR; + } - final public function getService(): UserService + final public function getService(): ServicePaymentService { if (!$this->_service) { - $this->_service = new UserService($this->request); + $this->_service = new ServicePaymentService($this->request); } return $this->_service; } public function getHelper(): mixed { if (!$this->_helper) { - $this->_helper = new UserHelper($this->request); + $this->_helper = new HomeHelper($this->request); } return $this->_helper; } + final public function getServiceService(): ServiceService + { + if (!$this->_serviceService) { + $this->_serviceService = new ServiceService($this->request); + } + return $this->_serviceService; + } + protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string + { + switch ($this->getAction()) { + case 'index': + $this->control = $this->getControlDatas(); + $this->getHelper()->setViewDatas($this->getViewDatas()); + $actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate; + if ($actionTemplate) { + $view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction(); + } else { + $view_file = $this->view_path . 'welcome_message'; + } + $result = view($view_file, ['viewDatas' => $this->getViewDatas()]); + break; + default: + $result = parent::getResultSuccess($message, $actionTemplate); + } + return $result; + } //Index,FieldForm관련 public function index(): RedirectResponse|string { + $this->initAction(__FUNCTION__); + //신규서비스정보 + $this->interval = $this->request->getVar('interval') ?? SERVICE_NEW_INTERVAL; + $this->newServiceEntities = $this->getServiceService()->getNewService(intval($this->interval)); + $this->newServiceCount = count($this->newServiceEntities); + + //미지금서버Count + $this->item_type = $this->request->getVar('item_type') ?? SERVICE_UNPAID_ITEM_TYPE; + $this->unPaidCount = $this->getService()->getUnPaid($this->item_type); + //LINE,IP,SERVER등 추가 FilterOption 셋팅용 + foreach (SERVICE_ITEM_TYPES as $item_type => $label) { + $options = $this->getService()->getServiceItemLinkService($item_type)->getEntities(); + $this->setFilterFieldOption($item_type, $options); + } helper(['form']); - return view('admin/welcome_message', ['viewDatas' => $this->getViewDatas()]); + return $this->getResultSuccess(); } } diff --git a/app/Entities/Customer/ServiceEntity.php b/app/Entities/Customer/ServiceEntity.php index b454422..bc41fea 100644 --- a/app/Entities/Customer/ServiceEntity.php +++ b/app/Entities/Customer/ServiceEntity.php @@ -17,11 +17,19 @@ class ServiceEntity extends CustomerEntity { return "S" . $this->getPK(); } + public function getSwitch(): string + { + return $this->attributes['switch']; + } //서버코드 public function getCode(): string { return $this->attributes['code']; } + public function getType(): string + { + return $this->attributes['type']; + } final public function getBillingAt(): string { return $this->attributes['billing_at']; diff --git a/app/Helpers/HomeHelper.php b/app/Helpers/HomeHelper.php new file mode 100644 index 0000000..e578170 --- /dev/null +++ b/app/Helpers/HomeHelper.php @@ -0,0 +1,73 @@ +setTitleField(field: ServicePaymentModel::TITLE); + } + + public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null + { + switch ($field) { + case "countdown": //결제일Countdown + $value = $viewDatas['entity']->getView_CounDueAt(); + break; + case 'item_uid': + // echo "Value:" . $viewDatas['entity']->getItemType() . ":" . $value; + // dd($viewDatas['control']['filter_optons']); + $value = $viewDatas['control']['filter_optons'][$viewDatas['entity']->getItemType()][$value]->getTitle(); + break; + case 'amount': + $value = number_format($value) . "원"; + break; + case 'status': + $value = parent::getFieldView($field, $value, $viewDatas, $extras); + break; + default: + dd($viewDatas['entity']); + if (in_array($field, $viewDatas['control']['filter_fields'])) { + $value = $viewDatas['control']['filter_optons'][$field][$value]->getTitle(); + } + break; + } + if (is_array($value)) { + echo __METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다"; + exit; + } + return $value; + } + public function getListButton(string $action, array $viewDatas, array $extras = []): string + { + switch ($action) { + case 'modify': + $action = $viewDatas['entity']->getPK(); + break; + case 'invoice': + $action = form_submit($action . "_submit", '청구서 발행', [ + "formaction" => current_url() . '/' . $action, + "class" => "btn btn-outline btn-primary", + // "onclick" => "return submitBatchJob()" + ]); + break; + case 'delete': + if ($viewDatas['entity']->getStatus() !== DEFAULTS['STATUS']) { + $action = ""; + } else { + $action = parent::getListButton($action, $viewDatas, $extras); + } + break; + default: + $action = parent::getListButton($action, $viewDatas, $extras); + break; + } + return $action; + } +} diff --git a/app/Services/Customer/ServicePaymentService.php b/app/Services/Customer/ServicePaymentService.php index b5b9826..f257037 100644 --- a/app/Services/Customer/ServicePaymentService.php +++ b/app/Services/Customer/ServicePaymentService.php @@ -75,6 +75,13 @@ class ServicePaymentService extends CustomerService } return $options; } + //미납 Count + final public function getUnPaid(string $item_type, string $status = DEFAULTS['STATUS']): int + { + $sql = "SELECT COUNT(*) as CNT FROM serviceinfo_payment WHERE billing_at < NOW() AND item_type = ? AND status = ?"; + $row = $this->getModel()->query($sql, [$item_type, $status])->getRow(); + return intval($row->CNT); + } //ServiceItemService에서 사용 public function createPaymentByServiceItem(ServiceItemEntity $serviceItemEntity): ServicePaymentEntity { diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index 9f3ae8b..7e2331f 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -97,6 +97,12 @@ class ServiceService extends CustomerService } return $options; } + //interval을 기준으로 신규서비스 가져오기 + final public function getNewService(int $interval, string $status = DEFAULTS['STATUS']) + { + $sql = "SELECT * FROM serviceinfo WHERE start_at >= NOW() - INTERVAL ? DAY AND status = ?"; + return $this->getModel()->query($sql, [$interval, $status])->getResult(ServiceEntity::class); + } //다음 달로 결제일을 연장합니다. final public function extendBillingAt(string $billing_at, string $status): bool { diff --git a/app/Views/admin/index.php b/app/Views/admin/index.php index ebe7bb8..041f35d 100644 --- a/app/Views/admin/index.php +++ b/app/Views/admin/index.php @@ -12,7 +12,7 @@ - include("templates/{$viewDatas['layout']}/index_header"); ?> +
include("templates/{$viewDatas['layout']}/index_header"); ?>
diff --git a/app/Views/admin/payment/index.php b/app/Views/admin/payment/index.php index 3f801b2..800547d 100644 --- a/app/Views/admin/payment/index.php +++ b/app/Views/admin/payment/index.php @@ -12,7 +12,7 @@ - include("templates/{$viewDatas['layout']}/index_header"); ?> +
include("templates/{$viewDatas['layout']}/index_header"); ?>
diff --git a/app/Views/admin/service/index.php b/app/Views/admin/service/index.php index da3bded..e160592 100644 --- a/app/Views/admin/service/index.php +++ b/app/Views/admin/service/index.php @@ -12,7 +12,7 @@ - include("templates/{$viewDatas['layout']}/index_header"); ?> +
include("templates/{$viewDatas['layout']}/index_header"); ?>
diff --git a/app/Views/admin/welcome_message.php b/app/Views/admin/welcome_message.php index 4b6614f..62f5ab3 100644 --- a/app/Views/admin/welcome_message.php +++ b/app/Views/admin/welcome_message.php @@ -1,5 +1,6 @@ extend(LAYOUTS[$viewDatas['layout']]['path']) ?> section('content') ?> +
include(LAYOUTS[$viewDatas['layout']]['path'] . '/top'); ?>
@@ -11,93 +12,19 @@
- include("templates/{$viewDatas['layout']}/index_header"); ?> -
- - -
- - + include("templates/{$viewDatas['layout']}/welcome_banner"); ?> +
+
+ include("templates/{$viewDatas['layout']}/welcome_total"); ?> +
+
+ include("templates/{$viewDatas['layout']}/welcome_new"); ?> +
-
-
include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?>
+
include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?>
endSection() ?> \ No newline at end of file diff --git a/app/Views/layouts/admin/top.php b/app/Views/layouts/admin/top.php index 0a0b670..9badbba 100644 --- a/app/Views/layouts/admin/top.php +++ b/app/Views/layouts/admin/top.php @@ -1,7 +1,7 @@