From 98d7404c09578cbd1b61aaf170a9ed8da88458a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Thu, 3 Aug 2023 13:52:53 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Config/Routes.php | 51 ++++++++++++++++++-- app/Config/Routes_Shoppinmall.php | 1 + app/Database/base.sql | 2 +- app/Helpers/BoardConfig_helper.php | 15 ++++-- app/Helpers/Board_helper.php | 4 +- app/Helpers/Category_helper.php | 11 ++--- app/Helpers/Common_helper.php | 74 ++++++++++++++++++++++++++++++ app/Helpers/Order_helper.php | 9 +--- app/Helpers/Product_helper.php | 11 ++--- app/Helpers/UserSNS_helper.php | 4 +- app/Helpers/User_helper.php | 8 ++-- app/Models/BaseModel.php | 2 +- app/Models/BoardConfigModel.php | 1 + app/Models/BoardModel.php | 2 +- app/Models/CategoryModel.php | 1 + app/Models/OrderModel.php | 2 +- app/Models/ProductModel.php | 2 +- app/Models/UserModel.php | 13 ++++++ 18 files changed, 170 insertions(+), 43 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1f05cb0..b55672c 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -39,9 +39,9 @@ $routes->get('/login', 'AuthController::login'); $routes->post('/signup', 'AuthController::signup/local'); $routes->get('/signup/(:alpha)', 'AuthController::signup/$1'); $routes->get('/logout', 'AuthController::logout'); -$routes->group('cart', ['namespace' => 'App\Controllers'], static function ($routes) { - $routes->post('addCart', 'CartController::addCart'); - $routes->get('cancelCart/(:uuid)', 'CartController::cancelCart/$1'); +$routes->group('ecommerce', ['namespace' => 'App\Controllers'], static function ($routes) { + $routes->post('addCart', 'EcommerceController::addCart'); + $routes->get('cancelCart/(:uuid)', 'EcommerceController::cancelCart/$1'); });; $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) { }); @@ -93,7 +93,41 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']); $routes->get('toggle/(:num)/(:hash)', 'BoardController::toggle/$1/$2'); $routes->post('batchjob', 'BoardController::batchjob'); - $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); + $routes->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2'); + }); + $routes->group('category', static function ($routes) { + $routes->get('', 'CategoryController::index'); + $routes->get('excel', 'CategoryController::excel/$1'); + $routes->get('insert', 'CategoryController::insert_form'); + $routes->post('insert', 'CategoryController::insert'); + $routes->get('update/(:num)', 'CategoryController::update_form/$1'); + $routes->post('update/(:num)', 'CategoryController::update/$1'); + $routes->get('view/(:num)', 'CategoryController::view/$1'); + $routes->get('reply/(:num)', 'CategoryController::reply_form/$1'); + $routes->post('reply/(:num)', 'CategoryController::reply/$1'); + $routes->get('delete/(:num)', 'CategoryController::delete/$1', ['filter' => 'authFilter:master']); + $routes->get('toggle/(:num)/(:hash)', 'CategoryController::toggle/$1/$2'); + $routes->post('batchjob', 'CategoryController::batchjob'); + }); + $routes->group('product', static function ($routes) { + $routes->get('', 'ProductController::index'); + $routes->get('excel', 'ProductController::excel/$1'); + $routes->get('insert', 'ProductController::insert_form'); + $routes->post('insert', 'ProductController::insert'); + $routes->get('update/(:uuid)', 'ProductController::update_form/$1'); + $routes->post('update/(:uuid)', 'ProductController::update/$1'); + $routes->get('view/(:uuid)', 'ProductController::view/$1'); + $routes->get('delete/(:uuid)', 'ProductController::delete/$1', ['filter' => 'authFilter:master']); + $routes->get('toggle/(:uuid)/(:hash)', 'ProductController::toggle/$1/$2'); + $routes->post('batchjob', 'ProductController::batchjob'); + $routes->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2'); + }); + $routes->group('order', static function ($routes) { + $routes->get('', 'OrderController::index'); + $routes->get('view/(:uuid)', 'OrderController::view/$1'); + $routes->get('delete/(:uuid)', 'OrderController::delete/$1', ['filter' => 'authFilter:master']); + $routes->get('toggle/(:uuid)/(:hash)', 'OrderController::toggle/$1/$2'); + $routes->post('batchjob', 'OrderController::batchjob`'); }); }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { @@ -115,6 +149,15 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou $routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']); $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); }); + $routes->group('product', static function ($routes) { + $routes->get('', 'ProductController::index'); + $routes->get('excel', 'ProductController::excel/$1'); + $routes->get('view/(:uuid)', 'ProductController::view/$1'); + }); + $routes->group('order', static function ($routes) { + $routes->get('', 'OrderController::index'); + $routes->get('view/(:uuid)', 'OrderController::view/$1'); + });; }); /* * -------------------------------------------------------------------- diff --git a/app/Config/Routes_Shoppinmall.php b/app/Config/Routes_Shoppinmall.php index 9a142d2..d3994be 100644 --- a/app/Config/Routes_Shoppinmall.php +++ b/app/Config/Routes_Shoppinmall.php @@ -120,6 +120,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->get('delete/(:uuid)', 'ProductController::delete/$1', ['filter' => 'authFilter:master']); $routes->get('toggle/(:uuid)/(:hash)', 'ProductController::toggle/$1/$2'); $routes->post('batchjob', 'ProductController::batchjob'); + $routes->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2'); }); $routes->group('order', static function ($routes) { $routes->get('', 'OrderController::index'); diff --git a/app/Database/base.sql b/app/Database/base.sql index 1c65dc2..995d4a4 100644 --- a/app/Database/base.sql +++ b/app/Database/base.sql @@ -7,7 +7,7 @@ CREATE TABLE servermgr.tw_user ( passwd varchar(100) NOT NULL, name varchar(20) NOT NULL COMMENT "사용자명", email varchar(50) NOT NULL, - role varchar(30) NOT NULL DEFAULT 'user' COMMENT '사용자등급', + role varchar(255) NOT NULL DEFAULT 'user' COMMENT '사용자등급', status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,unuse: 사용않함', updated_at timestamp NULL DEFAULT NULL, created_at timestamp NOT NULL DEFAULT current_timestamp(), diff --git a/app/Helpers/BoardConfig_helper.php b/app/Helpers/BoardConfig_helper.php index 6b43c33..d814931 100644 --- a/app/Helpers/BoardConfig_helper.php +++ b/app/Helpers/BoardConfig_helper.php @@ -23,16 +23,16 @@ function getFieldForm_BoardConfigHelper($field, $value, array $fieldFormOptions, case 'isupload': case 'isdownload': $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); + // return form_multiselect($field, $fieldFormOptions[$field], $value, [...$attributes]); // foreach ($fieldFormOptions[$field] as $key => $label) { // $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : explode(DEFAULTS['DELIMITER_ROLE'], $value)), $attributes) . $label; // } // return implode(" ", $checkboxs); - // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': @@ -90,6 +90,15 @@ function getFieldFilter_BoardConfigHelper($field, $value, array $fieldFormOption { $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { + case 'isaccess': + case 'isread': + case 'iswrite': + case 'isreply': + case 'isupload': + case 'isdownload': + $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); + break; default: return getFieldForm_BoardConfigHelper($field, $value, $fieldFormOptions, $attributes); break; diff --git a/app/Helpers/Board_helper.php b/app/Helpers/Board_helper.php index 2a0b0d4..c2b4125 100644 --- a/app/Helpers/Board_helper.php +++ b/app/Helpers/Board_helper.php @@ -18,11 +18,11 @@ function getFieldForm_BoardHelper($field, $value, array $fieldFormOptions, array case "board_config_uid": case "user_uid": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Board.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Board.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': diff --git a/app/Helpers/Category_helper.php b/app/Helpers/Category_helper.php index c953592..246ffbe 100644 --- a/app/Helpers/Category_helper.php +++ b/app/Helpers/Category_helper.php @@ -17,16 +17,11 @@ function getFieldForm_CategoryHelper($field, $value, array $fieldFormOptions, ar switch ($field) { case "user_uid": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Category.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); - // foreach ($fieldFormOptions[$field] as $key => $label) { - // $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : [$value]), $attributes) . $label; - // } - // return implode(" ", $checkboxs); - // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Category.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': @@ -83,7 +78,7 @@ function getFieldView_CategoryHelper($field, $entity, array $fieldFilters, array return html_entity_decode($value); break; case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['FILE_DLIMITER'], $value)[0], [...$attributes, "target" => "_self"]); + return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELLIMITER_FILE'], $value)[0], [...$attributes, "target" => "_self"]); break; case 'updated_at': case 'created_at': diff --git a/app/Helpers/Common_helper.php b/app/Helpers/Common_helper.php index 7d9e746..a039146 100644 --- a/app/Helpers/Common_helper.php +++ b/app/Helpers/Common_helper.php @@ -152,3 +152,77 @@ function imageSubmit_CommonHelper(string $src, array $attributes = []) ...$attributes, ]); } + +// STATUS가 use가 아닐때 option을 disabled되게 하기위함 (override form_dropdown) +function form_dropdown($data = '', $options = [], $selected = [], $extra = ''): string +{ + $defaults = []; + if (is_array($data)) { + if (isset($data['selected'])) { + $selected = $data['selected']; + unset($data['selected']); // select tags don't have a selected attribute + } + if (isset($data['options'])) { + $options = $data['options']; + unset($data['options']); // select tags don't use an options attribute + } + } else { + $defaults = ['name' => $data]; + } + + if (!is_array($selected)) { + $selected = [$selected]; + } + if (!is_array($options)) { + $options = [$options]; + } + + // If no selected state was submitted we will attempt to set it automatically + if (empty($selected)) { + if (is_array($data)) { + if (isset($data['name'], $_POST[$data['name']])) { + $selected = [$_POST[$data['name']]]; + } + } elseif (isset($_POST[$data])) { + $selected = [$_POST[$data]]; + } + } + + // Standardize selected as strings, like the option keys will be + foreach ($selected as $key => $item) { + $selected[$key] = (string) $item; + } + + $extra = stringify_attributes($extra); + $multiple = (count($selected) > 1 && stripos($extra, 'multiple') === false) ? ' multiple="multiple"' : ''; + $form = '\n"; +} diff --git a/app/Helpers/Order_helper.php b/app/Helpers/Order_helper.php index efa3495..e1e1eb5 100644 --- a/app/Helpers/Order_helper.php +++ b/app/Helpers/Order_helper.php @@ -18,16 +18,11 @@ function getFieldForm_OrderHelper($field, $value, array $fieldFormOptions, array case "product_uid": case "user_uid": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Order.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); - // foreach ($fieldFormOptions[$field] as $key => $label) { - // $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : [$value]), $attributes) . $label; - // } - // return implode(" ", $checkboxs); - // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Order.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': diff --git a/app/Helpers/Product_helper.php b/app/Helpers/Product_helper.php index 5d3fc81..112932a 100644 --- a/app/Helpers/Product_helper.php +++ b/app/Helpers/Product_helper.php @@ -18,16 +18,11 @@ function getFieldForm_ProductHelper($field, $value, array $fieldFormOptions, arr case "category_uid": case "user_uid": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Product.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); - // foreach ($fieldFormOptions[$field] as $key => $label) { - // $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : [$value]), $attributes) . $label; - // } - // return implode(" ", $checkboxs); - // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Product.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes]); break; case 'updated_at': case 'created_at': @@ -86,7 +81,7 @@ function getFieldView_ProductHelper($field, $entity, array $fieldFilters, array break; case 'photo': case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['FILE_DLIMITER'], $value)[0], [...$attributes, "target" => "_self"]); + return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], [...$attributes, "target" => "_self"]); break; case 'cost': case 'price': diff --git a/app/Helpers/UserSNS_helper.php b/app/Helpers/UserSNS_helper.php index 1b88279..634b598 100644 --- a/app/Helpers/UserSNS_helper.php +++ b/app/Helpers/UserSNS_helper.php @@ -18,11 +18,11 @@ function getFieldForm_UserSNSHelper($field, $value, array $fieldFormOptions, arr switch ($field) { case "user_uid": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("UserSNS.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("UserSNS.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': diff --git a/app/Helpers/User_helper.php b/app/Helpers/User_helper.php index 62de186..1492c23 100644 --- a/app/Helpers/User_helper.php +++ b/app/Helpers/User_helper.php @@ -18,16 +18,16 @@ function getFieldForm_UserHelper($field, $value, array $fieldFormOptions, array switch ($field) { case 'role': // $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - // return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + // return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); + // return form_multiselect($field, $fieldFormOptions[$field], $value, [...$attributes]); foreach ($fieldFormOptions[$field] as $key => $label) { $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : explode(DEFAULTS['DELIMITER_ROLE'], $value)), $attributes) . $label; } return implode(" ", $checkboxs); - // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); break; case "status": $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes); + return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes); break; case 'updated_at': case 'created_at': @@ -88,7 +88,7 @@ function getFieldFilter_UserHelper($field, $value, array $fieldFormOptions, arra switch ($field) { case 'role': $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]); break; default: return getFieldForm_UserHelper($field, $value, $fieldFormOptions, $attributes); diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 64051aa..3ca3e65 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -142,7 +142,7 @@ abstract class BaseModel extends Model switch ($field) { case 'user_uid': if (is_null($this->_user_options)) { - $userModel = new UserModel([$this->getPrimaryKey(), $this->getTitleField()]); + $userModel = new UserModel(); $this->_user_options = $userModel->getOptions(); } $options = $this->_user_options; diff --git a/app/Models/BoardConfigModel.php b/app/Models/BoardConfigModel.php index ddbda28..9fe87ef 100644 --- a/app/Models/BoardConfigModel.php +++ b/app/Models/BoardConfigModel.php @@ -42,6 +42,7 @@ class BoardConfigModel extends BaseModel case "isdownload": //아래 Rule은 입력시에는 되는데 수정시에는 않됨 이유를 ? // $rules[$field] = "required|in_list[master,director,cloudflare,manager,gold,silver,brone,vip,user,guest]"; + //아래 Rule은 checkbox를 사용시에는 required만 우선 써야 수정시 validate문제없음 $rules[$field] = "required"; break; default: diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index de21620..4238360 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -56,7 +56,7 @@ class BoardModel extends BaseHierarchyModel switch ($field) { case 'board_config_uid': if (is_null($this->_boardconfig_options)) { - $boardConfigModel = new BoardConfigModel([$this->getPrimaryKey(), $this->getTitleField()]); + $boardConfigModel = new BoardConfigModel(); $this->_boardconfig_options = $boardConfigModel->getOptions(); } $options = $this->_boardconfig_options; diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index 0cf6a93..8c549cf 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -47,6 +47,7 @@ class CategoryModel extends BaseHierarchyModel public function getOptions(array $conditions = array(), $options = array()): array { + //대분류 부분은 선택이 되지 않게 하기위해 따로 만듬 (form_dropdown의 optgroup 기능) $old_title = ""; foreach ($this->where($conditions)->orderby("grpno DESC, grporder ASC")->findAll() as $entity) { if ($entity->getPrimaryKey() == $entity->getHierarchy_No()) { diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php index 6da17e2..6107225 100644 --- a/app/Models/OrderModel.php +++ b/app/Models/OrderModel.php @@ -46,7 +46,7 @@ class OrderModel extends BaseModel switch ($field) { case 'product_uid': if (is_null($this->_product_options)) { - $productModel = new productModel([$this->getPrimaryKey(), 'product_uid']); + $productModel = new productModel(); $this->_product_options = $productModel->getOptions(); } $options = $this->_product_options; diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index a32a7c8..5be3553 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -67,7 +67,7 @@ class ProductModel extends BaseModel switch ($field) { case 'category_uid': if (is_null($this->_category_options)) { - $categoryModel = new CategoryModel([$this->getPrimaryKey(), $this->getTitleField()]); + $categoryModel = new CategoryModel(); $this->_category_options = $categoryModel->getOptions(); } $options = $this->_category_options; diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 9b98489..b5741be 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -45,6 +45,7 @@ class UserModel extends BaseModel case "role": //아래 Rule은 입력시에는 되는데 수정시에는 않됨 이유를 ? // $rules[$field] = "required|in_list[master,director,cloudflare,manager,gold,silver,brone,vip,user]"; + //아래 Rule은 checkbox를 사용시에는 required만 우선 써야 수정시 validate문제없음 $rules[$field] = "required"; break; default: @@ -57,6 +58,18 @@ class UserModel extends BaseModel { return parent::getEntity($conditions); } + public function getOptions(array $conditions = array(), $options = array()): array + { + foreach ($this->getEntitys($conditions) as $entity) { + // STATUS가 use가 아닐때 option을 disabled되게 하기위함 + if ($entity->getStatus() != DEFAULTS['STATUS']) { + $options[$entity->getPrimaryKey() . "\" disabled=\"disabled"] = $entity->getTitle(); + } else { + $options[$entity->getPrimaryKey()] = $entity->getTitle(); + } + } + return $options; + } protected function changeFormData(string $action, string $field, array $formDatas, $entity) { switch ($field) {