초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
11
lot_sales/_request.php
Normal file
11
lot_sales/_request.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
|
||||
$is_deleted = isset($_REQUEST['is_deleted']) ? $_REQUEST['is_deleted'] : null;
|
||||
$reg_date = isset($_REQUEST['reg_date']) ? $_REQUEST['reg_date'] : '';
|
||||
$lot_number = isset($_REQUEST['lot_number']) ? $_REQUEST['lot_number'] : '';
|
||||
$author = isset($_REQUEST['author']) ? $_REQUEST['author'] : '';
|
||||
$remark = isset($_REQUEST['remark']) ? $_REQUEST['remark'] : '';
|
||||
$update_log = isset($_REQUEST['update_log']) ? $_REQUEST['update_log'] : '';
|
||||
$search_tag = isset($_REQUEST['search_tag']) ? $_REQUEST['search_tag'] : '';
|
||||
$workplacename = isset($_REQUEST['workplacename']) ? $_REQUEST['workplacename'] : '';
|
||||
?>
|
||||
11
lot_sales/_row.php
Normal file
11
lot_sales/_row.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$num = isset($row['num']) ? $row['num'] : '';
|
||||
$is_deleted = isset($row['is_deleted']) ? $row['is_deleted'] : null;
|
||||
$reg_date = isset($row['reg_date']) ? $row['reg_date'] : '';
|
||||
$lot_number = isset($row['lot_number']) ? $row['lot_number'] : '';
|
||||
$author = isset($row['author']) ? $row['author'] : '';
|
||||
$remark = isset($row['remark']) ? $row['remark'] : '';
|
||||
$update_log = isset($row['update_log']) ? $row['update_log'] : '';
|
||||
$search_tag = isset($row['search_tag']) ? $row['search_tag'] : '';
|
||||
$workplacename = isset($row['workplacename']) ? $row['workplacename'] : '';
|
||||
?>
|
||||
135
lot_sales/css/style.css
Normal file
135
lot_sales/css/style.css
Normal file
@@ -0,0 +1,135 @@
|
||||
#openModalBtn {
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden; /* Changed from 'auto' to 'hidden' to prevent closing on outside click */
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #fefefe;
|
||||
margin: auto;
|
||||
border-radius: 10px;
|
||||
width: 80%;
|
||||
max-width: 1200px;
|
||||
animation: fadeIn 0.5s;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
background-color: #1f48d4;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.close {
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.close:hover,
|
||||
.close:focus {
|
||||
color: #bbb;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.custom-card {
|
||||
background-color: #f9f9f9;
|
||||
padding: 20px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
|
||||
.tooltip-inner {
|
||||
background-color: black !important; /* 배경색 */
|
||||
color: white !important; /* 글자색 */
|
||||
}
|
||||
.tooltip-arrow {
|
||||
color: black !important; /* 화살표 색상 */
|
||||
}
|
||||
|
||||
/* 입력창에 대한 설계 */
|
||||
.ui-autocomplete {
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.specialinputWrap {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.specialbtnClear {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.specialbtnClear:before {
|
||||
content: 'X';
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.specialbtnClear:hover {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.btnClear_lot {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btnClear_lot:before {
|
||||
content: 'X';
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btnClear_lot:hover {
|
||||
color: black;
|
||||
}
|
||||
99
lot_sales/fetch_modal.php
Normal file
99
lot_sales/fetch_modal.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$mode = isset($_POST['mode']) ? $_POST['mode'] : '';
|
||||
$num = isset($_POST['num']) ? $_POST['num'] : '';
|
||||
|
||||
$tablename = 'lot_sales';
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
if ($mode === 'update' && $num) {
|
||||
try {
|
||||
$sql = "SELECT * FROM ". $DB . "." . $tablename . " WHERE num=?";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $num, PDO::PARAM_INT);
|
||||
$stmh->execute();
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
include '_row.php';
|
||||
} catch (PDOException $Exception) {
|
||||
echo "오류: ".$Exception->getMessage();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
include '_request.php';
|
||||
$mode = 'insert';
|
||||
$reg_date = date('Y-m-d');
|
||||
$author = $user_name;
|
||||
$workplacename = '';
|
||||
$num = '';
|
||||
}
|
||||
|
||||
$title_message = ($mode === 'update') ? 'LOT 번호 수정' : 'LOT 번호 신규 등록';
|
||||
?>
|
||||
|
||||
<input type="hidden" id="update_log" name="update_log" value="<?=$update_log?>">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="d-flex align-items-center justify-content-center">
|
||||
<div class="card justify-content-center">
|
||||
<div class="card-header text-center">
|
||||
<span class="text-center fs-5"><?=$title_message?></span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row justify-content-center text-center">
|
||||
<div class="d-flex align-items-center justify-content-center m-2">
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">등록일</td>
|
||||
<td class="text-center" style="width:200px;">
|
||||
<input type="date" class="form-control fs-6" id="reg_date" name="reg_date" value="<?=$reg_date?>">
|
||||
</td>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">작성자</td>
|
||||
<td class="text-center" style="width:200px;">
|
||||
<div class="d-flex">
|
||||
<input class="form-control fs-6" id="author" name="author" value="<?=$author?>" autocomplete="off">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">LOT 번호</td>
|
||||
<td colspan="3" class="text-center" >
|
||||
<input type="text" class="form-control fs-6 text-start" id="lot_number" name="lot_number" value="<?=$lot_number?>" autocomplete="off">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">현장명</td>
|
||||
<td colspan="3" class="text-center" >
|
||||
<input type="text" class="form-control fs-6 text-start" id="workplacename" name="workplacename" value="<?=$workplacename?>" autocomplete="off">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">비고</td>
|
||||
<td colspan="3" class="text-center" >
|
||||
<input type="text" class="form-control fs-6 text-start" id="remark" name="remark" value="<?=$remark?>" autocomplete="off">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="button" id="saveBtn" class="btn btn-dark btn-sm me-3">
|
||||
<ion-icon name="save-outline"></ion-icon> 저장
|
||||
</button>
|
||||
<?php if($mode != 'insert') { ?>
|
||||
<button type="button" id="deleteBtn" class="btn btn-danger btn-sm me-3">
|
||||
<ion-icon name="trash-outline"></ion-icon> 삭제
|
||||
</button>
|
||||
<?php } ?>
|
||||
<button type="button" id="closeBtn" class="btn btn-outline-dark btn-sm me-2">
|
||||
<ion-icon name="close-circle-outline"></ion-icon> 닫기
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
474
lot_sales/list.php
Normal file
474
lot_sales/list.php
Normal file
@@ -0,0 +1,474 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
if (!isset($_SESSION["level"]) || $_SESSION["level"] > 5) {
|
||||
sleep(1);
|
||||
header("Location:" . $WebSite . "login/login_form.php");
|
||||
exit;
|
||||
}
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
||||
$title_message = '판매 - LOT번호';
|
||||
?>
|
||||
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
<title> <?=$title_message?> </title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
$header = isset($_REQUEST['header']) ? $_REQUEST['header'] : '';
|
||||
|
||||
if($header ==='header')
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/myheader.php');
|
||||
|
||||
function checkNull($strtmp) {
|
||||
return ($strtmp !== null && trim($strtmp) !== '');
|
||||
}
|
||||
|
||||
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
|
||||
$mode = isset($_REQUEST["mode"]) ? $_REQUEST["mode"] : '';
|
||||
|
||||
$tablename = 'lot_sales';
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
$order = " ORDER BY num DESC ";
|
||||
|
||||
if (checkNull($search)) {
|
||||
$sql = "SELECT * FROM ".$DB.".".$tablename."
|
||||
WHERE search_tag LIKE '%$search%' AND is_deleted IS NULL " . $order;
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT * FROM ".$DB.".".$tablename . " WHERE is_deleted IS NULL " . $order;
|
||||
}
|
||||
|
||||
// 서버에 저장된 로트번호 불러오기
|
||||
$filepath = $_SERVER['DOCUMENT_ROOT'] . '/output/lotnum.txt';
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
// 파일에서 로트번호 읽기
|
||||
$receivedlotNum = file_get_contents($filepath);
|
||||
} else {
|
||||
$receivedlotNum = '로트번호가 없습니다.'; // 파일이 없을 경우 기본 메시지
|
||||
}
|
||||
|
||||
try {
|
||||
$stmh = $pdo->query($sql);
|
||||
$total_row = $stmh->rowCount();
|
||||
|
||||
?>
|
||||
|
||||
<form id="board_form" name="board_form" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" id="mode" name="mode" value="<?=$mode?>">
|
||||
<input type="hidden" id="num" name="num">
|
||||
<input type="hidden" id="tablename" name="tablename" value="<?=$tablename?>">
|
||||
<input type="hidden" id="header" name="header" value="<?=$header?>">
|
||||
|
||||
<div class="container-fluid">
|
||||
<!-- Modal -->
|
||||
<div id="myModal" class="modal">
|
||||
<div class="modal-content" style="width:600px;">
|
||||
<div class="modal-header">
|
||||
<span class="modal-title">LOT 관리</span>
|
||||
<span class="close">×</span>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="custom-card"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="card justify-content-center text-center mt-1 mb-5">
|
||||
<div class="card-header">
|
||||
<span class="text-center fs-5"> <?=$title_message?> </span>
|
||||
<span class="badge bg-primary fs-5"> 서버 생성완료 : <?=$receivedlotNum?> </span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="container mt-2 mb-2">
|
||||
<div class="row mt-2 mb-2">
|
||||
<div class="col-sm-5">
|
||||
<table class="table table-bordered table-hover text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-primary" > 발주제품</th>
|
||||
<th class="text-primary" > Code</th>
|
||||
<th class="text-primary" > 셔터종류</th>
|
||||
<th class="text-primary" > Code</th>
|
||||
<th class="text-primary" > 인정제품</th>
|
||||
<th class="text-primary" > code</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>스크린 Set</td>
|
||||
<td>SC</td>
|
||||
<td>실리카</td>
|
||||
<td>SI</td>
|
||||
<td>실리카(EGI)</td>
|
||||
<td class="yellowBold" >SE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>철재 Set</td>
|
||||
<td>ST</td>
|
||||
<td>와이어</td>
|
||||
<td>WS</td>
|
||||
<td>실리카(SUS)</td>
|
||||
<td class="yellowBold" >SS</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>절곡 단품</td>
|
||||
<td>BE</td>
|
||||
<td>화이바</td>
|
||||
<td>FS</td>
|
||||
<td>와이어(EGI)</td>
|
||||
<td class="yellowBold" >WE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>슬랫 단품</td>
|
||||
<td>SL</td>
|
||||
<td rowspan="3">철재 <br> (인정제품 조적용)</td>
|
||||
<td rowspan="3" class="yellowBold" >IJ</td>
|
||||
<td>와이어(SUS) <br> <span class="badge bg-danger" >인정미취득 </span> </td>
|
||||
<td class="" >WS</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>모터 단품</td>
|
||||
<td>MO</td>
|
||||
<td>철재(EGI)</td>
|
||||
<td class="yellowBold" >TE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>기타 부자재 단품</td>
|
||||
<td>ET</td>
|
||||
<td>철재(SUS)</td>
|
||||
<td class="yellowBold" >TS</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#specailTable th, #specailTable td {
|
||||
padding: 3px!important;
|
||||
}
|
||||
#specailTable2 th, #specailTable2 td {
|
||||
padding: 3px!important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<div class="container mt-1">
|
||||
<h5 class="mb-1">인정제품 코드 (KD:경동기업)</h5>
|
||||
<table class="table table-bordered table-hover text-center" id="specailTable" >
|
||||
<thead class="table-secondary">
|
||||
<tr>
|
||||
<th colspan="2" >인정제품 코드 예시 <br>
|
||||
KSS01의 경우 KD-SS-240919-01
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>제품 코드</th>
|
||||
<th>인정제품 코드</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>SL60</td>
|
||||
<td class="yellowBold" >IJ</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KSS01</td>
|
||||
<td class="yellowBold" >SS</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KSE01</td>
|
||||
<td class="yellowBold" >SE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KWE01</td>
|
||||
<td class="yellowBold" >WE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KTE01</td>
|
||||
<td class="yellowBold" >TE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KQTS01</td>
|
||||
<td class="yellowBold" >TS</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div class="container mt-1">
|
||||
<h5 class="mb-1"><span class="badge bg-danger fw-6"> 신규 </span> 인정제품 코드</h5>
|
||||
<p>(인정서 취득시 적용예정 / 시험체적용)</p>
|
||||
<table class="table table-bordered table-hover text-center" id="specailTable2" >
|
||||
<thead class="table-secondary">
|
||||
<tr>
|
||||
<th>제품 코드</th>
|
||||
<th>인정제품 코드</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>KSS02</td>
|
||||
<td>SA</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KWWS02</td>
|
||||
<td>WW</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KJWS01</td>
|
||||
<td>JW</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KDSS01</td>
|
||||
<td>DS</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="d-flex justify-content-center align-items-center mt-2 mb-2">
|
||||
▷ <?= $total_row ?>
|
||||
<div class="inputWrap30">
|
||||
<input type="text" id="search" class="form-control text-start" style="width:200px;" name="search" value="<?=$search?>" autocomplete="off" onKeyPress="if (event.keyCode==13){ enter(); }">
|
||||
<button class="btnClear"></button>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-outline-dark btn-sm" type="button" id="searchBtn"> <i class="bi bi-search"></i> </button>
|
||||
|
||||
<button id="newBtn" type="button" class="btn btn-dark btn-sm me-2"> <i class="bi bi-pencil-square"></i> 신규 </button>
|
||||
<?php if($level=='1') { ?>
|
||||
<!-- <button id="uploadBtn" type="button" class="btn btn-dark btn-sm me-2"> <i class="bi bi-box-arrow-up"></i> 업로드 </button> -->
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover" id="myTable">
|
||||
<thead class="table-primary">
|
||||
<th class="text-center" style="width:60px;" >번호</th>
|
||||
<th class="text-center" style="width:120px;" >등록일</th>
|
||||
<th class="text-center" style="width:200px;" >LOT번호</th>
|
||||
<th class="text-center" style="width:200px;" >현장명</th>
|
||||
<th class="text-center" style="width:100px;" >작성자</th>
|
||||
<th class="text-center" style="width:300px;" >비고</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$start_num = $total_row;
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
include '_row.php';
|
||||
?>
|
||||
<tr onclick="loadForm('update', '<?=$row['num']?>');">
|
||||
<td class="text-center"><?= $start_num ?></td>
|
||||
<td class="text-center"><?= $row['reg_date'] ?></td>
|
||||
<td class="text-center fw-bold text-success"><?= $row['lot_number'] ?></td>
|
||||
<td class="text-center fw-bold text-success"><?= $row['workplacename'] ?></td>
|
||||
<td class="text-center"><?= $row['author'] ?></td>
|
||||
<td class="text-start"><?= $row['remark'] ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$start_num--;
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
$("#newBtn").on("click", function() {
|
||||
loadForm('insert');
|
||||
});
|
||||
|
||||
$("#searchBtn").on("click", function() {
|
||||
$("#board_form").submit();
|
||||
});
|
||||
});
|
||||
|
||||
function loadForm(mode, num = null) {
|
||||
if (num == null) {
|
||||
$("#mode").val('insert');
|
||||
} else {
|
||||
$("#mode").val('modify');
|
||||
$("#num").val(num);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "fetch_modal.php",
|
||||
data: { mode: mode, num: num },
|
||||
dataType: "html",
|
||||
success: function(response) {
|
||||
$(".modal-body .custom-card").html(response);
|
||||
$("#myModal").show();
|
||||
|
||||
$("#closeBtn").on("click", function() {
|
||||
$("#myModal").hide();
|
||||
});
|
||||
|
||||
let isSaving = false;
|
||||
|
||||
$("#saveBtn").on("click", function() {
|
||||
if (isSaving) return;
|
||||
isSaving = true;
|
||||
|
||||
var header = $("#header").val();
|
||||
var formData = $("#board_form").serialize(); // 파일전송은 안된다. serialize의 단점
|
||||
|
||||
$.ajax({
|
||||
url: "process.php",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function(response) {
|
||||
Toastify({
|
||||
text: "저장완료",
|
||||
duration: 3000,
|
||||
close: true,
|
||||
gravity: "top",
|
||||
position: "center",
|
||||
backgroundColor: "#4fbe87",
|
||||
}).showToast();
|
||||
setTimeout(function() {
|
||||
$("#myModal").hide();
|
||||
location.reload();
|
||||
isSaving = false;
|
||||
}, 1000);
|
||||
|
||||
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
console.log(jqxhr, status, error);
|
||||
isSaving = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#deleteBtn").on("click", function() {
|
||||
var level = '<?= $_SESSION["level"] ?>';
|
||||
|
||||
if (level !== '1') {
|
||||
Swal.fire({
|
||||
title: '삭제불가',
|
||||
text: "관리자만 삭제 가능합니다.",
|
||||
icon: 'error',
|
||||
confirmButtonText: '확인'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: '자료 삭제',
|
||||
text: "삭제는 신중! 정말 삭제하시겠습니까?",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: '삭제',
|
||||
cancelButtonText: '취소'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$("#mode").val('delete');
|
||||
var formData = $("#board_form").serialize();
|
||||
|
||||
$.ajax({
|
||||
url: "process.php",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function(response) {
|
||||
Toastify({
|
||||
text: "파일 삭제완료",
|
||||
duration: 2000,
|
||||
close: true,
|
||||
gravity: "top",
|
||||
position: "center",
|
||||
style: {
|
||||
background: "linear-gradient(to right, #00b09b, #96c93d)"
|
||||
},
|
||||
}).showToast();
|
||||
|
||||
$("#myModal").hide();
|
||||
location.reload();
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
console.log(jqxhr, status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
console.log("AJAX Error: ", status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
var loader = document.getElementById('loadingOverlay');
|
||||
loader.style.display = 'none';
|
||||
|
||||
var modal = document.getElementById("myModal");
|
||||
var span = document.getElementsByClassName("close")[0];
|
||||
|
||||
span.onclick = function() {
|
||||
modal.style.display = "none";
|
||||
}
|
||||
|
||||
$(".close").on("click", function() {
|
||||
$("#myModal").hide();
|
||||
});
|
||||
|
||||
$("#newBtn").on("click", function() {
|
||||
loadForm('insert');
|
||||
});
|
||||
|
||||
$("#searchBtn").on("click", function() {
|
||||
$("#board_form").submit();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function enter() {
|
||||
$("#board_form").submit();
|
||||
}
|
||||
|
||||
function inputNumberFormat(obj) {
|
||||
obj.value = obj.value.replace(/[^0-9]/g, '');
|
||||
|
||||
let value = obj.value.replace(/,/g, '');
|
||||
obj.value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
}
|
||||
|
||||
$(document).on("keypress", "input", function(event) {
|
||||
return event.keyCode != 13;
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
// 방문기록 남김
|
||||
var title_message = '<?php echo $title_message ; ?>';
|
||||
saveMenuLog(title_message);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
102
lot_sales/process.php
Normal file
102
lot_sales/process.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$tablename = isset($_REQUEST['tablename']) ? $_REQUEST['tablename'] : '';
|
||||
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
|
||||
|
||||
header("Content-Type: application/json"); // JSON 콘텐츠 유형 설정
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
include "_request.php";
|
||||
|
||||
$search_tag = $lot_number . ' ' .
|
||||
$reg_date . ' ' .
|
||||
$author . ' ' .
|
||||
$workplacename . ' ' .
|
||||
$remark . ' ' ;
|
||||
|
||||
if ($mode == "modify") {
|
||||
$update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . "
";
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
// SQL 쿼리 생성 (업데이트)
|
||||
$sql = "UPDATE " . $DB . "." . $tablename . " SET ";
|
||||
$sql .= "reg_date = ?, lot_number = ?, author = ?, remark = ?, update_log = ?, search_tag = ? , workplacename = ? ";
|
||||
$sql .= "WHERE num = ? LIMIT 1"; // num이 일치하는 하나의 레코드만 업데이트
|
||||
|
||||
$stmh = $pdo->prepare($sql);
|
||||
|
||||
// 변수 바인딩
|
||||
$stmh->bindValue(1, $reg_date, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $lot_number, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $author, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $remark, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, $update_log, PDO::PARAM_STR);
|
||||
$stmh->bindValue(6, $search_tag, PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $workplacename, PDO::PARAM_STR);
|
||||
$stmh->bindValue(8, $num, PDO::PARAM_INT);
|
||||
|
||||
// 실행
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
else if ($mode == "insert" || $mode == '' || $mode == null) {
|
||||
$update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . "
";
|
||||
// 데이터 삽입
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// SQL 쿼리 생성 (삽입)
|
||||
$sql = "INSERT INTO " . $DB . "." . $tablename . " (";
|
||||
$sql .= "reg_date, lot_number, author, remark, update_log, search_tag, workplacename ";
|
||||
$sql .= ") VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
$stmh = $pdo->prepare($sql);
|
||||
|
||||
// 변수 바인딩
|
||||
$stmh->bindValue(1, $reg_date, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $lot_number, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $author, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $remark, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, $update_log, PDO::PARAM_STR);
|
||||
$stmh->bindValue(6, $search_tag, PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $workplacename, PDO::PARAM_STR);
|
||||
|
||||
// 실행
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
else if ($mode == "delete") { // 데이터 삭제
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
$sql = "UPDATE " . $DB . "." . $tablename . " SET is_deleted=1 WHERE num = ?";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $num, PDO::PARAM_INT);
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $ex) {
|
||||
$pdo->rollBack();
|
||||
print "오류: ".$ex->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'num' => $num,
|
||||
'mode' => $mode
|
||||
];
|
||||
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user