shoppingmallv2 init...

This commit is contained in:
최준흠git config git config --helpgit config --global user.name 최준흠 2023-08-05 23:24:24 +09:00
parent f25082ed36
commit 42af053f90
10 changed files with 97 additions and 96 deletions

View File

@ -17,11 +17,11 @@ class ProductController extends FrontController
}
public function getFields(string $action = ""): array
{
$fields = ['name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",];
$fields = ["photo", 'user_uid', 'name', "cost", "price", "sale", "stock", "view_cnt", "content",];
switch ($action) {
case "index":
case "excel":
return ["user_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"];
return ["photo", "user_uid", 'name', "cost", "price", "sale", "stock", "view_cnt", "created_at"];
break;
case "view":
return [...$fields, "created_at"];
@ -33,7 +33,7 @@ class ProductController extends FrontController
}
public function getFieldFilters(): array
{
return ["user_uid", "status"];
return ["user_uid"];
}
public function getFieldBatchFilters(): array
{

View File

@ -23,11 +23,14 @@ class ProductEntity extends BaseEntity
}
//추가기능
public function getCategory_uid()
{
return $this->attributes['category_uid'];
}
public function getUer_uid()
{
return $this->attributes['user_uid'];
}
public function getCost()
{
return $this->attributes['cost'];
@ -40,10 +43,6 @@ class ProductEntity extends BaseEntity
{
return $this->attributes['sale'];
}
public function getFinalPrice()
{
return $this->getPrice() - $this->getSale();
}
public function getPhoto()
{
return $this->attributes['photo'];

View File

@ -79,9 +79,11 @@ function getFieldView_ProductHelper($field, $entity, array $viewDatas)
break;
case 'board_file':
case 'upload_file':
case 'photo':
return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], ["target" => "_self"]);
break;
case 'photo':
return "<img src=\"/upload_images/" . $entity->getPhotoBlock() . "\">";
break;
case 'cost':
case 'price':
case 'sale':

View File

@ -4,7 +4,7 @@ return [
'label' => [
'uid' => "번호",
'category_uid' => "분류",
'user_uid' => "생산",
'user_uid' => "판매",
'name' => "상품명",
'photo' => "이미지",
'cost' => "원가",

View File

@ -1,20 +1,20 @@
<?= form_open("ecommerce/addCart", ['method' => 'post']) ?>
<?= form_hidden("product_uid", $entity->getPrimaryKey()) ?>
<input type="hidden" id="price" name="price" value="<?= ($entity->getPrice() - $entity->getSale()) * 1 ?>">
<?= form_hidden("product_uid", $viewDatas['entity']->getPrimaryKey()) ?>
<input type="hidden" id="price" name="price" value="<?= ($viewDatas['entity']->getPrice()) * 1 ?>">
<?php
$quantityOptions = [DEFAULTS['EMPTY'] => "구매수량 선택"];
for ($i = 1; $i <= $entity->getStock(); $i++) {
for ($i = 1; $i <= $viewDatas['entity']->getStock(); $i++) {
$quantityOptions[$i] = $i . "";
}
?>
구매 수량 : <?= form_dropdown('quantity', $quantityOptions, 1, ['onChange' => "cal_price(this.options[this.selectedIndex].value)"]); ?>
구매 금액 : <span id="order_price"><?= number_format(($entity->getPrice() - $entity->getSale()) * 1) ?></span>원
<?= form_submit('', '최소:1 ~ 최대:' . $entity->getStock(), array("class" => "btn btn-outline btn-primary")); ?>
구매 금액 : <span id="order_price"><?= number_format($viewDatas['entity']->getPrice() * 1) ?></span>원
<?= form_submit('', '최소:1 ~ 최대:' . $viewDatas['entity']->getStock(), array("class" => "btn btn-outline btn-primary")); ?>
<?= form_close(); ?>
<script>
function cal_price(quantity) {
var price = 0;
price = (<?= $entity->getPrice() ?> - <?= $entity->getSale() ?>) * quantity;;
price = <?= $viewDatas['entity']->getPrice() ?> * quantity;;
document.getElementById('price').value = price;
document.getElementById('order_price').textContent = new Intl.NumberFormat().format(price);
}

View File

@ -3,36 +3,44 @@
<div class="content">
<div><?= html_entity_decode($viewDatas['category']->getHead()) ?></div>
<div class="top">
<span style="float:left; padding-left:10px; padding-right:100px;">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . 'order_field=price,order_value=ASC', '판매가순', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?>
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . 'order_field=view_cnt,order_value=DESC', '인기순', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
</span>
<?= form_open(current_url(), array("method" => "get")) ?>
<ul class="nav">
조건검색:<?php foreach ($viewDatas['fieldFilters'] as $field) : ?><?= getFieldFilter_ProductHelper($field, $viewDatas[$field], $viewDatas) ?><?php endforeach ?>
<?= $this->include('templates/front/index_head') ?>
</ul>
<?= $this->include('templates/front/index_head') ?>
<span style="float:right; padding-right:10px;">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . '&v=_list', 'List', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
</span>
<?= form_close() ?>
</div>
<div style="text-align:right;">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey(), 'List', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . '&v=_b', 'Block', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?>
</div>
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="table table-bordered table-hover table-striped">
<tr>
<th>번호</th>
<?php foreach ($viewDatas['fields'] as $field) : ?><th><?= getFieldIndex_Column_ProductHelper($field, $viewDatas) ?></th><?php endforeach ?>
</tr>
<div>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
<td>
<?= $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
</td>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<td nowrap><?= getFieldIndex_Row_ProductHelper($field, $entity, $viewDatas) ?></td>
<?php endforeach ?>
</tr>
<table class="table table-bordered">
<tr>
<td width="10%"><?= getFieldIndex_Row_ProductHelper('photo', $entity, $viewDatas) ?></td>
<td width="*">
<div style="text-align:left;"><?= getFieldIndex_Row_ProductHelper('name', $entity, $viewDatas) ?></div>
<div style="text-align:left;">
<b style="font-size:18px;">판매가:<?= getFieldIndex_Row_ProductHelper('price', $entity, $viewDatas) ?>원</b>
<span style="font-size:12px;">
원가:<?= getFieldIndex_Row_ProductHelper('cost', $entity, $viewDatas) ?>
-
할인가:<?= getFieldIndex_Row_ProductHelper('sale', $entity, $viewDatas) ?>
</span>
</div>
<div style="text-align:left;">
조회수:<?= getFieldIndex_Row_ProductHelper('view_cnt', $entity, $viewDatas) ?>
</div>
</td>
<td width="10%"><?= getFieldIndex_Row_ProductHelper('user_uid', $entity, $viewDatas) ?></td>
</tr>
</table>
<?php $cnt++ ?>
<?php endforeach ?>
</table>
</div>
<div class="bottom">
<?= $viewDatas['pagination'] ?>
</div>

View File

@ -1,50 +0,0 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<div class="content">
<div><?= html_entity_decode($viewDatas['category']->getHead()) ?></div>
<div class="top">
<?= form_open(current_url(), array("method" => "get")) ?>
<ul class="nav">
조건검색:<?php foreach ($viewDatas['fieldFilters'] as $field) : ?><?= getFieldFilter_ProductHelper($field, $viewDatas[$field], $viewDatas) ?><?php endforeach ?>
<?= $this->include('templates/front/index_head') ?>
</ul>
<?= form_close() ?>
</div>
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<div>
<div style="text-align:right;">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey(), 'List', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . '&v=_b', 'Block', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?>
</div>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<table class="table table-bordered">
<tr>
<td width="10%"><img src="/upload_images/<?= $entity->getPhotoBlock() ?>"></td>
<td width="*">
<div style="text-align:left;"><?= getFieldIndex_Row_ProductHelper('name', $entity, $viewDatas) ?></div>
<div style="text-align:left;">
<b style="font-size:18px;">판매가:<?= $entity->getFinalPrice() ?>원</b>
<span style="font-size:12px;">
원가:<?= getFieldIndex_Row_ProductHelper('price', $entity, $viewDatas) ?>
-
할인가:<?= getFieldIndex_Row_ProductHelper('sale', $entity, $viewDatas) ?>
</span>
</div>
<div style="text-align:left;">
조회수:<?= getFieldIndex_Row_ProductHelper('view_cnt', $entity, $viewDatas) ?>
</div>
</td>
<td width="10%"><?= getFieldIndex_Row_ProductHelper('user_uid', $entity, $viewDatas) ?></td>
</tr>
</table>
<?php $cnt++ ?>
<?php endforeach ?>
</div>
<div class="bottom">
<?= $viewDatas['pagination'] ?>
</div>
<?= form_close() ?>
<div><?= html_entity_decode($viewDatas['category']->getTail()) ?></div>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,42 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<div class="content">
<div><?= html_entity_decode($viewDatas['category']->getHead()) ?></div>
<div class="top">
<?= form_open(current_url(), array("method" => "get")) ?>
<span style="float:left; padding-left:10px; padding-right:100px;">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . 'order_field=price,order_value=ASC', '판매가순', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?>
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . 'order_field=view_cnt,order_value=DESC', '인기순', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
</span>
<?= $this->include('templates/front/index_head') ?>
<span style="float:right; padding-right:10px;">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey(), 'Block', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
</span>
<?= form_close() ?>
</div>
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="table table-bordered table-hover table-striped">
<tr>
<th>번호</th>
<?php foreach ($viewDatas['fields'] as $field) : ?><th><?= getFieldIndex_Column_ProductHelper($field, $viewDatas) ?></th><?php endforeach ?>
</tr>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
<td>
<?= $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
</td>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<td nowrap><?= getFieldIndex_Row_ProductHelper($field, $entity, $viewDatas) ?></td>
<?php endforeach ?>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
</table>
<div class="bottom">
<?= $viewDatas['pagination'] ?>
</div>
<?= form_close() ?>
<div><?= html_entity_decode($viewDatas['category']->getTail()) ?></div>
</div>
<?= $this->endSection() ?>

View File

@ -14,10 +14,10 @@
<?php endforeach; ?>
</table>
<div style="text-align:center">
<?php if ($entity->getStatus() == DEFAULTS['STATUS']) : ?>
<?php if ($viewDatas['entity']->getStatus() == DEFAULTS['STATUS']) : ?>
<?= $this->include('front/product/addCart'); ?>
<?php else : ?>
이제품은 현재[<?= lang('Product.STATUS.' . $entity->getStatus()) ?>]입니다.
이제품은 현재[<?= lang('Product.STATUS.' . $viewDatas['entity']->getStatus()) ?>]입니다.
<?php endif ?>
</div>
<div><?= html_entity_decode($viewDatas['category']->getTail()) ?></div>

View File

@ -1,6 +1,6 @@
<li class="nav-item">검색어:<?= form_input('word', $viewDatas['word']) ?></li>
<li class="nav-item">검색일:
<?= form_input('start', $viewDatas['start'], ["class" => "calender"]) ?><?= form_input('end', $viewDatas['end'], ["class" => "calender"]) ?>
<?= form_submit('', '검색', array("class" => "btn btn-outline btn-primary")); ?><?= anchor(current_url() . '/excel?' . $viewDatas['uri']->getQuery(), '<i class="bi bi-file-excel"></i>', ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
</li>
<li class="nav-item">page:<?= $viewDatas['page'] ?> / total:<?= $viewDatas['total_page'] ?> <?= form_dropdown('per_page', $viewDatas['pageOptions'], $viewDatas['per_page'], array('onChange' => 'this.form.submit()')) ?> / 총:<?= $viewDatas['total_count'] ?></li>
<span>검색어:<?= form_input('word', $viewDatas['word']) ?></span>
<span>검색일:
<?= form_input('start', $viewDatas['start'], ["class" => "calender"]) ?><?= form_input('end', $viewDatas['end'], ["class" => "calender"]) ?>
<?= form_submit('', '검색', array("class" => "btn btn-outline btn-primary")); ?><?= anchor(current_url() . '/excel?' . $viewDatas['uri']->getQuery(), '<i class="bi bi-file-excel"></i>', ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
</span>
<span>page:<?= $viewDatas['page'] ?> / total:<?= $viewDatas['total_page'] ?> <?= form_dropdown('per_page', $viewDatas['pageOptions'], $viewDatas['per_page'], array('onChange' => 'this.form.submit()')) ?> / 총:<?= $viewDatas['total_count'] ?></span>