diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index d51eef7..0a34536 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -70,10 +70,10 @@ class UserController extends AdminController switch ($field) { case 'role': //아래 Rule Array는 필드명.* checkbox를 사용 - $this->validation->setRule($field . "*", $field, $this->getModel()->getRule($action, $field)); + $this->validation->setRule($field . "*", $field, $this->getModel()->getFieldRule($action, $field)); break; default: - $this->validation->setRule($field, $field, $this->getModel()->getRule($action, $field)); + $this->validation->setRule($field, $field, $this->getModel()->getFieldRule($action, $field)); break; } } @@ -103,10 +103,10 @@ class UserController extends AdminController switch ($field) { case 'role': //아래 Rule Array는 필드명.* checkbox를 사용 - $this->validation->setRule($field . "*", $field, $this->getModel()->getRule($action, $field)); + $this->validation->setRule($field . "*", $field, $this->getModel()->getFieldRule($action, $field)); break; default: - $this->validation->setRule($field, $field, $this->getModel()->getRule($action, $field)); + $this->validation->setRule($field, $field, $this->getModel()->getFieldRule($action, $field)); break; } } diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php index 5705606..9a72980 100644 --- a/app/Controllers/MVController.php +++ b/app/Controllers/MVController.php @@ -102,9 +102,9 @@ abstract class MVController extends CommonController $this->getModel()->transStart(); try { $this->create_process(); + $this->getModel()->transCommit(); log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다."); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n"); - $this->getModel()->transCommit(); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback @@ -153,6 +153,7 @@ abstract class MVController extends CommonController } protected function modify_process(string $uid): void { + // dd($this->fields); $this->modify_validate($this->action, $this->fields); $this->formDatas = $this->getFormDatas(); $this->entity = $this->getModel()->getEntityByPK(intval($uid)); @@ -167,9 +168,9 @@ abstract class MVController extends CommonController $this->getModel()->transStart(); try { $this->modify_process($uid); + $this->getModel()->transCommit(); log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다."); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n"); - $this->getModel()->transCommit(); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback @@ -181,10 +182,10 @@ abstract class MVController extends CommonController } } //단일필드작업 - final public function toggle(string $field, string $uid): RedirectResponse + final public function toggle(string $uid, string $field): RedirectResponse { $this->action = __FUNCTION__; - $this->field = [$field]; + $this->fields = [$field]; return $this->modify_procedure($uid); } //일괄처리작업 @@ -207,9 +208,9 @@ abstract class MVController extends CommonController $this->getModel()->transStart(); try { $this->batcjob_process(); + $this->getModel()->transCommit(); log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다."); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n"); - $this->getModel()->transCommit(); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback @@ -235,9 +236,9 @@ abstract class MVController extends CommonController $this->getModel()->transStart(); try { $this->delete_process($uid); + $this->getModel()->transCommit(); log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다."); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n"); - $this->getModel()->transCommit(); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback diff --git a/app/Helpers/Admin/User_helper.php b/app/Helpers/Admin/User_helper.php index 24038be..e62380f 100644 --- a/app/Helpers/Admin/User_helper.php +++ b/app/Helpers/Admin/User_helper.php @@ -26,8 +26,9 @@ function getFieldForm_UserHelper(string $field, mixed $value, array $viewDatas, if (in_array($viewDatas['action'], ['create', 'modify'])) { $forms = []; foreach ($viewDatas['field_options'][$field] as $key => $label) { - $roles = explode(DEFAULTS["DELIMITER_ROLE"], $value); - $forms[] = form_checkbox("{$field}[]", $value, in_array($key, $roles)) . $label; + log_message("debug", var_export($value, true)); + $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); + $forms[] = form_checkbox($field, $key, in_array($key, $values)) . $label; } $form = implode(" ", $forms); } else { diff --git a/app/Views/templates/admin/footer.php b/app/Views/templates/admin/footer.php index f6e670c..58b050d 100644 --- a/app/Views/templates/admin/footer.php +++ b/app/Views/templates/admin/footer.php @@ -1,5 +1,5 @@