dbms_init...1

This commit is contained in:
choi.jh 2025-07-10 15:46:15 +09:00
parent cd76b2566d
commit 07f9be5e42
5 changed files with 21 additions and 32 deletions

View File

@ -160,6 +160,12 @@ abstract class CommonController extends BaseController
{ {
return $this->_control['filter_optons'][$field]; return $this->_control['filter_optons'][$field];
} }
final protected function setFilterValues(): void
{
foreach ($this->getFilterFields() as $field) {
$this->_control[$field] = $this->request->getVar($field);
}
}
protected function initAction(string $action, $fields = []): void protected function initAction(string $action, $fields = []): void
{ //각 Field 초기화 { //각 Field 초기화
@ -281,15 +287,10 @@ abstract class CommonController extends BaseController
//각 Field 초기화 //각 Field 초기화
// $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); // $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
$this->initAction(__FUNCTION__); $this->initAction(__FUNCTION__);
helper(['form']);
//filter_fields에 해당하는 값이 있을 경우 정의 //filter_fields에 해당하는 값이 있을 경우 정의
foreach ($this->getFilterFields() as $field) { $this->setFilterValues();
$value = $this->request->getVar($field);
if ($value) {
$this->$field = $value;
}
}
$this->create_form_process(); $this->create_form_process();
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -333,20 +334,15 @@ abstract class CommonController extends BaseController
//각 Field 초기화 //각 Field 초기화
// $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); // $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
$this->initAction(__FUNCTION__); $this->initAction(__FUNCTION__);
helper(['form']);
//filter_fields에 해당하는 값이 있을 경우 정의 //filter_fields에 해당하는 값이 있을 경우 정의
foreach ($this->getFilterFields() as $field) { $this->setFilterValues();
$value = $this->request->getVar($field);
if ($value) {
$this->$field = $value;
}
}
//기존 Entity 가져오기 //기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid); $entity = $this->getService()->getEntity($uid);
if (!$entity) { if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
} }
$this->modify_form_process($entity); $this->modify_form_process($entity);
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -547,20 +543,15 @@ abstract class CommonController extends BaseController
foreach ($this->getViewFields() as $field) { foreach ($this->getViewFields() as $field) {
$this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field)); $this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field));
} }
helper(['form']); //filter_fields에 해당하는 값이 있을 경우 정의
$this->setFilterValues();
//기존 Entity 가져오기 //기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid); $entity = $this->getService()->getEntity($uid);
if (!$entity) { if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
} }
//filter_fields에 해당하는 값이 있을 경우 정의
foreach ($this->getFilterFields() as $field) {
$value = $this->request->getVar($field);
if ($value) {
$this->$field = $value;
}
}
$this->view_process($entity); $this->view_process($entity);
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -572,13 +563,11 @@ abstract class CommonController extends BaseController
//Filter 조건절 처리 //Filter 조건절 처리
protected function setFilterConditionForList(): void protected function setFilterConditionForList(): void
{ {
if (!array_key_exists('filter_datas', $this->_control)) { //filter_fields에 해당하는 값이 있을 경우 정의
$this->_control['filter_values'] = []; $this->setFilterValues();
}
foreach ($this->getFilterFields() as $field) { foreach ($this->getFilterFields() as $field) {
$this->_control['filter_values'][$field] = $this->request->getVar($field); if ($this->_control[$field] !== null && $this->_control[$field] !== '') {
if ($this->_control['filter_values'][$field] !== null && $this->_control['filter_values'][$field] !== '') { $this->getService()->getModel()->where("{$this->getService()->getModel()->getTable()}.{$field}", $this->_control[$field]);
$this->getService()->getModel()->where("{$this->getService()->getModel()->getTable()}.{$field}", $this->_control['filter_values'][$field]);
} }
} }
} }

View File

@ -18,7 +18,7 @@ class ServiceItemHelper extends CustomerHelper
final function getFieldFormByByItemType(string $field, mixed $value, array $viewDatas, array $extras = []): string final function getFieldFormByByItemType(string $field, mixed $value, array $viewDatas, array $extras = []): string
{ {
// dd($viewDatas['control']); // dd($viewDatas['control']);
$item_type = $viewDatas['control']['filter_values']['item_type']; $item_type = $viewDatas['control']['item_type'];
//Field는 item_uid이지만 , item_tpe에 따라 filter_options가 달라진다. //Field는 item_uid이지만 , item_tpe에 따라 filter_options가 달라진다.
switch ($item_type) { switch ($item_type) {
case "IP": case "IP":

View File

@ -10,7 +10,7 @@
<tr> <tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th> <th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
<td nowrap class="text-start"> <td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas[$field] ?? null), $viewDatas) ?> <?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['control'][$field] ?? null), $viewDatas) ?>
<span><?= validation_show_error($field); ?></span> <span><?= validation_show_error($field); ?></span>
</td> </td>
</tr> </tr>

View File

@ -10,7 +10,7 @@
<tr> <tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th> <th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
<td nowrap class="text-start"> <td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas[$field] ?? null), $viewDatas) ?> <?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['control'][$field] ?? null), $viewDatas) ?>
<span><?= validation_show_error($field); ?></span> <span><?= validation_show_error($field); ?></span>
</td> </td>
</tr> </tr>

View File

@ -4,7 +4,7 @@
<nav class="condition nav"> <nav class="condition nav">
조건: 조건:
<?php foreach ($viewDatas['control']['filter_fields'] as $field): ?> <?php foreach ($viewDatas['control']['filter_fields'] as $field): ?>
<?= $viewDatas['helper']->getFieldForm($field, $viewDatas['control']['filter_values'][$field] ?? old($field), $viewDatas, ['id' => $field, 'index_content_top_filter' => 'true']) ?>&nbsp; <?= $viewDatas['helper']->getFieldForm($field, $viewDatas['control'][$field] ?? old($field), $viewDatas, ['id' => $field, 'index_content_top_filter' => 'true']) ?>&nbsp;
<?php endforeach ?> <?php endforeach ?>
</nav> </nav>
<nav class="search nav justify-content-center"> <nav class="search nav justify-content-center">