dbmsv2_init...1
This commit is contained in:
parent
0b46189461
commit
4b35876c75
@ -33,6 +33,7 @@ $routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
|
||||
//Admin 관련
|
||||
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->get('/search', 'SearchController::index');
|
||||
$routes->group('user', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
|
||||
$routes->get('/', 'UserController::index', ['filter' => 'authFilter:master']);
|
||||
$routes->get('create', 'UserController::create_form', ['filter' => 'authFilter:master']);
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use App\Services\PaymentService;
|
||||
@ -14,8 +13,8 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class ServiceController extends CustomerController
|
||||
{
|
||||
private ?PaymentService $_paymentService = null;
|
||||
private ?ServerService $_serverService = null;
|
||||
private ?PaymentService $_paymentService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Helpers\Customer\ServiceHelper;
|
||||
use App\Services\Customer\ServicePaymentService;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use App\Services\PaymentService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -13,14 +13,15 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class SearchController extends AdminController
|
||||
{
|
||||
private ?ServerService $_serverService = null;
|
||||
private ?PaymentService $_paymentService = 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;
|
||||
|
||||
$this->uri_path = '/admin/search';
|
||||
// $this->view_path = '/admin/search';
|
||||
}
|
||||
public function getService(): ServiceService
|
||||
{
|
||||
@ -29,11 +30,25 @@ class SearchController extends AdminController
|
||||
}
|
||||
return $this->_service;
|
||||
}
|
||||
public function getServerService(): ServerService
|
||||
{
|
||||
if ($this->_serverService === null) {
|
||||
$this->_serverService = new ServerService();
|
||||
}
|
||||
return $this->_serverService;
|
||||
}
|
||||
public function getPaymentService(): PaymentService
|
||||
{
|
||||
if ($this->_paymentService === null) {
|
||||
$this->_paymentService = new PaymentService();
|
||||
}
|
||||
return $this->_paymentService;
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getService()->getAction()) {
|
||||
case 'index':
|
||||
$result = parent::getResultSuccess($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'search');
|
||||
$result = parent::getResultSuccess($message, 'search');
|
||||
break;
|
||||
default:
|
||||
$result = parent::getResultSuccess($message, $actionTemplate);
|
||||
@ -41,5 +56,66 @@ class SearchController extends AdminController
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
|
||||
protected function getChildServers(ServiceEntity $entity): array
|
||||
{
|
||||
$servers = [];
|
||||
foreach ($this->getServerService()->getEntities(['serviceinfo_uid' => $entity->getPK()]) as $serverEntity) {
|
||||
$servers[] = view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
|
||||
'serverinfo_uid' => $serverEntity->getPK(),
|
||||
'types' => SERVERPART['SERVICE_PARTTYPES'],
|
||||
'serviceinfo_serverinfo_uid' => $entity->getServerEntity()->getPK(),
|
||||
'template' => 'partlist_service'
|
||||
]);
|
||||
}
|
||||
return $servers;
|
||||
}
|
||||
//
|
||||
|
||||
protected function index_process(array $entities = []): array
|
||||
{
|
||||
$keyword = $this->request->getGet('keyword'); // 검색어
|
||||
if (!$keyword) {
|
||||
throw new \Exception("[{$keyword}] 검색어가 지정되지 않았습니다. ");
|
||||
}
|
||||
// ->select([
|
||||
// 's.serviceinfo_uid',
|
||||
// 's.uid AS server_uid',
|
||||
// 's.title AS server_title',
|
||||
// 'c.uid AS client_uid',
|
||||
// 'c.name AS client_name',
|
||||
// 'sp.uid AS part_uid',
|
||||
// 'sp.title AS part_title'
|
||||
// ])
|
||||
$db = \Config\Database::connect();
|
||||
$builder = $db->table('serverinfo s')
|
||||
->distinct()
|
||||
->select('s.serviceinfo_uid AS serviceinfo_uid')
|
||||
->join('clientinfo c', 'c.uid = s.clientinfo_uid')
|
||||
->join('serverpartinfo sp', 'sp.clientinfo_uid = c.uid', 'left')
|
||||
->groupStart()
|
||||
->like('c.name', $keyword, 'both', null, true) // escape=true
|
||||
->orLike('s.title', $keyword, 'both', null, true)
|
||||
->orLike('sp.title', $keyword, 'both', null, true)
|
||||
->groupEnd();
|
||||
// SQL 확인용 (실제 운영에서는 주석 처리)
|
||||
// echo $builder->getCompiledSelect(); exit;
|
||||
$results = $builder->get()->getResultArray();
|
||||
// dd($results);
|
||||
$uids = [];
|
||||
foreach ($results as $result) {
|
||||
$uids[] = "'{$result['serviceinfo_uid']}'";
|
||||
}
|
||||
if (!count($uids)) {
|
||||
return [];
|
||||
}
|
||||
//서비스별 미납 Count
|
||||
$childServers = [];
|
||||
foreach ($this->getService()->getEntities("uid IN (" . implode(",", $uids) . ")") as $entity) {
|
||||
$entities[] = $entity;
|
||||
$childServers[$entity->getPK()] = $this->getChildServers($entity);
|
||||
}
|
||||
$this->childServers = $childServers;
|
||||
return $entities;
|
||||
}
|
||||
}
|
||||
|
||||
115
app/Views/admin/search/index.php
Normal file
115
app/Views/admin/search/index.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
|
||||
<?= $this->section('content') ?>
|
||||
<?php if ($error = session('error')): echo $viewDatas['service']->getHelper()->alert($error) ?><?php endif ?>
|
||||
<div class="layout_top"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/top'); ?></div>
|
||||
<!-- Layout Middle Start -->
|
||||
<table class="layout_middle">
|
||||
<tr>
|
||||
<td class="layout_left">
|
||||
<!-- Layout Left Start -->
|
||||
<?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu'); ?>
|
||||
<!-- Layout Left End -->
|
||||
</td>
|
||||
<td class="layout_right">
|
||||
<!-- Layout Right Start -->
|
||||
<div class="layout_header"><?= $this->include("templates/{$viewDatas['layout']}/index_header"); ?></div>
|
||||
<div id="container" class="layout_content">
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/index.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<div class="index_body">
|
||||
<?= form_open(current_url(), ["method" => "get"]) ?>
|
||||
<nav class="index_top navbar navbar-expand-lg">
|
||||
<div class="container-fluid">
|
||||
<nav class="condition nav">
|
||||
조건:
|
||||
<?php foreach ($viewDatas['control']['actionFilters'] as $field): ?>
|
||||
<?= $viewDatas['service']->getHelper()->getListFilter($field, $viewDatas['control']['index_filters'][$field] ?? old($field), $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
</nav>
|
||||
<?= $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
|
||||
</div>
|
||||
</nav>
|
||||
<?= form_close() ?>
|
||||
<?= form_open(current_url(), ['id' => 'batchjob_form', 'method' => "post"]) ?>
|
||||
<table class="index_table data table table-bordered table-hover table-striped" data-rtc-resizable-table="reisze_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="index_head_short_column" style="width:40px;">번호</th>
|
||||
<th class="index_head_short_column">
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('site', lang("{$viewDatas['class_path']}.label.site"), $viewDatas) ?>
|
||||
/ <?= $viewDatas['service']->getHelper()->getListLabel('location', lang("{$viewDatas['class_path']}.label.location"), $viewDatas) ?>
|
||||
</th>
|
||||
<th class="index_head_short_column">
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('clientinfo_uid', lang("{$viewDatas['class_path']}.label.clientinfo_uid"), $viewDatas) ?>
|
||||
</th>
|
||||
<th class="index_head_short_column" style="width:650px;">
|
||||
<span class="float-start rounded border border-primary" style="cursor:pointer;" onclick="copyServerPartsToClipboard()">ALL 📋</span>서버정보
|
||||
</th>
|
||||
<th class="index_head_short_column">
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('amount', lang("{$viewDatas['class_path']}.label.sale"), $viewDatas) ?>
|
||||
</th>
|
||||
<th class="index_head_short_column">
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('amount', lang("{$viewDatas['class_path']}.label.amount"), $viewDatas) ?>
|
||||
</th>
|
||||
<th class="index_head_short_column">
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('billing_at', lang("{$viewDatas['class_path']}.label.billing_at"), $viewDatas) ?> / 미지급
|
||||
</th>
|
||||
<th class="index_head_short_column">
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('status', lang("{$viewDatas['class_path']}.label.status"), $viewDatas) ?>
|
||||
</th>
|
||||
<th class="index_head_short_column">
|
||||
<?= $viewDatas['service']->getHelper()->getListLabel('start_at', lang("{$viewDatas['class_path']}.label.start_at"), $viewDatas) ?>
|
||||
</th>
|
||||
<th class="index_head_short_column">작업</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $cnt = 0 ?>
|
||||
<?php foreach ($viewDatas['entities'] as $entity): ?>
|
||||
<?php $viewDatas['entity'] = $entity; ?>
|
||||
<tr <?= $entity->getStatus() === $entity::DEFAULT_STATUS ? "" : 'class="table-danger"' ?>>
|
||||
<?php $num = $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt); ?>
|
||||
<td nowrap><?= $viewDatas['service']->getHelper()->getListButton('modify', $num, $viewDatas) ?></td>
|
||||
<td nowrap>
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('site', $entity->site, $viewDatas) ?>
|
||||
/ <?= $viewDatas['service']->getHelper()->getFieldView('location', $entity->getLocation(), $viewDatas) ?>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('clientinfo_uid', $entity->getClientInfoUID(), $viewDatas) ?>
|
||||
</td>
|
||||
<td nowrap><?= implode("", $viewDatas['childServers'][$entity->getPK()]) ?></td>
|
||||
<td nowrap class="text-end">
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('sale', $entity->getSale(), $viewDatas) ?>
|
||||
</td>
|
||||
<td nowrap class="text-end">
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('amount', $entity->getAmount(), $viewDatas) ?>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('billing_at', $entity->getBillingAt(), $viewDatas) ?>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<?= $viewDatas['service']->getHelper()->getFieldView('status', $entity->getStatus(), $viewDatas) ?>
|
||||
</td>
|
||||
<td nowrap><?= $viewDatas['service']->getHelper()->getFieldView('start_at', $entity->getStartAt(), $viewDatas) ?></td>
|
||||
<td nowrap>
|
||||
<?= $viewDatas['service']->getHelper()->getListButton('alternative', '', $viewDatas) ?>
|
||||
<?= $viewDatas['service']->getHelper()->getListButton('onetime', '', $viewDatas) ?>
|
||||
<?= $viewDatas['service']->getHelper()->getListButton('view', '', $viewDatas) ?>
|
||||
<?= $viewDatas['service']->getHelper()->getListButton('delete', '', $viewDatas) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $cnt++ ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= $this->include("templates/{$viewDatas['layout']}/index_content_bottom"); ?>
|
||||
<?= form_close() ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class=" layout_footer"><?= $this->include("templates/{$viewDatas['layout']}/index_footer"); ?></div>
|
||||
<!-- Layout Right End -->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- Layout Middle End -->
|
||||
<div class="layout_bottom"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?></div>
|
||||
<script src="/js/admin/clipboard.js"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -5,7 +5,7 @@
|
||||
<?= form_open("/admin/search", ['method' => 'GET']) ?>
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item">
|
||||
<input type="text" name="customer" value="" placeholder="고객명검색" id="search_customer" class="form-control" />
|
||||
<input type="text" name="keyword" value="" placeholder="고객명/IP/서버명/기타 검색" id="search_keyword" class="form-control" />
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button type="submit" class="btn btn-default border border-dark"><?= ICONS['SEARCH'] ?></button>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user