dbms_primeidc_init...1
This commit is contained in:
parent
1cc9d6c342
commit
082b941ad6
@ -194,6 +194,10 @@ define('DBMS_GEARLIST_CPU_TYPES', [
|
|||||||
'DX3',
|
'DX3',
|
||||||
'DQ233'
|
'DQ233'
|
||||||
]);
|
]);
|
||||||
|
define('DBMS_CLIENT_COUPON_TYPE', [
|
||||||
|
'domain' => '도메인구매',
|
||||||
|
'etc' => '기타',
|
||||||
|
]);
|
||||||
define('DBMS_CLIENT_POINT_TYPE', [
|
define('DBMS_CLIENT_POINT_TYPE', [
|
||||||
'deposit' => '입금',
|
'deposit' => '입금',
|
||||||
'withdrawal' => '출금',
|
'withdrawal' => '출금',
|
||||||
|
|||||||
@ -52,6 +52,11 @@ $router->group('dbms/client', function (Router $router) {
|
|||||||
return $controller->update();
|
return $controller->update();
|
||||||
// Response::view($result);
|
// Response::view($result);
|
||||||
});
|
});
|
||||||
|
$router->add('POST', 'use', function ($params) {
|
||||||
|
$controller = new CouponController(params: $params);
|
||||||
|
return $controller->use();
|
||||||
|
// Response::view($result);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
//Point관련
|
//Point관련
|
||||||
$router->group('point', function (Router $router) {
|
$router->group('point', function (Router $router) {
|
||||||
|
|||||||
@ -68,37 +68,44 @@ class CouponController extends ClientController
|
|||||||
//IdcCouponBuyMK.jsp -> domain_coupon_buy.php
|
//IdcCouponBuyMK.jsp -> domain_coupon_buy.php
|
||||||
//CLI 접속방법 : php index.php site/client/counpon/insert_form
|
//CLI 접속방법 : php index.php site/client/counpon/insert_form
|
||||||
//WEB 접속방법 : http://localhost/site/client/coupon/insert_form
|
//WEB 접속방법 : http://localhost/site/client/coupon/insert_form
|
||||||
public function update()
|
public function use()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
//기본적으로 필요한 client_code, member_code, service_code를 설정합니다.
|
//기본적으로 필요한 client_code, member_code, service_code를 설정합니다.
|
||||||
list($this->client, $this->member, $this->service) = $this->setDefaultRequestData(null, true, true);
|
list($this->client, $this->member, $this->service) = $this->setDefaultRequestData(null, true, true);
|
||||||
//onetime_sub 도메인 구매 수량
|
|
||||||
$coupon = $this->request->get('coupon');
|
|
||||||
if (! $coupon || $coupon < 1) {
|
|
||||||
throw new \Exception("도메인 구매 수량 값이 정의되지 않았거나, 도메인 구매 수량은 1개 이상이어야 합니다.");
|
|
||||||
}
|
|
||||||
//onetime_note 도메인 구매 수량
|
|
||||||
$note = $this->request->get('note');
|
|
||||||
if (!$note) {
|
|
||||||
throw new \Exception("도메인 리스트 값이 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
//onetime_case 사용용도
|
//onetime_case 사용용도
|
||||||
$onetime_case = $this->request->get('onetime_case', 'domain');
|
$onetime_case = $this->request->get('type');
|
||||||
|
if (! $onetime_case) {
|
||||||
|
throw new \Exception("쿠폰 사용용도를 선택하세요");
|
||||||
|
}
|
||||||
|
//onetime_note 사용내역
|
||||||
|
$title = $this->request->get('title');
|
||||||
|
if (! $title) {
|
||||||
|
throw new \Exception("쿠폰 사용제목을 입력하세요");
|
||||||
|
}
|
||||||
|
//onetime_sub 사용수량
|
||||||
|
$coupon_select = $this->request->get('select_coupon');
|
||||||
|
if (! $coupon_select) {
|
||||||
|
throw new \Exception("쿠폰 수량 값이 정의되지 않았거나, 도메인 구매 수량은 1개 이상이어야 합니다.");
|
||||||
|
}
|
||||||
|
//onetime_note 비고
|
||||||
|
$note = $this->request->get('coupon_note');
|
||||||
//onetime_request_date 사용일
|
//onetime_request_date 사용일
|
||||||
$onetime_request_date = $this->request->get('onetime_request_date') ?? date("Y-m-d");
|
$onetime_request_date = $this->request->get('onetime_request_date') ?? date("Y-m-d");
|
||||||
try {
|
|
||||||
$this->getServiceService()->beginTransaction();
|
$this->getServiceService()->beginTransaction();
|
||||||
//서비스쿠폰 갯수 수정
|
//서비스쿠폰 갯수 수정
|
||||||
$this->getServiceService()->useCouponByService($this->service, $coupon);
|
$this->getServiceService()->useCouponByService($this->service, $coupon_select);
|
||||||
//쿠폰 사용내역 onetime에 등록
|
//쿠폰 사용내역 onetime에 등록
|
||||||
$this->getOnetimeService()->useCouponByService($this->service, $this->client, $this->member, $onetime_case, $coupon, $note, $onetime_request_date);
|
$this->getOnetimeService()->useCouponByService($this->service, $this->client, $this->member, $onetime_case, $title, $coupon_select, $note, $onetime_request_date);
|
||||||
//쿠폰 사용내역 history에 등록
|
//쿠폰 사용내역 history에 등록
|
||||||
$this->getHistoryService()->useCouponByService($this->service, $this->client, $onetime_case, $coupon, $note, $onetime_request_date);;
|
$this->getHistoryService()->useCouponByService($this->service, $this->client, $onetime_case, $coupon_select, $note, $onetime_request_date);;
|
||||||
$this->getServiceService()->commit();
|
$this->getServiceService()->commit();
|
||||||
return $this->redirect->to(DBMS_SITE_URL . "/IdcCouponUseMK.cup?client_code=" . $this->service->getClientCode());
|
return $this->redirect->to(DBMS_SITE_URL . "/IdcCouponUseMK.cup?client_code=" . $this->service->getClientCode())->send();
|
||||||
} catch (\Exception $e) {
|
} catch (\PDOException $e) {
|
||||||
$this->getServiceService()->rollback();
|
$this->getServiceService()->rollback();
|
||||||
return $this->redirect->back()->withInput()->with('error', ['message' => '쿠폰 사용에 실패하였습니다.:' . $e->getMessage()]);
|
return $this->redirect->back()->withInput()->with('error', '쿠폰 사용에 실패하였습니다.:' . $e->getMessage())->send();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->redirect->back()->withInput()->with('error', '쿠폰 사용에 실패하였습니다.:' . $e->getMessage())->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //Class
|
} //Class
|
||||||
|
|||||||
@ -6,13 +6,11 @@ use lib\Core\Logger;
|
|||||||
use lib\Core\Http\Redirect;
|
use lib\Core\Http\Redirect;
|
||||||
use lib\Core\Http\Request;
|
use lib\Core\Http\Request;
|
||||||
use lib\Core\Http\Session;
|
use lib\Core\Http\Session;
|
||||||
use lib\Core\Http\Url;
|
|
||||||
use lib\Core\Http\Response;
|
use lib\Core\Http\Response;
|
||||||
|
|
||||||
abstract class Controller
|
abstract class Controller
|
||||||
{
|
{
|
||||||
protected ?View $_view = null;
|
protected ?View $_view = null;
|
||||||
protected ?Url $url = null;
|
|
||||||
protected ?Request $request = null;
|
protected ?Request $request = null;
|
||||||
protected ?Session $session = null;
|
protected ?Session $session = null;
|
||||||
protected ?Redirect $redirect = null;
|
protected ?Redirect $redirect = null;
|
||||||
@ -26,12 +24,16 @@ abstract class Controller
|
|||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
ini_set('display_errors', '0');
|
ini_set('display_errors', '0');
|
||||||
}
|
}
|
||||||
$this->url = new Url();
|
|
||||||
$this->request = new Request($params);
|
$this->request = new Request($params);
|
||||||
$this->session = new Session();
|
$this->session = new Session();
|
||||||
$this->redirect = new Redirect($this->session);
|
$this->redirect = new Redirect($this->session);
|
||||||
$this->logger = new Logger();
|
$this->logger = new Logger();
|
||||||
$this->_view = new View();
|
$this->_view = new View();
|
||||||
|
$this->_view->request = $this->request;
|
||||||
|
$this->_view->session = $this->session;
|
||||||
|
$this->_view->redirect = $this->redirect;
|
||||||
|
$this->_view->logger = $this->logger;
|
||||||
|
$this->session->set('_previous_url', $this->request->currentUrl());
|
||||||
} //
|
} //
|
||||||
final public function __get($name): mixed
|
final public function __get($name): mixed
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,13 +5,14 @@ namespace lib\Core\Http;
|
|||||||
class Redirect
|
class Redirect
|
||||||
{
|
{
|
||||||
protected Session $session;
|
protected Session $session;
|
||||||
|
protected ?string $targetUrl = null;
|
||||||
|
|
||||||
public function __construct(Session $session)
|
public function __construct(Session $session)
|
||||||
{
|
{
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 리다이렉트할 때 캐시를 방지하는 헤더 추가
|
// 캐시 방지 헤더
|
||||||
private function noCacheHeaders(): void
|
private function noCacheHeaders(): void
|
||||||
{
|
{
|
||||||
header("Cache-Control: no-cache, no-store, must-revalidate");
|
header("Cache-Control: no-cache, no-store, must-revalidate");
|
||||||
@ -19,34 +20,43 @@ class Redirect
|
|||||||
header("Expires: 0");
|
header("Expires: 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 이전 페이지로 리다이렉트 (캐시 방지)
|
// 이전 페이지로 이동 설정
|
||||||
public function back(): self
|
public function back(): self
|
||||||
{
|
{
|
||||||
$this->noCacheHeaders(); // 캐시 방지
|
$this->targetUrl = $_SERVER['HTTP_REFERER'] ?? $this->session->get('_previous_url') ?? '/';
|
||||||
$backUrl = $_SERVER['HTTP_REFERER'] ?? '/';
|
|
||||||
header("Location: {$backUrl}");
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 특정 URL로 리다이렉트 (캐시 방지)
|
// 특정 URL로 이동 설정
|
||||||
public function to(string $url): self
|
public function to(string $url): self
|
||||||
{
|
{
|
||||||
$this->noCacheHeaders(); // 캐시 방지
|
$this->targetUrl = $url;
|
||||||
header("Location: {$url}");
|
return $this;
|
||||||
return $this;;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 세션에 값 추가 후 리다이렉트
|
// POST 데이터 저장
|
||||||
public function withInput(): self
|
public function withInput(): self
|
||||||
{
|
{
|
||||||
$this->session->flashInput($_POST);
|
$this->session->flashInput($_POST);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 세션에 에러 메시지 저장 후 리다이렉트
|
// 기타 flash 데이터 저장
|
||||||
public function with(string $key, mixed $value): self
|
public function with(string $key, mixed $value): self
|
||||||
{
|
{
|
||||||
$this->session->flash($key, $value);
|
$this->session->flash($key, $value);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 실제 리다이렉트 전송
|
||||||
|
public function send(): void
|
||||||
|
{
|
||||||
|
if (!$this->targetUrl) {
|
||||||
|
throw new \Exception("Redirect URL is not set.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->noCacheHeaders();
|
||||||
|
header("Location: {$this->targetUrl}");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,12 +5,27 @@ namespace lib\Core\Http;
|
|||||||
class Request extends Http
|
class Request extends Http
|
||||||
{
|
{
|
||||||
private array $_datas = [];
|
private array $_datas = [];
|
||||||
|
private array $_files = [];
|
||||||
|
private array $_server = [];
|
||||||
|
|
||||||
|
protected string $baseUrl;
|
||||||
|
protected string $uri;
|
||||||
|
|
||||||
public function __construct(array $params = [])
|
public function __construct(array $params = [])
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->_datas = array_merge($_GET, $_POST, $params);
|
$this->_datas = array_merge($_GET, $_POST, $params);
|
||||||
|
$this->_files = $_FILES ?? [];
|
||||||
|
$this->_server = $_SERVER ?? [];
|
||||||
|
|
||||||
|
$this->baseUrl = $this->detectBaseUrl();
|
||||||
|
$this->uri = $this->detectUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
// 요청 데이터 관련
|
||||||
|
// --------------------
|
||||||
public function all(): array
|
public function all(): array
|
||||||
{
|
{
|
||||||
return $this->_datas;
|
return $this->_datas;
|
||||||
@ -34,25 +49,96 @@ class Request extends Http
|
|||||||
return array_key_exists($key, $this->_datas);
|
return array_key_exists($key, $this->_datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function file(string $key): mixed
|
||||||
* Validator 연동
|
{
|
||||||
*/
|
return $this->_files[$key] ?? null;
|
||||||
//사용예:
|
}
|
||||||
// $request = new Request();
|
|
||||||
|
|
||||||
// $validation = $request->validate([
|
public function method(): string
|
||||||
// 'username' => 'required|alpha_numeric|min[4]',
|
{
|
||||||
// 'email' => 'required|email',
|
return strtoupper($_SERVER['REQUEST_METHOD'] ?? 'GET');
|
||||||
// 'password' => 'required|min[6]'
|
}
|
||||||
// ]);
|
|
||||||
|
|
||||||
// if ($validation !== true) {
|
public function isPost(): bool
|
||||||
// // 에러 처리
|
{
|
||||||
// print_r($validation);
|
return $this->method() === 'POST';
|
||||||
// } else {
|
}
|
||||||
// // 통과
|
|
||||||
// echo "유효성 검사 통과!";
|
public function isGet(): bool
|
||||||
// }
|
{
|
||||||
|
return $this->method() === 'GET';
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
// URL/경로 관련
|
||||||
|
// --------------------
|
||||||
|
public function baseUrl(): string
|
||||||
|
{
|
||||||
|
return $this->baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function currentUrl(): string
|
||||||
|
{
|
||||||
|
return $this->baseUrl . '/' . ltrim($this->uri, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function previousUrl(): ?string
|
||||||
|
{
|
||||||
|
return $_SESSION['_previous_url'] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function segments(): array
|
||||||
|
{
|
||||||
|
return explode('/', trim($this->uri, '/'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function segment(int $n): ?string
|
||||||
|
{
|
||||||
|
$segments = $this->segments();
|
||||||
|
return $segments[$n - 1] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function urlIs(string $pattern): bool
|
||||||
|
{
|
||||||
|
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||||
|
$pattern = str_replace('*', '.*', preg_quote($pattern, '/'));
|
||||||
|
return preg_match("/^{$pattern}$/", $uri) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function to(string $path): string
|
||||||
|
{
|
||||||
|
return rtrim($this->baseUrl, '/') . '/' . ltrim($path, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 현재 URI 반환 (도메인 제외)
|
||||||
|
public function path(): string
|
||||||
|
{
|
||||||
|
return $this->uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
// 내부 URL 추출 로직
|
||||||
|
// --------------------
|
||||||
|
protected function detectUri(): string
|
||||||
|
{
|
||||||
|
$uri = $_SERVER['REQUEST_URI'] ?? '/';
|
||||||
|
$scriptName = dirname($_SERVER['SCRIPT_NAME'] ?? '');
|
||||||
|
$uri = str_replace($scriptName, '', $uri);
|
||||||
|
$uri = strtok($uri, '?'); // 쿼리 스트링 제거
|
||||||
|
return $uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function detectBaseUrl(): string
|
||||||
|
{
|
||||||
|
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
||||||
|
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
||||||
|
$scriptDir = rtrim(dirname($_SERVER['SCRIPT_NAME'] ?? ''), '/');
|
||||||
|
return $scheme . '://' . $host . $scriptDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
// Validator 연동
|
||||||
|
// --------------------
|
||||||
public function validate(array $rules, array $messages = []): bool|array
|
public function validate(array $rules, array $messages = []): bool|array
|
||||||
{
|
{
|
||||||
$validator = new Validator();
|
$validator = new Validator();
|
||||||
|
|||||||
@ -8,6 +8,7 @@ class Session extends Http
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->init();
|
$this->init();
|
||||||
|
$this->sweepFlash(); // flash 생명주기 관리
|
||||||
}
|
}
|
||||||
|
|
||||||
// 세션 시작
|
// 세션 시작
|
||||||
@ -22,51 +23,65 @@ class Session extends Http
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 세션에 값 저장
|
// 일반 세션 저장
|
||||||
public function set(string $key, $value): void
|
public function set(string $key, $value): void
|
||||||
{
|
{
|
||||||
$_SESSION[$key] = $value;
|
$_SESSION[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 세션에서 값 가져오기
|
// 일반 세션 가져오기
|
||||||
public function get(string $key): mixed
|
public function get(string $key): mixed
|
||||||
{
|
{
|
||||||
return $_SESSION[$key] ?? null;
|
return $_SESSION[$key] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 세션에서 값 삭제
|
// 일반 세션 제거
|
||||||
public function remove(string $key): void
|
public function remove(string $key): void
|
||||||
{
|
{
|
||||||
unset($_SESSION[$key]);
|
unset($_SESSION[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 세션에 에러 메시지 설정
|
// flash 메시지 저장 (다음 요청까지)
|
||||||
public function flash(string $key, $message): void
|
public function flash(string $key, $value): void
|
||||||
{
|
{
|
||||||
$_SESSION['flash'][$key] = $message;
|
$_SESSION['_flash_new'][$key] = $value;
|
||||||
}
|
|
||||||
|
|
||||||
// 세션에 입력값 설정 (입력값 유지)
|
|
||||||
public function flashInput(array $input): void
|
|
||||||
{
|
|
||||||
$_SESSION['flash']['input'] = $input;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 세션에 flash 메시지가 있는지 확인
|
|
||||||
public function hasFlash(string $key): bool
|
|
||||||
{
|
|
||||||
return isset($_SESSION['flash'][$key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// flash 메시지 가져오기
|
// flash 메시지 가져오기
|
||||||
public function getFlash(string $key): mixed
|
public function getFlash(string $key): mixed
|
||||||
{
|
{
|
||||||
return $_SESSION['flash'][$key] ?? null;
|
return $_SESSION['_flash_old'][$key] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// flash 메시지 삭제
|
// flash 메시지 존재 여부
|
||||||
|
public function hasFlash(string $key): bool
|
||||||
|
{
|
||||||
|
return isset($_SESSION['_flash_old'][$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 입력값을 flash로 저장
|
||||||
|
public function flashInput(array $input): void
|
||||||
|
{
|
||||||
|
$_SESSION['_flash_new']['_old_input'] = $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 이전 입력값 가져오기
|
||||||
|
public function old(string $key, $default = null): mixed
|
||||||
|
{
|
||||||
|
return $_SESSION['_flash_old']['_old_input'][$key] ?? $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 모든 flash 제거 (사용 후 직접 호출할 경우)
|
||||||
public function clearFlash(): void
|
public function clearFlash(): void
|
||||||
{
|
{
|
||||||
unset($_SESSION['flash']);
|
unset($_SESSION['_flash_new']);
|
||||||
|
unset($_SESSION['_flash_old']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 요청 시작 시 flash 생명주기 관리 (자동 호출)
|
||||||
|
private function sweepFlash(): void
|
||||||
|
{
|
||||||
|
$_SESSION['_flash_old'] = $_SESSION['_flash_new'] ?? [];
|
||||||
|
unset($_SESSION['_flash_new']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,103 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace lib\Core\Http;
|
|
||||||
|
|
||||||
class Url extends Http
|
|
||||||
{
|
|
||||||
protected string $baseUrl;
|
|
||||||
protected string $uri;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->baseUrl = $this->detectBaseUrl();
|
|
||||||
$this->uri = $this->detectUri();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 현재 전체 URL 반환
|
|
||||||
public function current(): string
|
|
||||||
{
|
|
||||||
return $this->baseUrl . '/' . ltrim($this->uri, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
// base URL만 반환
|
|
||||||
public function base(): string
|
|
||||||
{
|
|
||||||
return $this->baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 세그먼트 배열 반환
|
|
||||||
public function segments(): array
|
|
||||||
{
|
|
||||||
return explode('/', trim($this->uri, '/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// N번째 세그먼트 반환 (1부터 시작)
|
|
||||||
public function segment(int $n): ?string
|
|
||||||
{
|
|
||||||
$segments = $this->segments();
|
|
||||||
return $segments[$n - 1] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 특정 경로에 대한 URL 생성
|
|
||||||
public function to(string $path): string
|
|
||||||
{
|
|
||||||
return rtrim($this->baseUrl, '/') . '/' . ltrim($path, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
// URI 추출 (도메인 제외)
|
|
||||||
protected function detectUri(): string
|
|
||||||
{
|
|
||||||
$uri = $_SERVER['REQUEST_URI'] ?? '/';
|
|
||||||
$scriptName = dirname($_SERVER['SCRIPT_NAME'] ?? '');
|
|
||||||
$uri = str_replace($scriptName, '', $uri);
|
|
||||||
$uri = strtok($uri, '?'); // 쿼리 스트링 제거
|
|
||||||
return $uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
// base URL 추출
|
|
||||||
protected function detectBaseUrl(): string
|
|
||||||
{
|
|
||||||
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
|
||||||
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
||||||
$scriptDir = rtrim(dirname($_SERVER['SCRIPT_NAME'] ?? ''), '/');
|
|
||||||
return $scheme . '://' . $host . $scriptDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function baseUrl(): string
|
|
||||||
{
|
|
||||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
|
|
||||||
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
||||||
$script = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
|
|
||||||
|
|
||||||
return rtrim($protocol . $host . $script, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function currentUrl(): string
|
|
||||||
{
|
|
||||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
|
|
||||||
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
||||||
$uri = $_SERVER['REQUEST_URI'] ?? '';
|
|
||||||
|
|
||||||
return $protocol . $host . $uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function previousUrl(): ?string
|
|
||||||
{
|
|
||||||
return $_SERVER['HTTP_REFERER'] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function urlIs(string $pattern): bool
|
|
||||||
{
|
|
||||||
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
||||||
$pattern = str_replace('*', '.*', preg_quote($pattern, '/'));
|
|
||||||
return preg_match("/^{$pattern}$/", $uri) === 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getSegment(int $index): ?string
|
|
||||||
{
|
|
||||||
$uri = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
|
|
||||||
$segments = explode('/', $uri);
|
|
||||||
return $segments[$index - 1] ?? null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -46,8 +46,17 @@ class View
|
|||||||
{
|
{
|
||||||
// Blade 템플릿 렌더링
|
// Blade 템플릿 렌더링
|
||||||
$file = implode('.', $this->_paths) . '.' . $file;
|
$file = implode('.', $this->_paths) . '.' . $file;
|
||||||
|
|
||||||
|
// session 값을 BladeOne에 전역 공유
|
||||||
|
if (isset($this->_values['session'])) {
|
||||||
|
$this->_blade->share('session', $this->_values['session']);
|
||||||
|
}
|
||||||
|
|
||||||
if (APP_VIEW_DEBUG) {
|
if (APP_VIEW_DEBUG) {
|
||||||
echo "<pre>VIwe DEBUG:" . __METHOD__ . "에서 [" . $file . "]를 렌더링합니다.</pre>";
|
echo "<pre>VIwe DEBUG:" . __METHOD__ . "에서 [" . $file . "]를 렌더링합니다.</pre>";
|
||||||
|
// echo "<pre>Blade View 전달 값:\n";
|
||||||
|
// print_r($this->_values);
|
||||||
|
echo "</pre>";
|
||||||
}
|
}
|
||||||
return $this->_blade->run($file, $this->_values);
|
return $this->_blade->run($file, $this->_values);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,13 +33,13 @@ class OnetimeService extends CommonService
|
|||||||
}
|
}
|
||||||
|
|
||||||
//도메인쿠폰 사용용
|
//도메인쿠폰 사용용
|
||||||
public function useCouponByService(ServiceEntity $service, ClientEntity $client, MemberEntity $member, string $onetime_case, int $coupon, string $note, string $onetime_request_date): bool
|
public function useCouponByService(ServiceEntity $service, ClientEntity $client, MemberEntity $member, string $onetime_case, $onetime_sub, int $coupon, string $note, string $onetime_request_date): bool
|
||||||
{
|
{
|
||||||
$formDatas = [
|
$formDatas = [
|
||||||
"client_code" => $service->getClientCode(),
|
"client_code" => $service->getClientCode(),
|
||||||
"service_code" => $service->getServiceCode(),
|
"service_code" => $service->getServiceCode(),
|
||||||
"onetime_case" => $onetime_case,
|
"onetime_case" => $onetime_case,
|
||||||
"onetime_sub" => "도메인 쿠폰 구매 / {$coupon} 개",
|
"onetime_sub" => $onetime_sub,
|
||||||
"onetime_amount" => 0,
|
"onetime_amount" => 0,
|
||||||
"onetime_payment" => 0,
|
"onetime_payment" => 0,
|
||||||
"onetime_nonpayment" => 0,
|
"onetime_nonpayment" => 0,
|
||||||
|
|||||||
@ -18,9 +18,124 @@
|
|||||||
background-color: #f2f2f2;
|
background-color: #f2f2f2;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<script>
|
||||||
|
// 쿠폰 사용 버튼 클릭 시 처리
|
||||||
|
function onCouponUse(event, form) {
|
||||||
|
event.preventDefault(); // 기본 폼 제출을 막기
|
||||||
|
if (!form) {
|
||||||
|
console.error("폼을 찾을 수 없습니다.");
|
||||||
|
return false; // 폼을 찾을 수 없으면 종료
|
||||||
|
}
|
||||||
|
console.log("쿠폰 사용 클릭됨");
|
||||||
|
|
||||||
|
// 각 요소 선택
|
||||||
|
const type = form.querySelector('select[name="type"]');
|
||||||
|
const title = form.querySelector('input[name="title"]');
|
||||||
|
const coupon_select = form.querySelector('select[name="coupon_select"]');
|
||||||
|
const coupon_note = form.querySelector('textarea[name="coupon_note"]');
|
||||||
|
|
||||||
|
// 요소가 존재하는지 확인
|
||||||
|
if (!type || !title || !coupon_select || !coupon_note) {
|
||||||
|
console.error("폼 내부에서 요소를 찾을 수 없습니다.");
|
||||||
|
return false; // 요소가 없으면 종료
|
||||||
|
}
|
||||||
|
|
||||||
|
// 값 가져오기
|
||||||
|
const typeValue = type.value;
|
||||||
|
const titleValue = title.value;
|
||||||
|
const couponSelectValue = coupon_select.value;
|
||||||
|
const couponNoteValue = coupon_note.value;
|
||||||
|
|
||||||
|
if (typeValue == "") {
|
||||||
|
alert("사용용도를 선택하세요");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (titleValue == "") {
|
||||||
|
alert("사용내역을 입력하세요");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (couponSelectValue == "") {
|
||||||
|
alert("사용쿠폰수를 선택하세요");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (couponNoteValue == "") {
|
||||||
|
alert("비고내용을 입력하세요");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 폼 액션을 설정하고 제출
|
||||||
|
form.action = "{{DBMS_SITE_HOST}}/dbms/client/coupon/use";
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 쿠폰 수정 버튼 클릭 시 처리
|
||||||
|
function onCouponUpdate(event, form) {
|
||||||
|
event.preventDefault(); // 기본 폼 제출을 막기
|
||||||
|
if (!form) {
|
||||||
|
console.error("폼을 찾을 수 없습니다.");
|
||||||
|
return false; // 폼을 찾을 수 없으면 종료
|
||||||
|
}
|
||||||
|
console.log("쿠폰 수정 클릭됨");
|
||||||
|
|
||||||
|
// 각 요소 선택
|
||||||
|
const type = form.querySelector('select[name="type"]');
|
||||||
|
const title = form.querySelector('input[name="title"]');
|
||||||
|
const coupon = form.querySelector('select[name="coupon"]');
|
||||||
|
const coupon_use = form.querySelector('input[name="coupon_use"]');
|
||||||
|
|
||||||
|
// 요소가 존재하는지 확인
|
||||||
|
if (!type || !title || !coupon || !coupon_use) {
|
||||||
|
console.error("폼 내부에서 요소를 찾을 수 없습니다.");
|
||||||
|
return false; // 요소가 없으면 종료
|
||||||
|
}
|
||||||
|
|
||||||
|
// 값 가져오기
|
||||||
|
const typeValue = type.value;
|
||||||
|
const titleValue = title.value;
|
||||||
|
const couponValue = coupon.value;
|
||||||
|
const couponUseValue = coupon_use.value;
|
||||||
|
|
||||||
|
if (typeValue == "") {
|
||||||
|
alert("사용용도를 선택하세요");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (titleValue == "") {
|
||||||
|
alert("사용제목을 입력하세요");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isNaN(couponValue) || couponValue.trim() === "") {
|
||||||
|
alert("남은쿠폰수가 숫자가 아닌 값이 입력되었습니다!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isNaN(couponUseValue) || couponUseValue.trim() === "") {
|
||||||
|
alert("사용된된쿠폰수가 숫자가 아닌 값이 입력되었습니다!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 폼 액션을 설정하고 제출
|
||||||
|
form.action = "{{DBMS_SITE_HOST}}/dbms/client/coupon/update";
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 쿠폰 리셋 버튼 클릭 시 처리
|
||||||
|
function onCouponReset(event, form) {
|
||||||
|
event.preventDefault(); // 기본 폼 제출을 막기
|
||||||
|
if (!form) {
|
||||||
|
console.error("폼을 찾을 수 없습니다.");
|
||||||
|
return false; // 폼을 찾을 수 없으면 종료
|
||||||
|
}
|
||||||
|
console.log("쿠폰 리셋 클릭됨");
|
||||||
|
|
||||||
|
// 폼 액션을 설정하고 제출
|
||||||
|
form.action = "{{DBMS_SITE_HOST}}/dbms/client/coupon/reset";
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@if ($client)
|
@if ($client)
|
||||||
<h3>고객명 : <a href="/serviceDetail.sev?client_code={{$client->getClientCode()}}">{{$client->getTitle()}}</a> / 쿠폰발급대상 : {{count($entities)}} 대</h3>
|
<h3>고객명 : <a href="/serviceDetail.sev?client_code={{$client->getClientCode()}}">{{$client->getTitle()}}</a> / 쿠폰발급대상 : {{count($entities)}} 대</h3>
|
||||||
@endif
|
@endif
|
||||||
|
session:{{var_dump($session)}}
|
||||||
|
@if ($session->hasFlash('error'))<div class="alert alert-danger">{{$session->getFlash('error')}}</div>@endif
|
||||||
<div class="table-responsive" id="table">
|
<div class="table-responsive" id="table">
|
||||||
<input type="hidden" id="token">
|
<input type="hidden" id="token">
|
||||||
<table class="table table-bordered table-hover table-striped">
|
<table class="table table-bordered table-hover table-striped">
|
||||||
@ -30,9 +145,10 @@
|
|||||||
<th>고객명</th>
|
<th>고객명</th>
|
||||||
<th>서비스코드</th>
|
<th>서비스코드</th>
|
||||||
<th>장비명</th>
|
<th>장비명</th>
|
||||||
<th>사용내역</th>
|
<th>사용용도</th>
|
||||||
<th>남은 쿠폰수</th>
|
<th>사용제목</th>
|
||||||
<th>사용된 쿠폰수</th>
|
<th>남은수/사용된수</th>
|
||||||
|
<th>사용쿠폰수</th>
|
||||||
<th>비고</th>
|
<th>비고</th>
|
||||||
<th>작업</th>
|
<th>작업</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -40,21 +156,44 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@php $i=0 @endphp
|
@php $i=0 @endphp
|
||||||
@foreach($entities as $key=>$entity)
|
@foreach($entities as $key=>$entity)
|
||||||
<form method="post" action="{{DBMS_SITE_HOST}}/dbms/client/coupon/update">
|
<tr>
|
||||||
|
<form method="post">
|
||||||
<input type="hidden" name="service_code" value="{{$entity->getServiceCode()}}">
|
<input type="hidden" name="service_code" value="{{$entity->getServiceCode()}}">
|
||||||
<input type="hidden" name="member_code" value="{{$member ? $member->getPK() : ""}}">
|
<input type="hidden" name="member_code" value="{{$member ? $member->getPK() : ""}}">
|
||||||
<tr>
|
|
||||||
<td>{{$total-(($curPage-1)*$perPage+$i)}}</td>
|
<td>{{$total-(($curPage-1)*$perPage+$i)}}</td>
|
||||||
<td>{{$clients[$entity->getClientCode()]->getTitle()}}</td>
|
<td>{{$clients[$entity->getClientCode()]->getTitle()}}</td>
|
||||||
<td><a href="/serviceDetailSolo.sev?client_code={{$entity->getClientCode()}}&service_code={{$entity->getServiceCode()}}">{{$entity->getServiceCode()}}</td>
|
<td><a href="/serviceDetailSolo.sev?client_code={{$entity->getClientCode()}}&service_code={{$entity->getServiceCode()}}">{{$entity->getServiceCode()}}</td>
|
||||||
<td>{{$entity->getServerCode()}}</td>
|
<td>{{$entity->getServerCode()}}</td>
|
||||||
|
<td>
|
||||||
|
<select name="type" style="width:100%">
|
||||||
|
<option value="">용도 선택</option>
|
||||||
|
@foreach(DBMS_CLIENT_COUPON_TYPE as $key => $value)
|
||||||
|
<option value="{{$key}}">{{$value}}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
<td><input type="text" name="title" value="" style="width:100%"></td>
|
<td><input type="text" name="title" value="" style="width:100%"></td>
|
||||||
<td><input type="text" name="coupon" value="{{$entity->getCoupon()}}" maxlength="3" size="3"></td>
|
<td><input type="text" name="coupon" value="@if ($session->old('title')) ?? {{$entity->getCoupon()}}" @endif maxlength="3" size="3">/<input type="text" name="coupon_use" value="{{$entity->getUsedCoupon()}}" maxlength="3" size="3"> <a href="/IdcOnetimeList.sev?service_code={{$entity->getServiceCode()}}">내역</a>
|
||||||
<td><input type="text" name="coupon_use" value="{{$entity->getUsedCoupon()}}" maxlength="3" size="3"></td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<select name="coupon_select" style="width:100%">
|
||||||
|
<option value="">쿠폰수 선택</option>
|
||||||
|
@for($i=1; $i<=$entity->getCoupon(); $i++)
|
||||||
|
<option value="{{$i}}">{{$i}}개</option>
|
||||||
|
@endfor
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
<td><textarea name="coupon_note" rows="2" cols="40"></textarea></td>
|
<td><textarea name="coupon_note" rows="2" cols="40"></textarea></td>
|
||||||
<td><a href="/IdcOnetimeList.sev?service_code={{$entity->getServiceCode()}}">내역보기</a> <input type="submit" value="수정"></td>
|
<td>
|
||||||
</tr>
|
<!-- <button type="button" onClick="onCouponUse(event, this.form)">사용</button>
|
||||||
|
<button type="button" onClick="onCouponUpdate(event, this.form)">수정</button>
|
||||||
|
<button type="button" onClick="onCouponReset(event, this.form)">RESET</button> -->
|
||||||
|
<input type="submit" value="사용" formaction=" {{DBMS_SITE_HOST}}/dbms/client/coupon/use">
|
||||||
|
<input type="submit" value="수정" formaction=" {{DBMS_SITE_HOST}}/dbms/client/coupon/update">
|
||||||
|
<input type="submit" value="RESET" formaction="{{DBMS_SITE_HOST}}/dbms/client/coupon/reset">
|
||||||
|
</td>
|
||||||
</form>
|
</form>
|
||||||
|
</tr>
|
||||||
@php $i++ @endphp
|
@php $i++ @endphp
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user