초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
14
price_etc/_request.php
Normal file
14
price_etc/_request.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
|
||||
$registedate = isset($_REQUEST['registedate']) ? $_REQUEST['registedate'] : '';
|
||||
$spec = isset($_REQUEST['spec']) ? $_REQUEST['spec'] : '';
|
||||
$secondord = isset($_REQUEST['secondord']) ? $_REQUEST['secondord'] : '';
|
||||
$unit = isset($_REQUEST['unit']) ? $_REQUEST['unit'] : '';
|
||||
$comment = isset($_REQUEST['comment']) ? $_REQUEST['comment'] : '';
|
||||
$item_name = isset($_REQUEST['item_name']) ? $_REQUEST['item_name'] : '';
|
||||
$surang = isset($_REQUEST['surang']) ? $_REQUEST['surang'] : '';
|
||||
$unitprice = isset($_REQUEST['unitprice']) ? $_REQUEST['unitprice'] : 0;
|
||||
$is_deleted = isset($_REQUEST['is_deleted']) ? $_REQUEST['is_deleted'] : '';
|
||||
$searchtag = isset($_REQUEST['searchtag']) ? $_REQUEST['searchtag'] : '';
|
||||
$update_log = isset($_REQUEST['update_log']) ? $_REQUEST['update_log'] : '';
|
||||
?>
|
||||
14
price_etc/_row.php
Normal file
14
price_etc/_row.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
$num = isset($row['num']) ? $row['num'] : '';
|
||||
$registedate = isset($row['registedate']) ? $row['registedate'] : '';
|
||||
$spec = isset($row['spec']) ? $row['spec'] : '';
|
||||
$secondord = isset($row['secondord']) ? $row['secondord'] : '';
|
||||
$unit = isset($row['unit']) ? $row['unit'] : '';
|
||||
$comment = isset($row['comment']) ? $row['comment'] : '';
|
||||
$item_name = isset($row['item_name']) ? $row['item_name'] : '';
|
||||
$surang = isset($row['surang']) ? $row['surang'] : '';
|
||||
$unitprice = isset($row['unitprice']) ? $row['unitprice'] : 0;
|
||||
$is_deleted = isset($row['is_deleted']) ? $row['is_deleted'] : '';
|
||||
$searchtag = isset($row['searchtag']) ? $row['searchtag'] : '';
|
||||
$update_log = isset($row['update_log']) ? $row['update_log'] : '';
|
||||
?>
|
||||
136
price_etc/css/style.css
Normal file
136
price_etc/css/style.css
Normal file
@@ -0,0 +1,136 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
106
price_etc/fetch_inout_data.php
Normal file
106
price_etc/fetch_inout_data.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$num = isset($_POST['num']) ? $_POST['num'] : '';
|
||||
|
||||
$tablename = 'material_reg';
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
if ($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);
|
||||
|
||||
// Load the form for editing existing stock entry
|
||||
include '_row.php'; // Existing row data for editing
|
||||
} catch (PDOException $Exception) {
|
||||
echo "오류: ".$Exception->getMessage();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo "데이터가 없습니다."; // Handle error if no num is passed
|
||||
}
|
||||
|
||||
$title_message = '입고 수정'; // Update only, no insert option
|
||||
|
||||
?>
|
||||
|
||||
<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 me-3"><?=$title_message?></span> ( <?=$row['num']?> )
|
||||
<input type="hidden" id="mode" name="mode" value="<?= isset($mode) ? $mode : '' ?>">
|
||||
<input type="hidden" id="num" name="num" value="<?= isset($num) ? $num : '' ?>">
|
||||
</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="registedate" name="registedate" value="<?=$row['registedate']?>" readonly>
|
||||
</td>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">입고 일자</td>
|
||||
<td class="text-center" style="width:500px;">
|
||||
<input type="date" class="form-control fs-6" id="inoutdate" name="inoutdate" value="<?=$row['inoutdate']?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">품목코드</td>
|
||||
<td class="text-center">
|
||||
<div class="specialinputWrap">
|
||||
<input type="text" class="form-control inputcode fs-6" id="inout_item_code" name="inout_item_code" value="<?=$row['inout_item_code']?>" readonly>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">품목명</td>
|
||||
<td class="text-center" style="width:400px;">
|
||||
<div class="specialinputWrap">
|
||||
<input type="text" class="form-control inputitemname fs-6" id="item_name" name="item_name" value="<?=$row['item_name']?>" readonly>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">매입처</td>
|
||||
<td class="text-center" style="width:400px;">
|
||||
<input class="form-control fs-6" id="secondord" name="secondord" value="<?=$row['secondord']?>" autocomplete="off">
|
||||
</td>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">입고 단가</td>
|
||||
<td class="text-center">
|
||||
<input type="text" class="form-control fs-6" id="unitprice" name="unitprice" value="<?=$row['unitprice']?>" autocomplete="off" onkeyup="inputNumberFormat(this)">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">수량</td>
|
||||
<td class="text-center">
|
||||
<input type="text" class="form-control fs-6" id="surang" name="surang" value="<?=$row['surang']?>" autocomplete="off" onkeyup="inputNumberFormat(this)">
|
||||
</td>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">로트번호</td>
|
||||
<td class="text-center">
|
||||
<div class="specialinputWrap">
|
||||
<input type="text" class="form-control inputlot fs-6" id="lotnum" name="lotnum" value="<?=$row['lotnum']?>" autocomplete="off">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" style="width:150px;">비고</td>
|
||||
<td class="text-center" colspan="3">
|
||||
<input type="text" class="form-control fs-6" id="comment" name="comment" value="<?=$row['comment']?>" autocomplete="off">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
140
price_etc/fetch_modal.php
Normal file
140
price_etc/fetch_modal.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$mode = isset($_POST['mode']) ? $_POST['mode'] : '';
|
||||
$num = isset($_POST['num']) ? $_POST['num'] : '';
|
||||
|
||||
$tablename = 'price_etc';
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
$title_message = ($mode === 'update') ? '소모품 단가 수정' : (($mode === 'copy') ? '소모품 단가 복사' : '소모품 단가 신규 등록');
|
||||
|
||||
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 if ($mode === 'copy' && $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';
|
||||
$mode = 'copy';
|
||||
$num = null;
|
||||
} catch (PDOException $Exception) {
|
||||
echo "오류: ".$Exception->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
include '_request.php';
|
||||
$mode = 'insert';
|
||||
$registedate = date('Y-m-d');
|
||||
$inoutdate = date('Y-m-d');
|
||||
$secondord = '';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<input type="hidden" id="update_log" name="update_log" value="<?=$update_log?>">
|
||||
<input type="hidden" id="secondordnum" name="secondordnum" value="<?=$secondordnum?>">
|
||||
|
||||
<div class="container">
|
||||
<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" >등록일자</td>
|
||||
<td class="text-center" >
|
||||
<input type="date" class="form-control fs-6 noborder-input" id="registedate" name="registedate" style="width:130px;" value="<?=$registedate?>">
|
||||
</td>
|
||||
<td class="text-center fs-6 fw-bold" >품목명</td>
|
||||
<td class="text-center" style="width:100px;">
|
||||
<div class="specialinputWrap">
|
||||
<input type="text" class="form-control inputitemname fs-6 noborder-input" id="item_name" name="item_name" value="<?=$item_name?>" autocomplete="off">
|
||||
<button class="specialbtnClear"></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" >규격</td>
|
||||
<td class="text-center">
|
||||
<div class="specialinputWrap">
|
||||
<input type="text" class="form-control inputcode fs-6 noborder-input" id="spec" name="spec" value="<?=$spec?>" autocomplete="off">
|
||||
<button class="specialbtnClear"></button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center fs-6 fw-bold" >단위</td>
|
||||
<td class="text-center" style="width:500px;">
|
||||
<input type="text" class="form-control fs-6 noborder-input" id="unit" name="unit" value="<?=$unit?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" >매입처</td>
|
||||
<td class="text-center" >
|
||||
<div class="d-flex">
|
||||
<input type="text" class="form-control fs-6 noborder-input" id="secondord" name="secondord" value="<?=$secondord?>" autocomplete="off" onkeydown="if(event.keyCode == 13) { phonebookBtn('secondord'); }" >
|
||||
<button type="button" class="btn btn-dark-outline btn-sm " onclick="phonebookBtn('secondord');"> <i class="bi bi-gear"></i> </button>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td class="text-center fs-6 fw-bold" >입고 단가</td>
|
||||
<td class="text-center">
|
||||
<input type="text" class="form-control fs-6 noborder-input" id="unitprice" name="unitprice" value="<?=$unitprice ?>" autocomplete="off" onkeyup="inputNumberFormat(this)" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center fs-6 fw-bold" >수량</td>
|
||||
<td class="text-center">
|
||||
<input type="text" class="form-control fs-6 noborder-input" id="surang" name="surang" value="<?=$surang?>" autocomplete="off" onkeyup="inputNumberFormat(this)" >
|
||||
</td>
|
||||
<td class="text-center fs-6 fw-bold" >비고</td>
|
||||
<td class="text-center" colspan="3">
|
||||
<input type="text" class="form-control fs-6 noborder-input" id="comment" name="comment" value="<?=$comment?>" 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">
|
||||
<i class="bi bi-floppy-fill"></i> 저장
|
||||
</button>
|
||||
<?php if($mode != 'insert' && $mode != 'copy') { ?>
|
||||
<button type="button" id="copyBtn" class="btn btn-primary btn-sm me-3">
|
||||
<i class="bi bi-copy"></i> 복사
|
||||
</button>
|
||||
<button type="button" id="deleteBtn" class="btn btn-danger btn-sm me-3">
|
||||
<i class="bi bi-trash"></i> 삭제
|
||||
</button>
|
||||
<?php } ?>
|
||||
<button type="button" id="closeBtn" class="btn btn-outline-dark btn-sm me-2">
|
||||
× 닫기
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
500
price_etc/list.php
Normal file
500
price_etc/list.php
Normal file
@@ -0,0 +1,500 @@
|
||||
<?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 = '소모품 단가';
|
||||
?>
|
||||
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
<title> <?=$title_message?> </title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
$header = isset($_REQUEST['header']) ? $_REQUEST['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 = 'price_etc';
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
$order = " ORDER BY registedate desc ";
|
||||
|
||||
if (checkNull($search)) {
|
||||
$sql = "SELECT * FROM ".$DB.".".$tablename."
|
||||
WHERE searchtag LIKE '%$search%' AND is_deleted IS NULL " . $order;
|
||||
} else {
|
||||
$sql = "SELECT * FROM ".$DB.".".$tablename . " WHERE is_deleted IS NULL " . $order;
|
||||
}
|
||||
|
||||
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" >
|
||||
<div class="modal-header">
|
||||
<span class="modal-title">소모품 단가</span>
|
||||
<span class="close">×</span>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="custom-card"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
if ($chkMobile) {
|
||||
print '<div class="container-fluid">';
|
||||
print '<div class="card justify-content-center text-center mt-1">';
|
||||
} else {
|
||||
print '<div class="container">';
|
||||
print '<div class="card justify-content-center text-center mt-5">';
|
||||
}
|
||||
?>
|
||||
<div class="card-header">
|
||||
<span class="text-center fs-5"> <?=$title_message?> </span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="container mt-2 mb-2">
|
||||
▷ <?= $total_row ?>
|
||||
<div class="inputWrap30">
|
||||
<input type="text" id="search" class="form-control" style="width:150px;" name="search" value="<?=$search?>" 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($header !== 'header')
|
||||
print '<button id="closeBtn" type="button" class="btn btn-dark btn-sm"> × 닫기 </button>';
|
||||
?>
|
||||
</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:80px;">등록일자</th>
|
||||
<th class="text-center" style="width:200px;">품목명</th>
|
||||
<th class="text-center" style="width:150px;">규격</th>
|
||||
<th class="text-center" style="width:50px;">수량</th>
|
||||
<th class="text-center" style="width:50px;">단위</th>
|
||||
<th class="text-center" style="width:100px;">단가</th>
|
||||
<th class="text-center" style="width:100px;">매입처</th>
|
||||
<th class="text-center" style="width:200px;">비고</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$start_num = $total_row;
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
include '_row.php';
|
||||
?>
|
||||
<tr onclick="loadForm('update', '<?=$num?>');">
|
||||
<td class="text-center"><?= $start_num ?></td>
|
||||
<td class="text-center"><?= $registedate ?></td>
|
||||
<td class="text-start fw-bold text-primary"><?= $item_name ?></td>
|
||||
<td class="text-start text-secondary"><?= $spec ?></td>
|
||||
<td class="text-center">
|
||||
<?php if (is_numeric($surang)) : ?>
|
||||
<?= number_format($surang) ?>
|
||||
<?php else : ?>
|
||||
<?= htmlspecialchars($surang) ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td class="text-center"><?= $unit ?></td>
|
||||
<td class="text-end"><?= $unitprice ?></td>
|
||||
<td class="text-start"><?= $secondord?></td>
|
||||
<td class="text-start"><?= $comment ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$start_num--;
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<script>
|
||||
var ajaxRequest = null;
|
||||
var itemData = [];
|
||||
|
||||
function loadForm(mode, num = null) {
|
||||
if (mode === 'copy' && num) {
|
||||
$("#mode").val('copy');
|
||||
$("#num").val(num); // 기존 데이터 복사할 num 유지
|
||||
} else if (num == null) {
|
||||
$("#mode").val('insert');
|
||||
} else {
|
||||
$("#mode").val('update');
|
||||
$("#num").val(num);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "fetch_modal.php",
|
||||
data: { mode: mode, num: num },
|
||||
dataType: "html",
|
||||
success: function(response) {
|
||||
document.querySelector(".modal-body .custom-card").innerHTML = response;
|
||||
$("#myModal").show();
|
||||
|
||||
$("#closeBtn").off("click").on("click", function() {
|
||||
$("#myModal").hide();
|
||||
});
|
||||
|
||||
// 기존 이벤트 제거 후 재등록
|
||||
$(document).off('click', '.specialbtnClear').on('click', '.specialbtnClear', function(e) {
|
||||
e.preventDefault(); // 기본 동작을 방지합니다.
|
||||
$('#item_name').val('');
|
||||
});
|
||||
|
||||
let isSaving = false;
|
||||
|
||||
// 저장 버튼 (기존 이벤트 제거 후 재등록)
|
||||
$("#saveBtn").off("click").on("click", function() {
|
||||
if (isSaving) return;
|
||||
isSaving = true;
|
||||
|
||||
var header = $("#header").val();
|
||||
var formData = $("#board_form").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();
|
||||
}, 2000);
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
console.log(jqxhr, status, error);
|
||||
isSaving = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 복사 버튼 (기존 이벤트 제거 후 재등록)
|
||||
$("#copyBtn").off("click").on("click", function() {
|
||||
var num = $('#num').val(); // num을 비워 새로 삽입할 수 있도록 초기화
|
||||
$("#myModal").hide();
|
||||
setTimeout(function() {
|
||||
copyForm('copy', num); // 복사 모드로 폼 다시 로드
|
||||
}, 500);
|
||||
|
||||
});
|
||||
|
||||
// 삭제 버튼
|
||||
$("#deleteBtn").off("click").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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function copyForm(mode, num = null) {
|
||||
if (mode === 'copy' && num) {
|
||||
$("#mode").val('copy');
|
||||
$("#num").val(num); // 기존 데이터 복사할 num 유지
|
||||
} else if (num == null) {
|
||||
$("#mode").val('insert');
|
||||
} else {
|
||||
$("#mode").val('update');
|
||||
$("#num").val(num);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "fetch_modal.php",
|
||||
data: { mode: mode, num: num },
|
||||
dataType: "html",
|
||||
success: function(response) {
|
||||
document.querySelector(".modal-body .custom-card").innerHTML = response;
|
||||
$("#myModal").show();
|
||||
|
||||
$("#closeBtn").off("click").on("click", function() {
|
||||
$("#myModal").hide();
|
||||
});
|
||||
|
||||
// 기존 이벤트 제거 후 재등록
|
||||
$(document).off('click', '.specialbtnClear').on('click', '.specialbtnClear', function(e) {
|
||||
e.preventDefault(); // 기본 동작을 방지합니다.
|
||||
$('#item_name').val('');
|
||||
});
|
||||
|
||||
let isSaving = false;
|
||||
|
||||
// 저장 버튼 (기존 이벤트 제거 후 재등록)
|
||||
$("#saveBtn").off("click").on("click", function() {
|
||||
if (isSaving) return;
|
||||
isSaving = true;
|
||||
|
||||
var header = $("#header").val();
|
||||
var formData = $("#board_form").serialize();
|
||||
|
||||
$.ajax({
|
||||
url: "process.php",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function(response) {
|
||||
|
||||
console.log('response',response);
|
||||
Toastify({
|
||||
text: "저장완료",
|
||||
duration: 3000,
|
||||
close: true,
|
||||
gravity: "top",
|
||||
position: "center",
|
||||
backgroundColor: "#4fbe87",
|
||||
}).showToast();
|
||||
|
||||
setTimeout(function() {
|
||||
$("#myModal").hide();
|
||||
location.reload();
|
||||
}, 2000);
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
console.log(jqxhr, status, error);
|
||||
isSaving = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
console.log("AJAX Error: ", status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<!-- 데이터 테이블 및 기타 기능을 위한 스크립트 -->
|
||||
<script>
|
||||
var ajaxRequest_write = null;
|
||||
var dataTable; // DataTables 인스턴스 전역 변수
|
||||
var material_regpageNumber; // 현재 페이지 번호 저장을 위한 전역 변수
|
||||
|
||||
$(document).ready(function() {
|
||||
// DataTables 초기 설정
|
||||
dataTable = $('#myTable').DataTable({
|
||||
"paging": true,
|
||||
"ordering": true,
|
||||
"searching": true,
|
||||
"pageLength": 200,
|
||||
"lengthMenu": [ 100, 200, 500, 1000],
|
||||
"language": {
|
||||
"lengthMenu": "Show _MENU_ entries",
|
||||
"search": "Live Search:"
|
||||
},
|
||||
"order": [[1, 'desc']],
|
||||
"dom": 't<"bottom"ip>' // search 창과 lengthMenu 숨기기
|
||||
});
|
||||
|
||||
// 페이지 번호 복원 (초기 로드 시)
|
||||
var savedPageNumber = getCookie('material_regpageNumber');
|
||||
if (savedPageNumber) {
|
||||
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
||||
}
|
||||
|
||||
// 페이지 변경 이벤트 리스너
|
||||
dataTable.on('page.dt', function() {
|
||||
var material_regpageNumber = dataTable.page.info().page + 1;
|
||||
setCookie('material_regpageNumber', material_regpageNumber, 10); // 쿠키에 페이지 번호 저장
|
||||
});
|
||||
|
||||
// 페이지 길이 셀렉트 박스 변경 이벤트 처리
|
||||
$('#myTable_length select').on('change', function() {
|
||||
var selectedValue = $(this).val();
|
||||
dataTable.page.len(selectedValue).draw(); // 페이지 길이 변경 (DataTable 파괴 및 재초기화 없이)
|
||||
|
||||
// 변경 후 현재 페이지 번호 복원
|
||||
savedPageNumber = getCookie('material_regpageNumber');
|
||||
if (savedPageNumber) {
|
||||
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.specialbtnClear', function(e) {
|
||||
e.preventDefault(); // 기본 동작을 방지합니다.
|
||||
$(this).siblings('input').val('').focus();
|
||||
});
|
||||
|
||||
$(document).on('click', '.btnClear_lot', function(e) {
|
||||
e.preventDefault(); // 기본 동작을 방지합니다.
|
||||
$(this).siblings('input').val('').focus();
|
||||
});
|
||||
});
|
||||
|
||||
function restorePageNumber() {
|
||||
var savedPageNumber = getCookie('material_regpageNumber');
|
||||
location.reload(true);
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- 페이지로딩 및 Modal Script -->
|
||||
<script>
|
||||
$(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();
|
||||
});
|
||||
|
||||
$("#closeBtn").on("click", function() {
|
||||
var modal = document.getElementById("myModal");
|
||||
modal.style.display = "none";
|
||||
});
|
||||
});
|
||||
|
||||
function enter() {
|
||||
$("#board_form").submit();
|
||||
}
|
||||
|
||||
function phonebookBtn(searchfield)
|
||||
{
|
||||
var search = $("#" + searchfield).val();
|
||||
href = '../phonebook_buy/list.php?search=' + search ;
|
||||
popupCenter(href, '매입처 검색', 1600, 800);
|
||||
}
|
||||
|
||||
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, ',');
|
||||
}
|
||||
|
||||
// Prevent form submission on Enter key
|
||||
$(document).on("keypress", "input", function(event) {
|
||||
return event.keyCode != 13;
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
// 방문기록 남김
|
||||
var title_message = '<?php echo $title_message ; ?>';
|
||||
saveMenuLog(title_message);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
109
price_etc/process.php
Normal file
109
price_etc/process.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?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"); // Use JSON content type
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
include "_request.php";
|
||||
|
||||
$searchtag = $registedate . ' ' .
|
||||
$spec . ' ' .
|
||||
$unit . ' ' .
|
||||
$item_name . ' ' .
|
||||
$unitprice . ' ' .
|
||||
$secondord . ' ' .
|
||||
$surang;
|
||||
|
||||
if ($mode == "update") {
|
||||
$update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . "
";
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
// Prepare the SQL query for updating the material lot information
|
||||
$sql = "UPDATE " . $DB . "." . $tablename . " SET ";
|
||||
$sql .= "registedate = ?, spec = ?, unit = ?, item_name = ?, unitprice = ?, surang = ?, comment = ?, searchtag = ?, update_log = ?, secondord = ? ";
|
||||
$sql .= "WHERE num = ? LIMIT 1"; // Update only one record matching the 'num'
|
||||
|
||||
$stmh = $pdo->prepare($sql);
|
||||
|
||||
// Bind the variables to the prepared statement as parameters
|
||||
$stmh->bindValue(1, $registedate, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $spec, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $unit, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $item_name, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, str_replace(',', '', $unitprice), PDO::PARAM_STR); // 숫자안에 콤마제거후 저장
|
||||
$stmh->bindValue(6, str_replace(',', '', $surang), PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $comment, PDO::PARAM_STR);
|
||||
$stmh->bindValue(8, $searchtag, PDO::PARAM_STR);
|
||||
$stmh->bindValue(9, $update_log, PDO::PARAM_STR);
|
||||
$stmh->bindValue(10, $secondord, PDO::PARAM_STR);
|
||||
$stmh->bindValue(11, $num, PDO::PARAM_INT);
|
||||
|
||||
// Execute the statement
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
}
|
||||
if ($mode == "insert" || $mode == "copy" || $mode == '' || $mode == null) {
|
||||
$update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . "
";
|
||||
// Data insertion
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// Updated columns and values to be inserted
|
||||
$sql = "INSERT INTO " . $DB . "." . $tablename . " (";
|
||||
$sql .= "registedate, spec, unit, item_name, unitprice, surang, comment, searchtag, update_log, secondord ";
|
||||
$sql .= ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
$stmh = $pdo->prepare($sql);
|
||||
|
||||
$stmh->bindValue(1, $registedate, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $spec, PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $unit, PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $item_name, PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, str_replace(',', '', $unitprice), PDO::PARAM_STR);
|
||||
$stmh->bindValue(6, str_replace(',', '', $surang), PDO::PARAM_STR);
|
||||
$stmh->bindValue(7, $comment, PDO::PARAM_STR);
|
||||
$stmh->bindValue(8, $searchtag, PDO::PARAM_STR);
|
||||
$stmh->bindValue(9, $update_log, PDO::PARAM_STR);
|
||||
$stmh->bindValue(10, $secondord, PDO::PARAM_STR);
|
||||
|
||||
// Execute the statement
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "delete") { // Data deletion
|
||||
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,
|
||||
'secondord' => $secondord
|
||||
];
|
||||
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user