diff --git a/app/Cells/BoardCell.php b/app/Cells/BoardCell.php index e20ec0a..883f89f 100644 --- a/app/Cells/BoardCell.php +++ b/app/Cells/BoardCell.php @@ -15,13 +15,11 @@ class BoardCell extends BaseCell public function information(array $viewDatas): string { helper('Board'); - $viewDatas['currentCategory'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => __FUNCTION__]); - $viewDatas['cellDatas'] = array(); $viewDatas['cellDatas']['entitys'] = $this->getBoardModel()->getEntitys([ 'category' => __FUNCTION__ ]); return view( - 'Views/front/board/cell/' . __FUNCTION__, + 'Views/cells/board/' . __FUNCTION__, ['viewDatas' => $viewDatas] ); } diff --git a/app/Cells/ProductCell.php b/app/Cells/ProductCell.php index 1416c21..e6af540 100644 --- a/app/Cells/ProductCell.php +++ b/app/Cells/ProductCell.php @@ -3,14 +3,46 @@ namespace App\Cells; use App\Cells\BaseCell; +use App\Models\DeviceModel; class ProductCell extends BaseCell { - public function virtual_calculator(array $viewDatas): string + private $_deviceModel = null; + final protected function getDeviceModel(): DeviceModel + { + return $this->_deviceModel = $this->_deviceModel ?: new DeviceModel(); + } + + public function virtual(array $viewDatas): string { $viewDatas['cellDatas'] = array(); return view( - 'Views/front/product/cell/' . __FUNCTION__, + 'Views/cells/product/' . __FUNCTION__, + ['viewDatas' => $viewDatas] + ); + } + + public function beremetal(array $viewDatas): string + { + $viewDatas['cellDatas'] = []; + $viewDatas['cellDatas']['device'] = []; + $viewDatas['cellDatas']['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os']; + $viewDatas['cellDatas']['device']['options'] = $this->getDeviceModel()->getOptions(); + return view( + 'Views/cells/product/' . __FUNCTION__, + ['viewDatas' => $viewDatas] + ); + } + + public function beremetal_calulator(array $viewDatas): string + { + $viewDatas['cellDatas'] = []; + $viewDatas['cellDatas']['device'] = []; + $viewDatas['cellDatas']['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os']; + $viewDatas['cellDatas']['device']['options'] = $this->getDeviceModel()->getOptions(); + + return view( + 'Views/cells/product/' . __FUNCTION__, ['viewDatas' => $viewDatas] ); } diff --git a/app/Controllers/Admin/DeviceController.php b/app/Controllers/Admin/DeviceController.php index 65df63b..73aef2e 100644 --- a/app/Controllers/Admin/DeviceController.php +++ b/app/Controllers/Admin/DeviceController.php @@ -22,11 +22,11 @@ class DeviceController extends AdminController public function getFields(string $action = ""): array { - $fields = ["type", "name", "cost", "price", "sale", "stock", "status", "content",]; + $fields = ["category", "name", "cost", "price", "status",]; switch ($action) { case "index": case "excel": - return ["type", "name", "cost", "price", "sale", "stock", "status", "created_at"]; + return ["category", "name", "cost", "price", "status", "created_at"]; break; case "view": return [...$fields, "created_at"]; @@ -38,7 +38,7 @@ class DeviceController extends AdminController } public function getFieldFilters(): array { - return ["type", "status"]; + return ["category", "status"]; } public function getFieldBatchFilters(): array { diff --git a/app/Controllers/Admin/ProductController.php b/app/Controllers/Admin/ProductController.php index d817e36..a885dfa 100644 --- a/app/Controllers/Admin/ProductController.php +++ b/app/Controllers/Admin/ProductController.php @@ -24,18 +24,13 @@ class ProductController extends AdminController helper($this->_viewDatas['className']); } - final protected function getDeviceModel(): DeviceModel - { - return $this->_deviceModel = $this->_deviceModel ?: new DeviceModel(); - } - public function getFields(string $action = ""): array { - $fields = ["category_uid", 'type', 'name', "photo", "cost", "sale", "stock", "view_cnt", "status", "content",]; + $fields = ["category", 'type', 'name', "photo", "device", "cost", "sale", "stock", "view_cnt", "status", "content",]; switch ($action) { case "index": case "excel": - return ["category_uid", "user_uid", 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "status", "created_at"]; + return ["category", "user_uid", 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "status", "created_at"]; break; case "view": return [...$fields, "created_at"]; @@ -47,7 +42,7 @@ class ProductController extends AdminController } public function getFieldFilters(): array { - return ["category_uid", "user_uid", 'type', "status"]; + return ["category", "user_uid", 'type', "status"]; } public function getFieldBatchFilters(): array { @@ -84,12 +79,82 @@ class ProductController extends AdminController return $this->_viewDatas['fieldDatas']['cost'] - $this->_viewDatas['fieldDatas']['sale']; } - protected function action_init(array $action_datas): void + //가상서버 + protected function virtual_process() { - parent::action_init($action_datas); - $this->_viewDatas['device'] = []; - $this->_viewDatas['device']['fields'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os']; - $this->_viewDatas['device']['options'] = $this->getDeviceModel()->getOptions(); + //가상서버정보 + $protudctDatas = array( + 'category' => 'virtual', + 'name' => '', + 'content' => '', + 'cost' => $this->_viewDatas['fieldDatas']['price'], + 'price' => $this->_viewDatas['fieldDatas']['price'], + 'sale' => 0, + 'stock' => 1, + 'view_cnt' => 1, + 'status' => 'use', + ); + //서버부품정보검증 + $titles = array('가상서버'); + //foreach (Product['parts']['virtual']['category'] as $category => $attrs) { + foreach ([] as $category => $attrs) { + if (!$this->_viewDatas['fieldDatas'][$category]) { + throw new \Exception($category . "의 값이 지정되지 않았습니다."); + } else { + $protudctDatas[$category . "_model"] = $attrs['label']; + $protudctDatas[$category . "_cnt"] = $this->_viewDatas['fieldDatas'][$category]; + array_push( + $titles, + sprintf( + "%s * %s%s,", + $protudctDatas[$category . "_model"], + $protudctDatas[$category . "_cnt"], + $attrs['unit'], + ), + ); + } + } + $protudctDatas['name'] = implode(" ", $titles); + $protudctDatas['content'] = implode("\n", $titles); + $product = $this->_model->create($protudctDatas); + //return $this->add_procedure($product, 1, $this->_viewDatas['fieldDatas']['paymentday']); + } + //실서버 + protected function beremetal_process() + { + //상품정보가져오기 + $product = $this->_model->getEntity([$this->_model->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]); + //재고수 비교 + if ($product->stock < $this->_viewDatas['fieldDatas']['quantity']) { + throw new \Exception("구매수량이 너무 많습니다.\n구매수량:{$this->_viewDatas['fieldDatas']['quantity']}개, 남은 재고수량:{$product->stock}개"); + } + //구매 금액 비교 + $price = $product->price * $this->_viewDatas['fieldDatas']['quantity']; + if ($price != $this->_viewDatas['fieldDatas']['price']) { + throw new \Exception("실 상품금액{$price} 와 구매금액{$this->_viewDatas['fieldDatas']['price']}이 서로 다릅니다."); + } + //결제방식이 월이용권이면 결제일 확인 + $paymentDay = null; + if ($product->type == 'rental') { + $paymentDay = $this->request->getVar('paymentday') ?: throw new \Exception("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다."); + } + //return $this->add_procedure($product, $this->_viewDatas['fieldDatas']['quantity'], $paymentDay); + } + + //주문처리 + protected function device_process() + { + switch ($this->_viewDatas['fieldDatas']['category']) { + case 'virtual': + return $this->virtual_process(); + break; + case 'beremetal': + return $this->beremetal_process(); + break; + default: + throw new \Exception($this->_viewDatas['fieldDatas']['category'] . "는 알수없는 상품 구분입니다. 다시 확인 부탁드립니다."); + break; + } } //Insert관련 @@ -97,13 +162,12 @@ class ProductController extends AdminController { parent::insert_validate(); } - protected function insert_process() { + $this->device_process(); $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); return parent::insert_process(); } - //Update관련 protected function update_process($entity) { diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index f750880..1a54b42 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -530,28 +530,38 @@ abstract class BaseController extends Controller protected function index_condition() { //조건절 처리 - $filterFields = array(); foreach ($this->_viewDatas['fieldFilters'] as $field) { - if ($this->request->getVar($field) != DEFAULTS['EMPTY']) { - $filterFields[$field] = $this->request->getVar($field); - } + $value = $this->request->getVar($field); + $this->_model->setIndexFieldFilter($field, $this->request->getVar($field) ?: DEFAULTS['EMPTY']); } - $this->_viewDatas['word'] = $this->request->getVar('word') ?: ''; - $this->_viewDatas['start'] = $this->request->getVar('start') ?: ''; - $this->_viewDatas['end'] = $this->request->getVar('end') ?: ''; - $this->_viewDatas['order_field'] = $this->request->getVar('order_field') ?: 'created_at'; - $this->_viewDatas['order_value'] = $this->request->getVar('order_value') ?: 'DESC'; - $this->_model->setCondition( - $filterFields, - $this->_viewDatas['word'], - $this->_viewDatas['start'], - $this->_viewDatas['end'], - $this->_viewDatas['order_field'], - $this->_viewDatas['order_value'] - ); + //검색어 처리 + $this->_viewDatas['word'] = $this->request->getVar('word') ?: DEFAULTS['EMPTY']; + $this->_model->setIndexWordFilter($this->_viewDatas['word']); + //검색일 처리 + $this->_viewDatas['start'] = $this->request->getVar('start') ?: DEFAULTS['EMPTY']; + $this->_viewDatas['end'] = $this->request->getVar('end') ?: DEFAULTS['EMPTY']; + $this->_model->setIndexDateFilter($this->_viewDatas['start'], $this->_viewDatas['end']); } - private function index_pagination($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full'): string + //Totalcount 처리 + protected function index_total(): int { + $this->index_process(); + $this->index_condition(); + $total = $this->_model->countAllResults(); + // echo dd($this->_model->getLastQuery()); + return $total; + } + //PageNation 처리 + protected function index_pagination($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full'): string + { + //Page, Per_page필요부분 + $this->_viewDatas['page'] = (int)$this->request->getVar('page') ?: 1; + $this->_viewDatas['per_page'] = (int)$this->request->getVar('per_page') ?: $this->_per_page; + //줄수 처리용 + $this->_viewDatas['pageOptions'] = array("" => "줄수선택"); + for ($i = 10; $i <= $this->_viewDatas['total_count'] + $this->_viewDatas['per_page']; $i += 10) { + $this->_viewDatas['pageOptions'][$i] = $i; + } // 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성 // 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full', // 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가 @@ -569,49 +579,42 @@ abstract class BaseController extends Controller $this->_viewDatas['total_page'] = $pager->getPageCount($pager_group); return $pager->links($pager_group, $template); } - private function index_entitys(): array + protected function index_entitys(): array { $this->index_condition(); if (array_key_exists('page', $this->_viewDatas)) { - return $this->_model->findAll( + $this->_model->limit( $this->_viewDatas['per_page'], $this->_viewDatas['page'] * $this->_viewDatas['per_page'] - $this->_viewDatas['per_page'] ); } - return $this->_model->findAll(); + //Sorting 처리 + $this->_viewDatas['order_field'] = $this->request->getVar('order_field') ?: DEFAULTS['EMPTY']; + $this->_viewDatas['order_value'] = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY']; + $orderBy = []; + if ($this->_viewDatas['order_field'] && $this->_viewDatas['order_value']) { + $orderBy = ["{$this->_viewDatas['order_field']} {$this->_viewDatas['order_value']}"]; + } + return $this->_model->getEntitys([], $orderBy); } public function index() { try { + helper(['form']); $this->action_init(['action' => __FUNCTION__]); foreach ($this->_viewDatas['fieldFilters'] as $field) { $this->_viewDatas[$field] = $this->request->getVar($field) ?: DEFAULTS['EMPTY']; } - $this->index_process(); - //Totalcount 처리 - $this->index_condition(); - $this->_viewDatas['total_count'] = $this->_model->countAllResults(); - // echo $this->_model->getLastQuery(); - // echo "
"; - // log_message("debug", __METHOD__ . "에서 TotalCount 호출:" . $this->_model->getLastQuery()); - //Page, Per_page필요부분 - $this->_viewDatas['page'] = (int)$this->request->getVar('page') ?: 1; - $this->_viewDatas['per_page'] = (int)$this->request->getVar('per_page') ?: $this->_per_page; + //URL처리 $this->_viewDatas['uri'] = $this->request->getUri(); - //줄수 처리용 - $this->_viewDatas['pageOptions'] = array("" => "줄수선택"); - for ($i = 10; $i <= $this->_viewDatas['total_count'] + $this->_viewDatas['per_page']; $i += 10) { - $this->_viewDatas['pageOptions'][$i] = $i; - } + //total 처리 + $this->_viewDatas['total_count'] = $this->index_total(); //pagenation 처리 $this->_viewDatas['pagination'] = $this->index_pagination(); //모델 처리 $this->_viewDatas['entitys'] = $this->index_entitys(); - // echo $this->_model->getLastQuery(); - // exit; - // log_message("debug", __METHOD__ . "에서 findAll 호출:" . $this->_model->getLastQuery()); + // dd($this->_model->getLastQuery()); //setting return_url to session flashdata - helper(['form']); $this->_session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: ""); return view($this->_viewPath . '/index' . $this->request->getVar('v') ?: '', ['viewDatas' => $this->_viewDatas]); } catch (\Exception $e) { diff --git a/app/Controllers/Front/ProductController.php b/app/Controllers/Front/ProductController.php index 8174464..82ff850 100644 --- a/app/Controllers/Front/ProductController.php +++ b/app/Controllers/Front/ProductController.php @@ -68,7 +68,7 @@ class ProductController extends FrontController //Category 및 Status 조건추가 protected function index_condition() { - $this->_model->where("category_uid", $this->_viewDatas['currentCategory']->getPrimaryKey()); + $this->_model->where("category", $this->_viewDatas['currentCategory']->getPrimaryKey()); $this->_model->where("status", DEFAULTS['STATUS']); parent::index_condition(); } diff --git a/app/Database/base.sql b/app/Database/base.sql index f2a0ba3..48e5477 100644 --- a/app/Database/base.sql +++ b/app/Database/base.sql @@ -104,16 +104,30 @@ CREATE TABLE vhost.tw_sitepage ( created_at timestamp NOT NULL DEFAULT current_timestamp(), deleted_at timestamp NULL DEFAULT NULL, PRIMARY KEY (uid), - KEY category_uid (category_uid), KEY user_uid (user_uid), CONSTRAINT tw_sitepage_ibfk_1 FOREIGN KEY (user_uid) REFERENCES tw_user (uid) ) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT '사이트페이지'; +DROP TABLE IF EXISTS vhost.tw_device; + +CREATE TABLE vhost.tw_device ( + uid varchar(36) NOT NULL, + category varchar(20) NOT NULL COMMENT '형식:server(HP,KVM,Container),cpu,memory,disk(ssd,nvme),os(linux,windows),공인ip등등', + name varchar(255) NOT NULL, + cost int(10) unsigned NOT NULL DEFAULT 0 COMMENT '원가', + price int(10) unsigned NOT NULL DEFAULT 0 COMMENT '판매가', + status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매중 unuse: 판매중지, soldout:매진, outofstock:재고부족 등등', + updated_at timestamp NULL DEFAULT NULL, + created_at timestamp NOT NULL DEFAULT current_timestamp(), + deleted_at timestamp NULL DEFAULT NULL, + PRIMARY KEY (uid) +) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT '장비 정보'; + DROP TABLE IF EXISTS vhost.tw_product; CREATE TABLE vhost.tw_product ( uid varchar(36) NOT NULL, - category_uid varchar(50) NOT NULL COMMENT '범주_UID', + category varchar(20) NOT NULL COMMENT '범주_UID', user_uid varchar(36) DEFAULT NULL COMMENT '생산자 정보', type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대, onetime:판매,일회성', name varchar(255) NOT NULL COMMENT '상품명', @@ -129,30 +143,10 @@ CREATE TABLE vhost.tw_product ( created_at timestamp NOT NULL DEFAULT current_timestamp(), deleted_at timestamp NULL DEFAULT NULL, PRIMARY KEY (uid), - KEY category_uid (category_uid), KEY user_uid (user_uid), - CONSTRAINT tw_product_ibfk_1 FOREIGN KEY (category_uid) REFERENCES tw_category (uid), - CONSTRAINT tw_product_ibfk_2 FOREIGN KEY (user_uid) REFERENCES tw_user (uid) + CONSTRAINT tw_product_ibfk_1 FOREIGN KEY (user_uid) REFERENCES tw_user (uid) ) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT = '상품 정보'; -DROP TABLE IF EXISTS vhost.tw_device; - -CREATE TABLE vhost.tw_device ( - uid varchar(36) NOT NULL, - type varchar(20) NOT NULL COMMENT '형식:server(HP,KVM,Container),cpu,memory,disk(ssd,nvme),os(linux,windows),공인ip등등', - name varchar(255) NOT NULL, - cost int(10) unsigned NOT NULL DEFAULT 0 COMMENT '원가', - price int(10) unsigned NOT NULL DEFAULT 0 COMMENT '판매가', - sale int(10) unsigned NOT NULL DEFAULT 0 COMMENT '할인가', - stock int(5) unsigned NOT NULL DEFAULT 1 COMMENT '재고수량', - content text NOT NULL COMMENT '장비내용', - status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매중 unuse: 판매중지, soldout:매진, outofstock:재고부족 등등', - updated_at timestamp NULL DEFAULT NULL, - created_at timestamp NOT NULL DEFAULT current_timestamp(), - deleted_at timestamp NULL DEFAULT NULL, - PRIMARY KEY (uid) -) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT '장비 정보'; - DROP TABLE IF EXISTS vhost.tw_product_device; CREATE TABLE vhost.tw_product_device ( diff --git a/app/Entities/BoardEntity.php b/app/Entities/BoardEntity.php index 09f5b2f..0ce620c 100644 --- a/app/Entities/BoardEntity.php +++ b/app/Entities/BoardEntity.php @@ -18,6 +18,10 @@ class BoardEntity extends BaseHierarchyEntity { return $this->attributes['passwd']; } + public function getCategory(): string + { + return $this->attributes['category']; + } //파일관련 Field전용 final public function getFileDownload($url, $field = "upload_file") { diff --git a/app/Entities/DeviceEntity.php b/app/Entities/DeviceEntity.php index 610c890..1281a99 100644 --- a/app/Entities/DeviceEntity.php +++ b/app/Entities/DeviceEntity.php @@ -13,19 +13,19 @@ class DeviceEntity extends BaseEntity { return $this->attributes['name']; } - //추가기능 - public function getType(): string + public function getCategory(): string { - return $this->attributes['type']; + return $this->attributes['category']; } - - //판매금액표시용 - public function getSalePrice(array $options = []): string + public function getPrice(): int { - $price = $this->attributes['price'] - $this->attributes['sale']; - if (array_key_exists('format', $options)) { - $price = sprintf($options['format'], number_format($price)); - } - return $price; + return $this->attributes['price']; + } + //추가기능 + //판매금액표시용 + public function getTitleWithPrice(array $attrs = []): string + { + $format = array_key_exists('format', $attrs) ? $attrs['format'] : "%s원 %s"; + return sprintf($format, number_format($this->getPrice()), $this->getTitle()); } } diff --git a/app/Entities/ProductEntity.php b/app/Entities/ProductEntity.php index e49cee6..2806df8 100644 --- a/app/Entities/ProductEntity.php +++ b/app/Entities/ProductEntity.php @@ -13,6 +13,10 @@ class ProductEntity extends BaseEntity { return $this->attributes['name']; } + public function getCategory(): string + { + return $this->attributes['category']; + } //추가기능 //이미지관련 Field전용 final public function getFileImage($size = false, $field = "photo") @@ -28,4 +32,13 @@ class ProductEntity extends BaseEntity $files[0] ); } + //판매금액표시용 + public function getSalePrice(array $options = []): string + { + $price = $this->attributes['price'] - $this->attributes['sale']; + if (array_key_exists('format', $options)) { + $price = sprintf($options['format'], number_format($price)); + } + return $price; + } } diff --git a/app/Entities/SitepageEntity.php b/app/Entities/SitepageEntity.php index e8e289a..a533795 100644 --- a/app/Entities/SitepageEntity.php +++ b/app/Entities/SitepageEntity.php @@ -13,5 +13,9 @@ class SitepageEntity extends BaseEntity { return $this->attributes['title']; } + public function getCategory(): string + { + return $this->attributes['category']; + } //추가기능 } diff --git a/app/Helpers/Device_helper.php b/app/Helpers/Device_helper.php index 9346552..6dd5fb2 100644 --- a/app/Helpers/Device_helper.php +++ b/app/Helpers/Device_helper.php @@ -36,7 +36,7 @@ function getFieldForm_DeviceHelper($field, $value, array $viewDatas, array $attr return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']); break; case "status": - case "type": + case "category": $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]]; return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes); break; diff --git a/app/Helpers/Product_helper.php b/app/Helpers/Product_helper.php index 9741cf5..f2b5a91 100644 --- a/app/Helpers/Product_helper.php +++ b/app/Helpers/Product_helper.php @@ -26,15 +26,8 @@ function getFieldForm_ProductHelper($field, $value, array $viewDatas, array $att // } // return implode(" ", $checkboxs); break; - case 'server': - case 'cpu': - case 'memory': - case 'disk': - case 'nic': - case 'os': - case 'publicip': - $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("Device.TYPE.label.{$field}") . " 선택", ...$viewDatas['device']['options'][$field]]; - return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'style' => 'width:200px']); + case 'device': + return sprintf("
%s
", view_cell('ProductCell::beremetal', $viewDatas)); break; case 'title': case 'name': @@ -61,6 +54,7 @@ function getFieldForm_ProductHelper($field, $value, array $viewDatas, array $att case 'view_cnt': return form_input($field, $value, ['type' => 'number']); break; + case "category": case "status": case "type": $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]]; diff --git a/app/Language/ko/Category.php b/app/Language/ko/Category.php index 7dee6a8..4dd1ec1 100644 --- a/app/Language/ko/Category.php +++ b/app/Language/ko/Category.php @@ -3,25 +3,25 @@ $roles = []; foreach (ROLES as $role) { switch ($role) { case 'guest': - $roles[] = '비회원'; + $roles[$role] = '비회원'; break; case 'user': - $roles[] = '일반회원'; + $roles[$role] = '일반회원'; break; case 'vip': - $roles[] = 'VIP회원'; + $roles[$role] = 'VIP회원'; break; case 'manager': - $roles[] = '관리자'; + $roles[$role] = '관리자'; break; case 'cloudflare': - $roles[] = 'Cloudflare'; + $roles[$role] = 'Cloudflare'; break; case 'director': - $roles[] = '감독자'; + $roles[$role] = '감독자'; break; case 'master': - $roles[] = '마스터'; + $roles[$role] = '마스터'; break; } } diff --git a/app/Language/ko/Device.php b/app/Language/ko/Device.php index 10a4b98..5827b0e 100644 --- a/app/Language/ko/Device.php +++ b/app/Language/ko/Device.php @@ -3,7 +3,7 @@ return [ 'title' => "장비 정보", 'label' => [ 'uid' => "번호", - 'type' => '형식', + 'category' => '형식', 'name' => "모델명", 'cost' => "판매원가", 'price' => "판매금액", @@ -14,7 +14,7 @@ return [ 'updated_at' => "수정일", 'created_at' => "생성일" ], - "TYPE" => [ + "CATEGORY" => [ 'server' => '서버', 'cpu' => 'CPU', 'memory' => 'Memory', diff --git a/app/Language/ko/Product.php b/app/Language/ko/Product.php index 54df923..eab777e 100644 --- a/app/Language/ko/Product.php +++ b/app/Language/ko/Product.php @@ -3,7 +3,7 @@ return [ 'title' => "상품 정보", 'label' => [ 'uid' => "번호", - 'category_uid' => "분류", + 'category' => "분류", 'user_uid' => "판매자", 'type' => '형식', 'name' => "상품명", @@ -16,7 +16,12 @@ return [ 'content' => "상품정보", 'status' => "상태", 'updated_at' => "수정일", - 'created_at' => "생성일" + 'created_at' => "생성일", + 'device' => "기본장비" + ], + "CATEGORY" => [ + 'beremetal' => '단독서버', + 'vpc' => '가상서버', ], "TYPE" => [ "rental" => "월이용권", diff --git a/app/Language/ko/User.php b/app/Language/ko/User.php index 3f6b295..e0de1bf 100644 --- a/app/Language/ko/User.php +++ b/app/Language/ko/User.php @@ -3,25 +3,25 @@ $roles = []; foreach (ROLES as $role) { switch ($role) { case 'guest': - $roles[] = '비회원'; + $roles[$role] = '비회원'; break; case 'user': - $roles[] = '일반회원'; + $roles[$role] = '일반회원'; break; case 'vip': - $roles[] = 'VIP회원'; + $roles[$role] = 'VIP회원'; break; case 'manager': - $roles[] = '관리자'; + $roles[$role] = '관리자'; break; case 'cloudflare': - $roles[] = 'Cloudflare'; + $roles[$role] = 'Cloudflare'; break; case 'director': - $roles[] = '감독자'; + $roles[$role] = '감독자'; break; case 'master': - $roles[] = '마스터'; + $roles[$role] = '마스터'; break; } } diff --git a/app/Models/BaseHierarchyModel.php b/app/Models/BaseHierarchyModel.php index 9f8ea88..2a35880 100644 --- a/app/Models/BaseHierarchyModel.php +++ b/app/Models/BaseHierarchyModel.php @@ -15,9 +15,15 @@ abstract class BaseHierarchyModel extends BaseModel } abstract public function getContentField(); abstract public function reply($parent_entity, array $formDatas): BaseEntity; + + public function getEntitys(array $conditions = array(), array $orderBys = array()): array + { + $orderBys = ["grpno DESC", "grporder ASC", ...$orderBys]; + return parent::getEntitys($conditions, $orderBys); + } public function getSiblingEntitys($entity) { - return $this->getEntitys(['grpno' => $entity->getHierarchy_No()]); + return parent::getEntitys(['grpno' => $entity->getHierarchy_No()]); } public function getFieldRule(string $field, array $rules, string $action = ""): array { diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 6125a79..6ecc7c8 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -85,8 +85,12 @@ abstract class BaseModel extends Model { return $this->primaryKey; } - public function getEntitys(array $conditions = array()): array + public function getEntitys(array $conditions = array(), array $orderBys = array()): array { + //dd($orderBys); + foreach ($orderBys as $orderBy) { + $this->orderBy($orderBy); + } return $this->where($conditions)->findAll(); } final public function getUUID() @@ -270,27 +274,26 @@ abstract class BaseModel extends Model } //Index관련 - public function setIndexWordFilter(string $word) + public function setIndexFieldFilter(string $field, $value): void { - } - public function setIndexDateFilter($start, $end) - { - if ($start !== DEFAULTS['EMPTY'] && $end !== DEFAULTS['EMPTY']) { - $this->where("created_at >=", $start); - $this->where("created_at <=", $end); + if ($value !== DEFAULTS['EMPTY']) { + $this->where($field, $value); } } - public function setIndexOrderBy(string $field, string $order) + public function setIndexWordFilter(string $word): void + { + if ($word !== DEFAULTS['EMPTY']) { + $this->orLike($this->getTitleField(), $word, "both"); + } + } + public function setIndexDateFilter($start, $end): void + { + if ($start !== DEFAULTS['EMPTY'] && $end !== DEFAULTS['EMPTY']) { + $this->where(["created_at >={$start}", "created_at <={$end}"]); + } + } + public function setIndexOrderBy(string $field, string $order): void { $this->orderBy($field, $order); } - final public function setCondition(array $filterFields, $word, $start, $end, $order_field, $order_value) - { - foreach ($filterFields as $field => $value) { - $this->where($field, $value); - } - $this->setIndexWordFilter($word); - $this->setIndexDateFilter($start, $end); - $this->setIndexOrderBy($order_field, $order_value); - } } diff --git a/app/Models/BillingModel.php b/app/Models/BillingModel.php index 2193cd8..2f2dca8 100644 --- a/app/Models/BillingModel.php +++ b/app/Models/BillingModel.php @@ -75,12 +75,4 @@ class BillingModel extends BaseModel { return $this->modify_process($entity, $formDatas); } - //Index관련 - public function setIndexWordFilter(string $word) - { - if ($word !== DEFAULTS['EMPTY']) { - parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); - } - } } diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index 626dd7b..c379742 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -70,23 +70,14 @@ class BoardModel extends BaseHierarchyModel } //Index관련 - public function setIndexWordFilter(string $word) + public function setIndexWordFilter(string $word): void { if ($word !== DEFAULTS['EMPTY']) { parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); - $this->orLike("content", $word, "both"); //befor , after , both + $this->orLike("content", $word, "both"); } } - public function setIndexOrderBy(?string $field, ?string $order) - { - //계단식의 경우는 먼저 다른것보다 먼저 orderBy가 수행되어야 하므로 - $this->orderBy("grpno", "DESC"); - $this->orderBy("grporder", "DESC"); - parent::setIndexOrderBy($field, $order); - } - //조회수 올리기 final public function addViewCount(BoardEntity $entity, int $view_cnt = 1): BoardEntity { diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index 8a7eb19..16d2579 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -119,14 +119,6 @@ class CategoryModel extends BaseHierarchyModel { return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } - public function getEntitys(array $conditions = array()): array - { - $this->where($conditions); - $this->orderBy("grpno", "DESC"); - $this->orderBy("grporder", "ASC"); - return $this->findAll(); - } - public function create(array $formDatas): CategoryEntity { return $this->create_process(new CategoryEntity(), $formDatas); @@ -141,14 +133,15 @@ class CategoryModel extends BaseHierarchyModel } //Index관련 - public function setIndexWordFilter(string $word) + public function setIndexWordFilter(string $word): void { - parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); - $this->orLike("head", $word, "both"); //befor , after , both - $this->orLike("tail", $word, "both"); //befor , after , both + if ($word !== DEFAULTS['EMPTY']) { + parent::setIndexWordFilter($word); + $this->orLike("head", $word, "both"); + $this->orLike("tail", $word, "both"); + } } - public function setIndexOrderBy(?string $field, ?string $order) + public function setIndexOrderBy(?string $field, ?string $order): void { //계단식의 경우는 먼저 다른것보다 먼저 orderBy가 수행되어야 하므로 $this->orderBy("grpno", "DESC"); diff --git a/app/Models/DeviceModel.php b/app/Models/DeviceModel.php index 65c04c4..683beb6 100644 --- a/app/Models/DeviceModel.php +++ b/app/Models/DeviceModel.php @@ -17,8 +17,7 @@ class DeviceModel extends BaseModel parent::__construct('Device'); $this->allowedFields = [ ...$this->allowedFields, - 'type', 'name', "cost", "price", "sale", - "stock", "content", "status" + 'category', 'name', "cost", "price", "status" ]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } @@ -33,7 +32,7 @@ class DeviceModel extends BaseModel case $this->getTitleField(): $rules[$field] = "required|trim|string"; break; - case 'type': + case 'category': $rules[$field] = "required|string"; break; case 'photo': @@ -62,14 +61,10 @@ class DeviceModel extends BaseModel { //대분류 부분은 선택이 되지 않게 하기위해 따로 만듬 (form_dropdown의 optgroup 기능) foreach ($this->getEntitys($conditions) as $entity) { - if (!array_key_exists($entity->getType(), $options)) { - $options[$entity->getType()] = []; + if (!array_key_exists($entity->getCategory(), $options)) { + $options[$entity->getCategory()] = []; } - $options[$entity->getType()][$entity->getPrimaryKey()] = sprintf( - "%s %s", - $entity->getSalePrice(['format' => "%s원"]), - $entity->getTitle() - ); + $options[$entity->getCategory()][$entity->getPrimaryKey()] = $entity->getTitle(); } return $options; } @@ -78,6 +73,11 @@ class DeviceModel extends BaseModel { return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); } + public function getEntitys(array $conditions = array(), array $orderBys = array()): array + { + $orderBys = ["category ASC", "price DESC", ...$orderBys]; + return parent::getEntitys($conditions, $orderBys); + } public function create(array $formDatas): DeviceEntity { return $this->create_process(new DeviceEntity(), $formDatas); @@ -88,12 +88,11 @@ class DeviceModel extends BaseModel } //Index관련 - public function setIndexWordFilter(string $word) + public function setIndexWordFilter(string $word): void { if ($word !== DEFAULTS['EMPTY']) { parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); - $this->orLike("content", $word, "both"); //befor , after , both + $this->orLike("content", $word, "both"); } } } diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php index de88d1c..34a1d3d 100644 --- a/app/Models/OrderModel.php +++ b/app/Models/OrderModel.php @@ -84,14 +84,6 @@ class OrderModel extends BaseModel { return $this->modify_process($entity, $formDatas); } - //Index관련 - public function setIndexWordFilter(string $word) - { - if ($word !== DEFAULTS['EMPTY']) { - parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); - } - } //장바구니에 넣기() final public function addCart(ProductEntity $product, int $quantity, string $type, $paymentDay = null): OrderEntity diff --git a/app/Models/ProductDeviceModel.php b/app/Models/ProductDeviceModel.php new file mode 100644 index 0000000..a9a982e --- /dev/null +++ b/app/Models/ProductDeviceModel.php @@ -0,0 +1,50 @@ +allowedFields = [ + ...$this->allowedFields, "order_uid", "billing_uid" + ]; + $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; + } + final public function getTitleField(): string + { + return 'billing_uid'; + } + public function getFieldRule(string $field, array $rules, string $action = ""): array + { + switch ($field) { + case "order_uid": + $rules[$field] = $this->getUUIDFieldRule('required'); + break; + case 'billing_uid': + $rules[$field] = "required|numeric"; + break; + default: + $rules = parent::getFieldRule($field, $rules, $action); + break; + } + return $rules; + } + public function getEntity($conditions): OrderBillingEntity + { + return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다."); + } + public function create(array $formDatas): OrderBillingEntity + { + return $this->create_process(new OrderBillingEntity(), $formDatas); + } + public function modify(OrderBillingEntity $entity, array $formDatas): OrderBillingEntity + { + return $this->modify_process($entity, $formDatas); + } +} diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index 7ddcc93..0c2ec30 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -17,7 +17,7 @@ class ProductModel extends BaseModel parent::__construct('Product'); $this->allowedFields = [ ...$this->allowedFields, - "category_uid", "user_uid", + "category", "user_uid", 'type', 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "content", "status" ]; @@ -31,7 +31,7 @@ class ProductModel extends BaseModel public function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { - case "category_uid": + case "category": $rules[$field] = "required|string"; break; case "user_uid": @@ -78,12 +78,11 @@ class ProductModel extends BaseModel } //Index관련 - public function setIndexWordFilter(string $word) + public function setIndexWordFilter(string $word): void { if ($word !== DEFAULTS['EMPTY']) { parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); - $this->orLike("content", $word, "both"); //befor , after , both + $this->orLike("content", $word, "both"); } } diff --git a/app/Models/SitepageModel.php b/app/Models/SitepageModel.php index 630f88c..cd6ef03 100644 --- a/app/Models/SitepageModel.php +++ b/app/Models/SitepageModel.php @@ -61,12 +61,11 @@ class SitepageModel extends BaseModel } //Index관련 - public function setIndexWordFilter(string $word) + public function setIndexWordFilter(string $word): void { if ($word !== DEFAULTS['EMPTY']) { parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); - $this->orLike("content", $word, "both"); //befor , after , both + $this->orLike("content", $word, "both"); } } } diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 3c5a1f8..585c514 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -89,11 +89,10 @@ class UserModel extends BaseModel } //Index관련 - public function setIndexWordFilter(string $word) + public function setIndexWordFilter(string $word): void { if ($word !== DEFAULTS['EMPTY']) { parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); //befor , after , both $this->orLike("id", $word, "both"); } } diff --git a/app/Models/UserSNSModel.php b/app/Models/UserSNSModel.php index 0f68c50..1f57fdb 100644 --- a/app/Models/UserSNSModel.php +++ b/app/Models/UserSNSModel.php @@ -61,10 +61,11 @@ class UserSNSModel extends BaseModel } //Index관련 - public function setIndexWordFilter(string $word) + public function setIndexWordFilter(string $word): void { - parent::setIndexWordFilter($word); - $this->orLike($this->getTitleField(), $word, "both"); - $this->orLike("email", $word, "both"); //befor , after , both + if ($word !== DEFAULTS['EMPTY']) { + parent::setIndexWordFilter($word); + $this->orLike("email", $word, "both"); + } } } diff --git a/app/Views/admin/product/insert.php b/app/Views/admin/product/insert.php index 0c35f5b..4bae07f 100644 --- a/app/Views/admin/product/insert.php +++ b/app/Views/admin/product/insert.php @@ -5,19 +5,6 @@ - - - -
기본장비 - -
- - - - -
- -
diff --git a/app/Views/front/board/cell/information.php b/app/Views/cells/board/information.php similarity index 100% rename from app/Views/front/board/cell/information.php rename to app/Views/cells/board/information.php diff --git a/app/Views/cells/product/beremetal.php b/app/Views/cells/product/beremetal.php new file mode 100644 index 0000000..3eb0b15 --- /dev/null +++ b/app/Views/cells/product/beremetal.php @@ -0,0 +1,24 @@ + + + + + + + + + + + +
+ $category, + 'size' => "6", + 'class' => 'vhost_cellDatas', + 'onChange' => "calculator()" + ] + ) ?> +
\ No newline at end of file diff --git a/app/Views/cells/product/beremetal_calculator.php b/app/Views/cells/product/beremetal_calculator.php new file mode 100644 index 0000000..b0e5e46 --- /dev/null +++ b/app/Views/cells/product/beremetal_calculator.php @@ -0,0 +1,82 @@ + + +
+ 'post', + "onsubmit" => 'return calculator()' + ]) ?> + + + + + + + + + + + getPrimaryKey()] = $entity->getTitleWithPrice(); + } + ?> + + + + + + + + + + + + + + +
가상서버 견적 계산기
+ $category, + 'class' => 'vhost_cellDatas', + 'onChange' => "calculator()" + ] + ) ?> +
결제일 + "결제일 선택"]; + for ($i = 1; $i <= 28; $i++) { + $paymentDayOptions[$i] = "매월 {$i}일"; + } + ?> + 'paymentday']); + ?> +
주문금액 + 0원 + "btn btn-outline btn-primary")); ?> +
+ + + getFlashdata('return_message') ? alert_CommonHelper($viewDatas['session']->getFlashdata('return_message')) : "" ?> +
\ No newline at end of file diff --git a/app/Views/front/product/cell/virtual_calculator.php b/app/Views/cells/product/virtual.php similarity index 100% rename from app/Views/front/product/cell/virtual_calculator.php rename to app/Views/cells/product/virtual.php diff --git a/public/upload_images/1715920446_a395357eca0ed080d201.jpg b/public/upload_images/1715920446_a395357eca0ed080d201.jpg new file mode 100644 index 0000000..14e5914 Binary files /dev/null and b/public/upload_images/1715920446_a395357eca0ed080d201.jpg differ diff --git a/public/upload_images/large_1715920446_a395357eca0ed080d201.jpg b/public/upload_images/large_1715920446_a395357eca0ed080d201.jpg new file mode 100644 index 0000000..49891c5 Binary files /dev/null and b/public/upload_images/large_1715920446_a395357eca0ed080d201.jpg differ diff --git a/public/upload_images/middle_1715920446_a395357eca0ed080d201.jpg b/public/upload_images/middle_1715920446_a395357eca0ed080d201.jpg new file mode 100644 index 0000000..5ee17d5 Binary files /dev/null and b/public/upload_images/middle_1715920446_a395357eca0ed080d201.jpg differ diff --git a/public/upload_images/small_1715920446_a395357eca0ed080d201.jpg b/public/upload_images/small_1715920446_a395357eca0ed080d201.jpg new file mode 100644 index 0000000..4f884e4 Binary files /dev/null and b/public/upload_images/small_1715920446_a395357eca0ed080d201.jpg differ