vhost init...3
This commit is contained in:
parent
b8ee57dcb0
commit
1667606036
@ -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]
|
||||
);
|
||||
}
|
||||
|
||||
@ -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]
|
||||
);
|
||||
}
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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 "<HR>";
|
||||
// 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) {
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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 (
|
||||
|
||||
@ -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")
|
||||
{
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,5 +13,9 @@ class SitepageEntity extends BaseEntity
|
||||
{
|
||||
return $this->attributes['title'];
|
||||
}
|
||||
public function getCategory(): string
|
||||
{
|
||||
return $this->attributes['category'];
|
||||
}
|
||||
//추가기능
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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("<div id='device'>%s</div>", 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]];
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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" => "월이용권",
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
50
app/Models/ProductDeviceModel.php
Normal file
50
app/Models/ProductDeviceModel.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Entities\OrderBillingEntity;
|
||||
|
||||
class OrderBillingModel extends BaseModel
|
||||
{
|
||||
protected $table = "tw_orderbilling";
|
||||
protected $returnType = OrderBillingEntity::class;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('Billing');
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,19 +5,6 @@
|
||||
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="form table table-bordered table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align:right;">기본장비</td>
|
||||
<td>
|
||||
<?php foreach ($viewDatas['device']['fields'] as $field) : ?>
|
||||
<div>
|
||||
<label class="col-sm-1 col-form-label"><?= lang("Device.TYPE.label.{$field}") ?></label>
|
||||
<?= getFieldForm_ProductHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?= form_input('{$field}_cnt'); ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
<tr>
|
||||
<td class=" label"><?= getFieldLabel_ProductHelper($field, $viewDatas) ?>
|
||||
|
||||
24
app/Views/cells/product/beremetal.php
Normal file
24
app/Views/cells/product/beremetal.php
Normal file
@ -0,0 +1,24 @@
|
||||
<table class="table table-bordered" style="width:80%;">
|
||||
<tr>
|
||||
<?php foreach ($viewDatas['cellDatas']['device']['categorys'] as $category) : ?>
|
||||
<th style="background-color:silver; text-align:center;"><?= lang('Device.CATEGORY.' . $category) . " 선택" ?></th>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php foreach ($viewDatas['cellDatas']['device']['categorys'] as $category) : ?>
|
||||
<td>
|
||||
<?= form_dropdown(
|
||||
$category,
|
||||
$viewDatas['cellDatas']['device']['options'][$category],
|
||||
old($category, 0),
|
||||
[
|
||||
'id' => $category,
|
||||
'size' => "6",
|
||||
'class' => 'vhost_cellDatas',
|
||||
'onChange' => "calculator()"
|
||||
]
|
||||
) ?>
|
||||
</td>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
</table>
|
||||
82
app/Views/cells/product/beremetal_calculator.php
Normal file
82
app/Views/cells/product/beremetal_calculator.php
Normal file
@ -0,0 +1,82 @@
|
||||
<link href="/css/front/device_calculator.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script>
|
||||
function calculator(order_price = 0) {
|
||||
var cellDatas = Array.from(document.getElementsByClassName("vhost_cellDatas"));
|
||||
cellDatas.forEach(function(part) { //loop
|
||||
//console.log(part);
|
||||
order_price += parseInt((part.getAttribute('cost') - part.getAttribute('sale')) * part.options[part.selectedIndex].value);
|
||||
document.getElementById('price').value = order_price;
|
||||
document.getElementById('order_price').textContent = new Intl.NumberFormat().format(order_price);
|
||||
});
|
||||
var current = document.getElementById('paymentday');
|
||||
if (!current.selectedIndex) {
|
||||
alert("결제일을 선택해주세요");
|
||||
current.focus();
|
||||
return false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div id="device_calculator">
|
||||
<?= form_open(URLS['addCart'], [
|
||||
'method' => 'post',
|
||||
"onsubmit" => 'return calculator()'
|
||||
]) ?>
|
||||
<input type="hidden" id="category" name="category" value="device">
|
||||
<input type="hidden" id="price" name="price">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" colspan="3">가상서버 견적 계산기</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($viewDatas['cellDatas']['device']['categorys'] as $category) : ?>
|
||||
<?php
|
||||
$options = [];
|
||||
foreach ($viewDatas['cellDatas']['device']['options'][$category] as $entity) {
|
||||
$options[$entity->getPrimaryKey()] = $entity->getTitleWithPrice();
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><?= lang("Device.CATEGORY.{$category}") ?></td>
|
||||
<td>
|
||||
<?= form_dropdown(
|
||||
$category,
|
||||
$options,
|
||||
old($category, 0),
|
||||
[
|
||||
'id' => $category,
|
||||
'class' => 'vhost_cellDatas',
|
||||
'onChange' => "calculator()"
|
||||
]
|
||||
) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<tr>
|
||||
<th>결제일</th>
|
||||
<td class="column">
|
||||
<?php $paymentDayOptions = ['' => "결제일 선택"];
|
||||
for ($i = 1; $i <= 28; $i++) {
|
||||
$paymentDayOptions[$i] = "매월 {$i}일";
|
||||
}
|
||||
?>
|
||||
<?= form_dropdown('paymentday', $paymentDayOptions, old('paymentday', 25), ['id' => 'paymentday']);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="none">주문금액</th>
|
||||
<td class="none" colspan="3">
|
||||
<span id="order_price">0</span>원
|
||||
<?= form_submit('', '신청', array("class" => "btn btn-outline btn-primary")); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<script type="text/javascript">
|
||||
window.onload = calculator();
|
||||
</script>
|
||||
<?= $viewDatas['session']->getFlashdata('return_message') ? alert_CommonHelper($viewDatas['session']->getFlashdata('return_message')) : "" ?>
|
||||
</div>
|
||||
BIN
public/upload_images/1715920446_a395357eca0ed080d201.jpg
Normal file
BIN
public/upload_images/1715920446_a395357eca0ed080d201.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
BIN
public/upload_images/large_1715920446_a395357eca0ed080d201.jpg
Normal file
BIN
public/upload_images/large_1715920446_a395357eca0ed080d201.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
BIN
public/upload_images/middle_1715920446_a395357eca0ed080d201.jpg
Normal file
BIN
public/upload_images/middle_1715920446_a395357eca0ed080d201.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
public/upload_images/small_1715920446_a395357eca0ed080d201.jpg
Normal file
BIN
public/upload_images/small_1715920446_a395357eca0ed080d201.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue
Block a user