diff --git a/app/Controllers/Admin/ProductController.php b/app/Controllers/Admin/ProductController.php index 3515353..1f0b5d7 100644 --- a/app/Controllers/Admin/ProductController.php +++ b/app/Controllers/Admin/ProductController.php @@ -2,11 +2,11 @@ namespace App\Controllers\Admin; +use App\Controllers\Trait\UpDownloadTrait; use App\Models\ProductModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -use App\Controllers\Trait\UpDownloadTrait; class ProductController extends AdminController { @@ -56,7 +56,7 @@ class ProductController extends AdminController return $this->_viewDatas['fieldDatas']; } - protected function insert_process() + private function calculate_price(): int { if ($this->_viewDatas['fieldDatas']['cost'] < $this->_viewDatas['fieldDatas']['sale']) { throw new \Exception(sprintf( @@ -67,7 +67,16 @@ class ProductController extends AdminController number_format($this->_viewDatas['fieldDatas']['sale']), )); } - $this->_viewDatas['fieldDatas']['price'] = $this->_viewDatas['fieldDatas']['cost'] - $this->_viewDatas['fieldDatas']['sale']; + return $this->_viewDatas['fieldDatas']['cost'] - $this->_viewDatas['fieldDatas']['sale']; + } + protected function insert_process() + { + $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); return parent::insert_process(); } + protected function update_process($entity) + { + $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); + return parent::update_process($entity); + } } diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php index a3b02e5..066b292 100644 --- a/app/Controllers/Front/BoardController.php +++ b/app/Controllers/Front/BoardController.php @@ -21,7 +21,7 @@ class BoardController extends FrontController switch ($action) { case "index": case "excel": - return ['title', "board_file", "view_cnt", "created_at"]; + return ['title', "board_file", "created_at", "view_cnt"]; break; case "view": return ['title', "board_file", "view_cnt", "created_at", "content"]; diff --git a/app/Controllers/Front/ProductController.php b/app/Controllers/Front/ProductController.php index bc0f7d4..8e746e7 100644 --- a/app/Controllers/Front/ProductController.php +++ b/app/Controllers/Front/ProductController.php @@ -17,11 +17,11 @@ class ProductController extends FrontController } public function getFields(string $action = ""): array { - $fields = ["photo", 'user_uid', 'name', "cost", "price", "sale", "stock", "view_cnt", "content",]; + $fields = ["photo", 'user_uid', 'name', "cost", "sale", "price", "stock", "view_cnt", "content",]; switch ($action) { case "index": case "excel": - return ["photo", "user_uid", 'name', "cost", "price", "sale", "stock", "view_cnt"]; + return ["user_uid", "photo", 'name', "cost", "sale", "price", "stock", "view_cnt"]; break; case "view": return [...$fields, "created_at"]; diff --git a/app/Helpers/Product_helper.php b/app/Helpers/Product_helper.php index 36e96d7..57c8917 100644 --- a/app/Helpers/Product_helper.php +++ b/app/Helpers/Product_helper.php @@ -83,7 +83,7 @@ function getFieldView_ProductHelper($field, $entity, array $viewDatas) case 'name': return anchor( current_url() . '/view/' . $entity->getPrimaryKey(), - $value ? str_split($value, 40)[0] . "..." : "", + $value ? str_split($value, 66)[0] . "..." : "", ["target" => "_self"] ); break; diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index d3e921b..1717ac5 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -41,7 +41,7 @@ class ProductModel extends BaseModel $rules[$field] = "required|trim|string"; break; case 'photo': - $rules[$field] = !$action ? "if_exist|string" : "uploaded[$field]|is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; + $rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; break; case 'cost': case 'price': diff --git a/app/Views/front/board/index.php b/app/Views/front/board/index.php index 2e80421..399aa3a 100644 --- a/app/Views/front/board/index.php +++ b/app/Views/front/board/index.php @@ -1,17 +1,11 @@ extend('layouts/front') ?> section('content') ?> -
+ +
getHead()) ?>
-
- "get")) ?> - - -
+
include('templates/front/index_head') ?>
- +
diff --git a/app/Views/front/product/index.php b/app/Views/front/product/index.php index f9e34d2..9e9fce3 100644 --- a/app/Views/front/product/index.php +++ b/app/Views/front/product/index.php @@ -1,55 +1,53 @@ extend('layouts/front') ?> section('content') ?> -
+ +
getHead()) ?>
-
번호
- - - - - -
- getPrimaryKey() . 'order_field=price,order_value=ASC', '판매가순', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?> - getPrimaryKey() . 'order_field=view_cnt,order_value=DESC', '인기순', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?> - - "get")) ?> - include('templates/front/index_head') ?> - - - getPrimaryKey() . '&v=_list', 'List', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?> -
+
+ include('templates/front/index_head') ?> + +
-
- - - - - - - - - - -
-
-
- 판매가: - - 원가:원 - - - 할인가:원 - -
-
- 조회수: -
-
- - -
-
- -
+ + + + + + + + + + + + + + + +
getPhotoFileName('middle') ?> + + +
+ 판매가: + + 원가:원 + - + 할인가:원 + +
조회수:
+ + +
getTail()) ?>
diff --git a/app/Views/front/product/index_list.php b/app/Views/front/product/index_list.php index 30fdb9f..b7c238e 100644 --- a/app/Views/front/product/index_list.php +++ b/app/Views/front/product/index_list.php @@ -1,27 +1,27 @@ extend('layouts/front') ?> section('content') ?> -
+ +
getHead()) ?>
- - - - - - -
- getPrimaryKey() . 'order_field=price,order_value=ASC', '판매가순', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?> - getPrimaryKey() . 'order_field=view_cnt,order_value=DESC', '인기순', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?> - - "get")) ?> - include('templates/front/index_head') ?> - - - getPrimaryKey(), 'Block', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?> -
+
+ include('templates/front/index_head') ?> + +
- +
- + @@ -31,6 +31,8 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> @@ -41,9 +43,7 @@
번호
+ +
-
- -
+
getTail()) ?>
diff --git a/app/Views/layouts/front.php b/app/Views/layouts/front.php index 8f1755e..c42ed07 100644 --- a/app/Views/layouts/front.php +++ b/app/Views/layouts/front.php @@ -4,7 +4,7 @@ - + diff --git a/app/Views/layouts/front/left_menu.php b/app/Views/layouts/front/left_menu.php index 07ab2f9..fd09d42 100644 --- a/app/Views/layouts/front/left_menu.php +++ b/app/Views/layouts/front/left_menu.php @@ -3,12 +3,12 @@
-
-
getTitle() ?>
+
getTitle() ?>
getPrimaryKey(), $category->getTitle(), ["target" => "_self"] diff --git a/app/Views/layouts/front/top_menu.php b/app/Views/layouts/front/top_menu.php index 19ae193..fa58341 100644 --- a/app/Views/layouts/front/top_menu.php +++ b/app/Views/layouts/front/top_menu.php @@ -1,5 +1,5 @@ -