cfmgrv4 init...1
This commit is contained in:
parent
259761b597
commit
2990b6812f
@ -21,6 +21,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($rou
|
||||
$routes->group('cloudflare', ['namespace' => 'App\Controllers\Admin\Cloudflare'], function ($routes) {
|
||||
$routes->group('account', function ($routes) {
|
||||
$routes->get('/', 'AccountController::index');
|
||||
$routes->get('create', 'AccountController::create_form');
|
||||
$routes->post('create', 'AccountController::create');
|
||||
});
|
||||
$routes->group('zone', function ($routes) {
|
||||
|
||||
@ -2,16 +2,17 @@
|
||||
|
||||
namespace App\Controllers\Admin\Cloudflare;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
|
||||
use App\Libraries\MyCloudflare\Account;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class AccountController extends CloudflareController
|
||||
{
|
||||
private $_myLibrary = null;
|
||||
private $_model = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -20,6 +21,13 @@ class AccountController extends CloudflareController
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
helper($this->class_path);
|
||||
}
|
||||
final protected function getModel(): AccountModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new AccountModel();
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
final protected function getMyLibrary(): Account
|
||||
{
|
||||
if ($this->_myLibrary === null) {
|
||||
@ -27,44 +35,30 @@ class AccountController extends CloudflareController
|
||||
}
|
||||
return $this->_myLibrary;
|
||||
}
|
||||
//생성
|
||||
protected function create_init(): void
|
||||
{
|
||||
$this->action = 'create';
|
||||
$this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'authkey', 'type', 'status'];
|
||||
$this->filter_fields = ['type', 'status'];
|
||||
$this->fields = ['id', 'authkey'];
|
||||
$this->filter_fields = [];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getMyLibrary()->getMyStorage()->setAction($this->action);
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
// public function create_form(): RedirectResponse|string
|
||||
// {
|
||||
// $this->create_init();
|
||||
// return $this->create_form_process();
|
||||
// }
|
||||
protected function create_process_submit(): void
|
||||
protected function create_process(): void
|
||||
{
|
||||
$entity = $this->getMyLibrary()->create($this->formDatas);
|
||||
parent::create_process();
|
||||
$this->getMyLibrary()->create($this->formDatas);
|
||||
}
|
||||
public function create(): RedirectResponse
|
||||
{
|
||||
$this->create_init();
|
||||
$this->formDatas = [];
|
||||
$this->getFormDatas();
|
||||
$this->convertFormDatas();
|
||||
$this->validateFormDatas();
|
||||
return parent::create_process();
|
||||
}
|
||||
public function index(): string
|
||||
// 리스트
|
||||
public function list_init(): void
|
||||
{
|
||||
$this->action = 'index';
|
||||
$this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'oldkey', 'type', 'status', 'updated_at', 'created_at'];
|
||||
$this->fields = [$this->getModel()::TITLE, 'oldkey', 'type', 'status', 'updated_at', 'created_at'];
|
||||
$this->filter_fields = ['type', 'status'];
|
||||
$this->batchjob_fields = ['status'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getMyLibrary()->getMyStorage()->setAction($this->action);
|
||||
helper(['form']);
|
||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return parent::list_process();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Controllers\Admin\Cloudflare;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
|
||||
use App\Libraries\MyCloudflare\Record;
|
||||
use App\Models\Cloudflare\RecordModel;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class RecordController extends CloudflareController
|
||||
{
|
||||
@ -22,6 +22,13 @@ class RecordController extends CloudflareController
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
helper($this->class_name);
|
||||
}
|
||||
final protected function getModel(): RecordModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new RecordModel();
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
final protected function getMyLibrary(): Record
|
||||
{
|
||||
if ($this->_myLibrary === null) {
|
||||
@ -32,7 +39,7 @@ class RecordController extends CloudflareController
|
||||
protected function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
case $this->getMyLibrary()->getMyStorage()::PARENT:
|
||||
case $this->getModel()::PARENT:
|
||||
$this->getZoneModel()->where('status', DEFAULTS['STATUS']);
|
||||
$options[$field] = [
|
||||
DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택',
|
||||
@ -46,59 +53,56 @@ class RecordController extends CloudflareController
|
||||
return $options;
|
||||
}
|
||||
//전송된 데이터
|
||||
protected function getFormData(string $field): void
|
||||
protected function getFormData(string $field, array $formDatas): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'hosts':
|
||||
$this->formDatas[$field] = explode("\n", $this->request->getVar($field));
|
||||
$formDatas[$field] = explode("\n", $this->request->getVar($field));
|
||||
if (!is_array($this->formDatas[$field]) || !count($this->formDatas[$field])) {
|
||||
throw new \Exception("호스트명이 정의되지 않았습니다.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->formDatas[$field] = $this->request->getVar($field);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//전송된 데이터 검증
|
||||
protected function validateFormData(string $field): void
|
||||
{
|
||||
switch ($field) {
|
||||
case 'hosts':
|
||||
break;
|
||||
default:
|
||||
parent::validateFormData($field);
|
||||
$formDatas = parent::getFormData($field, $formDatas);
|
||||
break;
|
||||
}
|
||||
return $formDatas;
|
||||
}
|
||||
protected function create_init(): void
|
||||
{
|
||||
$this->action = 'create';
|
||||
$this->fields = [$this->getMyLibrary()->getMyStorage()::PARENT, 'type', 'content', 'proxied', 'hosts'];
|
||||
$this->filter_fields = [$this->getMyLibrary()->getMyStorage()::PARENT, 'type', 'proxied'];
|
||||
$this->fields = [$this->getModel()::PARENT, 'type', 'content', 'proxied', 'hosts'];
|
||||
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getMyLibrary()->getMyStorage()->setAction($this->action);
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
protected function create_validate(): void
|
||||
{
|
||||
//hosts를 제외한 fields Valid처리
|
||||
$this->validateFormDatas(array_diff($this->fields, ['hosts']));
|
||||
}
|
||||
// public function create_form(): RedirectResponse|string
|
||||
// {
|
||||
// return $this->create_form_process();
|
||||
// }
|
||||
protected function create_process_submit(): void
|
||||
{
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->_zone_entity->getParent());
|
||||
if ($this->_account_entity === null) {
|
||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||
}
|
||||
//Record생성
|
||||
foreach ($this->formDatas['hosts'] as $host) {
|
||||
$this->getMyLibrary()->create($host, $this->formDatas);
|
||||
}
|
||||
}
|
||||
public function create(string $zone_uid): RedirectResponse
|
||||
// 리스트
|
||||
public function list_init(): void
|
||||
{
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($zone_uid);
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->_zone_entity->getParent());
|
||||
$this->formDatas = [];
|
||||
$this->getFormDatas();
|
||||
$this->convertFormDatas();
|
||||
$this->validateFormDatas();
|
||||
return parent::create_process();
|
||||
$this->action = 'index';
|
||||
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
|
||||
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied', 'status'];
|
||||
$this->batchjob_fields = ['proxied'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,18 +2,19 @@
|
||||
|
||||
namespace App\Controllers\Admin\Cloudflare;
|
||||
|
||||
use App\Libraries\MyCloudflare\Record;
|
||||
use App\Libraries\MyCloudflare\Zone;
|
||||
use App\Models\Cloudflare\ZoneModel;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
use App\Libraries\MyCloudflare\Zone;
|
||||
use App\Libraries\MyCloudflare\Record;
|
||||
|
||||
class ZoneController extends CloudflareController
|
||||
{
|
||||
private $_myLibrary = null;
|
||||
private $_account_entity = null;
|
||||
private $_model = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -22,6 +23,13 @@ class ZoneController extends CloudflareController
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
helper($this->class_name);
|
||||
}
|
||||
final protected function getModel(): ZoneModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new ZoneModel();
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
final protected function getMyLibrary(): Zone
|
||||
{
|
||||
if ($this->_myLibrary === null) {
|
||||
@ -32,7 +40,7 @@ class ZoneController extends CloudflareController
|
||||
protected function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
case $this->getMyLibrary()->getMyStorage()::PARENT:
|
||||
case $this->getModel()::PARENT:
|
||||
$this->getAccountModel()->where('status', DEFAULTS['STATUS']);
|
||||
$options[$field] = [
|
||||
DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택',
|
||||
@ -45,53 +53,47 @@ class ZoneController extends CloudflareController
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
protected function getFormData(string $field): void
|
||||
protected function getFormData(string $field, array $formDatas): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'domains':
|
||||
$this->formDatas[$field] = explode("\n", $this->request->getVar($field));
|
||||
if (!is_array($this->formDatas[$field]) || !count($this->formDatas[$field])) {
|
||||
$formDatas[$field] = explode("\n", $this->request->getVar($field));
|
||||
if (!is_array($formDatas[$field]) || !count($formDatas[$field])) {
|
||||
throw new \Exception("도메인명이 정의되지 않았습니다.");
|
||||
}
|
||||
break;
|
||||
case 'hosts':
|
||||
$this->formDatas[$field] = $this->request->getVar($field);
|
||||
if (!is_array($this->formDatas[$field]) || !count($this->formDatas[$field])) {
|
||||
$formDatas[$field] = $this->request->getVar($field);
|
||||
if (!is_array($formDatas[$field]) || !count($formDatas[$field])) {
|
||||
throw new \Exception("호스트명이 정의되지 않았습니다");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->formDatas[$field] = $this->request->getVar($field);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//전송된 데이터 검증
|
||||
protected function validateFormData(string $field): void
|
||||
{
|
||||
switch ($field) {
|
||||
case 'domains':
|
||||
case 'hosts':
|
||||
break;
|
||||
default:
|
||||
parent::validateFormData($field);
|
||||
$formDatas = parent::getFormData($field, $formDatas);
|
||||
break;
|
||||
}
|
||||
return $formDatas;
|
||||
}
|
||||
protected function create_init(): void
|
||||
{
|
||||
$this->action = 'create';
|
||||
$this->fields = [$this->getMyLibrary()->getMyStorage()::PARENT, 'domains', 'hosts', 'type', 'content', 'proxied'];
|
||||
$this->filter_fields = [$this->getMyLibrary()->getMyStorage()::PARENT, 'type', 'proxied'];
|
||||
$this->fields = [$this->$this->getModel()::PARENT, 'domains', 'hosts', 'type', 'content', 'proxied'];
|
||||
$this->filter_fields = [$this->$this->getModel()::PARENT, 'type', 'proxied'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getMyLibrary()->getMyStorage()->setAction($this->action);
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
// public function create_form(): RedirectResponse|string
|
||||
// {
|
||||
// return $this->create_form_process();
|
||||
// }
|
||||
protected function create_process_submit(): void
|
||||
protected function create_validate(): void
|
||||
{
|
||||
//domains,hosts를 제외한 fields Valid처리
|
||||
$this->validateFormDatas(array_diff($this->fields, ['domains', 'hosts']));
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
if ($this->_account_entity === null) {
|
||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||
}
|
||||
foreach ($this->formDatas['domains'] as $domain) {
|
||||
//Zone생성
|
||||
$zone_entity = $this->getMyLibrary()->create($domain);
|
||||
@ -106,13 +108,15 @@ class ZoneController extends CloudflareController
|
||||
}
|
||||
}
|
||||
}
|
||||
public function create(string $account_uid): RedirectResponse
|
||||
// 리스트
|
||||
public function list_init(): void
|
||||
{
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($account_uid);
|
||||
$this->formDatas = [];
|
||||
$this->getFormDatas();
|
||||
$this->convertFormDatas();
|
||||
$this->validateFormDatas();
|
||||
return parent::create_process();
|
||||
$this->action = 'index';
|
||||
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'created_at'];
|
||||
$this->filter_fields = [$this->getModel()::PARENT, 'development_mode', 'ipv6', 'security_level', 'status'];
|
||||
$this->batchjob_fields = ['development_mode', 'ipv6', 'security_level'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,9 +14,8 @@ abstract class MVController extends CommonController
|
||||
parent::initController($request, $response, $logger);
|
||||
helper('common');
|
||||
}
|
||||
abstract protected function getModel(): mixed;
|
||||
abstract protected function getMyLibrary(): mixed;
|
||||
abstract protected function create_process_submit(): void;
|
||||
abstract protected function modify_process_submit(): void;
|
||||
//Field별 Form Option용
|
||||
protected function getFormFieldOption(string $field, array $options): array
|
||||
{
|
||||
@ -47,70 +46,67 @@ abstract class MVController extends CommonController
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
$rules = $this->getMyLibrary()->getMyStorage()->getFieldRule($field, $rules);
|
||||
$rules = $this->getModel()->getFieldRule($field, $rules);
|
||||
}
|
||||
// var_dump($rules);
|
||||
// exit;
|
||||
return $rules;
|
||||
}
|
||||
//전송된 데이터
|
||||
protected function getFormData(string $field): void
|
||||
protected function getFormData(string $field, array $formDatas): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$this->formDatas[$field] = $this->request->getVar($field);
|
||||
$formDatas[$field] = $this->request->getVar($field);
|
||||
break;
|
||||
}
|
||||
return $formDatas;
|
||||
}
|
||||
final protected function getFormDatas(): void
|
||||
final protected function getFormDatas(array $formDatas = []): array
|
||||
{
|
||||
foreach ($this->fields as $field) {
|
||||
$this->getFormData($field);
|
||||
$formDatas = $this->getFormData($field, $formDatas);
|
||||
}
|
||||
return $formDatas;
|
||||
}
|
||||
//전송된 데이터 재정의
|
||||
protected function convertFormData(string $field): void
|
||||
protected function convertFormData(string $field, array $formDatas): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return $formDatas;
|
||||
}
|
||||
final protected function convertFormDatas(): void
|
||||
final protected function convertFormDatas(array $formDatas = []): array
|
||||
{
|
||||
foreach ($this->fields as $field) {
|
||||
$this->convertFormData($field);
|
||||
$formDatas = $this->convertFormData($field, $formDatas);
|
||||
}
|
||||
return $formDatas;
|
||||
}
|
||||
//전송된 데이터 검증
|
||||
protected function validateFormData(string $field): void
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (
|
||||
!$this->validation->check(
|
||||
$this->formDatas[$field],
|
||||
$this->getMyLibrary()->getMyStorage()->getFieldRule($field)
|
||||
)
|
||||
) {
|
||||
throw new \Exception("데이터 검증 오류발생\n" . implode("\n", $this->validation->getError()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
final protected function validateFormDatas(): void
|
||||
final protected function validateFormDatas(array $fields): void
|
||||
{
|
||||
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
|
||||
$this->validation = service('validation');
|
||||
foreach ($this->fields as $field) {
|
||||
$this->validateFormData($field);
|
||||
$this->validation->setRules($this->getModel()->getFieldRules($fields));
|
||||
if (!$this->validation->withRequest($this->request)->run()) {
|
||||
throw new \Exception("{$this->class_name}의 {$this->action} 작업 데이터 검증 오류발생\n" . implode(
|
||||
"\n",
|
||||
$this->validation->getErrors()
|
||||
));
|
||||
}
|
||||
}
|
||||
// 생성
|
||||
final protected function create_form_process(): RedirectResponse|string
|
||||
protected function create_form_process(): void
|
||||
{
|
||||
}
|
||||
public function create_form(): RedirectResponse|string
|
||||
{
|
||||
helper(['form']);
|
||||
try {
|
||||
$this->create_init();
|
||||
$this->create_form_process();
|
||||
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return view(
|
||||
@ -122,54 +118,92 @@ abstract class MVController extends CommonController
|
||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage());
|
||||
}
|
||||
}
|
||||
final protected function create_process(): mixed
|
||||
protected function create_validate(): void
|
||||
{
|
||||
$this->validateFormDatas($this->fields);
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
}
|
||||
public function create(): RedirectResponse
|
||||
{
|
||||
$this->getMyLibrary()->getMyStorage()->transStart();
|
||||
try {
|
||||
$this->create_process_submit();
|
||||
$this->create_init();
|
||||
$this->create_validate();
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
$this->formDatas = $this->convertFormDatas($this->formDatas);
|
||||
//Transaction Start
|
||||
$this->getModel()->transStart();
|
||||
$this->create_process();
|
||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->getMyLibrary()->getMyStorage()->transRollback();
|
||||
$this->getModel()->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
// 수정
|
||||
final protected function modify_form_process(): RedirectResponse|string
|
||||
protected function modify_validate(): void
|
||||
{
|
||||
$this->validateFormDatas($this->fields);
|
||||
}
|
||||
protected function modify_form_process(): void
|
||||
{
|
||||
}
|
||||
public function modify_form(): RedirectResponse|string
|
||||
{
|
||||
helper(['form']);
|
||||
try {
|
||||
$this->modify_init();
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
//기존 데이터 가져오기
|
||||
$this->entity = $this->getModel()->getEntityByPK($this->formDatas[$this->getModel()->getPKField()]);
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("해당 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->modify_form_process();
|
||||
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return view(
|
||||
strtolower($this->class_path) . "/modify",
|
||||
['viewDatas' => $this->getViewDatas()]
|
||||
data: ['viewDatas' => $this->getViewDatas()]
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage());
|
||||
}
|
||||
}
|
||||
final protected function modify_process(): mixed
|
||||
protected function modify_process(): void
|
||||
{
|
||||
}
|
||||
public function modify(): mixed
|
||||
{
|
||||
$this->getMyLibrary()->getMyStorage()->transStart();
|
||||
try {
|
||||
$this->modify_process_submit();
|
||||
$this->modify_init();
|
||||
$this->modify_validate();
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
$this->formDatas = $this->convertFormDatas($this->formDatas);
|
||||
//기존 데이터 가져오기
|
||||
$this->entity = $this->getModel()->getEntityByPK($this->formDatas[$this->getModel()->getPKField()]);
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("해당 정보를 찾을수 없습니다.");
|
||||
}
|
||||
//Transaction Start
|
||||
$this->getModel()->transStart();
|
||||
$this->modify_process();
|
||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->getMyLibrary()->getMyStorage()->transRollback();
|
||||
$this->getModel()->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
// 리스트
|
||||
protected function list_condition($isTotalCount = false): void
|
||||
{
|
||||
@ -177,26 +211,24 @@ abstract class MVController extends CommonController
|
||||
foreach ($this->filter_fields as $field) {
|
||||
$this->$field = $this->request->getVar($field) ?: DEFAULTS['EMPTY'];
|
||||
if ($this->$field !== DEFAULTS['EMPTY']) {
|
||||
$this->getMyLibrary()->getMyStorage()->setList_FieldFilter($field, $this->$field);
|
||||
$this->getModel()->setList_FieldFilter($field, $this->$field);
|
||||
}
|
||||
}
|
||||
//검색어 처리
|
||||
$this->word = $this->request->getVar('word') ?: DEFAULTS['EMPTY'];
|
||||
if ($this->word !== DEFAULTS['EMPTY']) {
|
||||
$this->getMyLibrary()->getMyStorage()->setList_WordFilter($this->word);
|
||||
$this->getModel()->setList_WordFilter($this->word);
|
||||
}
|
||||
//검색일 처리
|
||||
$this->start = $this->request->getVar('start') ?: DEFAULTS['EMPTY'];
|
||||
$this->end = $this->request->getVar('end') ?: DEFAULTS['EMPTY'];
|
||||
if ($this->start !== DEFAULTS['EMPTY'] && $this->end !== DEFAULTS['EMPTY']) {
|
||||
$this->getMyLibrary()->getMyStorage()->setList_DateFilter($this->start, $this->end);
|
||||
}
|
||||
$this->getModel()->setList_DateFilter($this->start, $this->end);
|
||||
if (!$isTotalCount) {
|
||||
//Sorting 처리
|
||||
$this->order_field = $this->request->getVar('order_field') ?: DEFAULTS['EMPTY'];
|
||||
$this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY'];
|
||||
if ($this->order_field !== DEFAULTS['EMPTY'] && $this->order_value !== DEFAULTS['EMPTY']) {
|
||||
$this->getMyLibrary()->getMyStorage()->setList_OrderBy("{$this->order_field} {$this->order_value}");
|
||||
$this->getModel()->setList_OrderBy("{$this->order_field} {$this->order_value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,8 +236,8 @@ abstract class MVController extends CommonController
|
||||
protected function list_total(): int
|
||||
{
|
||||
$this->list_condition(true);
|
||||
$total_count = $this->getMyLibrary()->getMyStorage()->countAllResults();
|
||||
// dd($this->getMyLibrary()->getMyStorage()->getLastQuery());
|
||||
$total_count = $this->getModel()->countAllResults();
|
||||
// echo $this->getModel()->getLastQuery();
|
||||
return $total_count;
|
||||
}
|
||||
//PageNation 처리
|
||||
@ -224,7 +256,7 @@ abstract class MVController extends CommonController
|
||||
// 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full',
|
||||
// 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가
|
||||
$pager = service("pager");
|
||||
// $this->getMyLibrary()->getMyStorage()->paginate($this->per_page, $pager_group, $this->page, $segment);
|
||||
// $this->getModel()->paginate($this->per_page, $pager_group, $this->page, $segment);
|
||||
$pager->makeLinks(
|
||||
$this->page,
|
||||
$this->per_page,
|
||||
@ -241,18 +273,21 @@ abstract class MVController extends CommonController
|
||||
{
|
||||
$this->list_condition();
|
||||
if ($this->page) {
|
||||
$this->getMyLibrary()->getMyStorage()->limit(
|
||||
$this->getModel()->limit(
|
||||
$this->per_page,
|
||||
$this->page * $this->per_page - $this->per_page
|
||||
);
|
||||
}
|
||||
$entitys = $this->getMyLibrary()->getMyStorage()->findAll();
|
||||
// dd($this->getMyLibrary()->getMyStorage()->getLastQuery());
|
||||
$entitys = $this->getModel()->findAll();
|
||||
// echo $this->getModel()->getLastQuery();
|
||||
return $entitys;
|
||||
}
|
||||
public function list_process(): string
|
||||
public function list(): string
|
||||
{
|
||||
try {
|
||||
helper(['form']);
|
||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
$this->list_init();
|
||||
//URL처리
|
||||
$this->uri = $this->request->getUri();
|
||||
//total 처리
|
||||
|
||||
@ -39,6 +39,7 @@ function getFieldForm_AccountHelper(string $field, mixed $value, array $viewData
|
||||
break;
|
||||
case 'id':
|
||||
$form = form_input($field, $value, ["placeholder" => "예)sample@test.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'name':
|
||||
$form = form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
@ -47,7 +48,7 @@ function getFieldForm_AccountHelper(string $field, mixed $value, array $viewData
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
$form = form_input($field, $value);
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
|
||||
@ -68,19 +68,18 @@ class Account extends MyCloudflare
|
||||
// log_message("notice", "Account::" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
// return $entity;
|
||||
// }
|
||||
public function create($formDatas): AccountEntity
|
||||
public function create($formDatas): array
|
||||
{
|
||||
$this->_authkey = $formDatas['authkey'];
|
||||
$cf = $this->getRequest()->get('accounts', ['page' => 1, 'per_page' => 20]);
|
||||
$cf = json_decode($cf->getBody());
|
||||
if (!$cf->success) {
|
||||
throw new \Exception("Account:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||
}
|
||||
//Account의 경우 인증키를 가지고있고 생성할수 없으므로 get으로 읽은후 첫번째것을 사용하기로 함
|
||||
$formDatas = $this->getArrayByResult(array_shift($cf->result));
|
||||
$entity = $this->$this->getMyStorage()->create($formDatas);
|
||||
log_message("notice", "Account:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
return $entity;
|
||||
$entitys = [];
|
||||
foreach ($this->reload_cfs($this->getRequest(), 'accounts') as $cf) {
|
||||
$formDatas = $this->getArrayByResult($cf->result);
|
||||
$entity = $this->$this->getMyStorage()->create($formDatas);
|
||||
log_message("notice", "Account:" . __FUNCTION__ . "=> {$entity->getTitle()} 작업을 완료하였습니다.");
|
||||
$entitys[] = $entity;
|
||||
}
|
||||
return $entitys;
|
||||
}
|
||||
|
||||
protected function reload_entity($cf): AccountEntity
|
||||
|
||||
@ -63,21 +63,9 @@ abstract class CommonModel extends Model
|
||||
{
|
||||
return $this->_action = $action;
|
||||
}
|
||||
final public function getFields(string $key = "", array $fields = []): array
|
||||
final public function getFields(array $except_fields = []): array
|
||||
{
|
||||
$allowedFields = array_filter(
|
||||
$this->allowedFields,
|
||||
function ($value) use (&$key, &$fields) {
|
||||
if ($key == 'except') {
|
||||
return !in_array($value, $fields);
|
||||
} elseif ($key == 'only') {
|
||||
return in_array($value, $fields);
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
);
|
||||
return $allowedFields;
|
||||
return array_diff($this->allowedFields, $except_fields); //제외한 fields
|
||||
}
|
||||
public function getFieldRule(string $field, array $rules): array
|
||||
{
|
||||
@ -243,13 +231,16 @@ abstract class CommonModel extends Model
|
||||
}
|
||||
public function setList_WordFilter(string $word, string $field = null): void
|
||||
{
|
||||
$this->like($field ?? $this->getTitleField(), $word, 'before'); //befor , after , both
|
||||
$this->like($field ?? $this->getTitleField(), $word, 'both'); //befor , after , both
|
||||
}
|
||||
public function setList_DateFilter(string $start, string $end, $field = "created_at"): void
|
||||
final public function setList_DateFilter(string $start, string $end, $field = "created_at"): void
|
||||
{
|
||||
|
||||
$this->where("{$field} >= {$start}");
|
||||
$this->where("{$field} <= {$end}");
|
||||
if ($start !== DEFAULTS['EMPTY']) {
|
||||
$this->where("{$field} >= '{$start} 00:00:00'");
|
||||
}
|
||||
if ($end !== DEFAULTS['EMPTY']) {
|
||||
$this->where("{$field} <= '{$end} 23:59:59'");
|
||||
}
|
||||
}
|
||||
public function setList_OrderBy(string $order)
|
||||
{
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/admin/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="form table table-bordered table-striped">
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
@ -18,5 +16,4 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?= form_close(); ?>
|
||||
</table>
|
||||
<?= $this->endSection() ?>
|
||||
</table>
|
||||
@ -1,19 +1,23 @@
|
||||
<?= $this->extend("layouts/{$viewDatas['layout']}") ?>
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= form_open(current_url(), array("method" => "get")) ?>
|
||||
<nav class="index_top navbar navbar-expand-lg">
|
||||
<div class="container-fluid">
|
||||
<nav class="condition nav">
|
||||
조건검색:<?php foreach ($viewDatas['filter_fields'] as $field): ?><?= getFieldForm_AccountHelper($field, old($viewDatas[$field]), $viewDatas) ?><?php endforeach ?>
|
||||
조건검색:
|
||||
<?php foreach ($viewDatas['filter_fields'] as $field): ?>
|
||||
<?= getFieldForm_AccountHelper($field, $viewDatas[$field], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
</nav>
|
||||
<nav class="search nav justify-content-center">
|
||||
검색어:<?= form_input('word', $viewDatas['word']) ?>
|
||||
검색일:<?= form_input('start', $viewDatas['start'], ["class" => "calender"]) ?><?= form_input('end', $viewDatas['end'], ["class" => "calender"]) ?>
|
||||
<?= form_submit('', '검색하기') ?>
|
||||
<?= anchor(current_url() . '/excel?' . $viewDatas['uri']->getQuery(), ICONS['EXCEL'], ["target" => "_self"]) ?>
|
||||
<?= anchor(current_url() . '/excel?' . $viewDatas['uri']->getQuery(), ICONS['EXCEL'], ["target" => "_self", "class" => "excel"]) ?>
|
||||
</nav>
|
||||
<nav class="pageinfo nav justify-content-center">
|
||||
<nav class="pageinfo nav justify-content-end">
|
||||
페이지정보 : <?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?>
|
||||
<?= form_dropdown('per_page', $viewDatas['page_options'], $viewDatas['per_page'], array('onChange' => 'this.form.submit()')) ?>
|
||||
/ 총:<?= $viewDatas['total_count'] ?>
|
||||
@ -38,7 +42,7 @@
|
||||
<tr id="<?= $entity->getPK() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
|
||||
<td class="text-center text-wrap">
|
||||
<?= form_checkbox(["id" => "checkbox_uid_{$entity->getPK()}", "name" => "batchjob_uids[]", "value" => $entity->getPK(), "class" => "batchjobuids_checkboxs"]); ?>
|
||||
<?= anchor(current_url() . '/update/' . $entity->getPK(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
|
||||
<?= anchor(current_url() . '/modify/' . $entity->getPK(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
|
||||
</td>
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<td><?= getListColumns_AccountHelper($field, $entity, $viewDatas) ?></td>
|
||||
@ -51,18 +55,29 @@
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class=" index_bottom">
|
||||
<div class="index_bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
|
||||
<?= getFieldForm_AccountHelper($field, old($viewDatas[$field]), $viewDatas) ?>
|
||||
<?= getFieldForm_AccountHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
|
||||
<li class="nav-item">
|
||||
<?= anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
|
||||
<?= anchor(current_url() . '/create', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
|
||||
</li>
|
||||
</ul>
|
||||
<?= $viewDatas['pagination'] ?>
|
||||
</div>
|
||||
<div class="index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||
<?= form_close() ?>
|
||||
<div class="index_form">
|
||||
<div id="index_create_form"></div>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
loadContentForm(
|
||||
"<?= base_url('admin/cloudflare/account/create') ?>",
|
||||
document.getElementById('index_create_form')
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,5 +0,0 @@
|
||||
<?php foreach ($cellDatas['entitys'] as $entity) : ?>
|
||||
<?php foreach (['title', 'created_at'] as $field) : ?>
|
||||
<div><?= getFieldCell_Row_BoardHelper($field, $entity, $cellDatas) ?></div>
|
||||
<?php endforeach ?>
|
||||
<?php endforeach ?>
|
||||
@ -1,5 +0,0 @@
|
||||
<?php foreach ($cellDatas['entitys'] as $entity) : ?>
|
||||
<?php foreach (['title', 'created_at'] as $field) : ?>
|
||||
<div><?= getFieldCell_Row_BoardHelper($field, $entity, $cellDatas) ?></div>
|
||||
<?php endforeach ?>
|
||||
<?php endforeach ?>
|
||||
@ -1,82 +0,0 @@
|
||||
<link href="/css/front/device_calculator.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script>
|
||||
function calculator(order_price = 0) {
|
||||
var cellDatas = Array.from(document.getElementsByClassName("vhost_cellDatas"));
|
||||
cellDatas.forEach(function(part) { //loop
|
||||
//console.log(part);
|
||||
order_price += parseInt((part.getAttribute('cost') - part.getAttribute('sale')) * part.options[part.selectedIndex].value);
|
||||
document.getElementById('price').value = order_price;
|
||||
document.getElementById('order_price').textContent = new Intl.NumberFormat().format(order_price);
|
||||
});
|
||||
var current = document.getElementById('paymentday');
|
||||
if (!current.selectedIndex) {
|
||||
alert("결제일을 선택해주세요");
|
||||
current.focus();
|
||||
return false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div id="device_calculator">
|
||||
<?= form_open(URLS['addCart'], [
|
||||
'method' => 'post',
|
||||
"onsubmit" => 'return calculator()'
|
||||
]) ?>
|
||||
<input type="hidden" id="category" name="category" value="device">
|
||||
<input type="hidden" id="price" name="price">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" colspan="3">가상서버 견적 계산기</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($cellDatas['device']['categorys'] as $category) : ?>
|
||||
<?php
|
||||
$options = [];
|
||||
foreach ($cellDatas['device']['options'][$category] as $entity) {
|
||||
$options[$entity->getPrimaryKey()] = $entity->getTitleWithPrice();
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><?= lang("Device.CATEGORY.{$category}") ?></td>
|
||||
<td>
|
||||
<?= form_dropdown(
|
||||
$category,
|
||||
$options,
|
||||
old($category, 0),
|
||||
[
|
||||
'id' => $category,
|
||||
'class' => 'vhost_cellDatas',
|
||||
'onChange' => "calculator()"
|
||||
]
|
||||
) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<tr>
|
||||
<th>결제일</th>
|
||||
<td class="column">
|
||||
<?php $paymentDayOptions = ['' => "결제일 선택"];
|
||||
for ($i = 1; $i <= 28; $i++) {
|
||||
$paymentDayOptions[$i] = "매월 {$i}일";
|
||||
}
|
||||
?>
|
||||
<?= form_dropdown('paymentday', $paymentDayOptions, old('paymentday', 25), ['id' => 'paymentday']);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="none">주문금액</th>
|
||||
<td class="none" colspan="3">
|
||||
<span id="order_price">0</span>원
|
||||
<?= form_submit('', '신청', array("class" => "btn btn-outline btn-primary")); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<script type="text/javascript">
|
||||
window.onload = calculator();
|
||||
</script>
|
||||
<?= $cellDatas['session']->getFlashdata('return_message') ? alert_CommonHelper($cellDatas['session']->getFlashdata('return_message')) : "" ?>
|
||||
</div>
|
||||
@ -1,43 +0,0 @@
|
||||
<script>
|
||||
function addDevice(category, key, label) {
|
||||
var categoryBox = document.getElementById(category + "Box");
|
||||
var div = document.createElement("div");
|
||||
var checkbox = document.createElement("input");
|
||||
checkbox.setAttribute("type", "checkbox");
|
||||
checkbox.setAttribute("name", category + '[]');
|
||||
checkbox.setAttribute("value", key);
|
||||
checkbox.setAttribute("checked", true);
|
||||
checkbox.setAttribute("class", 'device');
|
||||
div.appendChild(checkbox);
|
||||
div.appendChild(document.createTextNode(label));
|
||||
// console.log(div);
|
||||
categoryBox.appendChild(div);
|
||||
}
|
||||
</script>
|
||||
<table class="table table-bordered" style="width: auto;">
|
||||
<tr>
|
||||
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
||||
<th style="background-color:silver; text-align:center;"><?= lang('Device.CATEGORY.' . $category) . " 선택" ?></th>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
||||
<td id="<?= $category ?>Box">
|
||||
<?php foreach ($cellDatas['selecteds'][$category] as $key => $productDevieceEntity) : ?>
|
||||
<div><input type="checkbox" id="<?= $key ?>" name="<?= $category ?>[]" value="<?= $productDevieceEntity->device_uid ?>" checked class="device"><?= $cellDatas['deviceEntitys'][$productDevieceEntity->device_uid]->getTitle() ?></div>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
||||
<td>
|
||||
<?php foreach ($cellDatas['device']['options'][$category] as $key => $label) : ?>
|
||||
<button type="button" class="device btn btn-light" data-bs-toggle="tooltip" data-bs-placement="bottom" title="<?= number_format($cellDatas['deviceEntitys'][$key]->getPrice()) ?>원" onClick="addDevice('<?= $category ?>','<?= $key ?>','<?= $label ?>')">
|
||||
<?= $label ?>
|
||||
</button>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1,30 +0,0 @@
|
||||
<div class="modal fade device-virtual" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<table class="table table-bordered" style="width: auto;">
|
||||
<tr>
|
||||
<?php foreach ($cellDatas['device']['categorys'] as $category) : ?>
|
||||
<th style="background-color:silver; text-align:center;"><?= lang('Device.CATEGORY.' . $category) . " 선택" ?></th>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php foreach ($cellDatas['device']['categorys'] as $category) : ?>
|
||||
<td>
|
||||
<?= form_dropdown(
|
||||
$category,
|
||||
$cellDatas['device']['options'][$category],
|
||||
old($category, 0),
|
||||
[
|
||||
'id' => $category,
|
||||
'size' => "6",
|
||||
'class' => 'vhost_cellDatas',
|
||||
'onChange' => "calculator()"
|
||||
]
|
||||
) ?>
|
||||
</td>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1,87 +0,0 @@
|
||||
<link href="/css/front/virtual_calculator.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script>
|
||||
function calculator(order_price) {
|
||||
var parts = Array.from(document.getElementsByClassName("vhost_parts"));
|
||||
parts.forEach(function(part) { //loop
|
||||
//console.log(part);
|
||||
order_price += parseInt((part.getAttribute('cost') - part.getAttribute('sale')) * part.options[part.selectedIndex].value);
|
||||
document.getElementById('price').value = order_price;
|
||||
document.getElementById('order_price').textContent = new Intl.NumberFormat().format(order_price);
|
||||
});
|
||||
var current = document.getElementById('paymentday');
|
||||
if (!current.selectedIndex) {
|
||||
alert("결제일을 선택해주세요");
|
||||
current.focus();
|
||||
return false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div id="virtual_calculator">
|
||||
<?= form_open(URLS['addCart'], [
|
||||
'method' => 'post',
|
||||
"onsubmit" => 'return calculator(' . $cellDatas['parts']['virtual']['default']['baserate'] . ')'
|
||||
]) ?>
|
||||
<input type="hidden" id="category" name="category" value="virtual">
|
||||
<input type="hidden" id="price" name="price">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" colspan="3">가상서버 견적 계산기</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>기본요금</th>
|
||||
<td>
|
||||
<strong><?= number_format($cellDatas['parts']['virtual']['default']['baserate']) ?>원</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($cellDatas['parts']['virtual']['category'] as $category => $attrs) : ?>
|
||||
<tr>
|
||||
<th><?= $attrs['label'] ?></th>
|
||||
<td>
|
||||
<strong class="line-through"><?= number_format($attrs['cost']) ?>원</strong>
|
||||
<strong class="f-back">할인가 <?= number_format($attrs['cost'] - $attrs['sale']) ?></strong> *
|
||||
<?= form_dropdown(
|
||||
$category,
|
||||
$attrs['options'],
|
||||
old($category, 0),
|
||||
[
|
||||
'id' => $category,
|
||||
'class' => 'vhost_parts',
|
||||
'cost' => $attrs['cost'],
|
||||
'sale' => $attrs['sale'],
|
||||
'onChange' => "calculator(" . $cellDatas['parts']['virtual']['default']['baserate'] . ")"
|
||||
]
|
||||
) ?>
|
||||
<?= $attrs['unit'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<tr>
|
||||
<th>결제일</th>
|
||||
<td class="column">
|
||||
<?php $paymentDayOptions = ['' => "결제일 선택"];
|
||||
for ($i = 1; $i <= 28; $i++) {
|
||||
$paymentDayOptions[$i] = "매월 {$i}일";
|
||||
}
|
||||
?>
|
||||
<?= form_dropdown('paymentday', $paymentDayOptions, old('paymentday', 25), ['id' => 'paymentday']);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="none">주문금액</th>
|
||||
<td class="none" colspan="3">
|
||||
<span id="order_price">0</span>원
|
||||
<?= form_submit('', '신청', array("class" => "btn btn-outline btn-primary")); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<script type="text/javascript">
|
||||
window.onload = calculator(<?= $cellDatas['parts']['virtual']['default']['baserate'] ?>);
|
||||
</script>
|
||||
<?= $cellDatas['session']->getFlashdata('return_message') ? alert_CommonHelper($cellDatas['session']->getFlashdata('return_message')) : "" ?>
|
||||
</div>
|
||||
@ -12,23 +12,39 @@ table.form tbody tr td.column {
|
||||
}
|
||||
/* insert,update,reply,view Form Page 관련 전용*/
|
||||
|
||||
/*조건검색*/
|
||||
nav.index_top nav.condition {
|
||||
max-width: 400px;
|
||||
border-color: 1px solid red;
|
||||
}
|
||||
/*검색*/
|
||||
nav.index_top input[type="text"] {
|
||||
nav.index_top nav.search {
|
||||
position: relative;
|
||||
height: 30px;
|
||||
border-color: 1px solid red;
|
||||
}
|
||||
nav.index_top nav.search input[type="text"] {
|
||||
width: 200px;
|
||||
height: 40px;
|
||||
height: 30px;
|
||||
}
|
||||
/*검색submit*/
|
||||
nav.index_top input[type="submit"] {
|
||||
nav.index_top nav.search input[type="submit"] {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
width: 80px;
|
||||
height: 40px;
|
||||
height: 30px;
|
||||
color: white;
|
||||
background-color: #555555;
|
||||
}
|
||||
/*검색submit*/
|
||||
nav.index_top nav.search a.excel {
|
||||
position: absolute;
|
||||
top: -9px;
|
||||
right: -45px;
|
||||
border-color: 1px solid red;
|
||||
}
|
||||
/*페이지정보*/
|
||||
nav.index_top nav.pageinfo {
|
||||
float: right;
|
||||
font-weight: bold;
|
||||
border-color: 1px solid red;
|
||||
}
|
||||
@ -56,22 +72,39 @@ div.index_bottom {
|
||||
/* border: 1px solid red; */
|
||||
}
|
||||
|
||||
div.index_bottom nav ul.pagination {
|
||||
div.index_pagination nav {
|
||||
margin-top: 20px;
|
||||
/* border: 1px solid red; */
|
||||
}
|
||||
div.index_bottom nav ul.pagination {
|
||||
display: inline-block; /* ul이 줄바꿈이 되지 않도록 설정 */
|
||||
div.index_pagination nav ul.pagination {
|
||||
/* border: 1px solid green; */
|
||||
width: fit-content; /* UL의 너비를 내용에 맞춤 */
|
||||
margin: 0 auto; /* 좌우 마진을 자동으로 설정하여 중앙 배치 */
|
||||
padding: 0;
|
||||
list-style: none; /* 기본 점 스타일 제거 (옵션) */
|
||||
}
|
||||
div.index_bottom nav ul.pagination li {
|
||||
border: 1px solid red;
|
||||
div.index_pagination nav ul.pagination li {
|
||||
margin-left: 5px;
|
||||
}
|
||||
div.index_bottom nav ul.pagination li a {
|
||||
padding: 8px;
|
||||
}
|
||||
div.index_bottom nav ul.pagination li.active a {
|
||||
background-color: silver;
|
||||
color: white;
|
||||
div.index_pagination nav ul.pagination li a {
|
||||
padding: 5px 10px 5px 10px;
|
||||
font-size: 20px;
|
||||
color: white;
|
||||
background-color: #808080;
|
||||
}
|
||||
div.index_pagination nav ul.pagination li.active a {
|
||||
color: black;
|
||||
border: 1px solid #808080;
|
||||
}
|
||||
div.index_pagination nav ul.pagination li a:hover {
|
||||
border: 1px solid black;
|
||||
}
|
||||
div.index_form {
|
||||
text-align: center;
|
||||
/* border: 1px solid red; */
|
||||
}
|
||||
div.index_form div#index_create_form {
|
||||
margin: auto; /*수평의 가운데정렬시*/
|
||||
width: 500px;
|
||||
/* border: 1px solid blue; */
|
||||
}
|
||||
|
||||
6
public/js/admin/content.js
Normal file
6
public/js/admin/content.js
Normal file
@ -0,0 +1,6 @@
|
||||
function loadContentForm(url,target) {
|
||||
fetch(url)
|
||||
.then(response => response.text())
|
||||
.then(data => {target.innerHTML = data;})
|
||||
.catch(error => console.error('Error loading form:', error));
|
||||
}
|
||||
@ -2,7 +2,7 @@ function openWin( winName ) {
|
||||
var blnCookie = getCookie( winName );
|
||||
var obj = eval( "window." + winName );
|
||||
if( !blnCookie ) {
|
||||
obj.style.display = "block";
|
||||
obj.style.display = "block";
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,20 +22,19 @@ function getCookie( name ) {
|
||||
var x = 0;
|
||||
while ( x <= document.cookie.length )
|
||||
{
|
||||
var y = (x+nameOfCookie.length);
|
||||
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
|
||||
var y = (x+nameOfCookie.length);
|
||||
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
|
||||
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
|
||||
endOfCookie = document.cookie.length;
|
||||
return unescape( document.cookie.substring( y, endOfCookie ) );
|
||||
}
|
||||
x = document.cookie.indexOf( " ", x ) + 1;
|
||||
if ( x == 0 )
|
||||
}
|
||||
x = document.cookie.indexOf( " ", x ) + 1;
|
||||
if ( x == 0 )
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
function setCookie( name, value, expiredays ) {
|
||||
var todayDate = new Date();
|
||||
todayDate.setDate( todayDate.getDate() + expiredays );
|
||||
@ -43,12 +42,12 @@ function setCookie( name, value, expiredays ) {
|
||||
}
|
||||
|
||||
function setCookieAt00( name, value, expiredays ) {
|
||||
var todayDate = new Date();
|
||||
var todayDate = new Date();
|
||||
todayDate = new Date(parseInt(todayDate.getTime() / 86400000) * 86400000 + 54000000);
|
||||
if ( todayDate > new Date() )
|
||||
{
|
||||
expiredays = expiredays - 1;
|
||||
}
|
||||
todayDate.setDate( todayDate.getDate() + expiredays );
|
||||
if ( todayDate > new Date() )
|
||||
{
|
||||
expiredays = expiredays - 1;
|
||||
}
|
||||
todayDate.setDate( todayDate.getDate() + expiredays );
|
||||
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
|
||||
}
|
||||
30
public/js/product.js
Normal file
30
public/js/product.js
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
function calculator(order_price) {
|
||||
var parts = Array.from(document.getElementsByClassName("vhost_parts"));
|
||||
parts.forEach(function(part) { //loop
|
||||
//console.log(part);
|
||||
order_price += parseInt((part.getAttribute('cost') - part.getAttribute('sale')) * part.options[part.selectedIndex].value);
|
||||
document.getElementById('price').value = order_price;
|
||||
document.getElementById('order_price').textContent = new Intl.NumberFormat().format(order_price);
|
||||
});
|
||||
var current = document.getElementById('paymentday');
|
||||
if (!current.selectedIndex) {
|
||||
alert("결제일을 선택해주세요");
|
||||
current.focus();
|
||||
return false
|
||||
}
|
||||
}
|
||||
function addDevice(category, key, label) {
|
||||
var categoryBox = document.getElementById(category + "Box");
|
||||
var div = document.createElement("div");
|
||||
var checkbox = document.createElement("input");
|
||||
checkbox.setAttribute("type", "checkbox");
|
||||
checkbox.setAttribute("name", category + '[]');
|
||||
checkbox.setAttribute("value", key);
|
||||
checkbox.setAttribute("checked", true);
|
||||
checkbox.setAttribute("class", 'device');
|
||||
div.appendChild(checkbox);
|
||||
div.appendChild(document.createTextNode(label));
|
||||
// console.log(div);
|
||||
categoryBox.appendChild(div);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user