- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
648 lines
23 KiB
PHP
648 lines
23 KiB
PHP
<?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'] : '';
|
|
$searchItem = isset($_REQUEST['searchItem']) ? $_REQUEST['searchItem'] : ''; // 제품검사요청서의 searchItem 설정 distributor 인 경우 return 변수 바꿈
|
|
|
|
// 세무사아이디면 다른 메뉴 연결
|
|
if($_SESSION["userid"] == '0266771300') {
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/myheader_accountant.php';
|
|
}
|
|
else {
|
|
include $_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"] : '';
|
|
$returnID = isset($_REQUEST["returnID"]) ? $_REQUEST["returnID"] : ''; // 금전출납부에서 수금등록 호출시
|
|
|
|
$tablename = 'phonebook';
|
|
|
|
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?>" >
|
|
<input type="hidden" id="secondordnum" name="secondordnum" value="<?=$secondordnum?>" > <!-- 구매처 코드 -->
|
|
<input type="hidden" id="paydate" name="paydate" value="<?=$paydate?>" > <!-- 매출 결재일자 -->
|
|
<input type="hidden" id="secondordpaydate" name="secondordpaydate" value="<?=$secondordpaydate?>" > <!-- 매입 결재일자 -->
|
|
<input type="hidden" id="searchItem" name="searchItem" value="<?=$searchItem?>" >
|
|
<input type="hidden" id="returnID" name="returnID" value="<?=$returnID?>" > <!-- 수금등록 호출시 거래처코드 전달 -->
|
|
|
|
<?php if($header !== 'header')
|
|
{
|
|
print '<div class="container-fluid" > ';
|
|
print '<div class="card justify-content-center text-center mt-3" >';
|
|
}
|
|
else
|
|
{
|
|
print '<div class="container-fluid" > ';
|
|
print '<div class="card justify-content-center text-center mt-5" >';
|
|
}
|
|
?>
|
|
<div class="card-header">
|
|
<div class="d-flex justify-content-center text-center align-items-center " >
|
|
<span class="text-center fs-5" > <?=$title_message?> </span>
|
|
<button type="button" class="btn btn-dark btn-sm mx-3" onclick='location.reload();' title="새로고침"> <i class="bi bi-arrow-clockwise"></i> </button>
|
|
</div>
|
|
<div class="d-flex justify-content-center text-center align-items-center mt-2 " >
|
|
<h5> <span class="text-center badge bg-danger" > (주의사항) 담당자 아이디 생성시 반드시 + 버튼을 이용해야 합니다. </span> </h5>
|
|
</div>
|
|
</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 ?>
|
|
<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>
|
|
|
|
<button class="btn btn-outline-dark btn-sm " type="button" id="searchBtn" > <i class="bi bi-search"></i> </button> </span>
|
|
|
|
<button id="newBtn" type="button" class="btn btn-dark btn-sm me-2"> <i class="bi bi-pencil-square"></i> 신규 </button>
|
|
<button id="csvExportBtn" type="button" class="btn btn-success btn-sm me-2"> <i class="bi bi-file-earmark-spreadsheet"></i> CSV 저장 </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 } ?>
|
|
<?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" style="table-layout: auto; width: 100%;">
|
|
<thead class="table-primary">
|
|
<th class="text-center" style="width: auto; min-width: 50px;">
|
|
<input type="checkbox" id="selectAll" title="전체 선택/해제">
|
|
</th>
|
|
<th class="text-center" style="width: auto;">대표코드 여부</th>
|
|
<th class="text-center" style="width: auto;">코드</th>
|
|
<th class="text-center" style="width: auto;">매입/매출</th>
|
|
<th class="text-center" style="width: auto;">거래처명</th>
|
|
<th class="text-center" style="width: auto;">대표자</th>
|
|
<th class="text-center" style="width: auto;">담당자</th>
|
|
<th class="text-center" style="width: auto;">전화번호</th>
|
|
<th class="text-center text-secondary" style="width: auto;">매입 결제일</th>
|
|
<th class="text-center text-primary" style="width: auto;">매출 결제일</th>
|
|
<th class="text-center text-danger" style="width: auto;">악성채권</th>
|
|
<th class="text-center" style="width: auto;">악성채권 금액</th>
|
|
<th class="text-center" style="width: auto;">추가/삭제</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;
|
|
|
|
if(intval($secondordnum) > 0)
|
|
$savenum= $secondordnum;
|
|
else
|
|
$savenum= $num;
|
|
?>
|
|
<?php
|
|
// 엔터 키와 <br> 태그 제거
|
|
$safe_address = preg_replace('/\s+/', ' ', str_replace(['<br>', '<br/>'], ' ', $address));
|
|
// JSON 문자열 준비
|
|
$jm = json_encode($manager_name, JSON_UNESCAPED_UNICODE);
|
|
$jr = json_encode($representative_name, JSON_UNESCAPED_UNICODE);
|
|
$jp = json_encode($phone, JSON_UNESCAPED_UNICODE);
|
|
$jvn = json_encode($vendor_name, JSON_UNESCAPED_UNICODE);
|
|
$jci = json_encode($contact_info, JSON_UNESCAPED_UNICODE);
|
|
$jsv = json_encode($savenum, JSON_UNESCAPED_UNICODE);
|
|
$jno = json_encode($num, JSON_UNESCAPED_UNICODE);
|
|
$ja = json_encode($safe_address, JSON_UNESCAPED_UNICODE);
|
|
$j2 = json_encode($secondordpaydate, JSON_UNESCAPED_UNICODE);
|
|
$j3 = json_encode($paydate, JSON_UNESCAPED_UNICODE);
|
|
?>
|
|
|
|
<tr data-num="<?= $num ?>" onclick='maketext(<?= $jm ?>,<?= $jr ?>,<?= $jp ?>,<?= $jvn ?>,<?= $jci ?>,<?= $jsv ?>,<?= $jno ?>,<?= $ja ?>,<?= $j2 ?>,<?= $j3 ?>);'>
|
|
<td class="text-center" onclick="event.stopPropagation();">
|
|
<input type="checkbox" class="row-checkbox" value="<?= $num ?>"
|
|
data-vendor-code="<?= htmlspecialchars($vendor_code, ENT_QUOTES, 'UTF-8') ?>"
|
|
data-vendor-name="<?= htmlspecialchars($vendor_name, ENT_QUOTES, 'UTF-8') ?>"
|
|
data-representative="<?= htmlspecialchars($representative_name, ENT_QUOTES, 'UTF-8') ?>"
|
|
data-address="<?= htmlspecialchars($address, ENT_QUOTES, 'UTF-8') ?>"
|
|
data-manager-name="<?= htmlspecialchars($manager_name, ENT_QUOTES, 'UTF-8') ?>"
|
|
data-email="<?= htmlspecialchars($email, ENT_QUOTES, 'UTF-8') ?>">
|
|
</td>
|
|
<td class="text-center text-primary fw-bold" ><?= $represent ?></td>
|
|
<td class="text-center text-secondary" ><?= $secondordnum ?></td>
|
|
<td class="text-center <?=
|
|
$PurchaseSales === '매입매출'
|
|
? 'text-danger'
|
|
: ( $PurchaseSales === '매입'
|
|
? 'text-primary'
|
|
: 'text-secondary'
|
|
)
|
|
?>">
|
|
<?= $PurchaseSales ?>
|
|
</td>
|
|
<td class="text-start text-dark fw-bold" title="<?=$vendor_name?>"><?= $vendor_name ?></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 text-secondary "><?= $secondordpaydate ?></td>
|
|
<td class="text-center text-primary "><?= $paydate ?></td>
|
|
<td class="text-center text-danger"><?= ($baddebt === '1') ? '악성채권' : '' ?></td>
|
|
<td class="text-end"><?= $debtAmount?></td>
|
|
<td class="text-center" >
|
|
<?php if(!empty($represent)) { ?>
|
|
<button type="button" class="btn btn-dark btn-sm" onclick="addFn('<?=$num?>'); event.stopPropagation();">
|
|
<i class="bi bi-plus-square"></i>
|
|
</button>
|
|
<?php } ?>
|
|
<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');
|
|
if(loader)
|
|
loader.style.display = 'none';
|
|
});
|
|
</script>
|
|
|
|
|
|
<script>
|
|
var ajaxRequest_write = null;
|
|
var dataTable; // DataTables 인스턴스 전역 변수
|
|
var pbpageNumber; // 현재 페이지 번호 저장을 위한 전역 변수
|
|
|
|
$(document).ready(function() {
|
|
// 포커스를 이동시킴, 강제로 포커스를 얻으면 계속 창이 뜨는 것을 방지함
|
|
if (opener && opener.document) {
|
|
$("#workplacename", opener.document).focus(); // 오프너 문서의 특정 요소에 포커스 설정
|
|
}
|
|
|
|
// DataTables 초기 설정
|
|
dataTable = $('#myTable').DataTable({
|
|
"paging": true,
|
|
"ordering": true,
|
|
"searching": false,
|
|
"pageLength": 50, // 한 페이지에 표시할 항목 수
|
|
"lengthMenu": [20, 50, 100, 200, 500, 1000, 2000], // 페이지당 표시 항목 선택 메뉴
|
|
"language": {
|
|
"lengthMenu": "Show _MENU_ entries"
|
|
},
|
|
"order": [[2, 'desc']], // 코드 열을 기준으로 내림차순 정렬 (체크박스 열 제외)
|
|
"autoWidth": true, // 자동 너비 조정
|
|
"columnDefs": [
|
|
{ "orderable": false, "targets": 0 }, // 체크박스 열은 정렬 비활성화
|
|
{ "width": "auto", "targets": "_all" } // 모든 열의 너비를 자동으로 설정
|
|
]
|
|
// "serverSide": true, // 서버 사이드 처리 활성화
|
|
// "ajax": {
|
|
// "url": "/phonebook/path_to_your_server_side_script.php", // 서버 측 스크립트 URL
|
|
// "type": "POST",
|
|
// "data": function (d) {
|
|
// // 필요에 따라 추가 데이터를 서버로 전송할 수 있음
|
|
// d.search = $('#search').val(); // 검색 값 추가
|
|
// }
|
|
// }
|
|
});
|
|
|
|
// 페이지 번호 복원 (초기 로드 시)
|
|
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(); // 페이지 길이 변경
|
|
|
|
// 변경 후 현재 페이지 번호 복원
|
|
savedPageNumber = getCookie('pbpageNumber');
|
|
if (savedPageNumber) {
|
|
dataTable.page(parseInt(savedPageNumber) - 1).draw(false);
|
|
}
|
|
});
|
|
});
|
|
|
|
function restorePageNumber() {
|
|
var savedPageNumber = getCookie('pbpageNumber');
|
|
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(managerName, representativeName, phone, vendorName, contact_info, savenum, num, vendorAddr, secondordpaydate, paydate)
|
|
{
|
|
var searchItem = $("#searchItem").val();
|
|
|
|
if(searchItem == 'distributor')
|
|
{
|
|
var managerFieldID = 'distributor_name'; // ID of the manager input field in the parent document
|
|
var phoneFieldID = 'distributor_tel'; // ID of the phone input field in the parent document
|
|
var vendorFieldID = 'distributor_corp'; // ID of the vendor input field in the parent document
|
|
var address = 'distributor_addr';
|
|
var textmsg;
|
|
|
|
managerName = representativeName;
|
|
|
|
if(contact_info ==='') // 담당자 전화가 없으면 대표전화
|
|
{
|
|
contact_info = phone;
|
|
}
|
|
if (opener && opener.document) {
|
|
// Set the values in the parent document
|
|
$("#" + managerFieldID, opener.document).val(managerName);
|
|
$("#" + phoneFieldID, opener.document).val(contact_info);
|
|
$("#" + vendorFieldID, opener.document).val(vendorName);
|
|
$("#" + address, opener.document).val(vendorAddr);
|
|
setTimeout(function() {
|
|
self.close();
|
|
}, 500);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
var managerFieldID = 'secondordman'; // 담당자 input ID
|
|
var phoneFieldID = 'secondordmantel'; // 전화 input ID
|
|
var vendorFieldID = 'secondord'; // 업체명 input ID
|
|
var vendorFieldCode = 'secondordnum'; // 업체코드 input ID
|
|
var vendorPurchaseSaleDate = 'secondordpaydate'; // 구매처 결재일
|
|
var header = $("#header").val();
|
|
var returnID = $("#returnID").val(); // 수금등록 호출시 거래처코드 전달
|
|
|
|
// 업체코드 세팅 (항상 존재한다고 가정)
|
|
$("#secondordnum").val(savenum);
|
|
|
|
if (header === 'header') {
|
|
updateFn(num);
|
|
return;
|
|
}
|
|
|
|
if (!managerName) managerName = representativeName; // 담당자 없으면 대표자
|
|
if (!contact_info) contact_info = phone; // 전화 없으면 대표전화
|
|
|
|
if (opener && opener.document) {
|
|
var $op = $(opener.document);
|
|
|
|
var $mgr = $op.find('#' + managerFieldID);
|
|
if ($mgr.length) {
|
|
$mgr.val(managerName);
|
|
}
|
|
|
|
var $tel = $op.find('#' + phoneFieldID);
|
|
if ($tel.length) {
|
|
$tel.val(contact_info);
|
|
}
|
|
|
|
var $vend = $op.find('#' + vendorFieldID);
|
|
if ($vend.length) {
|
|
$vend.val(vendorName);
|
|
}
|
|
|
|
var $vcode = $op.find('#' + vendorFieldCode);
|
|
if ($vcode.length) {
|
|
$vcode.val(savenum);
|
|
}
|
|
|
|
var $vpaydate = $op.find('#' + vendorPurchaseSaleDate);
|
|
if ($vpaydate.length) {
|
|
$vpaydate.val(secondordpaydate);
|
|
}
|
|
// 품의서의 store는 구매처 ID입니다. 여기서 구매처 이름 넣어주기
|
|
var $store = $op.find('#store');
|
|
if ($store.length) {
|
|
$store.val(vendorName);
|
|
}
|
|
|
|
if(returnID=='수금등록') {
|
|
var $content_detail = $op.find('#content_detail'); // 수금등록 호출시 거래처코드 전달
|
|
if ($content_detail.length) {
|
|
$content_detail.val(vendorName); // 수금등록 호출시 거래처코드 전달
|
|
}
|
|
}
|
|
|
|
// 부모창이 존재하고 부모창의 setCompanyInfo 함수가 있는 경우에만 실행
|
|
if (opener && typeof opener.setCompanyInfo === 'function') {
|
|
opener.setCompanyInfo(savenum, vendorName);
|
|
}
|
|
|
|
// 0.5초 후 창 닫기
|
|
setTimeout(function() {
|
|
self.close();
|
|
}, 500);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
$("#searchBtn").on("click", function() {
|
|
$("#board_form").submit();
|
|
});
|
|
|
|
$("#search_directinput").on("click", function() {
|
|
$("#custreg_search").hide();
|
|
});
|
|
|
|
// 신규 버튼
|
|
$("#newBtn").on("click", function() {
|
|
popupCenter('./write_form.php' , '거래처 신규등록', 800, 850);
|
|
});
|
|
// 창닫기 버튼
|
|
$("#closeBtn").on("click", function() {
|
|
self.close();
|
|
});
|
|
|
|
|
|
function updateFn(num) {
|
|
var header = $("#header").val();
|
|
|
|
popupCenter('./write_form.php?num=' + num + '&header=' + header , '수정', 800, 850);
|
|
}
|
|
|
|
function addFn(num) {
|
|
popupCenter('./write_form.php?option=add&num=' + num , '자료 추가등록', 800, 850);
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
// 전체 선택/해제 (DataTables와 호환)
|
|
$(document).on("change", "#selectAll", function() {
|
|
const isChecked = $(this).prop("checked");
|
|
// 현재 보이는 페이지의 체크박스만 선택/해제
|
|
dataTable.$(".row-checkbox").prop("checked", isChecked);
|
|
// 모든 페이지의 체크박스 선택/해제를 원하면 아래 주석 해제
|
|
// $(".row-checkbox").prop("checked", isChecked);
|
|
});
|
|
|
|
// 개별 체크박스 변경 시 전체 선택 체크박스 상태 업데이트
|
|
$(document).on("change", ".row-checkbox", function() {
|
|
// 현재 보이는 페이지의 체크박스만 확인
|
|
const visibleCheckboxes = dataTable.$(".row-checkbox");
|
|
const totalVisible = visibleCheckboxes.length;
|
|
const checkedVisible = visibleCheckboxes.filter(":checked").length;
|
|
|
|
// 모든 페이지의 체크박스 확인
|
|
const totalCheckboxes = $(".row-checkbox").length;
|
|
const checkedCheckboxes = $(".row-checkbox:checked").length;
|
|
|
|
// 현재 페이지의 모든 체크박스가 선택되었는지 확인
|
|
$("#selectAll").prop("checked", totalVisible > 0 && totalVisible === checkedVisible);
|
|
});
|
|
|
|
// CSV 저장 버튼
|
|
$("#csvExportBtn").on("click", function() {
|
|
const checkedBoxes = $(".row-checkbox:checked");
|
|
|
|
if (checkedBoxes.length === 0) {
|
|
Swal.fire({
|
|
icon: 'warning',
|
|
title: '선택된 항목이 없습니다',
|
|
text: 'CSV로 저장할 항목을 선택해주세요.',
|
|
confirmButtonText: '확인'
|
|
});
|
|
return;
|
|
}
|
|
|
|
// 체크된 항목들의 데이터 수집 (사업자번호, 상호, 대표자명, 주소, 담당자이름, 이메일)
|
|
const selectedData = [];
|
|
checkedBoxes.each(function() {
|
|
selectedData.push({
|
|
vendor_code: $(this).data('vendor-code') || '',
|
|
vendor_name: $(this).data('vendor-name') || '',
|
|
representative_name: $(this).data('representative') || '',
|
|
address: $(this).data('address') || '',
|
|
manager_name: $(this).data('manager-name') || '',
|
|
email: $(this).data('email') || ''
|
|
});
|
|
});
|
|
|
|
// CSV 다운로드 요청
|
|
$.ajax({
|
|
url: "export_csv.php",
|
|
type: "POST",
|
|
data: {
|
|
data: JSON.stringify(selectedData)
|
|
},
|
|
success: function(response) {
|
|
// CSV 파일 다운로드
|
|
const blob = new Blob([response], { type: 'text/csv;charset=utf-8;' });
|
|
const link = document.createElement('a');
|
|
const url = URL.createObjectURL(blob);
|
|
link.setAttribute('href', url);
|
|
link.setAttribute('download', '거래처리스트_' + new Date().toISOString().split('T')[0] + '.csv');
|
|
link.style.visibility = 'hidden';
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
document.body.removeChild(link);
|
|
|
|
Toastify({
|
|
text: "CSV 파일 다운로드 완료!",
|
|
duration: 3000,
|
|
close: true,
|
|
gravity: "top",
|
|
position: "center",
|
|
backgroundColor: "#4fbe87",
|
|
}).showToast();
|
|
},
|
|
error: function(jqxhr, status, error) {
|
|
console.log(jqxhr, status, error);
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: '오류 발생',
|
|
text: 'CSV 파일 생성 중 오류가 발생했습니다.',
|
|
confirmButtonText: '확인'
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<!-- 발주처 배송지 선택 모달창 -->
|
|
<script>
|
|
// ajax 중복처리를 위한 구문
|
|
var ajaxRequest = null;
|
|
var ajaxRequest1 = null;
|
|
var ajaxRequest2 = null;
|
|
var ajaxRequest3 = null;
|
|
var ajaxRequest4 = null;
|
|
var ajaxRequest5 = null;
|
|
var ajaxRequest6 = null;
|
|
var ajaxRequest7 = null;
|
|
var ajaxRequest8 = null;
|
|
|
|
$(document).ready(function() {
|
|
|
|
$('.closemodal').click(function() {
|
|
// Hide the modal with the id 'deliveryModal'
|
|
$('#deliveryModal').modal('hide');
|
|
self.close(); // Close the popup window after confirming
|
|
});
|
|
// upload
|
|
$("#uploadBtn").on("click", function() {
|
|
popupCenter('uploadgrid.php' , '업로드', 1800, 800);
|
|
});
|
|
|
|
});
|
|
|
|
function display(text) {
|
|
Toastify({
|
|
text: text,
|
|
duration: 2000,
|
|
close: true,
|
|
gravity: "top",
|
|
position: "center",
|
|
style: {
|
|
background: "linear-gradient(to right, #00b09b, #96c93d)",
|
|
fontSize: '20px' // 글씨 크기를 20px로 설정
|
|
},
|
|
}).showToast();
|
|
}
|
|
</script>
|