dbms_init...1

This commit is contained in:
최준흠 2025-05-12 16:58:29 +09:00
parent d89354b487
commit d5803e18ba
75 changed files with 1439 additions and 841 deletions

View File

@ -94,8 +94,8 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->get('download/(:alpha)', 'PointController::download/$1'); $routes->get('download/(:alpha)', 'PointController::download/$1');
}); });
}); });
$routes->group('device', ['namespace' => 'App\Controllers\Admin\Device'], function ($routes) { $routes->group('device', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->group('line', ['namespace' => 'App\Controllers\Admin\Device'], function ($routes) { $routes->group('line', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->get('/', 'LineController::index', []); $routes->get('/', 'LineController::index', []);
$routes->get('create', 'LineController::create_form'); $routes->get('create', 'LineController::create_form');
$routes->post('create', 'LineController::create'); $routes->post('create', 'LineController::create');
@ -108,7 +108,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'LineController::batchjob_delete'); $routes->post('batchjob_delete', 'LineController::batchjob_delete');
$routes->get('download/(:alpha)', 'LineController::download/$1'); $routes->get('download/(:alpha)', 'LineController::download/$1');
}); });
$routes->group('ip', ['namespace' => 'App\Controllers\Admin\Device'], function ($routes) { $routes->group('ip', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->get('/', 'IpController::index', []); $routes->get('/', 'IpController::index', []);
$routes->get('create', 'IpController::create_form'); $routes->get('create', 'IpController::create_form');
$routes->post('create', 'IpController::create'); $routes->post('create', 'IpController::create');
@ -121,7 +121,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'IpController::batchjob_delete'); $routes->post('batchjob_delete', 'IpController::batchjob_delete');
$routes->get('download/(:alpha)', 'IpController::download/$1'); $routes->get('download/(:alpha)', 'IpController::download/$1');
}); });
$routes->group('network', ['namespace' => 'App\Controllers\Admin\Device'], function ($routes) { $routes->group('network', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->get('/', 'NetworkController::index', []); $routes->get('/', 'NetworkController::index', []);
$routes->get('create', 'NetworkController::create_form'); $routes->get('create', 'NetworkController::create_form');
$routes->post('create', 'NetworkController::create'); $routes->post('create', 'NetworkController::create');
@ -134,7 +134,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'NetworkController::batchjob_delete'); $routes->post('batchjob_delete', 'NetworkController::batchjob_delete');
$routes->get('download/(:alpha)', 'NetworkController::download/$1'); $routes->get('download/(:alpha)', 'NetworkController::download/$1');
}); });
$routes->group('server', ['namespace' => 'App\Controllers\Admin\Device'], function ($routes) { $routes->group('server', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->get('/', 'ServerController::index', []); $routes->get('/', 'ServerController::index', []);
$routes->get('create', 'ServerController::create_form'); $routes->get('create', 'ServerController::create_form');
$routes->post('create', 'ServerController::create'); $routes->post('create', 'ServerController::create');
@ -147,7 +147,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'ServerController::batchjob_delete'); $routes->post('batchjob_delete', 'ServerController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServerController::download/$1'); $routes->get('download/(:alpha)', 'ServerController::download/$1');
}); });
$routes->group('part', ['namespace' => 'App\Controllers\Admin\Device'], function ($routes) { $routes->group('part', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->get('/', 'PartController::index', []); $routes->get('/', 'PartController::index', []);
$routes->get('create', 'PartController::create_form'); $routes->get('create', 'PartController::create_form');
$routes->post('create', 'PartController::create'); $routes->post('create', 'PartController::create');
@ -160,7 +160,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'PartController::batchjob_delete'); $routes->post('batchjob_delete', 'PartController::batchjob_delete');
$routes->get('download/(:alpha)', 'PartController::download/$1'); $routes->get('download/(:alpha)', 'PartController::download/$1');
}); });
$routes->group('software', ['namespace' => 'App\Controllers\Admin\Device'], function ($routes) { $routes->group('software', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->get('/', 'SoftwareController::index', []); $routes->get('/', 'SoftwareController::index', []);
$routes->get('create', 'SoftwareController::create_form'); $routes->get('create', 'SoftwareController::create_form');
$routes->post('create', 'SoftwareController::create'); $routes->post('create', 'SoftwareController::create');

View File

@ -37,10 +37,6 @@ class ClientController extends CustomerController
} }
return $this->_helper; return $this->_helper;
} }
public function getFields(): array
{
return ['name', 'email', 'phone', 'role'];
}
//Index,FieldForm관련 //Index,FieldForm관련
protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation
{ {
@ -92,7 +88,7 @@ class ClientController extends CustomerController
protected function view_process($uid): mixed protected function view_process($uid): mixed
{ {
$fields = [ $fields = [
'fields' => [$this->getService()->getModel()::TITLE, 'email', 'phone', 'role', 'account_balance', 'coupon_balance', 'point_balance', 'status'], 'fields' => [$this->getService()->getModel()->getTitleField(), 'email', 'phone', 'role', 'account_balance', 'coupon_balance', 'point_balance', 'status'],
]; ];
$this->init('view', $fields); $this->init('view', $fields);
return parent::view_process($uid); return parent::view_process($uid);
@ -100,7 +96,7 @@ class ClientController extends CustomerController
protected function index_process(): array protected function index_process(): array
{ {
$fields = [ $fields = [
'fields' => [$this->getService()->getModel()::TITLE, 'email', 'phone', 'role', 'account_balance', 'coupon_balance', 'point_balance', 'status'], 'fields' => [$this->getService()->getModel()->getTitleField(), 'email', 'phone', 'role', 'account_balance', 'coupon_balance', 'point_balance', 'status'],
]; ];
$this->init('index', $fields); $this->init('index', $fields);
return parent::index_process(); return parent::index_process();

View File

@ -1,19 +1,21 @@
<?php <?php
namespace App\Controllers\Admin\Device; namespace App\Controllers\Admin\Equipment;
use App\Controllers\Admin\AdminController; use App\Controllers\Admin\AdminController;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Services\Device\LineService; use App\Services\Equipment\LineService;
use App\Services\Device\ServerService; use App\Services\Equipment\ServerService;
use App\Services\Customer\ClientService;
abstract class DeviceController extends AdminController abstract class EquipmentController extends AdminController
{ {
private ?ServerService $_serverService = null; private ?ServerService $_serverService = null;
private ?LineService $_lineService = null; private ?LineService $_lineService = null;
private ?ClientService $_clientService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
@ -34,17 +36,19 @@ abstract class DeviceController extends AdminController
} }
return $this->_lineService; return $this->_lineService;
} }
final public function getClientService(): ClientService
{
if (!$this->_clientService) {
$this->_clientService = new ClientService($this->request);
}
return $this->_clientService;
}
//Index,FieldForm관련 //Index,FieldForm관련
protected function getFormFieldOption(string $field, array $options = []): array protected function getFormFieldOption(string $field, array $options = []): array
{ {
switch ($field) { switch ($field) {
case 'serverinfo_uid': case 'clientinfo_uid':
$options[$field] = $this->getServerService()->getFormFieldOption($field); $options[$field] = $this->getClientService()->getFormFieldOption($field);
// echo $this->getUserModel()->getLastQuery();
// dd($options);
break;
case 'lineinfo_uid':
$options[$field] = $this->getLineService()->getFormFieldOption($field);
// echo $this->getUserModel()->getLastQuery(); // echo $this->getUserModel()->getLastQuery();
// dd($options); // dd($options);
break; break;
@ -54,5 +58,4 @@ abstract class DeviceController extends AdminController
} }
return $options; return $options;
} }
//Index,FieldForm관련
} }

View File

@ -1,16 +1,16 @@
<?php <?php
namespace App\Controllers\Admin\Device; namespace App\Controllers\Admin\Equipment;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation; use CodeIgniter\Validation\Validation;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Helpers\Device\IpHelper; use App\Helpers\Equipment\IpHelper;
use App\Services\Device\IpService; use App\Services\Equipment\IpService;
class IpController extends DeviceController class IpController extends EquipmentController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
@ -35,11 +35,19 @@ class IpController extends DeviceController
return $this->_helper; return $this->_helper;
} }
//Index,FieldForm관련 //Index,FieldForm관련
protected function setOrcerByForList() protected function setOrcerByForList()
{ {
//OrderBy 처리 //OrderBy 처리
$this->getService()->getModel()->orderBy('INET_ATON(ip)', 'ASC', false); $this->getService()->getModel()->orderBy('INET_ATON(ip)', 'ASC', false);
parent::setOrcerByForList(); parent::setOrcerByForList();
} }
protected function index_process(): array
{
$fields = [
'fields' => ['lineinfo_uid', $this->getService()->getModel()->getTitleField(), 'price', 'status', 'updated_at'],
];
$this->init('index', $fields);
return parent::index_process();
}
} }

View File

@ -1,18 +1,18 @@
<?php <?php
namespace App\Controllers\Admin\Device; namespace App\Controllers\Admin\Equipment;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Entities\Device\LineEntity; use App\Entities\Equipment\LineEntity;
use App\Helpers\Device\LineHelper; use App\Helpers\Equipment\LineHelper;
use App\Services\Device\LineService; use App\Services\Equipment\LineService;
use App\Services\Device\IpService; use App\Services\Equipment\IpService;
use App\Entities\Device\IpEntity; use App\Entities\Equipment\IpEntity;
class LineController extends DeviceController class LineController extends EquipmentController
{ {
private ?IpService $_ipService = null; private ?IpService $_ipService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)

View File

@ -1,16 +1,16 @@
<?php <?php
namespace App\Controllers\Admin\Device; namespace App\Controllers\Admin\Equipment;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation; use CodeIgniter\Validation\Validation;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Helpers\Device\NetworkHelper; use App\Helpers\Equipment\NetworkHelper;
use App\Services\Device\NetworkService; use App\Services\Equipment\NetworkService;
class NetworkController extends DeviceController class NetworkController extends EquipmentController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
@ -35,18 +35,13 @@ class NetworkController extends DeviceController
return $this->_helper; return $this->_helper;
} }
//Index,FieldForm관련 //Index,FieldForm관련
protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation protected function index_process(): array
{ {
switch ($field) { $fields = [
case 'role': 'fields' => ['code', 'clientinfo_uid', 'type', $this->getService()->getModel()->getTitleField(), 'price', 'status', 'description'],
//아래 Rule Array는 필드명.* checkbox를 사용 ];
$validation->setRule("{$field}.*", $field, $rule); $this->init('index', $fields);
break; $this->modal_type = 'modal_iframe';
default: return parent::index_process();
$validation = parent::setValidation($validation, $action, $field, $rule);
break;
}
return $validation;
} }
//Index,FieldForm관련.
} }

View File

@ -1,16 +1,16 @@
<?php <?php
namespace App\Controllers\Admin\Device; namespace App\Controllers\Admin\Equipment;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation; use CodeIgniter\Validation\Validation;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Helpers\Device\PartHelper; use App\Helpers\Equipment\PartHelper;
use App\Services\Device\PartService; use App\Services\Equipment\PartService;
class PartController extends DeviceController class PartController extends EquipmentController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {

View File

@ -1,16 +1,16 @@
<?php <?php
namespace App\Controllers\Admin\Device; namespace App\Controllers\Admin\Equipment;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation; use CodeIgniter\Validation\Validation;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Helpers\Device\ServerHelper; use App\Helpers\Equipment\ServerHelper;
use App\Services\Device\ServerService; use App\Services\Equipment\ServerService;
class ServerController extends DeviceController class ServerController extends EquipmentController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
@ -35,18 +35,13 @@ class ServerController extends DeviceController
return $this->_helper; return $this->_helper;
} }
//Index,FieldForm관련 //Index,FieldForm관련
protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation protected function index_process(): array
{ {
switch ($field) { $fields = [
case 'role': 'fields' => ['code', 'clientinfo_uid', 'type', $this->getService()->getModel()->getTitleField(), 'price', 'status', 'description'],
//아래 Rule Array는 필드명.* checkbox를 사용 ];
$validation->setRule("{$field}.*", $field, $rule); $this->init('index', $fields);
break; $this->modal_type = 'modal_iframe';
default: return parent::index_process();
$validation = parent::setValidation($validation, $action, $field, $rule);
break;
}
return $validation;
} }
//Index,FieldForm관련.
} }

View File

@ -1,16 +1,16 @@
<?php <?php
namespace App\Controllers\Admin\Device; namespace App\Controllers\Admin\Equipment;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation; use CodeIgniter\Validation\Validation;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Helpers\Device\SoftwareHelper; use App\Helpers\Equipment\SoftwareHelper;
use App\Services\Device\SoftwareService; use App\Services\Equipment\SoftwareService;
class SoftwareController extends DeviceController class SoftwareController extends EquipmentController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {

View File

@ -66,7 +66,7 @@ class MyLogController extends AdminController
protected function view_process($uid): mixed protected function view_process($uid): mixed
{ {
$fields = [ $fields = [
'fields' => ['user_uid', 'class_name', 'method_name', $this->getService()->getModel()::TITLE, 'status', 'created_at', 'content'], 'fields' => ['user_uid', 'class_name', 'method_name', $this->getService()->getModel()->getTitleField(), 'status', 'created_at', 'content'],
]; ];
$this->init('view', $fields); $this->init('view', $fields);
return parent::view_process($uid); return parent::view_process($uid);
@ -74,7 +74,7 @@ class MyLogController extends AdminController
protected function index_process(): array protected function index_process(): array
{ {
$fields = [ $fields = [
'fields' => ['user_uid', 'class_name', 'method_name', $this->getService()->getModel()::TITLE, 'status', 'created_at'], 'fields' => ['user_uid', 'class_name', 'method_name', $this->getService()->getModel()->getTitleField(), 'status', 'created_at'],
]; ];
$this->init('index', $fields); $this->init('index', $fields);
return parent::index_process(); return parent::index_process();

View File

@ -54,11 +54,6 @@ class UserController extends AdminController
} }
//Index,FieldForm관련. //Index,FieldForm관련.
public function getFields(): array
{
return ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'];
}
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
{ {
switch ($action) { switch ($action) {
@ -78,7 +73,7 @@ class UserController extends AdminController
protected function view_process($uid): mixed protected function view_process($uid): mixed
{ {
$fields = [ $fields = [
'fields' => ['id', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status'], 'fields' => ['id', $this->getService()->getModel()->getTitleField(), 'email', 'mobile', 'role', 'status'],
]; ];
$this->init('view', $fields); $this->init('view', $fields);
return parent::view_process($uid); return parent::view_process($uid);
@ -86,7 +81,7 @@ class UserController extends AdminController
protected function index_process(): array protected function index_process(): array
{ {
$fields = [ $fields = [
'fields' => ['id', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status'], 'fields' => ['id', $this->getService()->getModel()->getTitleField(), 'email', 'mobile', 'role', 'status'],
]; ];
$this->init('index', $fields); $this->init('index', $fields);
return parent::index_process(); return parent::index_process();

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +0,0 @@
<?php
namespace App\Entities\Device;
use App\Models\Device\NetworkModel;
class NetworkEntity extends DeviceEntity
{
const PK = NetworkModel::PK;
const TITLE = NetworkModel::TITLE;
public function getAmount()
{
return $this->attributes['amount'];
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace App\Entities\Device;
use App\Models\Device\RackModel;
class RackEntity extends DeviceEntity
{
const PK = RackModel::PK;
const TITLE = RackModel::TITLE;
public function getAmount()
{
return $this->attributes['amount'];
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace App\Entities\Device;
use App\Models\Device\ServerModel;
class ServerEntity extends DeviceEntity
{
const PK = ServerModel::PK;
const TITLE = ServerModel::TITLE;
public function getAmount()
{
return $this->attributes['amount'];
}
}

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Entities\Device; namespace App\Entities\Equipment;
use App\Entities\CommonEntity; use App\Entities\CommonEntity;
abstract class DeviceEntity extends CommonEntity abstract class EquipmentEntity extends CommonEntity
{ {
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Entities\Device; namespace App\Entities\Equipment;
use App\Models\Device\IpModel; use App\Models\Equipment\IpModel;
class IpEntity extends DeviceEntity class IpEntity extends EquipmentEntity
{ {
const PK = IpModel::PK; const PK = IpModel::PK;
const TITLE = IpModel::TITLE; const TITLE = IpModel::TITLE;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Entities\Device; namespace App\Entities\Equipment;
use App\Models\Device\LineModel; use App\Models\Equipment\LineModel;
class LineEntity extends DeviceEntity class LineEntity extends EquipmentEntity
{ {
const PK = LineModel::PK; const PK = LineModel::PK;
const TITLE = LineModel::TITLE; const TITLE = LineModel::TITLE;

View File

@ -0,0 +1,11 @@
<?php
namespace App\Entities\Equipment;
use App\Models\Equipment\NetworkModel;
class NetworkEntity extends EquipmentEntity
{
const PK = NetworkModel::PK;
const TITLE = NetworkModel::TITLE;
}

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Entities\Device; namespace App\Entities\Equipment;
use App\Models\Device\PartModel; use App\Models\Equipment\PartModel;
class PartEntity extends DeviceEntity class PartEntity extends EquipmentEntity
{ {
const PK = PartModel::PK; const PK = PartModel::PK;
const TITLE = PartModel::TITLE; const TITLE = PartModel::TITLE;

View File

@ -0,0 +1,11 @@
<?php
namespace App\Entities\Equipment;
use App\Models\Equipment\ServerModel;
class ServerEntity extends EquipmentEntity
{
const PK = ServerModel::PK;
const TITLE = ServerModel::TITLE;
}

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Entities\Device; namespace App\Entities\Equipment;
use App\Models\Device\SoftwareModel; use App\Models\Equipment\SoftwareModel;
class SoftwareEntity extends DeviceEntity class SoftwareEntity extends EquipmentEntity
{ {
const PK = SoftwareModel::PK; const PK = SoftwareModel::PK;
const TITLE = SoftwareModel::TITLE; const TITLE = SoftwareModel::TITLE;

View File

@ -244,11 +244,12 @@ class CommonHelper
break; break;
case 'updated_at': case 'updated_at':
case 'created_at': case 'created_at':
case 'manufactur_at':
$extra_class = isset($extras['class']) ? $extras['class'] . ' calender' : 'calender'; $extra_class = isset($extras['class']) ? $extras['class'] . ' calender' : 'calender';
$form = form_input($field, $value ?? "", ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]); $form = form_input($field, $value ?? "", ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
break; break;
case 'description': case 'description':
$extra_class = isset($extras['class']) ? $extras['class'] . ' calender' : 'calender'; $extra_class = isset($extras['class']) ? $extras['class'] . ' tinymce' : 'tinymce';
$form = form_textarea($field, $value ?? "", ['id' => $field, 'class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]); $form = form_textarea($field, $value ?? "", ['id' => $field, 'class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
break; break;
default: default:
@ -311,6 +312,7 @@ class CommonHelper
break; break;
case 'updated_at': case 'updated_at':
case 'created_at': case 'created_at':
case 'manufactur_at':
$value = $value ? date("Y-m-d", strtotime($value)) : ""; $value = $value ? date("Y-m-d", strtotime($value)) : "";
break; break;
default: default:

View File

@ -1,16 +0,0 @@
<?php
namespace App\Helpers\Device;
use App\Models\Device\NetworkModel;
use CodeIgniter\HTTP\IncomingRequest;
class NetworkHelper extends DeviceHelper
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
$this->setTitleField(field: NetworkModel::TITLE);
}
}

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Helpers\Device; namespace App\Helpers\Equipment;
use App\Helpers\CommonHelper; use App\Helpers\CommonHelper;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class DeviceHelper extends CommonHelper class EquipmentHelper extends CommonHelper
{ {
protected function __construct(?IncomingRequest $request = null) protected function __construct(?IncomingRequest $request = null)
{ {

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Helpers\Device; namespace App\Helpers\Equipment;
use App\Models\Device\IpModel; use App\Models\Equipment\IpModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class IpHelper extends DeviceHelper class IpHelper extends EquipmentHelper
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Helpers\Device; namespace App\Helpers\Equipment;
use App\Models\Device\LineModel; use App\Models\Equipment\LineModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class LineHelper extends DeviceHelper class LineHelper extends EquipmentHelper
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)

View File

@ -0,0 +1,34 @@
<?php
namespace App\Helpers\Equipment;
use App\Models\Equipment\NetworkModel;
use CodeIgniter\HTTP\IncomingRequest;
class NetworkHelper extends EquipmentHelper
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
$this->setTitleField(field: NetworkModel::TITLE);
}
// public function getListButton(string $action, array $viewDatas, array $extras = []): string
// {
// switch ($action) {
// case 'create':
// $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
// $action = anchor(
// current_url() . '/' . $action . '?' . $this->request->getUri()->getQuery(),
// '입력',
// $extras
// );
// break;
// default:
// $action = parent::getListButton($action, $viewDatas, $extras);
// break;
// }
// return $action;
// }
}

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Helpers\Device; namespace App\Helpers\Equipment;
use App\Models\Device\PartModel; use App\Models\Equipment\PartModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class PartHelper extends DeviceHelper class PartHelper extends EquipmentHelper
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Helpers\Device; namespace App\Helpers\Equipment;
use App\Models\Device\ServerModel; use App\Models\Equipment\ServerModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class ServerHelper extends DeviceHelper class ServerHelper extends EquipmentHelper
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Helpers\Device; namespace App\Helpers\Equipment;
use App\Models\Device\SoftwareModel; use App\Models\Equipment\SoftwareModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class SoftwareHelper extends DeviceHelper class SoftwareHelper extends EquipmentHelper
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)

View File

@ -2,9 +2,10 @@
return [ return [
'title' => "네트워크장비정보", 'title' => "네트워크장비정보",
'label' => [ 'label' => [
'clientinfo_uid' => "소유자명",
'code' => "코드", 'code' => "코드",
'type' => "종류", 'type' => "종류",
'model' => "제목", 'model' => "모델",
'price' => "금액", 'price' => "금액",
'description' => "설명", 'description' => "설명",
'status' => "상태", 'status' => "상태",
@ -18,7 +19,9 @@ return [
"TYPE" => [ "TYPE" => [
"L2" => "L2", "L2" => "L2",
"L3" => "L3", "L3" => "L3",
"Backbone" => "Backbone", "L4" => "L4",
"Router" => "Router",
"colocation" => "코로케이션",
], ],
"STATUS" => [ "STATUS" => [
"use" => "사용", "use" => "사용",

View File

@ -0,0 +1,34 @@
<?php
return [
'title' => "서버장비정보",
'label' => [
'clientinfo_uid' => "소유자명",
'code' => "코드",
'type' => "종류",
'model' => "모델",
'price' => "금액",
'description' => "설명",
'status' => "상태",
'manufactur_at' => "제조일",
'updated_at' => "수정일",
'created_at' => "작성일",
],
'DEFAULTS' => [
'type' => 'L2',
'status' => "use"
],
"TYPE" => [
"normal" => "일반",
"kcs" => "KCS",
"vpc" => "VPC",
"jcs" => "JCS",
"VPN" => "VPN",
"defence" => "방어",
"colocation" => "코로케이션",
],
"STATUS" => [
"use" => "사용",
"pause" => "수리중",
"occupied" => "사용중",
],
];

View File

@ -50,8 +50,6 @@ abstract class CommonModel extends Model
{ {
parent::__construct(); parent::__construct();
} }
abstract public function getFilterFields(): array;
abstract public function getBatchJobFields(): array;
final public function getTable(): string final public function getTable(): string
{ {
return constant("static::TABLE"); return constant("static::TABLE");
@ -207,6 +205,8 @@ abstract class CommonModel extends Model
foreach (array_keys($formDatas) as $field) { foreach (array_keys($formDatas) as $field) {
$entity->$field = $this->convertEntityData($field, $formDatas); $entity->$field = $this->convertEntityData($field, $formDatas);
} }
//수정일추가
$entity->updated_at = date("Y-m-d H:i:s");
LogCollector::debug("[{$entity->getPK()}/{$entity->getTitle()}] 변경 후 내용"); LogCollector::debug("[{$entity->getPK()}/{$entity->getTitle()}] 변경 후 내용");
LogCollector::debug(var_export($entity->toArray(), true)); LogCollector::debug(var_export($entity->toArray(), true));
return $this->save_process($entity); return $this->save_process($entity);

View File

@ -18,19 +18,12 @@ class AccountModel extends CustomerModel
"alias", "alias",
"title", "title",
"amount", "amount",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -20,20 +20,13 @@ class ClientModel extends CustomerModel
"account_balance", "account_balance",
"coupon_balance", "coupon_balance",
"point_balance", "point_balance",
"status" "status",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ['role', 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -17,19 +17,12 @@ class CouponModel extends CustomerModel
"status", "status",
"title", "title",
"amount", "amount",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -17,19 +17,12 @@ class PointModel extends CustomerModel
"status", "status",
"title", "title",
"amount", "amount",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Device; namespace App\Models\Equipment;
use App\Models\CommonModel; use App\Models\CommonModel;
abstract class DeviceModel extends CommonModel abstract class EquipmentModel extends CommonModel
{ {
protected function __construct() protected function __construct()
{ {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Device; namespace App\Models\Equipment;
use App\Entities\Device\IpEntity; use App\Entities\Equipment\IpEntity;
class IpModel extends DeviceModel class IpModel extends EquipmentModel
{ {
const TABLE = "ipinfo"; const TABLE = "ipinfo";
const PK = "uid"; const PK = "uid";
@ -17,19 +17,12 @@ class IpModel extends DeviceModel
"ip", "ip",
"price", "price",
"status", "status",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["lineinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Device; namespace App\Models\Equipment;
use App\Entities\Device\LineEntity; use App\Entities\Equipment\LineEntity;
class LineModel extends DeviceModel class LineModel extends EquipmentModel
{ {
const TABLE = "lineinfo"; const TABLE = "lineinfo";
const PK = "uid"; const PK = "uid";
@ -18,19 +18,12 @@ class LineModel extends DeviceModel
"bandwith", "bandwith",
"price", "price",
"status", "status",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["type", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Device; namespace App\Models\Equipment;
use App\Entities\Device\NetworkEntity; use App\Entities\Equipment\NetworkEntity;
class NetworkModel extends DeviceModel class NetworkModel extends EquipmentModel
{ {
const TABLE = "networkinfo"; const TABLE = "networkinfo";
const PK = "uid"; const PK = "uid";
@ -13,31 +13,28 @@ class NetworkModel extends DeviceModel
protected $primaryKey = self::PK; protected $primaryKey = self::PK;
protected $returnType = NetworkEntity::class; protected $returnType = NetworkEntity::class;
protected $allowedFields = [ protected $allowedFields = [
"clientinfo_uid",
"code", "code",
"type", "type",
"model", "model",
"price", "price",
"description",
"status", "status",
"description",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["type", 'status'];
}
public function getBatchJobFields(): array
{
return ["type", 'status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true)); throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
} }
switch ($field) { switch ($field) {
case "clientinfo_uid":
$rule = "if_exist|numeric";
break;
case "price": case "price":
$rule = "required|numeric"; $rule = "required|numeric";
break; break;
@ -45,6 +42,9 @@ class NetworkModel extends DeviceModel
case "model": case "model":
$rule = "required|trim|string"; $rule = "required|trim|string";
break; break;
case "type":
$rule = "required|in_list[L2,L3,L4,Router]";
break;
case "status": case "status":
$rule = "required|in_list[use,pause,occupied]"; $rule = "required|in_list[use,pause,occupied]";
break; break;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Device; namespace App\Models\Equipment;
use App\Entities\Device\PartEntity; use App\Entities\Equipment\PartEntity;
class PartModel extends DeviceModel class PartModel extends EquipmentModel
{ {
const TABLE = "partinfo"; const TABLE = "partinfo";
const PK = "uid"; const PK = "uid";
@ -17,19 +17,12 @@ class PartModel extends DeviceModel
"status", "status",
"title", "title",
"amount", "amount",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -1,35 +1,32 @@
<?php <?php
namespace App\Models\Device; namespace App\Models\Equipment;
use App\Entities\Device\ServerEntity; use App\Entities\Equipment\ServerEntity;
class ServerModel extends DeviceModel class ServerModel extends EquipmentModel
{ {
const TABLE = "serverinfo"; const TABLE = "serverinfo";
const PK = "uid"; const PK = "uid";
const TITLE = "title"; const TITLE = "model";
protected $table = self::TABLE; protected $table = self::TABLE;
protected $primaryKey = self::PK; protected $primaryKey = self::PK;
protected $returnType = ServerEntity::class; protected $returnType = ServerEntity::class;
protected $allowedFields = [ protected $allowedFields = [
"clientinfo_uid", "clientinfo_uid",
"code",
"type",
"model",
"manufactur_at",
"price",
"status", "status",
"title", "description",
"amount", "updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {
@ -37,14 +34,26 @@ class ServerModel extends DeviceModel
} }
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": $rule = "if_exist|numeric";
break;
case "price":
$rule = "required|numeric"; $rule = "required|numeric";
break; break;
case "title": case "code":
case "model":
$rule = "required|trim|string"; $rule = "required|trim|string";
break; break;
case "type":
$rule = "required|in_list[normal,kcs,vpc,jcs,vpn,defence,clocation]";
break;
case "status": case "status":
$rule = "required|in_list[in,out]"; $rule = "required|in_list[use,pause,occupied]";
break;
case "description":
$rule = "if_exist|trim|string";
break;
case "manufactur_at":
$rule = "required|valid_date";
break; break;
default: default:
$rule = parent::getFieldRule($action, $field); $rule = parent::getFieldRule($action, $field);

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Device; namespace App\Models\Equipment;
use App\Entities\Device\SoftwareEntity; use App\Entities\Equipment\SoftwareEntity;
class SoftwareModel extends DeviceModel class SoftwareModel extends EquipmentModel
{ {
const TABLE = "serverinfo"; const TABLE = "serverinfo";
const PK = "uid"; const PK = "uid";
@ -17,19 +17,12 @@ class SoftwareModel extends DeviceModel
"status", "status",
"title", "title",
"amount", "amount",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -19,20 +19,13 @@ class MyLogModel extends CommonModel
"method_name", "method_name",
"title", "title",
"content", "content",
"status" "status",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ['user_uid', 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -20,20 +20,13 @@ class UserModel extends CommonModel
"email", "email",
"mobile", "mobile",
"role", "role",
"status" "status",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function getFilterFields(): array
{
return ['role', 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getFieldRule(string $action, string $field): string public function getFieldRule(string $action, string $field): string
{ {
if (is_array($field)) { if (is_array($field)) {

View File

@ -22,7 +22,8 @@ class UserSNSModel extends CommonModel
"name", "name",
"email", "email",
"detail", "detail",
"status" "status",
"updated_at"
]; ];
public function __construct() public function __construct()
{ {

View File

@ -36,6 +36,19 @@ class GoogleService extends AuthService
return new UserEntity(); return new UserEntity();
} }
public function getFields(): array
{
return ['id', 'passwd'];
}
public function getFilterFields(): array
{
return [];
}
public function getBatchJobFields(): array
{
return [];
}
public function checkUser(string $access_code): UserEntity public function checkUser(string $access_code): UserEntity
{ {
try { try {

View File

@ -24,6 +24,21 @@ class LocalService extends AuthService
{ {
return new UserEntity(); return new UserEntity();
} }
public function getFields(): array
{
return ['id', 'passwd'];
}
public function getFilterFields(): array
{
return [];
}
public function getBatchJobFields(): array
{
return [];
}
public function checkUser(array $formDatas): UserEntity public function checkUser(array $formDatas): UserEntity
{ {
$entity = $this->getEntity(['id' => $formDatas['id']]); $entity = $this->getEntity(['id' => $formDatas['id']]);

View File

@ -18,6 +18,9 @@ abstract class CommonService
abstract public function getModelClass(): mixed; abstract public function getModelClass(): mixed;
abstract public function getEntityClass(): mixed; abstract public function getEntityClass(): mixed;
abstract public function getClassName(): string; abstract public function getClassName(): string;
abstract public function getFields(): array;
abstract public function getFilterFields(): array;
abstract public function getBatchJobFields(): array;
final public function __get($name) final public function __get($name)
{ {
if (!array_key_exists($name, $this->_serviceDatas)) { if (!array_key_exists($name, $this->_serviceDatas)) {
@ -44,18 +47,6 @@ abstract class CommonService
} }
return $this->_model; return $this->_model;
} }
public function getFields(): array
{
return $this->getModel()->getFields();
}
public function getFilterFields(): array
{
return $this->getModel()->getFilterFields();
}
public function getBatchJobFields(): array
{
return $this->getModel()->getBatchJobFields();
}
final public function getEntity(mixed $where, $isThrow = true): mixed final public function getEntity(mixed $where, $isThrow = true): mixed
{ {
$entity = is_array($where) ? $this->getModel()->where($where)->first() : $this->getModel()->find($where); $entity = is_array($where) ? $this->getModel()->where($where)->first() : $this->getModel()->find($where);

View File

@ -25,4 +25,22 @@ class AccountService extends CustomerService
{ {
return new AccountEntity(); return new AccountEntity();
} }
public function getFields(): array
{
return [
"clientinfo_uid",
"status",
"alias",
"title",
"amount"
];
}
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
} }

View File

@ -42,4 +42,16 @@ class ClientService extends CustomerService
// die(var_export($formDatas, true)); // die(var_export($formDatas, true));
return parent::modify($entity, $formDatas); return parent::modify($entity, $formDatas);
} }
public function getFields(): array
{
return ['name', 'email', 'phone', 'role'];
}
public function getFilterFields(): array
{
return ['role', 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
} }

View File

@ -25,4 +25,21 @@ class CouponService extends CustomerService
{ {
return new CouponEntity(); return new CouponEntity();
} }
public function getFields(): array
{
return [
"clientinfo_uid",
"status",
"title",
"amount",
];
}
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
} }

View File

@ -25,4 +25,21 @@ class PointService extends CustomerService
{ {
return new PointEntity(); return new PointEntity();
} }
public function getFields(): array
{
return [
"clientinfo_uid",
"status",
"title",
"amount"
];
}
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
} }

View File

@ -1,28 +0,0 @@
<?php
namespace App\Services\Device;
use App\Entities\Device\NetworkEntity;
use App\Models\Device\NetworkModel;
use CodeIgniter\HTTP\IncomingRequest;
class NetworkService extends DeviceService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Network";
}
public function getModelClass(): NetworkModel
{
return new NetworkModel();
}
public function getEntityClass(): NetworkEntity
{
return new NetworkEntity();
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace App\Services\Device;
use App\Entities\Device\ServerEntity;
use App\Models\Device\ServerModel;
use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Device\DeviceService; // Ensure this path is correct and the class exists or create the class if missing
class ServerService extends DeviceService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Server";
}
public function getModelClass(): ServerModel
{
return new ServerModel();
}
public function getEntityClass(): ServerEntity
{
return new ServerEntity();
}
}

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Services\Device; namespace App\Services\Equipment;
use App\Services\CommonService; use App\Services\CommonService;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
abstract class DeviceService extends CommonService abstract class EquipmentService extends CommonService
{ {
protected function __construct(?IncomingRequest $request = null) protected function __construct(?IncomingRequest $request = null)
{ {
@ -13,6 +13,6 @@ abstract class DeviceService extends CommonService
} }
public function getClassName(): string public function getClassName(): string
{ {
return "Device"; return "Equipment";
} }
} }

View File

@ -1,12 +1,12 @@
<?php <?php
namespace App\Services\Device; namespace App\Services\Equipment;
use App\Entities\Device\IpEntity; use App\Entities\Equipment\IpEntity;
use App\Models\Device\IpModel; use App\Models\Equipment\IpModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class IpService extends DeviceService class IpService extends EquipmentService
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)
@ -25,4 +25,21 @@ class IpService extends DeviceService
{ {
return new IpEntity(); return new IpEntity();
} }
public function getFields(): array
{
return [
"lineinfo_uid",
"ip",
"price",
"status",
];
}
public function getFilterFields(): array
{
return ["lineinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
} }

View File

@ -1,12 +1,12 @@
<?php <?php
namespace App\Services\Device; namespace App\Services\Equipment;
use App\Entities\Device\LineEntity; use App\Entities\Equipment\LineEntity;
use App\Models\Device\LineModel; use App\Models\Equipment\LineModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class LineService extends DeviceService class LineService extends EquipmentService
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)
@ -25,4 +25,22 @@ class LineService extends DeviceService
{ {
return new LineEntity(); return new LineEntity();
} }
public function getFields(): array
{
return [
"type",
"title",
"bandwith",
"price",
"status",
];
}
public function getFilterFields(): array
{
return ["type", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
} }

View File

@ -0,0 +1,48 @@
<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\NetworkEntity;
use App\Models\Equipment\NetworkModel;
use CodeIgniter\HTTP\IncomingRequest;
class NetworkService extends EquipmentService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Network";
}
public function getModelClass(): NetworkModel
{
return new NetworkModel();
}
public function getEntityClass(): NetworkEntity
{
return new NetworkEntity();
}
public function getFields(): array
{
return [
"clientinfo_uid",
"code",
"type",
"model",
"price",
"status",
"description",
];
}
public function getFilterFields(): array
{
return ["clientinfo_uid", "type", 'status'];
}
public function getBatchJobFields(): array
{
return ["clientinfo_uid", "type", 'status'];
}
}

View File

@ -1,12 +1,12 @@
<?php <?php
namespace App\Services\Device; namespace App\Services\Equipment;
use App\Entities\Device\PartEntity; use App\Entities\Equipment\PartEntity;
use App\Models\Device\PartModel; use App\Models\Equipment\PartModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class PartService extends DeviceService class PartService extends EquipmentService
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)
@ -25,4 +25,21 @@ class PartService extends DeviceService
{ {
return new PartEntity(); return new PartEntity();
} }
public function getFields(): array
{
return [
"clientinfo_uid",
"status",
"title",
"amount",
];
}
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
} }

View File

@ -0,0 +1,50 @@
<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\ServerEntity;
use App\Models\Equipment\ServerModel;
use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Equipment\EquipmentService; // Ensure this path is correct and the class exists or create the class if missing
class ServerService extends EquipmentService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Server";
}
public function getModelClass(): ServerModel
{
return new ServerModel();
}
public function getEntityClass(): ServerEntity
{
return new ServerEntity();
}
public function getFields(): array
{
return [
"clientinfo_uid",
"code",
"type",
"model",
"manufactur_at",
"price",
"status",
"description",
];
}
public function getFilterFields(): array
{
return ["clientinfo_uid", "type", 'status'];
}
public function getBatchJobFields(): array
{
return ["clientinfo_uid", 'type', 'status'];
}
}

View File

@ -1,12 +1,12 @@
<?php <?php
namespace App\Services\Device; namespace App\Services\Equipment;
use App\Entities\Device\SoftwareEntity; use App\Entities\Equipment\SoftwareEntity;
use App\Models\Device\SoftwareModel; use App\Models\Equipment\SoftwareModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
class SoftwareService extends DeviceService class SoftwareService extends EquipmentService
{ {
protected ?IncomingRequest $request = null; protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)
@ -25,4 +25,21 @@ class SoftwareService extends DeviceService
{ {
return new SoftwareEntity(); return new SoftwareEntity();
} }
public function getFields(): array
{
return [
"clientinfo_uid",
"status",
"title",
"amount",
];
}
public function getFilterFields(): array
{
return ["clientinfo_uid", 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
} }

View File

@ -27,6 +27,26 @@ class MyLogService extends CommonService
return new MyLogEntity(); return new MyLogEntity();
} }
public function getFields(): array
{
return [
"user_uid",
"class_name",
"method_name",
"title",
"content",
"status",
];
}
public function getFilterFields(): array
{
return ['user_uid', 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function save($service, string $method, AuthService $myauth, string $title): MyLogEntity public function save($service, string $method, AuthService $myauth, string $title): MyLogEntity
{ {
$formDatas = [ $formDatas = [

View File

@ -26,4 +26,25 @@ class UserSNSService extends CommonService
{ {
return new UserSNSEntity(); return new UserSNSEntity();
} }
public function getFields(): array
{
return [
"site",
"user_uid",
"id",
"name",
"email",
"detail",
"status",
];
}
public function getFilterFields(): array
{
return [];
}
public function getBatchJobFields(): array
{
return [];
}
} }

View File

@ -25,6 +25,20 @@ class UserService extends CommonService
{ {
return new UserEntity(); return new UserEntity();
} }
public function getFields(): array
{
return ['id', 'passwd', 'confirmpassword', $this->getModel()->getTitleField(), 'email', 'mobile', 'role'];
}
public function getFilterFields(): array
{
return ['role', 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function create(array $formDatas, mixed $entity = null): UserEntity public function create(array $formDatas, mixed $entity = null): UserEntity
{ {
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);

View File

@ -1,41 +1,25 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?> <?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?> <?= $this->section('content') ?>
<!DOCTYPE html> <div id="container" class="content">
<html lang="ko"> <link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/js/<?= $viewDatas['layout'] ?>/form.js" referrerpolicy="origin"></script>
<body> <script src="/assets/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
<div id="container" class="content"> <?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" /> <div class="action_form">
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?> <table class="table table-bordered">
<div class="action_form"> <?php foreach ($viewDatas['fields'] as $field): ?>
<table class="table table-bordered"> <tr>
<?php foreach ($viewDatas['fields'] as $field): ?> <th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<tr> <td nowrap class="text-start">
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th> <?= $viewDatas['helper']->getFieldForm($field, old($field), $viewDatas) ?>
<td nowrap class="text-start"> <span><?= validation_show_error($field); ?></span>
<?= $viewDatas['helper']->getFieldForm($field, old($field), $viewDatas) ?> </td>
<div><?= validation_show_error($field); ?></div> </tr>
</td> <?php endforeach; ?>
</tr> </table>
<?php endforeach; ?> <div class="text-center"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></div>
</table> <?= form_close(); ?>
<div class="text-center"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></div>
<?= form_close(); ?>
</div>
<?php if (session()->has('error')): ?><div class="alert alert-info text-start"><?= nl2br(session('error')) ?></div><?php endif; ?>
</div> </div>
<!-- <script src="/assets/tinymce/tinymce.min.js" referrerpolicy="origin"></script> <?php if ($error = session('error')): ?><?= $viewDatas['helper']->alert($error) ?><?php endif ?>
<script> </div>
tinymce.init({
selector: 'textarea#description', // Replace this CSS selector to match the placeholder element for TinyMCE
license_key: 'gpl',
// inline: true,
plugins: 'advlist autolink lists link image charmap preview anchor',
toolbar: 'undo redo | accordion accordionremove | importword exportword exportpdf | math | blocks fontfamily fontsize | bold italic underline strikethrough | align numlist bullist | link image | table media | lineheight outdent indent| forecolor backcolor removeformat | charmap emoticons | code fullscreen preview | save print | pagebreak anchor codesample | ltr rtl',
menubar: 'file edit view insert format tools table help'
});
</script> -->
</body>
</html>
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -47,12 +47,12 @@
<?= form_close() ?> <?= form_close() ?>
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div> <div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
</div> </div>
<div class="index_bottom"><?= $this->include("templates/common/modal_fetch"); ?></div> <div class="index_bottom"><?= $this->include("templates/common/" . (isset($viewDatas['modal_type']) ? $viewDatas['modal_type'] : 'modal_fetch')); ?></div>
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script> <script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script>
</div> </div>
<div class="layout_footer"><?= $this->include("templates/{$viewDatas['layout']}/index_footer"); ?></div> <div class="layout_footer"><?= $this->include("templates/{$viewDatas['layout']}/index_footer"); ?></div>
<!-- Layout Right End --> <!-- Layout Right End -->
</td> </td>SSS
</tr> </tr>
</table> </table>
<?php if ($error = session('error')): ?><?= $viewDatas['helper']->alert($error) ?><?php endif ?> <?php if ($error = session('error')): ?><?= $viewDatas['helper']->alert($error) ?><?php endif ?>

View File

@ -1,7 +1,9 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?> <?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?> <?= $this->section('content') ?>
<div id="container" class="content"> <div id="container" class="content">
<script src="/assets/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" /> <link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/js/<?= $viewDatas['layout'] ?>/form.js" referrerpolicy="origin"></script>
<?= form_open(current_url(), ['id' => 'action_form', ...$viewDatas['forms']['attributes']], $viewDatas['forms']['hiddens']) ?> <?= form_open(current_url(), ['id' => 'action_form', ...$viewDatas['forms']['attributes']], $viewDatas['forms']['hiddens']) ?>
<div class="action_form"> <div class="action_form">
<table class="table table-bordered"> <table class="table table-bordered">
@ -18,17 +20,6 @@
<div class="text-center"><?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?></div> <div class="text-center"><?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?></div>
<?= form_close(); ?> <?= form_close(); ?>
</div> </div>
<?php if (session()->has('error')): ?><div class="alert alert-info text-start"><?= nl2br(session('error')) ?></div><?php endif; ?> <?php if ($error = session('error')): ?><?= $viewDatas['helper']->alert($error) ?><?php endif ?>
</div> </div>
<!-- <script src="/assets/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
<script>
tinymce.init({
selector: 'textarea#description', // Replace this CSS selector to match the placeholder element for TinyMCE
license_key: 'gpl',
// inline: true,
plugins: 'advlist autolink lists link image charmap preview anchor',
toolbar: 'undo redo | accordion accordionremove | importword exportword exportpdf | math | blocks fontfamily fontsize | bold italic underline strikethrough | align numlist bullist | link image | table media | lineheight outdent indent| forecolor backcolor removeformat | charmap emoticons | code fullscreen preview | save print | pagebreak anchor codesample | ltr rtl',
menubar: 'file edit view insert format tools table help'
});
</script> -->
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -20,6 +20,7 @@
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]--> <![endif]-->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head> </head>
<body> <body>

View File

@ -1,11 +1,5 @@
<!-- 처음 호출할때 사용법 <!-- 모달 HTML -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="시작URL">시작</button> <div id="index_action_form" class="index_action_form modal fade" tabindex="-1" aria-labelledby="modal_label" aria-hidden="true">
-->
<!-- 동적으로 ifram src 바꾸고싶을때
<span data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="바꾸고싶은URL" style="cursor:pointer;">바꾸기</span>
-->
<div id="index_action_form" class="index_action_form modal fade" tabindex="-1" aria-labelledby="modal_label"
aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable"> <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -18,8 +12,7 @@
<!-- 여기에 동적으로 콘텐츠가 로드됩니다 --> <!-- 여기에 동적으로 콘텐츠가 로드됩니다 -->
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" onClick="window.location.reload()">닫기</button>
onClick="window.location.reload()">닫기</button>
</div> </div>
</div> </div>
</div> </div>
@ -29,58 +22,49 @@
const modal = document.getElementById('index_action_form'); const modal = document.getElementById('index_action_form');
const modalBody = document.getElementById('modal-body-content'); const modalBody = document.getElementById('modal-body-content');
// 콘텐츠 로드 함수
async function loadContent(url) { async function loadContent(url) {
try { try {
//console.log('콘텐츠 로딩 시작:', url);
const response = await fetch(url); const response = await fetch(url);
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP 오류! 상태: ${response.status}`); throw new Error(`HTTP 오류! 상태: ${response.status}`);
} }
const content = await response.text(); const content = await response.text();
//console.log('받은 콘텐츠:', content.substring(0, 100) + '...'); // 콘텐츠의 처음 100자만 로그
modalBody.innerHTML = content; modalBody.innerHTML = content;
try {
// ✅ form.js 로딩
await loadScript('/js/<?= $viewDatas['layout'] ?>/form.js');
//console.log('form.js 로드 완료');
if (typeof window.initializeForm === 'function') {
//console.log('initializeForm 함수 실행');
window.initializeForm();
} else {
//console.log('initializeForm 함수를 찾을 수 없음');
}
} catch (scriptError) {
console.error('스크립트 로드 중 오류 발생:', scriptError);
}
//console.log('추가 스크립트 실행 시작'); // 스크립트 로딩 순서 보장 및 실행
const scripts = modalBody.getElementsByTagName('script'); const scripts = modalBody.getElementsByTagName('script');
for (let script of scripts) { for (let script of scripts) {
if (script.src) { if (script.src) {
//console.log('외부 스크립트 로드:', script.src); await loadScript(script.src); // 외부 스크립트 순차적으로 로드
const newScript = document.createElement('script');
newScript.src = script.src;
document.body.appendChild(newScript);
} else { } else {
//console.log('인라인 스크립트 실행'); eval(script.innerHTML); // 인라인 스크립트 실행
eval(script.innerHTML);
} }
} }
//console.log('setupFormSubmission 실행');
setupFormSubmission(); setupFormSubmission(); // 폼 제출 이벤트 핸들러 재설정
} catch (error) { } catch (error) {
console.error('콘텐츠 로드 중 오류 발생:', error); console.error('콘텐츠 로드 중 오류 발생:', error);
modalBody.innerHTML = '<p>콘텐츠를 로드하는 중 오류가 발생했습니다. 다시 시도해 주세요.</p>'; modalBody.innerHTML = '<p>콘텐츠를 로드하는 중 오류가 발생했습니다. 다시 시도해 주세요.</p>';
} }
} }
// 외부 스크립트 동적으로 로드하는 함수
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = src;
script.onload = () => resolve();
script.onerror = () => reject(new Error(`스크립트 로드 실패: ${src}`));
document.body.appendChild(script);
});
}
// 폼 제출 처리
function setupFormSubmission() { function setupFormSubmission() {
//console.log('setupFormSubmission 시작');
const form = modalBody.querySelector('form'); const form = modalBody.querySelector('form');
if (form) { if (form) {
//console.log('폼 찾음:', form);
form.addEventListener('submit', async (e) => { form.addEventListener('submit', async (e) => {
//console.log('폼 제출 이벤트 발생');
e.preventDefault(); e.preventDefault();
const formData = new FormData(form); const formData = new FormData(form);
try { try {
@ -102,14 +86,12 @@
setupFormSubmission(); // 새로운 폼에 대해 다시 이벤트 리스너 설정 setupFormSubmission(); // 새로운 폼에 대해 다시 이벤트 리스너 설정
} }
} else { } else {
// HTML 응답 처리
const htmlContent = await response.text(); const htmlContent = await response.text();
modalBody.innerHTML = htmlContent; modalBody.innerHTML = htmlContent;
// HTML에 포함된 스크립트 실행
const scripts = modalBody.getElementsByTagName('script'); const scripts = modalBody.getElementsByTagName('script');
for (let script of scripts) { for (let script of scripts) {
eval(script.innerHTML); eval(script.innerHTML); // 인라인 스크립트 실행
} }
setupFormSubmission(); // 새로운 폼에 대해 다시 이벤트 리스너 설정 setupFormSubmission(); // 새로운 폼에 대해 다시 이벤트 리스너 설정
@ -119,11 +101,10 @@
modalBody.innerHTML = '<p>데이터 저장 중 오류가 발생했습니다. 다시 시도해 주세요.</p>'; modalBody.innerHTML = '<p>데이터 저장 중 오류가 발생했습니다. 다시 시도해 주세요.</p>';
} }
}); });
} else {
//console.log('폼을 찾을 수 없음');
} }
} }
// 모달 열릴 때 콘텐츠 로딩
modal.addEventListener('show.bs.modal', (event) => { modal.addEventListener('show.bs.modal', (event) => {
const button = event.relatedTarget; const button = event.relatedTarget;
const url = button.getAttribute('data-src'); const url = button.getAttribute('data-src');
@ -135,30 +116,8 @@
} }
}); });
// 모달 닫힐 때 콘텐츠 초기화
modal.addEventListener('hidden.bs.modal', () => { modal.addEventListener('hidden.bs.modal', () => {
modalBody.innerHTML = ''; modalBody.innerHTML = '';
}); });
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = src;
script.onload = () => {
//console.log(`스크립트 로드 완료: ${src}`);
resolve();
};
script.onerror = () => reject(new Error(`스크립트 로드 실패: ${src}`));
document.body.appendChild(script);
});
}
// 모달이 완전히 표시된 후 form.js 초기화 함수 호출
document.getElementById('index_action_form').addEventListener('shown.bs.modal', function() {
if (typeof window.initializeForm === 'function') {
//console.log('모달 표시 후 initializeForm 함수 실행');
window.initializeForm();
} else {
//console.log('모달 표시 후에도 initializeForm 함수를 찾을 수 없음');
}
});
</script> </script>

View File

@ -1,119 +1,34 @@
(function() { document.addEventListener('DOMContentLoaded', function() {
//console.log('form.js가 로드되었습니다.'); //class가 calender인 inputbox용,날짜field용
if (document.querySelector(".calender")) {
function initializeModalComponents(modal) { $(".calender").datepicker({
//console.log('모달 컴포넌트 초기화 시작'); changeYear: true,
changeMonth: true,
// 약간의 지연을 주어 모달이 완전히 렌더링되도록 함 yearRange: "-10:+0",
setTimeout(() => { dateFormat: "yy-mm-dd"
initializeCalendar(modal);
initializeSelectField(modal);
initializeTinyMCE(modal);
}, 100);
}
function initializeCalendar(container) {
const calendarInputs = container.querySelectorAll('.calender');
if (calendarInputs.length > 0) {
//console.log('달력 초기화 시작');
$(calendarInputs).datepicker({
changeYear: true,
changeMonth: true,
yearRange: "-10:+0",
dateFormat: "yy-mm-dd"
});
//console.log('달력 초기화 완료');
}
}
function initializeSelectField(container) {
const selectFields = container.querySelectorAll('.select-field');
if (selectFields.length > 0 && typeof $.fn.select2 !== 'undefined') {
//console.log('선택 필드 초기화 시작');
$(selectFields).select2({
theme: "classic",
width: 'style',
dropdownAutoWidth: true,
dropdownParent: $('#index_action_form'),
containerCssClass: 'text-start', // 왼쪽 정렬을 위한 클래스 추가
dropdownCssClass: 'text-start' // 드롭다운 메뉴도 왼쪽 정렬
});
//console.log('선택 필드 초기화 완료');
}
}
function initializeTinyMCE(container) {
const textareas = container.querySelectorAll('textarea.tinymce');
if (textareas.length > 0 && typeof tinymce !== 'undefined') {
//console.log('TinyMCE 초기화 시작');
tinymce.init({
selector: textareas,
plugins: ['code', 'image', 'preview', 'table', 'emoticons', 'autoresize'],
height: 600,
automatic_uploads: false,
images_upload_url: '/tinymce_upload.php',
images_upload_handler: function (blobInfo, success, failure) {
var xhr, formData;
xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.open('POST', '/tinymce_upload.php');
xhr.onload = function () {
var json;
if (xhr.status != 200) {
failure('HTTP Error: ' + xhr.status);
return;
}
json = JSON.parse(xhr.responseText);
if (!json || typeof json.file_path != 'string') {
failure('Invalid JSON: ' + xhr.responseText);
return;
}
success(json.file_path);
};
formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());
xhr.send(formData);
},
setup: function(editor) {
editor.on('init', function() {
//console.log('TinyMCE 에디터 초기화 완료');
});
}
});
}
}
// MutationObserver 설정
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList') {
const addedNodes = mutation.addedNodes;
for (let i = 0; i < addedNodes.length; i++) {
if (addedNodes[i].nodeType === 1 && addedNodes[i].matches('.modal')) {
//console.log('새로운 모달이 추가되었습니다.');
initializeModalComponents(addedNodes[i]);
}
}
}
}); });
}); }
if (document.querySelector(".tinymce")) {
// 전체 문서에 대해 MutationObserver 시작 // HTML 문서가 표준 모드로 렌더링되고 있는지 확인
observer.observe(document.body, { childList: true, subtree: true }); if (document.compatMode !== "CSS1Compat") {
console.error("문서가 표준 모드가 아닙니다.");
// 모달 표시 이벤트 리스너 return;
document.body.addEventListener('shown.bs.modal', function(event) { }
//console.log('모달이 표시되었습니다.'); tinymce.init({
initializeModalComponents(event.target); selector: 'textarea',
}); license_key: 'gpl',
height: 250,
// 페이지 로드 시 전체 문서에 대해 초기화 실행 plugins: 'advlist autolink lists link image charmap preview anchor',
//console.log('페이지 로드 시 초기화 시작'); toolbar: 'undo redo blocks fontfamily fontsize forecolor backcolor | bold italic underline strikethrough | align numlist bullist | link image | table media | code fullscreen preview',
initializeModalComponents(document.body); menubar: 'file edit view insert format tools table help'
});
// 전역 스코프에 함수 노출 }
window.initializeForm = function() { if (document.querySelector(".select-field")) {
//console.log('initializeForm 함수가 호출되었습니다.'); //class가 select-field인 SelectBox용
initializeModalComponents(document.body); $(".select-field").select2({
}; theme: "classic",
})(); width: 'style',
dropdownAutoWidth: true
});
}
});