shoppingmallv2 init...
This commit is contained in:
parent
cde478771c
commit
db90d56cb5
@ -40,6 +40,19 @@ class UserController extends AdminController
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||||
|
{
|
||||||
|
switch ($field) {
|
||||||
|
case 'role':
|
||||||
|
//checkbox형태로 들어오면 $fieldDatas['role']가 array이기때문에
|
||||||
|
$rules[$field . '.*'] = "required|in_list[master,director,cloudflare,manager,gold,silver,brone,vip,user]";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$rules = parent::getFieldRule($field, $rules, $action);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
public function getFieldFilters(): array
|
public function getFieldFilters(): array
|
||||||
{
|
{
|
||||||
return ["role", "status"];
|
return ["role", "status"];
|
||||||
@ -48,21 +61,4 @@ class UserController extends AdminController
|
|||||||
{
|
{
|
||||||
return parent::getFieldBatchFilters();
|
return parent::getFieldBatchFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function insert_validate()
|
|
||||||
{
|
|
||||||
$rules = [];
|
|
||||||
foreach ($this->_viewDatas['fieldRules'] as $field => $rule) {
|
|
||||||
switch ($field) {
|
|
||||||
case 'role':
|
|
||||||
//checkbox형태로 들어오면 $fieldDatas['role']가 array이기때문에
|
|
||||||
$rules[$field . '.*'] = $rule;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$rules[$field] = $rule;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent::insert_validate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,6 +47,7 @@ abstract class BaseController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
|
private $_validation = null;
|
||||||
protected $_model = null;
|
protected $_model = null;
|
||||||
protected $_session = null;
|
protected $_session = null;
|
||||||
protected $_viewPath = '';
|
protected $_viewPath = '';
|
||||||
@ -58,6 +59,7 @@ abstract class BaseController extends Controller
|
|||||||
// Preload any models, libraries, etc, here.
|
// Preload any models, libraries, etc, here.
|
||||||
// E.g.: $this->session = \Config\Services::session();
|
// E.g.: $this->session = \Config\Services::session();
|
||||||
$this->_session = \Config\Services::session();
|
$this->_session = \Config\Services::session();
|
||||||
|
$this->_validation = \Config\Services::validation();
|
||||||
$this->_viewDatas['session'] = $this->_session;
|
$this->_viewDatas['session'] = $this->_session;
|
||||||
//사용자 기본 Role 지정
|
//사용자 기본 Role 지정
|
||||||
$this->_viewDatas[SESSION_NAMES['ISLOGIN']] = false;
|
$this->_viewDatas[SESSION_NAMES['ISLOGIN']] = false;
|
||||||
@ -171,21 +173,16 @@ abstract class BaseController extends Controller
|
|||||||
}
|
}
|
||||||
protected function insert_validate()
|
protected function insert_validate()
|
||||||
{
|
{
|
||||||
//fieldData Rule 검사
|
|
||||||
//추후 VersionUP용
|
|
||||||
// $this->_model->getValidation($this->getFields());
|
|
||||||
// if (! $this->_validation->run($user)) {
|
|
||||||
// throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
// }
|
|
||||||
//fieldData Rule 검사
|
|
||||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
|
||||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
}
|
|
||||||
//fieldData 적용
|
//fieldData 적용
|
||||||
$this->_viewDatas['fieldDatas'] = array();
|
$this->_viewDatas['fieldDatas'] = array();
|
||||||
foreach ($this->_viewDatas['fields'] as $field) {
|
foreach ($this->_viewDatas['fields'] as $field) {
|
||||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
|
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||||
|
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
|
||||||
|
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected function insert_process()
|
protected function insert_process()
|
||||||
{
|
{
|
||||||
@ -232,20 +229,17 @@ abstract class BaseController extends Controller
|
|||||||
}
|
}
|
||||||
protected function update_validate($entity)
|
protected function update_validate($entity)
|
||||||
{
|
{
|
||||||
//fieldData Rule 검사
|
|
||||||
//추후 VersionUP용
|
|
||||||
// $this->_model->getValidation($this->getFields());
|
|
||||||
// if (! $this->_validation->run($user)) {
|
|
||||||
// throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
// }
|
|
||||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
|
||||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
}
|
|
||||||
//fieldData 적용
|
//fieldData 적용
|
||||||
$this->_viewDatas['fieldDatas'] = array();
|
$this->_viewDatas['fieldDatas'] = array();
|
||||||
foreach ($this->_viewDatas['fields'] as $field) {
|
foreach ($this->_viewDatas['fields'] as $field) {
|
||||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||||
|
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
|
||||||
|
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||||
|
}
|
||||||
|
|
||||||
//변견된 데이터 Log로 남기기
|
//변견된 데이터 Log로 남기기
|
||||||
foreach ($this->_viewDatas['fieldDatas'] as $field => $value) {
|
foreach ($this->_viewDatas['fieldDatas'] as $field => $value) {
|
||||||
if ($field != "passwd") { //보안위험성이 있으므로 passwd는 Log에 남기지 않는다.
|
if ($field != "passwd") { //보안위험성이 있으므로 passwd는 Log에 남기지 않는다.
|
||||||
@ -308,14 +302,16 @@ abstract class BaseController extends Controller
|
|||||||
}
|
}
|
||||||
protected function reply_validate($entity)
|
protected function reply_validate($entity)
|
||||||
{
|
{
|
||||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
|
||||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
}
|
|
||||||
//fieldData 적용
|
//fieldData 적용
|
||||||
$this->_viewDatas['fieldDatas'] = array();
|
$this->_viewDatas['fieldDatas'] = array();
|
||||||
foreach ($this->_viewDatas['fields'] as $field) {
|
foreach ($this->_viewDatas['fields'] as $field) {
|
||||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||||
|
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
|
||||||
|
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected function reply_process($entity)
|
protected function reply_process($entity)
|
||||||
{
|
{
|
||||||
@ -344,14 +340,16 @@ abstract class BaseController extends Controller
|
|||||||
//Toggle 관련
|
//Toggle 관련
|
||||||
protected function toggle_validate($entity)
|
protected function toggle_validate($entity)
|
||||||
{
|
{
|
||||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
|
||||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
}
|
|
||||||
//fieldData 적용
|
//fieldData 적용
|
||||||
$this->_viewDatas['fieldDatas'] = array();
|
$this->_viewDatas['fieldDatas'] = array();
|
||||||
foreach ($this->_viewDatas['fields'] as $field) {
|
foreach ($this->_viewDatas['fields'] as $field) {
|
||||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||||
|
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
|
||||||
|
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected function toggle_process($entity)
|
protected function toggle_process($entity)
|
||||||
{
|
{
|
||||||
@ -378,14 +376,16 @@ abstract class BaseController extends Controller
|
|||||||
//Batchjob 관련
|
//Batchjob 관련
|
||||||
protected function batchjob_validate($entity)
|
protected function batchjob_validate($entity)
|
||||||
{
|
{
|
||||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
|
||||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
||||||
}
|
|
||||||
//fieldData 적용
|
//fieldData 적용
|
||||||
$this->_viewDatas['fieldDatas'] = array();
|
$this->_viewDatas['fieldDatas'] = array();
|
||||||
foreach ($this->_viewDatas['fields'] as $field) {
|
foreach ($this->_viewDatas['fields'] as $field) {
|
||||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||||
|
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
|
||||||
|
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected function batchjob_process($entity)
|
protected function batchjob_process($entity)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -40,16 +40,16 @@ class CardController extends BillingController
|
|||||||
$rules[$field] = 'required|in_list[00,01]';
|
$rules[$field] = 'required|in_list[00,01]';
|
||||||
break;
|
break;
|
||||||
case "card_number":
|
case "card_number":
|
||||||
$rules[$field] = 'required|regex_match[/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}/]';
|
$rules[$field] = 'required|regex_match[/^[0-9]{4}[\/-][0-9]{4}[\/-][0-9]{4}[\/-][0-9]{4}/]';
|
||||||
break;
|
break;
|
||||||
case "card_expiration":
|
case "card_expiration":
|
||||||
$rules[$field] = 'required|regex_match[/^[1-12]{2}-[0-9]{4}/]';
|
$rules[$field] = 'required|regex_match[/^[0-9]{4}[\/-](0[0-9]|1[0-2])/]';
|
||||||
break;
|
break;
|
||||||
case "email":
|
case "email":
|
||||||
$rules[$field] = 'required|valid_email';
|
$rules[$field] = 'required|valid_email';
|
||||||
break;
|
break;
|
||||||
case "phone":
|
case "phone":
|
||||||
$rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]';
|
$rules[$field] = 'required|regex_match[/^[0-9]{3}[\/-][0-9]{4}[\/-][0-9]{4}/]';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rules = parent::getFieldRule($field, $rules, $action);
|
$rules = parent::getFieldRule($field, $rules, $action);
|
||||||
@ -81,6 +81,25 @@ class CardController extends BillingController
|
|||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
//Field별 Form Datas 처리용
|
||||||
|
protected function getFieldFormData(string $field, $entity = null): array
|
||||||
|
{
|
||||||
|
switch ($field) {
|
||||||
|
case 'card_number':
|
||||||
|
case 'card_expiration':
|
||||||
|
$temps = array();
|
||||||
|
foreach ($this->request->getVar($field) as $value) {
|
||||||
|
array_push($temps, $value);
|
||||||
|
}
|
||||||
|
$this->_viewDatas['fieldDatas'][$field] = implode("-", $temps);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return parent::getFieldFormData($field, $entity);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $this->_viewDatas['fieldDatas'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Update관련
|
//Update관련
|
||||||
//카드결제처리
|
//카드결제처리
|
||||||
@ -108,6 +127,7 @@ class CardController extends BillingController
|
|||||||
$this->_viewDatas['fieldDatas']["response"] = $this->pg_process(true);
|
$this->_viewDatas['fieldDatas']["response"] = $this->pg_process(true);
|
||||||
//Card 결제처리
|
//Card 결제처리
|
||||||
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
|
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
|
||||||
|
$this->_viewDatas['fieldDatas']["status"] = DEFAULTS['STATUS'];
|
||||||
return parent::update_process($entity);
|
return parent::update_process($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,16 +30,16 @@ function getFieldForm_CardHelper($field, $value, array $viewDatas, array $attrib
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'card_expiration':
|
case 'card_expiration':
|
||||||
$months = [];
|
|
||||||
for ($i = 1; $i <= 12; $i++) {
|
|
||||||
$months[$i] = "{$i}월";
|
|
||||||
}
|
|
||||||
$start = date('Y');
|
$start = date('Y');
|
||||||
$end = date('Y', strtotime(date("Y") . ' + 10 year'));
|
$end = date('Y', strtotime(date("Y") . ' + 10 year'));
|
||||||
$years = [];
|
$years = [];
|
||||||
for ($i = $start; $i <= $end; $i++) {
|
for ($i = $start; $i <= $end; $i++) {
|
||||||
$years[$i] = "{$i}년";
|
$years[$i] = "{$i}년";
|
||||||
}
|
}
|
||||||
|
$months = [];
|
||||||
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
|
$months[sprintf("%02d", $i)] = "{$i}월";
|
||||||
|
}
|
||||||
return form_dropdown("{$field}[]", $years, DEFAULTS['EMPTY']) . '/ ' .
|
return form_dropdown("{$field}[]", $years, DEFAULTS['EMPTY']) . '/ ' .
|
||||||
form_dropdown("{$field}[]", $months, DEFAULTS['EMPTY']);
|
form_dropdown("{$field}[]", $months, DEFAULTS['EMPTY']);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user