shoppingmallv2 init...

This commit is contained in:
최준흠 2023-08-07 19:08:12 +09:00
parent 67705e9fe9
commit ad107ed029
15 changed files with 174 additions and 162 deletions

View File

@ -2,11 +2,11 @@
namespace App\Controllers\Admin;
use App\Controllers\Trait\UpDownloadTrait;
use App\Models\ProductModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Controllers\Trait\UpDownloadTrait;
class ProductController extends AdminController
{
@ -56,7 +56,7 @@ class ProductController extends AdminController
return $this->_viewDatas['fieldDatas'];
}
protected function insert_process()
private function calculate_price(): int
{
if ($this->_viewDatas['fieldDatas']['cost'] < $this->_viewDatas['fieldDatas']['sale']) {
throw new \Exception(sprintf(
@ -67,7 +67,16 @@ class ProductController extends AdminController
number_format($this->_viewDatas['fieldDatas']['sale']),
));
}
$this->_viewDatas['fieldDatas']['price'] = $this->_viewDatas['fieldDatas']['cost'] - $this->_viewDatas['fieldDatas']['sale'];
return $this->_viewDatas['fieldDatas']['cost'] - $this->_viewDatas['fieldDatas']['sale'];
}
protected function insert_process()
{
$this->_viewDatas['fieldDatas']['price'] = $this->calculate_price();
return parent::insert_process();
}
protected function update_process($entity)
{
$this->_viewDatas['fieldDatas']['price'] = $this->calculate_price();
return parent::update_process($entity);
}
}

View File

@ -21,7 +21,7 @@ class BoardController extends FrontController
switch ($action) {
case "index":
case "excel":
return ['title', "board_file", "view_cnt", "created_at"];
return ['title', "board_file", "created_at", "view_cnt"];
break;
case "view":
return ['title', "board_file", "view_cnt", "created_at", "content"];

View File

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

View File

@ -83,7 +83,7 @@ function getFieldView_ProductHelper($field, $entity, array $viewDatas)
case 'name':
return anchor(
current_url() . '/view/' . $entity->getPrimaryKey(),
$value ? str_split($value, 40)[0] . "..." : "",
$value ? str_split($value, 66)[0] . "..." : "",
["target" => "_self"]
);
break;

View File

@ -41,7 +41,7 @@ class ProductModel extends BaseModel
$rules[$field] = "required|trim|string";
break;
case 'photo':
$rules[$field] = !$action ? "if_exist|string" : "uploaded[$field]|is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]";
$rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]";
break;
case 'cost':
case 'price':

View File

@ -1,17 +1,11 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<div class="content">
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="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_BoardHelper($field, $viewDatas[$field], $viewDatas) ?><?php endforeach ?>
<?= $this->include('templates/front/index_head') ?>
</ul>
<?= form_close() ?>
</div>
<div class="top"><?= $this->include('templates/front/index_head') ?></div>
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="table table-bordered table-hover table-striped">
<table class="table table-hover">
<thead>
<tr>
<th>번호</th>

View File

@ -1,55 +1,53 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<div class="content">
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<div><?= html_entity_decode($viewDatas['category']->getHead()) ?></div>
<table class="table">
<tr>
<td width="10%">
<?= 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"]) ?>
</td>
<td>
<?= form_open(current_url(), array("method" => "get")) ?>
<?= $this->include('templates/front/index_head') ?>
<?= form_close() ?>
</td>
<td width="10%" style="text-align:right; padding-right:10px;">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . '&v=_list', 'List', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
</td>
</tr>
</table>
<div class="top">
<?= $this->include('templates/front/index_head') ?>
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<nav class="nav">
<?= 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"]) ?>
</nav>
<nav class="nav justify-content-center"></nav>
<nav class="nav justify-content-end">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . '&v=_list', 'List', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
</nav>
</div>
</nav>
</div>
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<div>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<table class="table table-bordered">
<tbody>
<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>
</tbody>
</table>
<?php $cnt++ ?>
<?php endforeach ?>
</div>
<div class="bottom">
<?= $viewDatas['pagination'] ?>
</div>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<table class="table">
<tbody>
<tr id="table_tr_border">
<td width="14%" rowspan="3"><?= $entity->getPhotoFileName('middle') ?></td>
<td width="*">
<?= getFieldIndex_Row_ProductHelper('name', $entity, $viewDatas) ?>
<td>
<td width="6%" rowspan="3"><?= getFieldIndex_Row_ProductHelper('user_uid', $entity, $viewDatas) ?></td>
</tr>
<tr>
<td>
<b style="font-size:24px;">판매가:<?= getFieldIndex_Row_ProductHelper('price', $entity, $viewDatas) ?>원</b>
<span>
원가:<?= getFieldIndex_Row_ProductHelper('cost', $entity, $viewDatas) ?>
-
할인가:<?= getFieldIndex_Row_ProductHelper('sale', $entity, $viewDatas) ?>
</span>
</td>
</tr>
<tr>
<td>조회수:<?= getFieldIndex_Row_ProductHelper('view_cnt', $entity, $viewDatas) ?></td>
</tr>
</tbody>
</table>
<?php $cnt++ ?>
<?php endforeach ?>
<div class="bottom"><?= $viewDatas['pagination'] ?></div>
<?= form_close() ?>
<div><?= html_entity_decode($viewDatas['category']->getTail()) ?></div>
</div>

View File

@ -1,27 +1,27 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<div class="content">
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<div><?= html_entity_decode($viewDatas['category']->getHead()) ?></div>
<table class="table">
<tr>
<td width="10%">
<?= 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"]) ?>
</td>
<td>
<?= form_open(current_url(), array("method" => "get")) ?>
<?= $this->include('templates/front/index_head') ?>
<?= form_close() ?>
</td>
<td width="10%" style="text-align:right; padding-right:10px;">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey(), 'Block', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
</td>
</tr>
</table>
<div class="top">
<?= $this->include('templates/front/index_head') ?>
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<nav class="nav">
<?= 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"]) ?>
</nav>
<nav class="nav justify-content-center"></nav>
<nav class="nav justify-content-end">
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey(), 'Block', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
</nav>
</div>
</nav>
</div>
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="table table-bordered table-hover table-striped">
<table class="table table-hover">
<thead>
<tr>
<tr id="table_tr_border">
<th>번호</th>
<?php foreach ($viewDatas['fields'] as $field) : ?><th><?= getFieldIndex_Column_ProductHelper($field, $viewDatas) ?></th><?php endforeach ?>
</tr>
@ -31,6 +31,8 @@
<?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>
<!-- 사용자가 자신의 작성한것인지 확인되면 update 가능-->
<?= $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt) ?>
</td>
<?php foreach ($viewDatas['fields'] as $field) : ?>
@ -41,9 +43,7 @@
<?php endforeach ?>
</tbody>
</table>
<div class="bottom">
<?= $viewDatas['pagination'] ?>
</div>
<div class="bottom"><?= $viewDatas['pagination'] ?></div>
<?= form_close() ?>
<div><?= html_entity_decode($viewDatas['category']->getTail()) ?></div>
</div>

View File

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" id="viewport" content="width=1280px">
<meta name="viewport" id="viewport" content="width=1280">
<meta name="subject" content="IT Solution">
<meta name="description" content="일본IDC 일본서버 일본 서버 일본호스팅 서버호스팅 디도스 공격 해외 호스팅 DDOS 방어 ddos 의뢰 디도스 보안 일본 단독서버">
<meta name="keywords" content="일본IDC 일본서버 일본 서버 일본호스팅 서버호스팅 디도스 공격 해외 호스팅 DDOS 방어 ddos 의뢰 디도스 보안 일본 단독서버">

View File

@ -3,12 +3,12 @@
<div id="left_menu">
<div class="parent">
<div>-</div>
<div><?= $viewDatas['parent_category']->getTitle() ?></div>
<div class="title"><?= $viewDatas['parent_category']->getTitle() ?></div>
</div>
<?php foreach ($viewDatas['sibling_categorys'] as $category) : ?>
<div class="sibling <?php if ($viewDatas['category']->getPrimaryKey() == $category->getPrimaryKey()) : ?>active<?php endif ?>">
<?= anchor(
current_url() .
'/front/' . strtolower($viewDatas['className']) .
'?category=' . $category->getPrimaryKey(),
$category->getTitle(),
["target" => "_self"]

View File

@ -1,5 +1,5 @@
<link href="/css/front/top_menu.css" media="screen" rel="stylesheet" type="text/css" />
<nav class="navbar navbar-expand-lg" style="background-color:white">
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<nav class="nav"></nav>
<nav class="nav justify-content-center">

View File

@ -1,4 +1,15 @@
<span>검색어:<?= form_input('word', $viewDatas['word']) ?></span>
<?= 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>
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<nav class="nav">
<span>페이지정보:<?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?></span>
</nav>
<nav class="nav justify-content-center"></nav>
<nav class="nav justify-content-end">
<?= form_open(current_url(), array("method" => "get")) ?>
<span>검색어:<?= form_input('word', $viewDatas['word']) ?></span>
<?= 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>
<?= form_close() ?>
</nav>
</div>
</nav>

View File

@ -18,10 +18,9 @@ body {
width:1280px;
/* border:1px solid blue; */
}
#layout #body{
padding-left:10px;
padding-right:10px;
background-color:white;
/* border:1px solid red; */
}
@ -35,10 +34,6 @@ body {
border-radius: 10px 10px 0px 0px;
background-color:#efefef;
}
#layout #body div.content{
border:1px solid silver;
background-color:white;
}
#layout #body div.footer
/*content 하단라인*/{
height:20px;
@ -48,63 +43,4 @@ body {
border-right:1px solid silver;
border-radius: 0px 0px 10px 10px;
background-color:white;
}
#layout #body div.content div.top{
/*조건 검색*/
padding:10px;
/* border:1px solid red; */
}
#layout #body div.content div.top ul.nav li.nav-item{
/*조건검색 ITEMS*/
/* border:1px solid red; */
margin-left:10px;
}
#layout #body div.content table {
white-space: nowrap;
/* overflow-x: auto;
padding-top:5px;
padding-bottom:5px; */
}
#layout #body div.content table th{
text-align:center;
font-size: 16px;
/* border:1px solid silver; */
}
#layout #body div.content table th a{
color:black;
/* border:1px solid silver; */
}
#layout #body div.content table td{
/* border:1px solid silver; */
text-align:center;
}
#layout #body div.content table td a{
color:black;
/* border:1px solid silver; */
}
#layout #body div.content table.form td.label{
background-color:#e8ebe9;
width:10%;
text-align:right;
padding-right:20px;
}
#layout #body div.content table.form td.column{
height:27px;
text-align:left;
padding-left:20px;
}
#layout #body div.content div.bottom {
padding-top:15px;
text-align:center;
}
#layout #body div.content div.bottom ul.nav{
/* border:1px solid red; */
margin-bottom:15px;
}
#layout #body div.content div.bottom ul.nav li.nav-item{
/*조건검색 ITEMS*/
/* border:1px solid red; */
margin-left:10px;
}

View File

@ -0,0 +1,61 @@
div#content{
border-left:1px solid silver;
border-right:1px solid silver;
/* border:1px solid red; */
}
/* div#content div.top{
border:1px solid red;
} */
div#content table {
white-space: nowrap;
/* overflow-x: auto;
padding-top:5px;
padding-bottom:5px; */
}
div#content table tr#table_tr_border{
border-top:2px solid black;
border-bottom:1px solid silver;
}
div#content table thead th{
text-align:center;
font-size: 16px;
font-weight: bolder;
background-color:#eeeeee;
/* border:1px solid silver; */
}
div#content table thead th a{
color:black;
/* border:1px solid silver; */
}
div#content table tbody td {
color: black;
/* border:1px solid silver; */
text-align:center;
}
div#content table tbody td a{
color:blue;
/* border:1px solid silver; */
}
div#content table.form td.label{
background-color:#e8ebe9;
width:10%;
text-align:right;
padding-right:20px;
}
div#content table.form td.column{
height:27px;
text-align:left;
padding-left:20px;
}
div#content div.bottom {
padding-top:15px;
text-align:center;
}
div#content div.bottom ul.nav{
/* border:1px solid red; */
margin-bottom:15px;
}
div#content div.bottom ul.nav li.nav-item{
/* border:1px solid red; */
margin-left:10px;
}

View File

@ -9,10 +9,13 @@ div#left_menu div.parent {
font-size:24px;
height:160px;
padding-top:30px;
background-color: #d5dfed;
background-color: #efefef;
border:1px solid silver;
text-align:center;
}
div#left_menu div.parent div.title{
color:#0d4491;
}
div#left_menu div.parent div{
font-size:24px;
}