초기 커밋: 5130 레거시 시스템

- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경
- DB 연결 하드코딩 → .env 기반으로 변경
- MySQL strict mode DATE 오류 수정
This commit is contained in:
2025-12-10 20:14:31 +09:00
commit aca1767eb9
6728 changed files with 1863265 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<?
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
$vendor_code = isset($_REQUEST['vendor_code']) ? $_REQUEST['vendor_code'] : '';
$vendor_name = isset($_REQUEST['vendor_name']) ? $_REQUEST['vendor_name'] : '';
$representative_name = isset($_REQUEST['representative_name']) ? $_REQUEST['representative_name'] : '';
$address = isset($_REQUEST['address']) ? $_REQUEST['address'] : '';
$business_type = isset($_REQUEST['business_type']) ? $_REQUEST['business_type'] : '';
$item_type = isset($_REQUEST['item_type']) ? $_REQUEST['item_type'] : '';
$phone = isset($_REQUEST['phone']) ? $_REQUEST['phone'] : '';
$mobile = isset($_REQUEST['mobile']) ? $_REQUEST['mobile'] : '';
$email = isset($_REQUEST['email']) ? $_REQUEST['email'] : '';
$fax = isset($_REQUEST['fax']) ? $_REQUEST['fax'] : '';
$manager_name = isset($_REQUEST['manager_name']) ? $_REQUEST['manager_name'] : '';
$contact_info = isset($_REQUEST['contact_info']) ? $_REQUEST['contact_info'] : '';
$note = isset($_REQUEST['note']) ? $_REQUEST['note'] : '';
$is_deleted = isset($_REQUEST['is_deleted']) ? $_REQUEST['is_deleted'] : 0;
$searchtag = isset($_REQUEST['searchtag']) ? $_REQUEST['searchtag'] : '';
$update_log = isset($_REQUEST['update_log']) ? $_REQUEST['update_log'] : '';
$item = isset($_REQUEST['item']) ? $_REQUEST['item'] : '';
?>

20
phonebook_buy/_row.php Normal file
View File

@@ -0,0 +1,20 @@
<?
$num = isset($row['num']) ? $row['num'] : '';
$vendor_code = isset($row['vendor_code']) ? $row['vendor_code'] : '';
$vendor_name = isset($row['vendor_name']) ? $row['vendor_name'] : '';
$representative_name = isset($row['representative_name']) ? $row['representative_name'] : '';
$address = isset($row['address']) ? $row['address'] : '';
$business_type = isset($row['business_type']) ? $row['business_type'] : '';
$item_type = isset($row['item_type']) ? $row['item_type'] : '';
$phone = isset($row['phone']) ? $row['phone'] : '';
$mobile = isset($row['mobile']) ? $row['mobile'] : '';
$email = isset($row['email']) ? $row['email'] : '';
$fax = isset($row['fax']) ? $row['fax'] : '';
$manager_name = isset($row['manager_name']) ? $row['manager_name'] : '';
$contact_info = isset($row['contact_info']) ? $row['contact_info'] : '';
$note = isset($row['note']) ? $row['note'] : '';
$is_deleted = isset($row['is_deleted']) ? $row['is_deleted'] : 0;
$searchtag = isset($row['searchtag']) ? $row['searchtag'] : '';
$update_log = isset($row['update_log']) ? $row['update_log'] : '';
$item = isset($row['item']) ? $row['item'] : '';
?>

View File

@@ -0,0 +1,66 @@
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.1/font/bootstrap-icons.css");
fieldset.groupbox-border {
border: 1px groove #ddd !important;
padding: 3 3 3 3 !important;
margin: 3 3 3 3 !important;
box-shadow: 0px 0px 0px 0px #000;
}
legend.groupbox-border {
background-color: #F0F0F0;
color: #000;
padding: 3px 6px;
font-size: 1.0em !important;
font-weight: bold !important;
text-align: left !important;
border-bottom:none;
}
fieldset.groupbox1-border {
border: 1px groove #ddd !important;
padding: 3 3 3 3 !important;
margin: 3 3 3 3 !important;
}
legend.groupbox1-border {
background-color: #F0F0F0;
color: #000;
padding: 9px 9px;
font-size: 1.0em !important;
font-weight: bold !important;
text-align: left !important;
border-bottom:none;
}
.input-group-text {
display: flex;
align-items: center;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1;
color: #212529;
text-align: center;
white-space: nowrap;
background-color: #e9ecef;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
background-color: #dddddd;
}
footer.btnBox_todayClose {
padding: 0.5rem 0 0.7rem;
display: flex;
}
form {padding-right: 2rem;}
input#chkday {
vertical-align: middle;
}
label {vertical-align: middle;}

View File

@@ -0,0 +1,30 @@
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect(); // 데이터베이스 연결
// `secondordnum` 값을 GET 파라미터에서 받아옴
$secondordnum = isset($_GET['secondordnum']) ? $_GET['secondordnum'] : null;
if ($secondordnum) {
// SQL 쿼리 작성, `secondordnum`을 조건으로 추가
$sql = "SELECT secondord, secondordman, secondordmantel
FROM motor
WHERE secondordnum = :secondordnum";
// 준비된 명령문 준비
$stmt = $pdo->prepare($sql);
// `secondordnum` 파라미터 바인딩
$stmt->bindParam(':secondordnum', $secondordnum, PDO::PARAM_INT);
// 쿼리 실행
$stmt->execute();
// 결과를 JSON 형태로 변환
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($results);
} else {
// `secondordnum`이 제공되지 않은 경우
echo json_encode(array("error" => "No secondordnum provided"));
}
?>

View File

@@ -0,0 +1,30 @@
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect(); // 데이터베이스 연결
// `secondordnum` 값을 GET 파라미터에서 받아옴
$secondordnum = isset($_GET['secondordnum']) ? $_GET['secondordnum'] : null;
if ($secondordnum) {
// SQL 쿼리 작성, `secondordnum`을 조건으로 추가
$sql = "SELECT deliverymethod, delcompany, address, delbranch, delbranchaddress, delcaritem, delcartel, loadplace, chargedmantel, chargedman
FROM motor
WHERE secondordnum = :secondordnum and is_deleted IS NULL ";
// 준비된 명령문 준비
$stmt = $pdo->prepare($sql);
// `secondordnum` 파라미터 바인딩
$stmt->bindParam(':secondordnum', $secondordnum, PDO::PARAM_INT);
// 쿼리 실행
$stmt->execute();
// 결과를 JSON 형태로 변환
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($results);
} else {
// `secondordnum`이 제공되지 않은 경우
echo json_encode(array("error" => "No secondordnum provided"));
}
?>

339
phonebook_buy/list.php Normal file
View File

@@ -0,0 +1,339 @@
<?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
$header = isset($_REQUEST['header']) ? $_REQUEST['header'] : '';
if($header == 'header')
require_once($_SERVER['DOCUMENT_ROOT'] . '/myheader.php');
function checkNull($strtmp) {
if ($strtmp === null || trim($strtmp) === '') {
return false;
} else {
return true;
}
}
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
$enterpress = isset($_REQUEST["enterpress"]) ? $_REQUEST["enterpress"] : '';
$belong = isset($_REQUEST["belong"]) ? $_REQUEST["belong"] : '';
$vendor_name = isset($_REQUEST["vendor_name"]) ? $_REQUEST["vendor_name"] : '';
$mode = isset($_REQUEST["mode"]) ? $_REQUEST["mode"] : '';
$tablename = 'phonebook_buy';
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();
$a=" order by num desc";
if(checkNull($search))
{
$sql = "SELECT * FROM ".$DB.".".$tablename."
WHERE searchtag LIKE '%$search%' AND is_deleted IS NULL " . $a;
}
else
{
$sql ="select * from ".$DB.".".$tablename . " where is_deleted IS NULL " . $a; ;
}
// print 'mode : ' . $mode;
// print 'search : ' . $search;
// print $sql;
try{
$stmh = $pdo->query($sql); // 검색조건에 맞는글 stmh
$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?>" >
<?php if($header !== 'header')
{
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="d-flex justify-content-center text-center align-items-center mb-2" >
<i class="bi bi-caret-right"></i> <?= $total_row ?> &nbsp;
<div class="inputWrap30">
<input type="text" id="search" class="form-control" style="width:150px;" name="search" value="<?=$search?>" autocomplete="off" onKeyPress="if (event.keyCode==13){ enter(); }" >
<button class="btnClear"> </button>
</div>
&nbsp;&nbsp;
<button class="btn btn-outline-dark btn-sm " type="button" id="searchBtn" > <i class="bi bi-search"></i> </button> </span> &nbsp;&nbsp;&nbsp;&nbsp;
<button id="uploadBtn" type="button" class="btn btn-dark btn-sm me-2"> <i class="bi bi-box-arrow-up"></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-outline-dark btn-sm"> <i class="bi bi-x-lg"></i> 창닫기 </button>';
?>
</div>
<div class="table-reponsive" >
<table class="table table-hover" id="myTable">
<thead class="table-primary">
<th class="text-center" >번호</th>
<th class="text-center" >회사</th>
<th class="text-center" >대상품목</th>
<th class="text-center" >대표자</th>
<th class="text-center" >담당자</th>
<th class="text-center" >전화번호</th>
<th class="text-center" style="width:100px;" >수정/삭제</th>
</thead>
<tbody>
<?php
$start_num=$total_row;
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
include '_row.php';
if(empty($contact_info))
$contact_info = $phone;
?>
<tr onclick="maketext('<?=$vendor_name?>','<?=$num?>');">
<td class="text-center" ><?= $start_num ?></td>
<td title="<?=$vendor_name?>"><?= $vendor_name ?></td>
<td class="text-center" title="<?=$item?>"><?= $item ?></td>
<td class="text-center" title="<?=$representative_name?>"><?= $representative_name ?></td>
<td class="text-center" title="<?=$manager_name?>"><?= $manager_name ?></td>
<td class="text-center" title="<?=$contact_info?>"><?= $contact_info ?></td>
<td class="text-center" >
<button type="button" class="btn btn-primary btn-sm" onclick="updateFn('<?=$num?>'); event.stopPropagation();">
<ion-icon name="create-outline"></ion-icon>
</button>
<button type="button" class="btn btn-danger btn-sm" onclick="delFn('<?=$num?>'); event.stopPropagation();">
<i class="bi bi-x-circle"></i>
</button>
</td>
</tr>
<?php
$start_num--;
}
} catch (PDOException $Exception) {
print "오류: ".$Exception->getMessage();
}
?>
</tbody>
</table>
</div>
</div>
</div>
</form>
</body>
</html>
<!-- 페이지로딩 -->
<script>
// 페이지 로딩
$(document).ready(function(){
var loader = document.getElementById('loadingOverlay');
loader.style.display = 'none';
});
</script>
<script>
var ajaxRequest_write = null;
var dataTable; // DataTables 인스턴스 전역 변수
var pbpageNumber; // 현재 페이지 번호 저장을 위한 전역 변수
$(document).ready(function() {
// DataTables 초기 설정
dataTable = $('#myTable').DataTable({
"paging": true,
"ordering": true,
"searching": true,
"pageLength": 50,
"lengthMenu": [25, 50, 100, 200, 500, 1000],
"language": {
"lengthMenu": "Show _MENU_ entries",
"search": "Live Search:"
},
"order": [[0, 'desc']]
});
// 페이지 번호 복원 (초기 로드 시)
var savedPageNumber = getCookie('pbpageNumber');
if (savedPageNumber) {
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
}
// 페이지 변경 이벤트 리스너
dataTable.on('page.dt', function() {
var pbpageNumber = dataTable.page.info().page + 1;
setCookie('pbpageNumber', pbpageNumber, 10); // 쿠키에 페이지 번호 저장
});
// 페이지 길이 셀렉트 박스 변경 이벤트 처리
$('#myTable_length select').on('change', function() {
var selectedValue = $(this).val();
dataTable.page.len(selectedValue).draw(); // 페이지 길이 변경 (DataTable 파괴 및 재초기화 없이)
// 변경 후 현재 페이지 번호 복원
savedPageNumber = getCookie('pbpageNumber');
if (savedPageNumber) {
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
}
});
});
function restorePageNumber() {
var savedPageNumber = getCookie('pbpageNumber');
// if (savedPageNumber) {
// dataTable.page(parseInt(savedPageNumber) - 1).draw('page');
// }
location.reload(true);
}
// Enterkey 동작
function enter()
{
$("#board_form").submit();
}
/* ESC 키 누를시 팝업 닫기 */
$(document).keydown(function(e){
//keyCode 구 브라우저, which 현재 브라우저
var code = e.keyCode || e.which;
if (code == 27) { // 27은 ESC 키번호
self.close();
}
});
function maketext( vendorName, num) {
var vendorFieldID = 'secondord'; // ID of the vendor input field in the parent document
var textmsg;
var header = $("#header").val();
if(header=='header'){
updateFn(num);
return;
}
if(opener && opener.document) {
$("#" + vendorFieldID, opener.document).val(vendorName);
}
self.close();
}
$("#searchBtn").on("click", function() {
$("#board_form").submit();
});
$("#search_directinput").on("click", function() {
$("#custreg_search").hide();
});
// upload
$("#uploadBtn").on("click", function() {
popupCenter('uploadgrid.php' , '업로드', 1800, 800);
});
// 신규 버튼
$("#newBtn").on("click", function() {
popupCenter('./write.php' , '매입처 신규등록', 800, 600);
});
// 창닫기 버튼
$("#closeBtn").on("click", function() {
self.close();
});
function updateFn(num) {
var header = $("#header").val();
popupCenter('./write.php?num=' + num + '&header=' + header , '수정', 800, 600);
}
function delFn(delfirstitem) {
console.log(delfirstitem);
// console.log($("#board_form").serialize());
$("#mode").val("delete");
$("#num").val(delfirstitem);
// DATA 삭제버튼 클릭시
Swal.fire({
title: '해당 DATA 삭제',
text: " DATA 삭제는 신중하셔야 합니다. '\n 정말 삭제 하시겠습니까?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: '삭제',
cancelButtonText: '취소' })
.then((result) => { if (result.isConfirmed) {
if (ajaxRequest_write !== null) {
ajaxRequest_write.abort();
}
ajaxRequest_write = $.ajax({
url: "process.php",
type: "post",
data: $("#board_form").serialize(),
success : function( data ){
console.log(data);
Toastify({
text: "파일 삭제 완료!",
duration: 3000,
close:true,
gravity:"top",
position: "center",
backgroundColor: "#4fbe87",
}).showToast();
setTimeout(function() {
location.reload();
}, 1500);
},
error : function( jqxhr , status , error ){
console.log( jqxhr , status , error );
}
});
} });
}
// 자식창에서 돌아와서 이걸 실행한다
function reloadlist() {
const search = $("#search").val();
$("#board_form").submit();
}
</script>

140
phonebook_buy/process.php Normal file
View File

@@ -0,0 +1,140 @@
<?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";
// Construct searchtag
$searchtag = $vendor_name . ' ' .
$representative_name . ' ' .
$address . ' ' .
$business_type . ' ' .
$item_type . ' ' .
$phone . ' ' .
$mobile . ' ' .
$email . ' ' .
$fax . ' ' .
$manager_name . ' ' .
$contact_info . ' ' .
$note . ' ' .
$is_deleted . ' ' .
$item . ' ' .
$update_log;
if ($mode == "update") {
$update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . "&#10";
try {
$pdo->beginTransaction();
// Prepare the SQL query for updating the vendor information
$sql = "UPDATE " . $DB . "." . $tablename . " SET ";
$sql .= "vendor_code = ?, vendor_name = ?, representative_name = ?, address = ?, ";
$sql .= "business_type = ?, item_type = ?, phone = ?, mobile = ?, email = ?, ";
$sql .= "fax = ?, manager_name = ?, contact_info = ?, note = ?, searchtag = ?, update_log = ?, item=? ";
$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, $vendor_code, PDO::PARAM_STR);
$stmh->bindValue(2, $vendor_name, PDO::PARAM_STR);
$stmh->bindValue(3, $representative_name, PDO::PARAM_STR);
$stmh->bindValue(4, $address, PDO::PARAM_STR);
$stmh->bindValue(5, $business_type, PDO::PARAM_STR);
$stmh->bindValue(6, $item_type, PDO::PARAM_STR);
$stmh->bindValue(7, $phone, PDO::PARAM_STR);
$stmh->bindValue(8, $mobile, PDO::PARAM_STR);
$stmh->bindValue(9, $email, PDO::PARAM_STR);
$stmh->bindValue(10, $fax, PDO::PARAM_STR);
$stmh->bindValue(11, $manager_name, PDO::PARAM_STR);
$stmh->bindValue(12, $contact_info, PDO::PARAM_STR);
$stmh->bindValue(13, $note, PDO::PARAM_STR);
$stmh->bindValue(14, $searchtag, PDO::PARAM_STR);
$stmh->bindValue(15, $update_log, PDO::PARAM_STR);
$stmh->bindValue(16, $item, PDO::PARAM_STR);
$stmh->bindValue(17, $num, PDO::PARAM_INT);
// Execute the statement
$stmh->execute();
$pdo->commit();
} catch (PDOException $Exception) {
$pdo->rollBack();
print "오류: " . $Exception->getMessage();
}
} elseif ($mode == "insert") {
$update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . "&#10";
try {
$pdo->beginTransaction();
// Prepare the SQL query for inserting a new vendor
$sql = "INSERT INTO " . $DB . "." . $tablename . " (";
$sql .= "vendor_code, vendor_name, representative_name, address, ";
$sql .= "business_type, item_type, phone, mobile, email, ";
$sql .= "fax, manager_name, contact_info, note, searchtag, update_log, item ";
$sql .= ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmh = $pdo->prepare($sql);
// Bind the variables to the prepared statement as parameters
$stmh->bindValue(1, $vendor_code, PDO::PARAM_STR);
$stmh->bindValue(2, $vendor_name, PDO::PARAM_STR);
$stmh->bindValue(3, $representative_name, PDO::PARAM_STR);
$stmh->bindValue(4, $address, PDO::PARAM_STR);
$stmh->bindValue(5, $business_type, PDO::PARAM_STR);
$stmh->bindValue(6, $item_type, PDO::PARAM_STR);
$stmh->bindValue(7, $phone, PDO::PARAM_STR);
$stmh->bindValue(8, $mobile, PDO::PARAM_STR);
$stmh->bindValue(9, $email, PDO::PARAM_STR);
$stmh->bindValue(10, $fax, PDO::PARAM_STR);
$stmh->bindValue(11, $manager_name, PDO::PARAM_STR);
$stmh->bindValue(12, $contact_info, PDO::PARAM_STR);
$stmh->bindValue(13, $note, PDO::PARAM_STR);
$stmh->bindValue(14, $searchtag, PDO::PARAM_STR);
$stmh->bindValue(15, $update_log, PDO::PARAM_STR);
$stmh->bindValue(16, $item, PDO::PARAM_STR);
// Execute the statement
$stmh->execute();
$pdo->commit();
} catch (PDOException $Exception) {
$pdo->rollBack();
print "오류: " . $Exception->getMessage();
}
// Retrieve the newly inserted row's num
$sql = "SELECT num FROM " . $DB . "." . $tablename . " ORDER BY num DESC LIMIT 1";
try {
$stmh = $pdo->query($sql);
$row = $stmh->fetch(PDO::FETCH_ASSOC);
$num = $row["num"];
} catch (PDOException $Exception) {
print "오류: " . $Exception->getMessage();
}
} elseif ($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 (Exception $ex) {
$pdo->rollBack();
print "오류: " . $ex->getMessage();
}
}
$data = [
'num' => $num,
'mode' => $mode
];
echo json_encode($data, JSON_UNESCAPED_UNICODE);
?>

133
phonebook_buy/upload.php Normal file
View File

@@ -0,0 +1,133 @@
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
header("Content-Type: application/json"); //json을 사용하기 위해 필요한 구문
$tablename = isset($_REQUEST['tablename']) ? $_REQUEST['tablename'] : '';
function conv_num($num) {
$number = (int)str_replace(',', '', $num);
return $number;
}
function pipetocomma($str) {
$strtmp = str_replace('|', ',', $str);
return $strtmp;
}
isset($_REQUEST["col1"]) ? $col1=$_REQUEST["col1"] : $col1='';
isset($_REQUEST["col2"]) ? $col2=$_REQUEST["col2"] : $col2='';
isset($_REQUEST["col3"]) ? $col3=$_REQUEST["col3"] : $col3='';
isset($_REQUEST["col4"]) ? $col4=$_REQUEST["col4"] : $col4='';
isset($_REQUEST["col5"]) ? $col5=$_REQUEST["col5"] : $col5='';
isset($_REQUEST["col6"]) ? $col6=$_REQUEST["col6"] : $col6='';
isset($_REQUEST["col7"]) ? $col7=$_REQUEST["col7"] : $col7='';
isset($_REQUEST["col8"]) ? $col8=$_REQUEST["col8"] : $col8='';
isset($_REQUEST["col9"]) ? $col9=$_REQUEST["col9"] : $col9='';
isset($_REQUEST["col10"]) ? $col10=$_REQUEST["col10"] : $col10='';
isset($_REQUEST["col11"]) ? $col11=$_REQUEST["col11"] : $col11='';
isset($_REQUEST["col12"]) ? $col12=$_REQUEST["col12"] : $col12='';
isset($_REQUEST["col13"]) ? $col12=$_REQUEST["col13"] : $col13='';
$colarr1 = explode(",",$col1[0]);
$colarr2 = explode(",",$col2[0]);
$colarr3 = explode(",",$col3[0]);
$colarr4 = explode(",",$col4[0]);
$colarr5 = explode(",",$col5[0]);
$colarr6 = explode(",",$col6[0]);
$colarr7 = explode(",",$col7[0]);
$colarr8 = explode(",",$col8[0]);
$colarr9 = explode(",",$col9[0]);
$colarr10 = explode(",",$col10[0]);
$colarr11 = explode(",",$col11[0]);
$colarr12 = explode(",",$col12[0]);
$colarr13 = explode(",",$col13[0]);
$orderday = date("Y-m-d"); // 현재날짜 2022-01-20 형태로 지정
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();
for($i=0;$i<count($colarr1);$i++) {
if($colarr1[$i]!='')
{
// | -> , 로 변환함
$colarr1[$i] = pipetocomma($colarr1[$i]);
$colarr2[$i] = pipetocomma($colarr2[$i]);
$colarr3[$i] = pipetocomma($colarr3[$i]);
$colarr4[$i] = pipetocomma($colarr4[$i]);
$colarr5[$i] = pipetocomma($colarr5[$i]);
$colarr6[$i] = pipetocomma($colarr6[$i]);
$colarr7[$i] = pipetocomma($colarr7[$i]);
$colarr8[$i] = pipetocomma($colarr8[$i]);
$colarr9[$i] = pipetocomma($colarr9[$i]);
$colarr10[$i] = pipetocomma($colarr10[$i]);
$colarr11[$i] = pipetocomma($colarr11[$i]);
$colarr12[$i] = pipetocomma($colarr12[$i]);
$colarr13[$i] = pipetocomma($colarr13[$i]);
try {
$pdo->beginTransaction();
// Collect input data
$vendor_code = $colarr1[$i];
$vendor_name = $colarr2[$i];
$representative_name = $colarr3[$i];
$address = $colarr4[$i];
$business_type = $colarr5[$i];
$item_type = $colarr6[$i];
$phone = $colarr7[$i];
$mobile = $colarr8[$i];
$email = $colarr9[$i];
$fax = $colarr10[$i];
$manager_name = $colarr11[$i];
$contact_info = $colarr12[$i];
$note = $colarr13[$i];
// Prepare SQL insert statement
$sql = "INSERT INTO " . $DB . "." . $tablename . " (";
$sql .= "vendor_code, vendor_name, representative_name, address, ";
$sql .= "business_type, item_type, phone, mobile, email, ";
$sql .= "fax, manager_name, contact_info, note";
$sql .= ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmh = $pdo->prepare($sql);
// Bind the values to the prepared statement
$stmh->bindValue(1, $vendor_code, PDO::PARAM_STR);
$stmh->bindValue(2, $vendor_name, PDO::PARAM_STR);
$stmh->bindValue(3, $representative_name, PDO::PARAM_STR);
$stmh->bindValue(4, $address, PDO::PARAM_STR);
$stmh->bindValue(5, $business_type, PDO::PARAM_STR);
$stmh->bindValue(6, $item_type, PDO::PARAM_STR);
$stmh->bindValue(7, $phone, PDO::PARAM_STR);
$stmh->bindValue(8, $mobile, PDO::PARAM_STR);
$stmh->bindValue(9, $email, PDO::PARAM_STR);
$stmh->bindValue(10, $fax, PDO::PARAM_STR);
$stmh->bindValue(11, $manager_name, PDO::PARAM_STR);
$stmh->bindValue(12, $contact_info, PDO::PARAM_STR);
$stmh->bindValue(13, $note, PDO::PARAM_STR);
// Execute the statement
$stmh->execute();
$pdo->commit();
} catch (PDOException $Exception) {
$pdo->rollBack();
print "오류: " . $Exception->getMessage();
}
}
}
//각각의 정보를 하나의 배열 변수에 넣어준다.
$data = array(
"colarr1" => $colarr1
);
//json 출력
echo(json_encode($data, JSON_UNESCAPED_UNICODE));
?>

View File

@@ -0,0 +1,456 @@
<?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 = '매입처 업로드'
?>
<title> <?=$title_message?> </title>
</head>
<body>
<?php
$sql=" select * from " . $DB . ".phonebook_buy " ;
$tablename = 'phonebook_buy';
?>
<div class="container-fluid">
<div class="card-header">
<h6> <?=$title_message?> &nbsp; &nbsp;
<button type="button" class="btn btn-dark btn-sm" id="savegridBtn"> <i class="bi bi-check-square-fill"></i> 일괄등록 실행 </button> &nbsp; &nbsp; &nbsp;
<button type="button" class="btn btn-dark btn-sm" onclick="self.close();" > <i class="bi bi-x-lg"></i> 창닫기 </button> &nbsp;
</h6>
</div>
<form name="regform" id="regform" method="post" >
<input id="tablename" name="tablename" value='<?=$tablename?>'type=hidden >
<input id="col1" name="col1[]" type=hidden >
<input id="col2" name="col2[]" type=hidden >
<input id="col3" name="col3[]" type=hidden >
<input id="col4" name="col4[]" type=hidden >
<input id="col5" name="col5[]" type=hidden >
<input id="col6" name="col6[]" type=hidden >
<input id="col7" name="col7[]" type=hidden >
<input id="col8" name="col8[]" type=hidden >
<input id="col9" name="col9[]" type=hidden >
<input id="col10" name="col10[]" type=hidden >
<input id="col11" name="col11[]" type=hidden >
<input id="col12" name="col12[]" type=hidden >
<input id="col13" name="col13[]" type=hidden >
<div class="container-fluid">
<div class="card mb-2 mt-2">
<div class="card-body">
<div class="input-group p-2 mb-2">
<span style="margin-left:20px;font-size:20px;color:blue;"> ※ 해당셀 엑셀 내용을 복사 후 붙여넣기 </span>
</div>
<div class="d-flex mt-2 mb-2">
<div id="grid" style="width:1870px;">
</div>
</div>
</form>
</div>
</div>
</div>
</div> <!-- end of wrap -->
<!-- 페이지로딩 -->
<script>
// 페이지 로딩
$(document).ready(function(){
var loader = document.getElementById('loadingOverlay');
loader.style.display = 'none';
});
</script>
<script>
$(document).ready(function(){
$("#searchBtn").click(function(){ document.getElementById('board_form').submit(); });
var total_sum=0;
var count=0; // 전체줄수 카운트
var rowNum = 300;
const data = [];
const columns = [];
const COL_COUNT = 13;
for(i=0;i<rowNum + 1;i++) {
row = { name: i };
for (let k = 0; k < COL_COUNT; k++ ) {
row[`col1`] = '' ;
row[`col2`] = '' ;
row[`col3`] = '' ;
row[`col4`] = '' ;
row[`col5`] = '' ;
row[`col6`] = '' ;
row[`col7`] = '' ;
row[`col8`] = '' ;
row[`col9`] = '' ;
row[`col10`] = '' ;
row[`col11`] = '' ;
row[`col12`] = '' ;
row[`col13`] = '' ;
}
data.push(row);
}
class CustomTextEditor {
constructor(props) {
const el = document.createElement('input');
const { maxLength } = props.columnInfo.editor.options;
el.type = 'text';
el.maxLength = maxLength;
el.value = String(props.value);
this.el = el;
}
getElement() {
return this.el;
}
getValue() {
return this.el.value;
}
mounted() {
this.el.select();
}
}
const grid = new tui.Grid({
el: document.getElementById('grid'),
data: data,
bodyHeight: 700,
columns: [
{
header: '매입처코드',
name: 'col1',
sortingType: 'desc',
sortable: true,
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 80
}
},
align: 'center'
},
{
header: '매입처명',
name: 'col2',
width:200,
editor: {
type: CustomTextEditor,
options: {
maxLength: 80
}
},
align: 'center'
},
{
header: '대표자',
name: 'col3',
width: 100,
editor: {
type: CustomTextEditor,
},
align: 'center'
},
{
header: '주소1',
name: 'col4',
width:200,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: '업태',
name: 'col5',
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: '종목',
name: 'col6',
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: '전화',
name: 'col7',
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: '모바일',
name: 'col8',
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: 'Email',
name: 'col9',
width:200,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: 'Fax',
name: 'col10',
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: '담당자명',
name: 'col11',
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: '연락처',
name: 'col12',
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
},
{
header: '비고',
name: 'col13',
width:100,
editor: {
type: CustomTextEditor,
options: {
maxLength: 40
}
},
align: 'center'
}
],
columnOptions: {
resizable: true
},
// rowHeaders: ['rowNum','checkbox'], // checkbox 형성
});
var Grid = tui.Grid; // or require('tui-grid')
Grid.applyTheme('default', {
cell: {
normal: {
background: '#fbfbfb',
border: '#e0e0e0',
showVerticalBorder: true
},
header: {
background: '#eee',
border: '#ccc',
showVerticalBorder: true
},
rowHeader: {
border: '#ccc',
showVerticalBorder: true
},
editable: {
background: '#fbfbfb'
},
selectedHeader: {
background: '#d8d8d8'
},
focused: {
border: '#418ed4'
},
disabled: {
text: '#b0b0b0'
}
}
});
function savegrid() {
let col1 = new Array();
let col2 = new Array();
let col3 = new Array();
let col4 = new Array();
let col5 = new Array();
let col6 = new Array();
let col7 = new Array();
let col8 = new Array();
let col9 = new Array();
let col10 = new Array();
let col11 = new Array();
let col12 = new Array();
let col13 = new Array();
// console.log(grid.getRowCount()); //삭제시 숫자가 정상적으로 줄어든다.
const MAXcount=grid.getRowCount() ;
let pushcount=0;
for(i=0;i<MAXcount;i++) { // grid.value는 중간중간 데이터가 빠진다. rowkey가 삭제/ 추가된 것을 반영못함.
if( grid.getValue(i, 'col1')!= null ) {
col1.push(swapcommatopipe(grid.getValue(i, 'col1')));
col2.push(swapcommatopipe(grid.getValue(i, 'col2')));
col3.push(swapcommatopipe(grid.getValue(i, 'col3')));
col4.push(swapcommatopipe(grid.getValue(i, 'col4')));
col5.push(swapcommatopipe(grid.getValue(i, 'col5')));
col6.push(swapcommatopipe(grid.getValue(i, 'col6')));
col7.push(swapcommatopipe(grid.getValue(i, 'col7')));
col8.push(swapcommatopipe(grid.getValue(i, 'col8')));
col9.push(swapcommatopipe(grid.getValue(i, 'col9')));
col10.push(swapcommatopipe(grid.getValue(i, 'col10')));
col11.push(swapcommatopipe(grid.getValue(i, 'col11')));
col12.push(swapcommatopipe(grid.getValue(i, 'col12')));
col13.push(swapcommatopipe(grid.getValue(i, 'col13')));
}
}
$('#col1').val(col1);
$('#col2').val(col2);
$('#col3').val(col3);
$('#col4').val(col4);
$('#col5').val(col5);
$('#col6').val(col6);
$('#col7').val(col7);
$('#col8').val(col8);
$('#col9').val(col9);
$('#col10').val(col10);
$('#col11').val(col11);
$('#col12').val(col12);
$('#col13').val(col13);
$.ajax({
url: "upload.php",
type: "post",
data: $("#regform").serialize(),
dataType:"json",
success : function( data ){
console.log( data);
Swal.fire(
'처리되었습니다.',
'데이터가 성공적으로 등록되었습니다.',
'success'
)
setTimeout(function() {
self.close();
window.opener.location.reload(); // 부모창 새로고침
}, 2000);
},
error : function( jqxhr , status , error ){
console.log( jqxhr , status , error );
}
});
}
$("#savegridBtn").click(function(){ savegrid(); });
});
function SearchEnter(){
if(event.keyCode == 13){
document.getElementById('board_form').submit();
}
}
function swapcommatopipe(strtmp)
{
let replaced_str = strtmp.replace(/,/g, '|');
return replaced_str;
}
</script>
</body>
</html>

234
phonebook_buy/write.php Normal file
View File

@@ -0,0 +1,234 @@
<?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 = '매입처 주소록'; ?>
<title> <?=$title_message?> </title>
</head>
<body>
<?php
$option = isset($_REQUEST['option']) ? $_REQUEST['option'] : '';
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
$header = isset($_REQUEST['header']) ? $_REQUEST['header'] : '';
$tablename = 'phonebook_buy';
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();
$num = isset($_REQUEST["num"]) ? $_REQUEST["num"] : 0;
// 수정일 경우
if($num > 0) {
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) {
print "오류: ".$Exception->getMessage();
}
if($option !== 'add') {
$mode = 'update';
} else {
$mode = 'insert';
$manager_name = '';
$contact_info = '010-';
$title_message = '업체 담당자 추가화면 ';
$parentnum = $num;
}
} else {
include '_request.php';
$mode = 'insert';
$representative_name = $search;
$manager_name = $search;
$phone = '010-';
}
?>
<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" value="<?=$num?>">
<input type="hidden" id="tablename" name="tablename" value="<?=$tablename?>">
<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 fw-bold">거래처코드<br>(사업자번호)</td>
<td class="text-center">
<input type="text" class="form-control" id="vendor_code" name="vendor_code" value="<?=$vendor_code?>">
</td>
<td class="text-center fw-bold" style="width:150px;">거래처 명</td>
<td class="text-center">
<input type="text" class="form-control" id="vendor_name" name="vendor_name" style="width:250px;" value="<?=$vendor_name?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold" style="width:170px;">대표자 성함</td>
<td class="text-center fw-bold">
<input type="text" class="form-control" id="representative_name" name="representative_name" style="width:200px;" value="<?=$representative_name?>">
</td>
<td class="text-center fw-bold" style="width:150px;">대상품목(아이템)</td>
<td class="text-center">
<input type="text" class="form-control" id="item" name="item" style="width:250px;" value="<?=$item?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">주소</td>
<td colspan="3" class="text-center">
<input type="text" class="form-control" id="address" name="address" value="<?=$address?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">업태</td>
<td class="text-center">
<input type="text" class="form-control" id="business_type" name="business_type" value="<?=$business_type?>">
</td>
<td class="text-center fw-bold">종목</td>
<td class="text-center">
<input type="text" class="form-control" id="item_type" name="item_type" value="<?=$item_type?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">전화</td>
<td class="text-center">
<input type="text" class="form-control" id="phone" name="phone" value="<?=$phone?>">
</td>
<td class="text-center fw-bold">모바일</td>
<td class="text-center">
<input type="text" class="form-control" id="mobile" name="mobile" value="<?=$mobile?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">이메일</td>
<td class="text-center">
<input type="email" class="form-control" id="email" name="email" value="<?=$email?>">
</td>
<td class="text-center fw-bold">팩스</td>
<td class="text-center">
<input type="text" class="form-control" id="fax" name="fax" value="<?=$fax?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">담당자명</td>
<td class="text-center">
<input type="text" class="form-control" id="manager_name" name="manager_name" value="<?=$manager_name?>">
</td>
<td class="text-center fw-bold">담당자Tel</td>
<td class="text-center">
<input type="text" class="form-control" id="contact_info" name="contact_info" value="<?=$contact_info?>">
</td>
</tr>
<tr>
<td class="text-center fw-bold">비고</td>
<td colspan="3" class="text-center">
<textarea class="form-control" id="note" name="note"><?=$note?></textarea>
</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>
<button type="button" id="closeBtn" class="btn btn-outline-dark btn-sm me-2">
&times; 닫기
</button>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
<!-- 페이지로딩 -->
<script>
// 페이지 로딩
$(document).ready(function(){
var loader = document.getElementById('loadingOverlay');
loader.style.display = 'none';
});
</script>
<script>
ajaxRequest_write = null;
$(document).ready(function(){
// 창닫기 버튼
$("#closeBtn").on("click", function() {
self.close();
});
// 저장 버튼 서버에 저장하고 Ecount 전송함
$("#saveBtn").on("click", function() {
var header = $("#header").val();
let msg = '저장완료';
if (ajaxRequest_write !== null) {
ajaxRequest_write.abort();
}
ajaxRequest_write = $.ajax({
url: "process.php",
type: "post",
data: $("#board_form").serialize(),
success: function(data) {
console.log(data);
Toastify({
text: msg,
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#4fbe87",
}).showToast();
if(header !== 'header'){
// 부모창 실행
if($("#manager_name").val() !== '')
$("#search", opener.document).val($("#manager_name").val());
else
$("#search", opener.document).val($("#representative_name").val());
}
$(opener.location).attr("href", "javascript:reloadlist();");
setTimeout(function() {
// 창 닫기
self.close();
}, 500);
},
error: function(jqxhr, status, error) {
console.log(jqxhr, status, error);
}
});
});
});
</script>