초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
1
eworks/RefLine/RefLine_a.json
Normal file
1
eworks/RefLine/RefLine_a.json
Normal file
@@ -0,0 +1 @@
|
||||
[{"userId":"a","savedName":"\uae30\ubcf8","RefOrder":[{"order":1,"user-id":"0656","name":"\n\t\t\t\t\t\t\t\t\t\uc625\ub3d9\uc218 \uc8fc\uc784\t\t\t\t\t\t\t\t"},{"order":2,"user-id":5702,"name":"\n\t\t\t\t\t\t\t\t\t\uae40\uc218\ub85c \uc0ac\uc6d0\t\t\t\t\t\t\t\t"},{"order":3,"user-id":5123,"name":"\n\t\t\t\t\t\t\t\t\t\uc548\ud604\uc12d \ucc28\uc7a5\t\t\t\t\t\t\t\t"},{"order":4,"user-id":2562,"name":"\n\t\t\t\t\t\t\t\t\t\uc870\uc131\uc6d0 \ud300\uc7a5\t\t\t\t\t\t\t\t"},{"order":5,"user-id":7473,"name":"\n\t\t\t\t\t\t\t\t\t\uc774\uacbd\ubb35 \uacf5\uc7a5\uc7a5\t\t\t\t\t\t\t\t"},{"order":6,"user-id":7210,"name":"\n\t\t\t\t\t\t\t\t\t\uae4c\uc2ec \uc0ac\uc6d0\t\t\t\t\t\t\t\t"}]},{"userId":"a","savedName":"basic","RefOrder":[{"order":1,"user-id":"0656","name":"\n\t\t\t\t\t\t\t\t\t\uc625\ub3d9\uc218 \uc8fc\uc784\t\t\t\t\t\t\t\t"},{"order":2,"user-id":5702,"name":"\n\t\t\t\t\t\t\t\t\t\uae40\uc218\ub85c \uc0ac\uc6d0\t\t\t\t\t\t\t\t"},{"order":3,"user-id":7473,"name":"\n\t\t\t\t\t\t\t\t\t\uc774\uacbd\ubb35 \uacf5\uc7a5\uc7a5\t\t\t\t\t\t\t\t"},{"order":4,"user-id":7210,"name":"\n\t\t\t\t\t\t\t\t\t\uae4c\uc2ec \uc0ac\uc6d0\t\t\t\t\t\t\t\t"}]}]
|
||||
1
eworks/RefLine/RefLine_cjj.json
Normal file
1
eworks/RefLine/RefLine_cjj.json
Normal file
@@ -0,0 +1 @@
|
||||
[{"userId":"cjj","savedName":"\u314f\u314f\u3153\u314f","RefOrder":[{"order":1,"user-id":7067,"name":"\n\t\t\t\t\t\t\t\t\t\uae40\uc601\ubb34 \uc8fc\uc784\t\t\t\t\t\t\t\t"},{"order":2,"user-id":5702,"name":"\n\t\t\t\t\t\t\t\t\t\uae40\uc218\ub85c \uc0ac\uc6d0\t\t\t\t\t\t\t\t"},{"order":3,"user-id":7473,"name":"\n\t\t\t\t\t\t\t\t\t\uc774\uacbd\ubb35 \uacf5\uc7a5\uc7a5\t\t\t\t\t\t\t\t"}]}]
|
||||
1
eworks/RefLine/RefLine_ckn5342.json
Normal file
1
eworks/RefLine/RefLine_ckn5342.json
Normal file
@@ -0,0 +1 @@
|
||||
[{"userId":"ckn5342","savedName":"\ucc38\uc8701","RefOrder":[{"order":1,"user-id":"0656","name":"\n\t\t\t\t\t\t\t\t\t\uc625\ub3d9\uc218 \uc8fc\uc784\t\t\t\t\t\t\t\t"},{"order":2,"user-id":"0615","name":"\n\t\t\t\t\t\t\t\t\t\uc154\uc9d1 \uc0ac\uc6d0\t\t\t\t\t\t\t\t"},{"order":3,"user-id":5123,"name":"\n\t\t\t\t\t\t\t\t\t\uc548\ud604\uc12d \ucc28\uc7a5\t\t\t\t\t\t\t\t"}]}]
|
||||
1
eworks/RefLine/RefLine_mirae.json
Normal file
1
eworks/RefLine/RefLine_mirae.json
Normal file
@@ -0,0 +1 @@
|
||||
[{"userId":"mirae","savedName":"\ucc38\uc8701","RefOrder":[{"order":1,"user-id":7067,"name":"\n\t\t\t\t\t\t\t\t\t\uae40\uc601\ubb34 \uc8fc\uc784\t\t\t\t\t\t\t\t"},{"order":2,"user-id":7179,"name":"\n\t\t\t\t\t\t\t\t\t\uad8c\uc601\ucca0 \ud300\uc7a5\t\t\t\t\t\t\t\t"},{"order":3,"user-id":9992,"name":"\n\t\t\t\t\t\t\t\t\t\ub77c\ub098 \uc0ac\uc6d0\t\t\t\t\t\t\t\t"}]}]
|
||||
52
eworks/_request.php
Normal file
52
eworks/_request.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
$num = $_REQUEST["num"] ?? '';
|
||||
$e_num = $_REQUEST["e_num"] ?? 0; // int(11)
|
||||
$is_deleted = $_REQUEST["is_deleted"] ?? NULL; // tinyint(1)
|
||||
$e_viewexcept_id = $_REQUEST["e_viewexcept_id"] ?? ''; // text
|
||||
$eworks_item = $_REQUEST["eworks_item"] ?? ''; // text
|
||||
$e_title = $_REQUEST["e_title"] ?? ''; // text
|
||||
$contents = $_REQUEST["contents"] ?? ''; // text
|
||||
$registdate = $_REQUEST["registdate"] ?? ''; // datetime
|
||||
$status = $_REQUEST["status"] ?? ''; // text
|
||||
$e_line = $_REQUEST["e_line"] ?? ''; // text
|
||||
$e_line_id = $_REQUEST["e_line_id"] ?? ''; // text
|
||||
$e_confirm = $_REQUEST["e_confirm"] ?? ''; // text
|
||||
$e_confirm_id = $_REQUEST["e_confirm_id"] ?? ''; // text
|
||||
$r_line = $_REQUEST["r_line"] ?? ''; // text
|
||||
$r_line_id = $_REQUEST["r_line_id"] ?? ''; // text
|
||||
$recordtime = $_REQUEST["recordtime"] ?? ''; // datetime
|
||||
$author = $_REQUEST["author"] ?? $user_name; // text
|
||||
$author_id = $_REQUEST["author_id"] ?? $user_id; // text
|
||||
$done = $_REQUEST["done"] ?? ''; // text
|
||||
$al_askdatefrom = $_REQUEST["al_askdatefrom"] ?? ''; // date
|
||||
$al_askdateto = $_REQUEST["al_askdateto"] ?? ''; // date
|
||||
$al_item = $_REQUEST["al_item"] ?? ''; // text
|
||||
$al_part = $_REQUEST["al_part"] ?? ''; // text
|
||||
$al_usedday = $_REQUEST["al_usedday"] ?? ''; // text
|
||||
$al_content = $_REQUEST["al_content"] ?? ''; // text
|
||||
$which = $_REQUEST["which"] ?? ''; // text
|
||||
$outdate = $_REQUEST["outdate"] ?? ''; // date
|
||||
$requestdate = $_REQUEST["requestdate"] ?? ''; // date
|
||||
$indate = $_REQUEST["indate"] ?? ''; // date
|
||||
$outworkplace = $_REQUEST["outworkplace"] ?? ''; // text
|
||||
$steel_item = $_REQUEST["steel_item"] ?? ''; // text
|
||||
$spec = $_REQUEST["spec"] ?? ''; // text
|
||||
$steelnum = $_REQUEST["steelnum"] ?? ''; // text
|
||||
$company = $_REQUEST["company"] ?? ''; // text
|
||||
$request_comment = $_REQUEST["request_comment"] ?? ''; // text
|
||||
$model = $_REQUEST["model"] ?? ''; // text
|
||||
$first_writer = $_REQUEST["first_writer"] ?? ''; // text
|
||||
$update_log = $_REQUEST["update_log"] ?? ''; // text
|
||||
$supplier = $_REQUEST["supplier"] ?? ''; // text
|
||||
$suppliercost = $_REQUEST["suppliercost"] ?? ''; // text
|
||||
$inventory = $_REQUEST["inventory"] ?? ''; // text
|
||||
$payment = $_REQUEST["payment"] ?? ''; // text
|
||||
$store = $_REQUEST["store"] ?? ''; // 구매처
|
||||
$al_company = $_REQUEST["al_company"] ?? ''; // 경동,주일 부서
|
||||
$paymentdate = $_REQUEST["paymentdate"] ?? ''; // 결재일자
|
||||
$requestpaymentdate = $_REQUEST["requestpaymentdate"] ?? ''; // 지출요청일자
|
||||
$expense_data = $_REQUEST["expense_data"] ?? ''; // 지출결의서 내역(JSON)
|
||||
$companyCard = $_REQUEST["companyCard"] ?? ''; // 회사법인카드번호
|
||||
$secondordpaydate = $_REQUEST["secondordpaydate"] ?? ''; // 구매처 결재일자
|
||||
$secondordnum = $_REQUEST["secondordnum"] ?? ''; // 구매처 코드
|
||||
?>
|
||||
52
eworks/_row.php
Normal file
52
eworks/_row.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
$num = $row["num"] ?? '';
|
||||
$e_num = $row["num"] ?? 0 ; // int(11) // 반드시 num으로 _row.php에서는 받아와야 한다.
|
||||
$is_deleted = $row["is_deleted"] ?? NULL;
|
||||
$e_viewexcept_id = $row["e_viewexcept_id"] ?? ''; // text
|
||||
$eworks_item = $row["eworks_item"] ?? ''; // text
|
||||
$e_title = $row["e_title"] ?? ''; // text
|
||||
$contents = $row["contents"] ?? ''; // text
|
||||
$registdate = $row["registdate"] ?? ''; // datetime
|
||||
$status = $row["status"] ?? ''; // text
|
||||
$e_line = $row["e_line"] ?? ''; // text
|
||||
$e_line_id = $row["e_line_id"] ?? ''; // text
|
||||
$e_confirm = $row["e_confirm"] ?? ''; // text
|
||||
$e_confirm_id = $row["e_confirm_id"] ?? ''; // text
|
||||
$r_line = $row["r_line"] ?? ''; // text
|
||||
$r_line_id = $row["r_line_id"] ?? ''; // text
|
||||
$recordtime = $row["recordtime"] ?? ''; // datetime
|
||||
$author = $row["author"] ?? ''; // text
|
||||
$author_id = $row["author_id"] ?? ''; // text
|
||||
$done = $row["done"] ?? ''; // text
|
||||
$al_askdatefrom = $row["al_askdatefrom"] ?? ''; // date
|
||||
$al_askdateto = $row["al_askdateto"] ?? ''; // date
|
||||
$al_item = $row["al_item"] ?? ''; // text
|
||||
$al_part = $row["al_part"] ?? ''; // text
|
||||
$al_usedday = $row["al_usedday"] ?? ''; // text
|
||||
$al_content = $row["al_content"] ?? ''; // text
|
||||
$which = $row["which"] ?? ''; // text
|
||||
$outdate = $row["outdate"] ?? ''; // date
|
||||
$requestdate = $row["requestdate"] ?? ''; // date
|
||||
$indate = $row["indate"] ?? ''; // date
|
||||
$outworkplace = $row["outworkplace"] ?? ''; // text
|
||||
$steel_item = $row["steel_item"] ?? ''; // text
|
||||
$spec = $row["spec"] ?? ''; // text
|
||||
$steelnum = $row["steelnum"] ?? ''; // text
|
||||
$company = $row["company"] ?? ''; // text
|
||||
$request_comment = $row["request_comment"] ?? ''; // text
|
||||
$model = $row["model"] ?? ''; // text
|
||||
$first_writer = $row["first_writer"] ?? ''; // text
|
||||
$update_log = $row["update_log"] ?? ''; // text
|
||||
$supplier = $row["supplier"] ?? ''; // text
|
||||
$suppliercost = $row["suppliercost"] ?? ''; // text
|
||||
$inventory = $row["inventory"] ?? ''; // text
|
||||
$payment = $row["payment"] ?? ''; // text
|
||||
$store = $row["store"] ?? ''; // text
|
||||
$al_company = $row["al_company"] ?? ''; // text
|
||||
$paymentdate = $row["paymentdate"] ?? ''; // 결재일자
|
||||
$requestpaymentdate = $row["requestpaymentdate"] ?? ''; // 지출요청일자
|
||||
$expense_data = $row["expense_data"] ?? ''; // 지출결의서 내역(JSON)
|
||||
$companyCard = $row["companyCard"] ?? ''; // 회사법인카드번호
|
||||
$secondordpaydate = $row["secondordpaydate"] ?? ''; // 구매처 결재일자
|
||||
$secondordnum = $row["secondordnum"] ?? ''; // 구매처 코드
|
||||
?>
|
||||
88
eworks/approvalSelected.php
Normal file
88
eworks/approvalSelected.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json"); //json을 사용하기 위해 필요한 구문
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/common.php';
|
||||
|
||||
$date = date('Y-m-d H:i:s'); // 현재 시간
|
||||
|
||||
$e_nums = isset($_REQUEST["selectedIds"]) ? $_REQUEST["selectedIds"] : [];
|
||||
|
||||
require_once("eworksmydb.php");
|
||||
|
||||
function getPosition($userId, $conn) {
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
$query = "SELECT position FROM {$DB}.member WHERE id = ?"; // Assuming 'id' is the field for user ID and 'position' for the job title
|
||||
$position = '';
|
||||
|
||||
if ($stmt = mysqli_prepare($conn, $query)) {
|
||||
mysqli_stmt_bind_param($stmt, "s", $userId); // 's' is used for string type
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
|
||||
if ($row = mysqli_fetch_assoc($result)) {
|
||||
$position = $row['position']; // Assuming 'position' is the field that contains the job title
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
}
|
||||
return $position; // Returns the position as a string
|
||||
}
|
||||
|
||||
function getEConfirmValues($e_num, $conn) {
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$query = "SELECT e_confirm, e_confirm_id, e_line_id FROM {$DB}.eworks WHERE num = ?";
|
||||
$stmt = mysqli_prepare($conn, $query);
|
||||
mysqli_stmt_bind_param($stmt, "i", $e_num);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$values = mysqli_fetch_assoc($result);
|
||||
mysqli_stmt_close($stmt);
|
||||
return $values;
|
||||
}
|
||||
|
||||
foreach ($e_nums as $e_num) {
|
||||
$confirmValues = getEConfirmValues($e_num, $conn);
|
||||
$e_confirm = $confirmValues['e_confirm'];
|
||||
$e_confirm_id = $confirmValues['e_confirm_id'];
|
||||
$e_line_id = $confirmValues['e_line_id'];
|
||||
|
||||
$e_confirm_value = ($e_confirm === '' || $e_confirm === null) ? $user_name . " " . getPosition($user_id, $conn) . " " . $date : $e_confirm . '!' . $user_name . " " . getPosition($user_id, $conn) . " ". $date;
|
||||
$e_confirm_id_value = ($e_confirm_id === '' || $e_confirm_id === null) ? $user_id : $e_confirm_id . '!' . $user_id;
|
||||
|
||||
|
||||
// 결재상태 확인 및 업데이트
|
||||
$e_line_id_count = count(explode("!", $e_line_id));
|
||||
$e_confirm_count = count(explode("!", $e_confirm_id_value));
|
||||
$status = 'ing';
|
||||
// $done = "(" . $e_confirm_count . ") e_confirm_count " . $e_line_id . " + e_line_count(" . $e_line_count .")" . $e_confirm_id_value ;
|
||||
$done = null;
|
||||
|
||||
if ($e_line_id_count == $e_confirm_count) {
|
||||
// 모든 결재자가 결재를 완료했으므로 '결재완료'
|
||||
$status = 'end';
|
||||
$done = 'done';
|
||||
}
|
||||
|
||||
// 데이터 이스케이핑 및 쿼리 준비
|
||||
$e_num = mysqli_real_escape_string($conn, $e_num);
|
||||
$query = $conn->prepare("UPDATE {$DB}.eworks SET e_confirm=?, e_confirm_id=?, done=? , status=? WHERE num=?");
|
||||
$query->bind_param("ssssi", $e_confirm_value, $e_confirm_id_value, $done, $status, $e_num);
|
||||
$result = $query->execute();
|
||||
if (!$result) {
|
||||
die("Query failed: " . mysqli_error($conn));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//각각의 정보를 하나의 배열 변수에 넣어준다.
|
||||
$data = array(
|
||||
"num" => $e_num, // 이 부분은 마지막 처리된 e_num만 반영될 것입니다.
|
||||
);
|
||||
|
||||
//json 출력
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
?>
|
||||
|
||||
32
eworks/deleteApprovalLine.php
Normal file
32
eworks/deleteApprovalLine.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
error_reporting(0); // 오류 리포팅 비활성화
|
||||
header("Content-Type: application/json");
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$savedName = $_POST['savedName'] ?? '';
|
||||
$filePath = './approvalLine/approvalLine_' . $_SESSION['userid'] . '.json';
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
$data = json_decode(file_get_contents($filePath), true);
|
||||
if (is_array($data)) {
|
||||
// 결재라인 제거
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value['savedName'] === $savedName) {
|
||||
unset($data[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 파일 업데이트
|
||||
file_put_contents($filePath, json_encode(array_values($data), JSON_UNESCAPED_UNICODE));
|
||||
echo json_encode(["status" => "success", "message" => "Approval line deleted successfully"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Invalid data format"]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "File not found"]);
|
||||
}
|
||||
?>
|
||||
29
eworks/deleteRefLine.php
Normal file
29
eworks/deleteRefLine.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$savedName = $_POST['savedName'] ?? '';
|
||||
$filePath = './RefLine/RefLine_' . $_SESSION['userid'] . '.json';
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
$data = json_decode(file_get_contents($filePath), true);
|
||||
if (is_array($data)) {
|
||||
// 결재라인 제거
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value['savedName'] === $savedName) {
|
||||
unset($data[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 파일 업데이트
|
||||
file_put_contents($filePath, json_encode(array_values($data), JSON_UNESCAPED_UNICODE));
|
||||
echo json_encode(["status" => "success", "message" => "Ref line deleted successfully"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Invalid data format"]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "File not found"]);
|
||||
}
|
||||
?>
|
||||
59
eworks/deleteSelected.php
Normal file
59
eworks/deleteSelected.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json"); //json을 사용하기 위해 필요한 구문
|
||||
|
||||
isset($_REQUEST["e_num"]) ? $e_num=$_REQUEST["e_num"] : $e_num='';
|
||||
isset($_REQUEST["ripple_num"]) ? $ripple_num=$_REQUEST["ripple_num"] : $ripple_num='';
|
||||
isset($_REQUEST["SelectWork"]) ? $SelectWork = $_REQUEST["SelectWork"] : $SelectWork="";
|
||||
isset($_REQUEST["e_line"]) ? $e_line = $_REQUEST["e_line"] : $e_line="";
|
||||
isset($_REQUEST["e_line_id"]) ? $e_line_id = $_REQUEST["e_line_id"] : $e_line_id="";
|
||||
isset($_REQUEST["e_confirm"]) ? $e_confirm = $_REQUEST["e_confirm"] : $e_confirm="";
|
||||
isset($_REQUEST["eworks_item"]) ? $eworks_item = $_REQUEST["eworks_item"] : $eworks_item="";
|
||||
isset($_REQUEST["author"]) ? $author = $_REQUEST["author"] : $author="";
|
||||
isset($_REQUEST["author_id"]) ? $author_id = $_REQUEST["author_id"] : $author_id="";
|
||||
|
||||
// 여러 e_num 값을 배열로 받아옵니다.
|
||||
$e_nums = isset($_REQUEST["selectedIds"]) ? $_REQUEST["selectedIds"] : [];
|
||||
|
||||
require_once("eworksmydb.php");
|
||||
|
||||
// MySQL 연결 오류 발생 시 스크립트 종료
|
||||
if (mysqli_connect_errno()) {
|
||||
die("Failed to connect to MySQL: " . mysqli_connect_error());
|
||||
}
|
||||
|
||||
include "_request.php";
|
||||
|
||||
// viewexcept 처리 본인에게 보이지 않게 하는 메뉴
|
||||
// '제외' 작업을 처리합니다.
|
||||
foreach ($e_nums as $e_num) {
|
||||
// 데이터 이스케이핑 및 쿼리 준비
|
||||
$e_viewexcept_id = ($e_viewexcept_id === '' || $e_viewexcept_id === null) ? $user_id : $e_viewexcept_id . '!' . $user_id;
|
||||
|
||||
// 데이터 이스케이핑 및 쿼리 준비
|
||||
$e_num = mysqli_real_escape_string($conn, $e_num);
|
||||
$sqlstatement = "UPDATE " . $DB . ".eworks SET e_viewexcept_id=? WHERE num=?" ;
|
||||
$query = $conn->prepare($sqlstatement);
|
||||
$query->bind_param("si", $e_viewexcept_id, $e_num);
|
||||
$result = $query->execute();
|
||||
$result = $query->execute();
|
||||
|
||||
if (!$result) {
|
||||
die("Query failed: " . mysqli_error($conn));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//각각의 정보를 하나의 배열 변수에 넣어준다.
|
||||
$data = array(
|
||||
"num" => $e_num, // 이 부분은 마지막 처리된 e_num만 반영될 것입니다.
|
||||
"SelectWork" => $SelectWork,
|
||||
"selectedIds" => $e_nums, // 여기서 $selectedIds 대신 $e_nums를 사용합니다.
|
||||
);
|
||||
|
||||
//json 출력
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
?>
|
||||
|
||||
22
eworks/delete_ripple.php
Normal file
22
eworks/delete_ripple.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$ripple_num=$_REQUEST["ripple_num"];
|
||||
$tablename=$_REQUEST["tablename"]; //tablename 이름
|
||||
|
||||
require_once("../lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try{
|
||||
$pdo->beginTransaction();
|
||||
$sql = "delete from $DB.eworks_ripple where num = ?"; //db만 수정
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1,$ripple_num,PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$pdo->rollBack();
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
?>
|
||||
172
eworks/eworksBtn.php
Normal file
172
eworks/eworksBtn.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
// 각 상황에 따른 버튼을 구현하기 위한 부분 결재상황별 버튼이 다르게 나와야 한다.
|
||||
isset($_REQUEST["e_num"]) ? $e_num = $_REQUEST["e_num"] : $e_num="";
|
||||
isset($_REQUEST["status"]) ? $status = $_REQUEST["status"] : $status="draft";
|
||||
isset($_REQUEST["done"]) ? $done = $_REQUEST["done"] : $done="";
|
||||
?>
|
||||
|
||||
<div class="row p-1 mt-1 mb-1 justify-content-center">
|
||||
<div class="d-flex justify-content-center mb-2" id="comments-container">
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try {
|
||||
$sql_ripple = "SELECT * FROM $DB.eworks_ripple WHERE parent = ? AND is_deleted IS NULL";
|
||||
$stmh = $pdo->prepare($sql_ripple);
|
||||
$stmh->bindValue(1, $e_num, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$result = $stmh->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($result as $row_ripple) {
|
||||
$ripple_num = htmlspecialchars($row_ripple["num"], ENT_QUOTES, 'UTF-8');
|
||||
$ripple_id = htmlspecialchars($row_ripple["author_id"], ENT_QUOTES, 'UTF-8');
|
||||
$ripple_nick = htmlspecialchars($row_ripple["author"], ENT_QUOTES, 'UTF-8');
|
||||
$ripple_content = htmlspecialchars($row_ripple["content"], ENT_QUOTES, 'UTF-8');
|
||||
$ripple_content = str_replace("\n", "", $ripple_content);
|
||||
$ripple_content = str_replace(" ", " ", $ripple_content);
|
||||
$ripple_date = htmlspecialchars($row_ripple["regist_day"], ENT_QUOTES, 'UTF-8');
|
||||
?>
|
||||
<div class="card ripple-item" id="ripple-<?=$ripple_num?>" style="width:80%">
|
||||
<div class="row justify-content-center">
|
||||
<div class="card-body">
|
||||
<span class="mt-1 mb-2">▶ <?=$ripple_content?> ✔ 작성자: <?=$ripple_nick?> | <?=$ripple_date?>
|
||||
<?php
|
||||
if (isset($_SESSION["userid"])) {
|
||||
if ($_SESSION["userid"] == "admin" || $_SESSION["userid"] == $ripple_id || $_SESSION["level"] === '1') {
|
||||
echo "<a href='#' class='text-danger' onclick='eworks_delete_ripple(\"$ripple_num\")'><i class='bi bi-trash'></i> </a>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row p-1 mb-1 justify-content-center">
|
||||
<div class="card justify-content-center" style="width:80% ">
|
||||
<div class="row justify-content-center">
|
||||
<div class="card-body">
|
||||
<div class="row d-flex mt-3 mb-1 justify-content-center">
|
||||
<div class="d-flex">
|
||||
<span class="form-control badge bg-dark text-center fs-6" style="width:10%;"> <i class="bi bi-chat-dots"></i> 의견 </span>
|
||||
|
||||
<textarea rows="1" class="form-control" id="ripple_content" name="ripple_content" ></textarea>
|
||||
|
||||
<button type="button" class="form-control btn btn-dark btm-sm" style="width:10%;" onclick="eworks_insert_ripple('<?=$e_num?>')"> <i class="bi bi-floppy-fill"></i> 저장</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
|
||||
<?php
|
||||
|
||||
$myTurn = false ; // 현재 결재 차례임
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try {
|
||||
$sql = "select * from $DB.eworks where num=?";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $e_num, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC) ;
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/eworks/_row.php";
|
||||
|
||||
$arr = explode("!", $e_line_id);
|
||||
$approval_time = explode("!", $e_confirm_id);
|
||||
$last_approved_id = end($approval_time); // 마지막으로 결재한 사용자 ID
|
||||
|
||||
//나의 결재 차례인지 확인하는 로직
|
||||
if ($status !== 'reject' && $status !== 'end') {
|
||||
if (empty($e_confirm_id)) {
|
||||
// e_confirm_id가 비어 있으면 첫 번째 결재자가 현재 차례인지 확인
|
||||
$myTurn = ($arr[0] == $user_id);
|
||||
} else {
|
||||
$approval_time = explode("!", $e_confirm_id);
|
||||
$last_approved_id = end($approval_time); // 마지막으로 결재한 사용자 ID
|
||||
|
||||
$index = array_search($last_approved_id, $arr);
|
||||
if ($index !== false && isset($arr[$index + 1]) && $arr[$index + 1] == $user_id) {
|
||||
$myTurn = true; // 현재 결재 차례임
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
|
||||
if( $myTurn && $done!=='done' ) // 승인자이름에 포함되면?
|
||||
{
|
||||
print '<button id="eworks_approvalBtn" class="btn btn-primary btn-sm me-2 "><i class="bi bi-window-dock"></i> 승인</button> ';
|
||||
print '<button id="eworks_rejectBtn" class="btn btn-danger btn-sm me-2 "><i class="bi bi-arrow-counterclockwise"></i> 반려</button> ';
|
||||
print '<button id="eworks_waitBtn" class="btn btn-secondary btn-sm me-2 "><i class="bi bi-hourglass"></i>보류</button> ';
|
||||
print '<button type="button" id="eworks_closeviewBtn" class="btn btn-outline-dark btn-sm me-2"> <i class="bi bi-x-lg"></i> 닫기 </button> ';
|
||||
}
|
||||
else if( $done==='done' )
|
||||
{
|
||||
print '<button type="button" id="eworks_closeviewBtn" class="btn btn-outline-dark btn-sm me-2"> <i class="bi bi-x-lg"></i> 닫기 </button> ';
|
||||
}
|
||||
else if( $status === 'draft' || $status === '' || $status === null )
|
||||
{
|
||||
print '<button id="eworks_saveBtn" class="btn btn-dark btn-sm me-2 "><i class="bi bi-floppy-fill"></i>저장</button> ';
|
||||
print '<button id="eworks_delBtn" class="btn btn-danger btn-sm me-2 "><i class="bi bi-trash"></i> 삭제</button> ';
|
||||
print '<button id="eworks_sendBtn" class="btn btn-primary btn-sm me-2 "><i class="bi bi-window-dock"></i>상신</button> ';
|
||||
print '<button type="button" id="eworks_closeviewBtn" class="btn btn-outline-dark btn-sm me-2"> <i class="bi bi-x-lg"></i> 닫기 </button> ';
|
||||
|
||||
}
|
||||
else if( $status === 'reject' )
|
||||
{
|
||||
print '<button id="eworks_saveBtn" class="btn btn-dark btn-sm me-2 "><i class="bi bi-floppy-fill"></i>저장</button> ';
|
||||
print '<button id="eworks_approvalBtn" class="btn btn-primary btn-sm me-2 "><i class="bi bi-credit-card-2-front-fill"></i> 재승인요청</button> ';
|
||||
print '<button id="eworks_delBtn" class="btn btn-danger me-2 "><i class="bi bi-trash"></i> 삭제</button> ';
|
||||
print '<button type="button" id="eworks_closeviewBtn" class="btn btn-outline-dark btn-sm me-2"> <i class="bi bi-x-lg"></i> 닫기 </button> ';
|
||||
}
|
||||
|
||||
else if( $status === 'wait' )
|
||||
{
|
||||
print '<button id="eworks_approvalBtn" class="btn btn-primary btn-sm me-2 "><i class="bi bi-window-dock"></i> 승인</button> ';
|
||||
print '<button id="eworks_delBtn" class="btn btn-danger"><i class="bi bi-trash"></i> 삭제</button> ';
|
||||
print '<button type="button" id="eworks_closeviewBtn" class="btn btn-outline-dark btn-sm me-2"> <i class="bi bi-x-lg"></i> 닫기 </button> ';
|
||||
}
|
||||
else if( $status === 'ing' && $user_id == $author_id )
|
||||
{
|
||||
|
||||
}
|
||||
else if( $status === 'send' )
|
||||
{
|
||||
if($user_id !== $author_id)
|
||||
{
|
||||
print '<button id="eworks_approvalBtn" class="btn btn-primary btn-sm me-2 "><i class="bi bi-credit-card-2-front-fill"></i> 승인</button> ';
|
||||
print '<button type="button" id="eworks_closeviewBtn" class="btn btn-outline-dark btn-sm me-2"> <i class="bi bi-x-lg"></i> 닫기 </button> ';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<button id="eworks_recallBtn" class="btn btn-dark btn-sm me-2 "><i class="bi bi-arrow-counterclockwise"></i> 회수</button>';
|
||||
print '<button type="button" id="eworks_closeviewBtn" class="btn btn-outline-dark btn-sm me-2"> <i class="bi bi-x-lg"></i> 닫기 </button> ';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
174
eworks/eworks_nav.php
Normal file
174
eworks/eworks_nav.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
isset($_REQUEST["selnum"]) ? $selnum=$_REQUEST["selnum"] : $selnum='';
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
// 결재라인을 잡으려면 배열저장
|
||||
$eworks_lv_arr = array();
|
||||
$part_arr = array();
|
||||
$position_arr = array();
|
||||
$name_arr = array();
|
||||
$id_arr = array();
|
||||
|
||||
try{
|
||||
$sql = "select * from $DB.member WHERE division IN ('경동', '주일')";
|
||||
$stmh=$pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
array_push($name_arr, $row["name"]);
|
||||
array_push($id_arr, $row["id"]);
|
||||
array_push($eworks_lv_arr, $row["eworks_lv"]);
|
||||
array_push($part_arr, $row["division"]);
|
||||
array_push($position_arr, $row["position"]);
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
|
||||
}
|
||||
|
||||
// var_dump($eworks_lv_arr);
|
||||
// var_dump($DB);
|
||||
|
||||
// 결재권자 여부를 확인하기 전에 $foundUser1을 초기화
|
||||
$foundUser1 = 0;
|
||||
|
||||
// 결재권자 배열 넣기
|
||||
$firstStep = array();
|
||||
$firstStepID = array();
|
||||
for($i = 0; $i < count($eworks_lv_arr); $i++) {
|
||||
if((int)$eworks_lv_arr[$i] == 2 or (int)$eworks_lv_arr[$i] == 1) {
|
||||
array_push($firstStep, $name_arr[$i] . " " . $position_arr[$i]);
|
||||
array_push($firstStepID, $id_arr[$i]);
|
||||
// 현재 사용자가 결재권자 목록에 있으면 $foundUser1을 1로 설정
|
||||
if ($user_id === $id_arr[$i]) {
|
||||
$foundUser1 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$status_arr = array();
|
||||
|
||||
function countEworksStatus($pdo, $user_id, $viewCondition, $isApprover, $DB) {
|
||||
|
||||
$counts = array("draft" => 0, "send" => 0, "noend" => 0, "ing" => 0, "end" => 0, "reject" => 0, "wait" => 0, "refer" => 0, "deleted" => 0);
|
||||
|
||||
// SQL 기본 쿼리 설정
|
||||
if ($isApprover) {
|
||||
$sqlBase = "SELECT * FROM {$DB}.eworks WHERE CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND is_deleted IS NULL";
|
||||
} else {
|
||||
$sqlBase = "SELECT * FROM {$DB}.eworks WHERE author_id='$user_id' AND is_deleted IS NULL";
|
||||
}
|
||||
$sql = $sqlBase . $viewCondition;
|
||||
|
||||
try {
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
|
||||
while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/eworks/_row.php";
|
||||
|
||||
if($isApprover)
|
||||
{
|
||||
$arr = explode("!", $e_line_id);
|
||||
$approval_time = explode("!", $e_confirm_id);
|
||||
$last_user_id = end($arr); // e_line_id의 마지막 사용자 ID
|
||||
$last_approved_id = end($approval_time); // e_confirm_id의 마지막 결재 ID
|
||||
|
||||
foreach ($arr as $id) {
|
||||
if ($id == $user_id) {
|
||||
if ($status !== 'reject' && $status !== 'wait' && $status !== 'refer' && $status !== 'end')
|
||||
{
|
||||
if ($id == $last_user_id) { // 마지막 사용자인 경우
|
||||
if ($last_approved_id == $id) {
|
||||
$status = 'end'; // '결재완료'
|
||||
} else {
|
||||
$status = 'noend'; // '미결'
|
||||
}
|
||||
} else { // 마지막 사용자가 아닌 경우
|
||||
if (in_array($id, $approval_time)) {
|
||||
$status = 'ing'; // '진행중'
|
||||
} else {
|
||||
$status = 'noend'; // '미결'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($counts[$status])) {
|
||||
$counts[$status]++;
|
||||
}
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
|
||||
return $counts;
|
||||
}
|
||||
|
||||
// 함수 호출
|
||||
$viewconVisible = " AND CONCAT('!', e_viewexcept_id, '!') NOT LIKE '%!{$user_id}!%' ";
|
||||
$visibleCounts = countEworksStatus($pdo, $user_id, $viewconVisible, $foundUser1, $DB);
|
||||
|
||||
$viewconDeleted = " AND CONCAT('!', e_viewexcept_id, '!') LIKE '%!{$user_id}!%' ";
|
||||
$deletedCounts = countEworksStatus($pdo, $user_id, $viewconDeleted, $foundUser1, $DB);
|
||||
|
||||
// 각 상태별 카운트 할당
|
||||
$data = array(
|
||||
"val1" => $visibleCounts["draft"],
|
||||
"val2" => $visibleCounts["send"],
|
||||
"val3" => $visibleCounts["noend"],
|
||||
"val4" => $visibleCounts["ing"],
|
||||
"val5" => $visibleCounts["end"],
|
||||
"val6" => $visibleCounts["reject"],
|
||||
"val7" => $visibleCounts["wait"],
|
||||
"val8" => $visibleCounts["refer"],
|
||||
"val9" => $deletedCounts["deleted"]
|
||||
);
|
||||
|
||||
// 탭 데이터 설정
|
||||
$tabs = array(
|
||||
array("작성", 1, "bi-pencil-square", $data["val1"]),
|
||||
array("상신", 2, "bi-cloud-arrow-up", $data["val2"]),
|
||||
array("미결", 3, "bi-patch-minus", $data["val3"]),
|
||||
array("진행", 4, "bi-arrow-right-circle", $data["val4"]),
|
||||
array("결재", 5, "bi-journal-check", $data["val5"]),
|
||||
array("반려", 6, "bi-slash-circle", $data["val6"]),
|
||||
array("보류", 7, "bi-hourglass", $data["val7"]),
|
||||
array("참조", 8, "bi-info-circle", $data["val8"]),
|
||||
array("삭제", 9, "bi-trash", $data["val9"])
|
||||
);
|
||||
?>
|
||||
|
||||
<ul class="nav nav-tabs justify-content-center">
|
||||
<?php foreach ($tabs as $tab) {
|
||||
$label = $tab[0];
|
||||
$tabId = $tab[1];
|
||||
$iconClass = $tab[2];
|
||||
$count = $tab[3];
|
||||
$active = '';
|
||||
if($selnum == $tabId)
|
||||
$active = 'active';
|
||||
// if($eworks_lv && ($tabId>=3) )
|
||||
if(!$eworks_lv && ($tabId>0) || $eworks_lv && ($tabId>=3))
|
||||
{
|
||||
?>
|
||||
<li class="nav-item">
|
||||
<div class="nav-link text-dark <?php echo $active;?> " id="navtab<?php echo $tabId; ?>" onclick="seltab(<?php echo $tabId; ?>);">
|
||||
<i class="bi <?php echo $iconClass; ?>"></i> <?php echo $label; ?>
|
||||
<?php if ($count > 0) { ?>
|
||||
<span class="badge bg-primary"><?php echo $count; ?></span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
75
eworks/eworks_ripple.php
Normal file
75
eworks/eworks_ripple.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
isset($_REQUEST["e_num"]) ? $e_num = $_REQUEST["e_num"] : $e_num = "";
|
||||
isset($_REQUEST["page"]) ? $page = $_REQUEST["page"] : $page = 1;
|
||||
|
||||
// 데이터베이스 연결
|
||||
|
||||
require_once("eworksmydb.php");
|
||||
|
||||
$tablename = 'eworks_ripple';
|
||||
|
||||
// MySQL 연결 오류 발생 시 스크립트 종료
|
||||
if (mysqli_connect_errno()) {
|
||||
die("Failed to connect to MySQL: " . mysqli_connect_error());
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="row p-1 m-1 mt-1 mb-1 justify-content-center">
|
||||
<?php
|
||||
$sql_ripple = "SELECT * FROM " . $DB . ".eworks_ripple WHERE parent=?";
|
||||
if ($stmt = mysqli_prepare($conn, $sql_ripple)) {
|
||||
mysqli_stmt_bind_param($stmt, "s", $e_num);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
|
||||
while ($row_ripple = mysqli_fetch_assoc($result)) {
|
||||
$ripple_num = $row_ripple["num"];
|
||||
$ripple_id = $row_ripple["id"];
|
||||
$ripple_nick = $row_ripple["nick"];
|
||||
$ripple_content = str_replace("\n", "", $row_ripple["content"]);
|
||||
$ripple_content = str_replace(" ", " ", $ripple_content);
|
||||
$ripple_date = $row_ripple["regist_day"];
|
||||
?>
|
||||
<div class="card" style="width:80%">
|
||||
<div class="row justify-content-center">
|
||||
<div class="card-body">
|
||||
<span class="mt-1 mb-2">▶ <?=$ripple_content?> ✔ 작성자: <?=$ripple_nick?> | <?=$ripple_date?>
|
||||
<?php
|
||||
if (isset($_SESSION["userid"])) {
|
||||
if ($_SESSION["userid"] == "admin" || $_SESSION["userid"] == $ripple_id || $_SESSION["level"] === 1) {
|
||||
echo "<a href='#' onclick='rippledelete(\"$tablename\", \"$e_num\", \"$ripple_num\", \"$page\")'>[삭제]</a>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function rippledelete(tablename, e_num, ripple_num, page) {
|
||||
Swal.fire({
|
||||
title: '댓글 삭제',
|
||||
text: "정말 삭제하시겠습니까?",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: '삭제',
|
||||
cancelButtonText: '취소'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = `delete_ripple.php?tablename=${tablename}&e_num=${e_num}&ripple_num=${ripple_num}&page=${page}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
27
eworks/eworksmydb.php
Normal file
27
eworks/eworksmydb.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// .env 파일 로드
|
||||
$envFile = $_SERVER['DOCUMENT_ROOT'] . '/.env';
|
||||
if (file_exists($envFile)) {
|
||||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos($line, '=') !== false && strpos($line, '#') !== 0) {
|
||||
list($key, $value) = explode('=', $line, 2);
|
||||
$_ENV[trim($key)] = trim($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 데이터베이스 연결 정보
|
||||
$host = $_ENV['DB_HOST'] ?? 'localhost';
|
||||
$dbname = $_ENV['DB_NAME'] ?? 'chandj';
|
||||
$username = $_ENV['DB_USER'] ?? 'chandj';
|
||||
$password = $_ENV['DB_PASS'] ?? '';
|
||||
|
||||
// MySQL 데이터베이스 연결
|
||||
$conn = mysqli_connect($host, $username, $password, $dbname);
|
||||
|
||||
// MySQL 연결 오류 발생 시 스크립트 종료
|
||||
if (mysqli_connect_errno()) {
|
||||
die("Failed to connect to MySQL: " . mysqli_connect_error());
|
||||
}
|
||||
?>
|
||||
25
eworks/getApprovalLine.php
Normal file
25
eworks/getApprovalLine.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// POST 데이터 수신
|
||||
$savedName = $_POST['savedName'] ?? '';
|
||||
$filePath = './approvalLine/approvalLine_' . $_SESSION['userid'] . '.json';
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
$data = json_decode(file_get_contents($filePath), true);
|
||||
|
||||
foreach ($data as $approvalLine) {
|
||||
if ($approvalLine['savedName'] === $savedName) {
|
||||
echo json_encode($approvalLine, JSON_UNESCAPED_UNICODE);
|
||||
// echo json_encode(["status" => "success", "num" => "num"], JSON_UNESCAPED_UNICODE);
|
||||
// echo json_encode(array('status' => 'success', 'message' => 'Approval line saved successfully.'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
25
eworks/getApprovalLines.php
Normal file
25
eworks/getApprovalLines.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
error_reporting(0); // 오류 리포팅 비활성화
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$filePath = './approvalLine/approvalLine_' . $_SESSION['userid'] . '.json';
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
$data = json_decode(file_get_contents($filePath), true);
|
||||
$jsonData = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
echo $jsonData;
|
||||
} else {
|
||||
echo json_encode(["error" => "JSON encoding error"]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode([]);
|
||||
}
|
||||
|
||||
?>
|
||||
29
eworks/getRefLine.php
Normal file
29
eworks/getRefLine.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
error_reporting(0); // 오류 리포팅 비활성화
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// POST 데이터 수신
|
||||
$savedName = $_POST['savedName'] ?? '';
|
||||
$filePath = './RefLine/RefLine_' . $_SESSION['userid'] . '.json';
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
$data = json_decode(file_get_contents($filePath), true);
|
||||
|
||||
foreach ($data as $RefLine) {
|
||||
if ($RefLine['savedName'] === $savedName) {
|
||||
echo json_encode($RefLine, JSON_UNESCAPED_UNICODE);
|
||||
// echo json_encode(["status" => "success", "num" => "num"], JSON_UNESCAPED_UNICODE);
|
||||
// echo json_encode(array('status' => 'success', 'message' => 'Ref line saved successfully.'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
21
eworks/getRefLines.php
Normal file
21
eworks/getRefLines.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$filePath = './RefLine/RefLine_' . $_SESSION['userid'] . '.json';
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
$data = json_decode(file_get_contents($filePath), true);
|
||||
$jsonData = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
echo $jsonData;
|
||||
} else {
|
||||
echo json_encode(["error" => "JSON encoding error"]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode([]);
|
||||
}
|
||||
|
||||
?>
|
||||
30
eworks/insert_ripple.php
Normal file
30
eworks/insert_ripple.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$e_num=$_REQUEST["e_num"];
|
||||
$page=$_REQUEST["page"];
|
||||
$tablename=$_REQUEST["tablename"]; //tablename 이름
|
||||
$ripple_content=$_REQUEST["ripple_content"];
|
||||
|
||||
require_once("../lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
|
||||
try{
|
||||
$pdo->beginTransaction();
|
||||
$sql = "insert into " . $DB . ".eworks_ripple(parent, id, name, nick, content, regist_day) ";
|
||||
$sql.= "values(?, ?, ?, ?, ?,now())";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $e_num, PDO::PARAM_STR);
|
||||
$stmh->bindValue(2, $_SESSION["userid"], PDO::PARAM_STR);
|
||||
$stmh->bindValue(3, $_SESSION["name"], PDO::PARAM_STR);
|
||||
$stmh->bindValue(4, $_SESSION["nick"], PDO::PARAM_STR);
|
||||
$stmh->bindValue(5, $ripple_content, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
|
||||
} catch (PDOException $Exception) {
|
||||
$pdo->rollBack();
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
?>
|
||||
486
eworks/list.php
Normal file
486
eworks/list.php
Normal file
@@ -0,0 +1,486 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
?>
|
||||
|
||||
<div id="eworks_list" style="height:480px;" class="mb-1">
|
||||
<!-- 로딩 인디케이터 -->
|
||||
<div id="loadingIndicator" style="display: none;">
|
||||
<div class="loader"></div>
|
||||
</div>
|
||||
|
||||
<table class="table table-hover table-sm" id="myEworks_Table" >
|
||||
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
// 결재라인을 잡으려면 배열저장
|
||||
$eworks_lv_arr = array();
|
||||
$part_arr = array();
|
||||
$position_arr = array();
|
||||
$name_arr = array();
|
||||
$id_arr = array();
|
||||
|
||||
try{
|
||||
$sql="select * from $DB.member ";
|
||||
$stmh=$pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
if($row["division"] =='경동' || $row["division"] =='주일')
|
||||
{
|
||||
array_push($name_arr, $row["name"]);
|
||||
array_push($id_arr, $row["id"]);
|
||||
array_push($eworks_lv_arr, $row["eworks_lv"]);
|
||||
array_push($part_arr, $row["division"]);
|
||||
array_push($position_arr, $row["position"]);
|
||||
}
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
|
||||
}
|
||||
|
||||
// var_dump($eworks_lv_arr);
|
||||
|
||||
// 결재권자 배열 넣기
|
||||
$firstStep = array();
|
||||
$firstStepID = array();
|
||||
for($i=0;$i<count($eworks_lv_arr);$i++)
|
||||
{
|
||||
if((int)$eworks_lv_arr[$i] === 2 or (int)$eworks_lv_arr[$i] === 1 )
|
||||
{
|
||||
array_push($firstStep, $name_arr[$i] . " " . $position_arr[$i] );
|
||||
array_push($firstStepID, $id_arr[$i] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
isset($_REQUEST["eworksPage"]) ? $eworksPage=$_REQUEST["eworksPage"] : $eworksPage='';
|
||||
isset($_REQUEST["EworksSearch"]) ? $EworksSearch=$_REQUEST["EworksSearch"] : $EworksSearch='';
|
||||
isset($_REQUEST["eworksel"]) ? $eworksel=$_REQUEST["eworksel"] : $eworksel='draft';
|
||||
isset($_REQUEST["author_id"]) ? $author_id=$_REQUEST["author_id"] : $author_id='';
|
||||
isset($_REQUEST["eworksPage"]) ? $eworksPage=$_REQUEST["eworksPage"] : $eworksPage=1;
|
||||
|
||||
if((int)$eworksPage<1) $eworksPage=1;
|
||||
|
||||
$scale = 8; // 한 페이지에 보여질 게시글 수
|
||||
$page_scale = 15; // 한 페이지당 표시될 페이지 수 10페이지
|
||||
$first_num = ($eworksPage-1) * $scale; // 리스트에 표시되는 게시글의 첫 순번.
|
||||
|
||||
$now = date("Y-m-d"); // 현재 날짜와 크거나 같으면 출고예정으로 구분
|
||||
|
||||
$where = " ";
|
||||
$andwhere = " ";
|
||||
|
||||
// 결재 이름이 있는 경우
|
||||
$eworks_admin = 0; // 1차 결재권자
|
||||
|
||||
for($i = 0; $i < count($firstStepID); $i++) {
|
||||
if($user_id === $firstStepID[$i]) {
|
||||
$eworks_admin = 1;
|
||||
break; // 일치하는 경우가 발견되면 루프를 종료
|
||||
}
|
||||
}
|
||||
|
||||
// 조건을 만들어서 결재권자 올리는 분들의 구분이 있어야 한다.
|
||||
|
||||
// view가 보이지 않는 설정 찾기
|
||||
$viewcon = " AND CONCAT('!', e_viewexcept_id, '!') NOT LIKE '%!{$user_id}!%' " ;
|
||||
// view 설정 찾기
|
||||
$viewconNone = " AND CONCAT('!', e_viewexcept_id, '!') LIKE '%!{$user_id}!%' " ;
|
||||
|
||||
if($eworks_admin)
|
||||
{
|
||||
// 결재권자인 경우
|
||||
// 상태별 조건 설정
|
||||
switch($eworksel) {
|
||||
case 'draft':
|
||||
$where = "WHERE author_id = '$user_id' AND status = '$eworksel' AND is_deleted IS NULL" . $viewcon ;
|
||||
$andwhere = "AND author_id = '$user_id' AND status = '$eworksel' AND is_deleted IS NULL" . $viewcon ;
|
||||
break;
|
||||
case 'send':
|
||||
// 첫 번째 결재권자이며, 문서 상태가 '상신'인 경우
|
||||
$all = "CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' " .
|
||||
"AND CONCAT('!', e_confirm_id, '!') = '!'" . // 아직 아무도 결재하지 않았음
|
||||
"AND LOCATE('{$user_id}', e_line_id) = 1 " . // e_line_id의 첫 번째 결재권자임
|
||||
"AND status = 'send' " . // 문서 상태가 '상신'
|
||||
"AND is_deleted IS NULL " . $viewcon;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
case 'noend': // 미결인 경우
|
||||
// 첫 번째 결재권자에 대해 '상신' 상태를 '미결'로 처리
|
||||
// 그리고 나머지 결재권자에 대해서는 다음 결재자가 되는 경우를 처리
|
||||
$all = "CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' " .
|
||||
"AND ( " .
|
||||
" (CONCAT('!', e_confirm_id, '!') = '!!' AND LOCATE('{$user_id}', e_line_id) = 1 AND status = 'send') " .
|
||||
" OR " .
|
||||
" (CONCAT('!', e_confirm_id, '!') NOT LIKE '%!{$user_id}!%' AND INSTR(CONCAT('!', e_line_id, '!'), CONCAT('!', SUBSTRING_INDEX(e_confirm_id, '!', -1), '!', '{$user_id}', '!')) > 0 AND status != 'send')" .
|
||||
") " .
|
||||
"AND is_deleted IS NULL AND status != 'end' AND status != 'reject' AND status != 'wait'" . $viewcon;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'ing': // 진행중인 경우
|
||||
$all = "(author_id = '$user_id' OR CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%') " .
|
||||
"AND CONCAT('!', e_confirm_id, '!') LIKE '%!{$user_id}!%' " .
|
||||
"AND is_deleted IS NULL AND status != 'end' AND status != 'reject' AND status != 'wait' AND status != 'noend'" . $viewcon;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'end': // 결재완료인 경우
|
||||
$all = "CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND CONCAT('!', e_confirm_id, '!') LIKE '%!{$user_id}!%' AND is_deleted IS NULL AND status = 'end'" . $viewcon ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'reject': // 반려인 경우
|
||||
$all = "CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND status = 'reject' AND is_deleted IS NULL" . $viewcon ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'wait': // 보류인 경우
|
||||
$all = "CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND status = 'wait' AND is_deleted IS NULL" . $viewcon ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'refer': // 참조인 경우
|
||||
$all = "CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND status = 'refer' AND is_deleted IS NULL" . $viewcon ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'trash': // trash
|
||||
$all = " is_deleted IS NULL" . $viewconNone ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
// 기타 다른 상태들을 여기에 추가할 수 있습니다.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 결재권자가 아닌경우
|
||||
// 상태별 조건 설정
|
||||
switch($eworksel) {
|
||||
case 'draft':
|
||||
$where = "WHERE author_id = '$user_id' AND status = '$eworksel' AND is_deleted IS NULL" . $viewcon ;
|
||||
$andwhere = "AND author_id = '$user_id' AND status = '$eworksel' AND is_deleted IS NULL" . $viewcon ;
|
||||
break;
|
||||
case 'send':
|
||||
// 첫 번째 결재권자이며, 문서 상태가 '상신'인 경우
|
||||
$all = "CONCAT('!', author_id, '!') LIKE '%!{$user_id}!%' " .
|
||||
"AND status = 'send' " . // 문서 상태가 '상신' send인 경우 수정
|
||||
"AND is_deleted IS NULL " . $viewcon;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'noend': // 미결인 경우
|
||||
// 첫 번째 결재권자에 대해 '상신' 상태를 '미결'로 처리
|
||||
// 그리고 나머지 결재권자에 대해서는 다음 결재자가 되는 경우를 처리
|
||||
$all = "CONCAT('!', author_id, '!') LIKE '%!{$user_id}!%' " .
|
||||
"AND ( " .
|
||||
" (CONCAT('!', e_confirm_id, '!') = '!!' AND LOCATE('{$user_id}', author_id) = 1 AND status = 'send') " .
|
||||
" OR " .
|
||||
" (CONCAT('!', e_confirm_id, '!') NOT LIKE '%!{$user_id}!%' AND INSTR(CONCAT('!', author_id, '!'), CONCAT('!', SUBSTRING_INDEX(e_confirm_id, '!', -1), '!', '{$user_id}', '!')) > 0 AND status != 'send')" .
|
||||
") " .
|
||||
"AND is_deleted IS NULL AND status != 'end' AND status != 'reject' AND status != 'wait'" . $viewcon;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'ing': // 진행중인 경우
|
||||
$all = "(author_id = '$user_id' OR CONCAT('!', author_id, '!') LIKE '%!{$user_id}!%') " .
|
||||
"AND is_deleted IS NULL AND status != 'end' AND status != 'reject' AND status != 'wait' AND status != 'noend'" . $viewcon;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'end': // 결재완료인 경우
|
||||
$all = "CONCAT('!', author_id, '!') LIKE '%!{$user_id}!%' AND is_deleted IS NULL AND status = 'end'" . $viewcon ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'reject': // 반려인 경우
|
||||
$all = "CONCAT('!', author_id, '!') LIKE '%!{$user_id}!%' AND status = 'reject' AND is_deleted IS NULL" . $viewcon ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'wait': // 보류인 경우
|
||||
$all = "CONCAT('!', author_id, '!') LIKE '%!{$user_id}!%' AND status = 'wait' AND is_deleted IS NULL" . $viewcon ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'refer': // 참조인 경우
|
||||
$all = "CONCAT('!', author_id, '!') LIKE '%!{$user_id}!%' AND status = 'refer' AND is_deleted IS NULL" . $viewcon ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
|
||||
case 'trash': // trash
|
||||
$all = " is_deleted IS NULL" . $viewconNone ;
|
||||
$where = "WHERE " . $all;
|
||||
$andwhere = "AND " . $all;
|
||||
break;
|
||||
// 기타 다른 상태들을 여기에 추가할 수 있습니다.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 결재자인 경우는 결재가 진행된 것 완료된 것등 구분해서 표시해야 한다.
|
||||
$orderby=" order by registdate desc ";
|
||||
|
||||
$a= " " . $orderby . " limit $first_num, $scale";
|
||||
$b= " " . $orderby ;
|
||||
|
||||
// $total_row 계산
|
||||
|
||||
if ($EworksSearch == "") {
|
||||
$sqlcon = "select * from $DB.eworks " . $where;
|
||||
} elseif ($EworksSearch != "") {
|
||||
$sqlcon = "select * from $DB.eworks where ((e_title like '%$EworksSearch%') or (contents like '%$EworksSearch%') or (e_line like '%$EworksSearch%') or (r_line like '%$EworksSearch%')) " . $andwhere;
|
||||
}
|
||||
|
||||
try {
|
||||
$allstmh = $pdo->query($sqlcon);
|
||||
$total_row = $allstmh->rowCount();
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
|
||||
// 페이지 계산 로직
|
||||
if ($total_row <= $scale) {
|
||||
$eworksPage = 1;
|
||||
} else {
|
||||
if ($total_row < ($eworksPage - 1) * $scale) {
|
||||
$eworksPage = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$first_num = ($eworksPage - 1) * $scale;
|
||||
|
||||
// SQL 쿼리 문장 구성
|
||||
$a= " " . $orderby . " limit $first_num, $scale";
|
||||
|
||||
if ($EworksSearch == "") {
|
||||
$sql = "select * from $DB.eworks " . $where . $a;
|
||||
} elseif ($EworksSearch != "") {
|
||||
$sql = "select * from $DB.eworks where ((e_title like '%$EworksSearch%') or (contents like '%$EworksSearch%') or (e_line like '%$EworksSearch%') or (r_line like '%$EworksSearch%')) " . $andwhere . $a;
|
||||
}
|
||||
|
||||
try{
|
||||
$allstmh = $pdo->query($sqlcon); // 검색 조건에 맞는 쿼리 전체 개수
|
||||
$temp2=$allstmh->rowCount();
|
||||
$stmh = $pdo->query($sql); // 검색조건에 맞는글 stmh
|
||||
|
||||
$total_row = $temp2; // 전체 글수
|
||||
|
||||
// 페이지가 넘어간 경우는 1페이지로 만들어주는 로직
|
||||
if($total_row < ($eworksPage-1) * $scale)
|
||||
$eworksPage = 1;
|
||||
|
||||
$total_page = ceil($total_row / $scale); // 검색 전체 페이지 블록 수
|
||||
$current_page = ceil($eworksPage/$page_scale); //현재 페이지 블록 위치계산
|
||||
|
||||
if ($eworksPage<1)
|
||||
$start_num=$total_row; // 페이지당 표시되는 첫번째 글순번
|
||||
else
|
||||
$start_num=$total_row-($eworksPage-1) * $scale;
|
||||
|
||||
$count = $stmh->rowCount();
|
||||
|
||||
if($count<1){
|
||||
print '<div class="row d-flex mt-3 p-1 mb-1 justify-content-center" > 자료가 없습니다. </div>';
|
||||
} else
|
||||
{
|
||||
$start_num = 0;
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/eworks/_row.php";
|
||||
|
||||
switch ($status) {
|
||||
case 'draft' :
|
||||
$statusStr = "작성";
|
||||
break;
|
||||
case 'send' :
|
||||
$statusStr = "상신";
|
||||
break;
|
||||
case 'noend' :
|
||||
$statusStr = "미결";
|
||||
break;
|
||||
case 'ing' :
|
||||
$statusStr = "진행";
|
||||
break;
|
||||
case 'end' :
|
||||
$statusStr = "결재완료";
|
||||
break;
|
||||
case 'reject' :
|
||||
$statusStr = "반려";
|
||||
break;
|
||||
case 'wait' :
|
||||
$statusStr = "보류";
|
||||
break;
|
||||
case 'refer' :
|
||||
$statusStr = "참조";
|
||||
break;
|
||||
}
|
||||
|
||||
$prograssStr = '';
|
||||
|
||||
//print $e_line;
|
||||
$arr = explode("!",$e_line_id);
|
||||
$arr_str = explode("!",$e_line);
|
||||
|
||||
// 결재시간 추출해서 조합하기
|
||||
$approval_time = explode("!",$e_confirm_id);
|
||||
$approval_str = explode("!",$e_confirm);
|
||||
|
||||
for($i=0;$i<count($arr);$i++)
|
||||
if($approval_time[$i] !== '' && $approval_time[$i] !== null)
|
||||
$prograssStr .= $approval_str[$i] . '<br>';
|
||||
else
|
||||
$prograssStr .= $arr_str[$i] . " " . '<br>';
|
||||
// print count($approval_time);
|
||||
|
||||
$e_viewexcept_id_value = explode("!",$e_viewexcept_id);
|
||||
$e_viewexcept_exist = 0;
|
||||
if (in_array($user_id, $e_viewexcept_id_value))
|
||||
$e_viewexcept_exist = 1;
|
||||
|
||||
// print $sql;
|
||||
if($start_num<1)
|
||||
{
|
||||
|
||||
$Eworks_record_num = 0;
|
||||
|
||||
?>
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th class="text-center" style="width:5%;">
|
||||
<input type="checkbox" id="checkAll" class="master-checkbox" />
|
||||
<label for="checkAll" class="checkbox-numbered-label"></label>
|
||||
</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" > 결재진행</th>
|
||||
<th class="text-center" > 참조자</th>
|
||||
<th class="text-center" > 제목</th>
|
||||
|
||||
<?php if($e_viewexcept_exist) { ?>
|
||||
<th class="text-center align-items-center" > <i class="bi bi-skip-backward"></i> 복구 </th>
|
||||
<?php } else if($status === 'end') { ?>
|
||||
<th class="text-center align-items-center" >
|
||||
<button type="button" class="btn btn-outline-danger btn-sm" id="selectedDeleteBtn" onclick="deleteSelectedEworks()">
|
||||
<i class="bi bi-trash"></i> 삭제
|
||||
</button>
|
||||
</th>
|
||||
<?php } else if($eworks_admin && ($status === 'ing' or $status === 'send' ) ) { ?>
|
||||
<th class="text-center align-items-center" >
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="approvalselectedBtn" onclick="approvalSelectedEworks()">
|
||||
<i class="bi bi-duffle"></i> 결재
|
||||
</button>
|
||||
</th>
|
||||
<?php } ?>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php } ?>
|
||||
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<input type="checkbox" class="checkItem" style="width:5%;" id="checkItem<?= $Eworks_record_num + 1 ?>" data-id="<?= $e_num ?>" />
|
||||
<label for="checkItem<?=($Eworks_record_num+1)?>" class="checkbox-numbered-label"> <?=($Eworks_record_num+1)?></label>
|
||||
</td>
|
||||
<td class="text-center" onclick="javascript:viewEworks_detail('<?=$e_num?>','<?=$eworksPage?>');"> <?=$eworks_item?> </td>
|
||||
<td class="text-center" onclick="javascript:viewEworks_detail('<?=$e_num?>','<?=$eworksPage?>');"><?=$registdate?></td>
|
||||
<td class="text-center"
|
||||
onclick="javascript:viewEworks_detail('<?=$e_num?>','<?=$eworksPage?>');">
|
||||
<?php if ($al_item === '연차'): ?>
|
||||
<?=$al_item?> : <?=$al_askdatefrom?> ~ <br>
|
||||
<?=$al_askdateto?> (<?=$al_usedday?>일)
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-center" onclick="javascript:viewEworks_detail('<?=$e_num?>','<?=$eworksPage?>');"><?=$author?></td>
|
||||
<td class="text-center" onclick="javascript:viewEworks_detail('<?=$e_num?>','<?=$eworksPage?>');"><?=$statusStr?></td>
|
||||
<td class="text-center" onclick="javascript:viewEworks_detail('<?=$e_num?>','<?=$eworksPage?>');"><?=$prograssStr?></td>
|
||||
<?php
|
||||
// 표시할 문자열 길이를 제한
|
||||
$display_text = mb_strlen($r_line) > 10 ? mb_substr($r_line, 0, 8) . '...' : $r_line;
|
||||
?>
|
||||
<td class="text-start" onclick="javascript:viewEworks_detail('<?=$e_num?>','<?=$eworksPage?>');" title="<?= htmlspecialchars($r_line, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?= htmlspecialchars($display_text, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</td>
|
||||
|
||||
<td class="text-start" onclick="javascript:viewEworks_detail('<?=$e_num?>','<?=$eworksPage?>');" ><?=iconv_substr($e_title,0,30,"utf-8")?> </td>
|
||||
<?php if($e_viewexcept_exist) { ?>
|
||||
<td class="text-center" >
|
||||
<button type="button" class="btn btn-outline-dark btn-sm" id="eworks_restoreBtn" onclick="restore('<?=$e_num?>','<?=$eworksPage?>');"> <i class="bi bi-skip-backward"></i>
|
||||
</button>
|
||||
</td>
|
||||
<?php } else if($status === 'end') { ?>
|
||||
<td class="text-center" >
|
||||
<button type="button" class="btn btn-outline-danger btn-sm" id="eworks_viewExceptBtn" onclick="viewExcept('<?=$e_num?>','<?=$eworksPage?>');"> <i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
<?php } else if($eworks_admin && $status === 'ing') { ?>
|
||||
<td class="text-center" >
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="eworks_approvalviewExceptBtn" onclick="approvalviewExcept('<?=$e_num?>','<?=$eworksPage?>');"> <i class="bi bi-duffle"></i>
|
||||
</button>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php
|
||||
$Eworks_record_num++;
|
||||
$start_num++;
|
||||
}
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
|
||||
// 페이지 구분 블럭의 첫 페이지 수 계산 ($start_page)
|
||||
$start_page = ($current_page - 1) * $page_scale + 1;
|
||||
// 페이지 구분 블럭의 마지막 페이지 수 계산 ($end_page)
|
||||
$end_page = $start_page + $page_scale - 1;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="row row-cols-auto mt-1 mb-2 justify-content-center align-items-center">
|
||||
<?php
|
||||
if($eworksPage!=1 && $eworksPage>$page_scale){
|
||||
$prev_page = $eworksPage - $page_scale;
|
||||
// 이전 페이지값은 해당 페이지 수에서 리스트에 표시될 페이지수 만큼 감소
|
||||
if($prev_page <= 0)
|
||||
$prev_page = 1; // 만약 감소한 값이 0보다 작거나 같으면 1로 고정
|
||||
print '<button class="btn btn-outline-secondary btn-sm" type="button" onclick="javascript:eworks_movetoPage(' . $prev_page . ');"> ◀ </button> ' ;
|
||||
}
|
||||
for($i=$start_page; $i<=$end_page && $i<= $total_page; $i++) { // [1][2][3] 페이지 번호 목록 출력
|
||||
if($eworksPage==$i) // 현재 위치한 페이지는 링크 출력을 하지 않도록 설정.
|
||||
print '<span class="text-secondary" > ' . $i . ' </span>';
|
||||
else
|
||||
print '<button class="btn btn-outline-secondary btn-sm" type="button" onclick="javascript:eworks_movetoPage(' . $i . ');"> ' . $i . '</button> ' ;
|
||||
}
|
||||
|
||||
if($eworksPage<$total_page){
|
||||
$next_page = $eworksPage + $page_scale;
|
||||
if($next_page > $total_page)
|
||||
$next_page = $total_page;
|
||||
print '<button class="btn btn-outline-secondary btn-sm" type="button" onclick="javascript:eworks_movetoPage(' . $next_page . ');"> ▶ </button> ' ;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
48
eworks/list_form.php
Normal file
48
eworks/list_form.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<!--전자결재 리스트창 -->
|
||||
<!--Extra Full Modal -->
|
||||
<div class="modal fade" id="eworks_form" tabindex="-90">
|
||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-full" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<?php if($mycompany ==='경동')
|
||||
$companydir = "../img/companylogo0.png";
|
||||
else
|
||||
$companydir = "../img/companylogo1.png";
|
||||
?>
|
||||
|
||||
<h5 class="modal-title"><img src="<?=$companydir?>" style="width:50%;"> 전자결재 </h5>
|
||||
<button type="button" class="btn btn-light-secondary" id="closeModalxBtn">
|
||||
<i class="bx bx-x d-block d-sm-none"></i>
|
||||
<span class="d-none d-sm-block"><i class="bi bi-x"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body ">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div id="eworksNavContainer">
|
||||
<!-- nav 리스트 가져오기 -->
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . "/eworks/eworks_nav.php"; ?>
|
||||
</div>
|
||||
<div class="d-flex mt-2 mb-1 justify-content-center" >
|
||||
<button class="btn btn-dark btn-sm me-2" type="button" id="E_searchAllBtn" > 전체 </button>
|
||||
|
||||
<input type="text" id="EworksSearch" name="EworksSearch" class="form-control me-2" style="width:150px;" value="<?= isset($EworksSearch) ? $EworksSearch : '' ?>" onkeydown="if (event.keyCode === 13) enterkey()">
|
||||
|
||||
<button class="btn btn-dark btn-sm me-2" type="button" onclick="enterkey(); " > <i class="bi bi-search"></i> </button> </span>
|
||||
|
||||
<button class="btn btn-dark btn-sm me-2" type="button" onclick="viewEworks_detail('',1);" > <i class="bi bi-pencil-square"></i> 작성 </button>
|
||||
</div>
|
||||
<div class="row" >
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . "/eworks/list.php"; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-end mt-1">
|
||||
<button type="button" id="closeEworksBtn" class="btn btn-outline-dark btn-sm">
|
||||
× 닫기
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
6
eworks/load_eworks.php
Normal file
6
eworks/load_eworks.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
include 'load_eworkslist.php';
|
||||
|
||||
|
||||
?>
|
||||
130
eworks/load_eworkslist.php
Normal file
130
eworks/load_eworkslist.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
// 결재라인을 설정하기 위해 사용자 정보를 배열에 저장
|
||||
$eworks_lv_arr = array();
|
||||
$part_arr = array();
|
||||
$position_arr = array();
|
||||
$name_arr = array();
|
||||
$id_arr = array();
|
||||
|
||||
if(!empty($DB))
|
||||
{
|
||||
try{
|
||||
$sql="select * from $DB.member WHERE division IS NOT NULL ";
|
||||
$stmh=$pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
array_push($name_arr, $row["name"]);
|
||||
array_push($id_arr, $row["id"]);
|
||||
array_push($eworks_lv_arr, $row["eworks_lv"]);
|
||||
array_push($part_arr, $row["division"]);
|
||||
array_push($position_arr, $row["position"]);
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
|
||||
// 결재권자 여부를 확인
|
||||
$workLevel = 0; // 1차 결재권자 여부
|
||||
|
||||
$firstStep = array();
|
||||
$firstStepID = array();
|
||||
for($i = 0; $i < count($eworks_lv_arr); $i++) {
|
||||
if((int)$eworks_lv_arr[$i] == 2 or (int)$eworks_lv_arr[$i] == 1) {
|
||||
array_push($firstStep, $name_arr[$i] . " " . $position_arr[$i]);
|
||||
array_push($firstStepID, $id_arr[$i]);
|
||||
if ($user_id === $id_arr[$i]) {
|
||||
$workLevel = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 각 상태별 문서 개수를 카운트하는 함수
|
||||
function countEworksStatus($pdo, $user_id, $status, $workLevel) {
|
||||
|
||||
if(isset($_SESSION["DB"]))
|
||||
$DB = $_SESSION["DB"] ;
|
||||
else
|
||||
$DB = 'chandj' ;
|
||||
|
||||
// view 설정
|
||||
$viewcon = " AND CONCAT('!', e_viewexcept_id, '!') NOT LIKE '%!{$user_id}!%' ";
|
||||
$viewconNone = " AND CONCAT('!', e_viewexcept_id, '!') LIKE '%!{$user_id}!%' ";
|
||||
|
||||
$count = 0;
|
||||
$sql = "";
|
||||
|
||||
if (!$workLevel) { // 일반 사용자의 경우 자신이 작성한 문서만 카운트
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE author_id = '$user_id' AND status = '$status' AND is_deleted IS NULL " . $viewcon;
|
||||
} else { // 결재권자의 경우 다양한 상태의 문서를 카운트
|
||||
switch ($status) {
|
||||
case 'draft':
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE author_id = '$user_id' AND status = 'draft' AND is_deleted IS NULL" . $viewcon;
|
||||
break;
|
||||
case 'send':
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE author_id = '$user_id' AND CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND status = 'send' AND is_deleted IS NULL" . $viewcon;
|
||||
break;
|
||||
case 'noend':
|
||||
// '미결' 상태: 사용자가 결재해야 하는 문서 카운트
|
||||
// 첫 번째 결재권자에 대해 '상신' 상태를 '미결'로 처리
|
||||
// 그리고 나머지 결재권자에 대해서는 다음 결재자가 되는 경우를 처리
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' " .
|
||||
"AND ( " .
|
||||
" (CONCAT('!', e_confirm_id, '!') = '!!' AND LOCATE('{$user_id}', e_line_id) = 1 AND status = 'send') " .
|
||||
" OR " .
|
||||
" (CONCAT('!', e_confirm_id, '!') NOT LIKE '%!{$user_id}!%' AND INSTR(CONCAT('!', e_line_id, '!'), CONCAT('!', SUBSTRING_INDEX(e_confirm_id, '!', -1), '!', '{$user_id}', '!')) > 0 AND status IN ('send', 'noend', 'ing')) " .
|
||||
") AND is_deleted IS NULL" . $viewcon;
|
||||
break;
|
||||
|
||||
case 'ing':
|
||||
// '진행중' 상태: 사용자가 결재 중인 문서 카운트
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND CONCAT('!', e_confirm_id, '!') LIKE '%!{$user_id}!%' AND status IN ('send', 'ing') AND is_deleted IS NULL" . $viewcon;
|
||||
break;
|
||||
case 'end':
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND status = 'end' AND is_deleted IS NULL" . $viewcon;
|
||||
break;
|
||||
case 'reject':
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND status = 'reject' AND is_deleted IS NULL" . $viewcon;
|
||||
break;
|
||||
case 'wait':
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND status = 'wait' AND is_deleted IS NULL" . $viewcon;
|
||||
break;
|
||||
case 'refer':
|
||||
$sql = "SELECT COUNT(*) FROM " . $DB . ".eworks WHERE CONCAT('!', e_line_id, '!') LIKE '%!{$user_id}!%' AND status = 'refer' AND is_deleted IS NULL" . $viewcon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$stmh = $pdo->query($sql);
|
||||
$count = $stmh->fetchColumn();
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
|
||||
if($status!=='sql')
|
||||
return $count;
|
||||
else
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// 각 상태별 문서 개수 카운트
|
||||
// $statuses = ['draft', 'send', 'noend', 'ing', 'end', 'reject', 'wait', 'refer', 'sql'];
|
||||
$statuses = ['draft', 'send', 'noend', 'ing', 'end', 'reject', 'wait', 'refer'];
|
||||
$data = [] ;
|
||||
$data['workLevel'] = $workLevel ;
|
||||
|
||||
foreach ($statuses as $status) {
|
||||
$data['val'.array_search($status, $statuses)] = countEworksStatus($pdo, $user_id, $status, $workLevel);
|
||||
}
|
||||
|
||||
//json 출력
|
||||
echo(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
}
|
||||
?>
|
||||
79
eworks/load_list.php
Normal file
79
eworks/load_list.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json"); //json을 사용하기 위해 필요한 구문
|
||||
|
||||
isset($_REQUEST["e_num"]) ? $e_num = $_REQUEST["e_num"] : $e_num="";
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
$num_arr= array();
|
||||
$e_title_arr= array();
|
||||
$contents_arr= array();
|
||||
$registdate_arr= array();
|
||||
$status_arr= array();
|
||||
$e_line_arr= array();
|
||||
$e_line_id_arr= array();
|
||||
$e_confirm_arr= array();
|
||||
$r_line_arr= array();
|
||||
$r_line_id_arr= array();
|
||||
$recordtime_arr= array();
|
||||
$author_arr= array();
|
||||
$author_id_arr= array();
|
||||
$done_arr= array();
|
||||
|
||||
try{
|
||||
$sql = "select * from $DB.eworks where is_deleted IS NULL ";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
$count = $stmh->rowCount();
|
||||
if($count<1){
|
||||
// print "검색결과가 없습니다.<br>";
|
||||
} else {
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
include "_row.php";
|
||||
array_push($num_arr, $e_num);
|
||||
array_push($e_title_arr, $e_title);
|
||||
array_push($contents_arr, $contents);
|
||||
array_push($registdate_arr, $registdate);
|
||||
array_push($status_arr, $status);
|
||||
array_push($e_line_arr, $e_line);
|
||||
array_push($e_line_id_arr, $e_line_id);
|
||||
array_push($e_confirm_arr, $e_confirm);
|
||||
array_push($r_line_arr, $r_line);
|
||||
array_push($r_line_id_arr, $r_line_id);
|
||||
array_push($recordtime_arr, $recordtime);
|
||||
array_push($author_arr, $author);
|
||||
array_push($author_id_arr, $author_id);
|
||||
array_push($done_arr, $done);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
|
||||
|
||||
//각각의 정보를 하나의 배열 변수에 넣어준다.
|
||||
$data = array(
|
||||
"num_arr" => $num_arr,
|
||||
"e_title_arr" => $e_title_arr,
|
||||
"contents_arr" => $contents_arr,
|
||||
"registdate_arr" => $registdate_arr,
|
||||
"status_arr" => $status_arr,
|
||||
"e_line_arr" => $e_line_arr,
|
||||
"e_line_id_arr" => $e_line_id_arr,
|
||||
"e_confirm_arr" => $e_confirm_arr,
|
||||
"r_line_arr" => $r_line_arr,
|
||||
"r_line_id_arr" => $r_line_id_arr,
|
||||
"recordtime_arr" => $recordtime_arr,
|
||||
"author_arr" => $author_arr,
|
||||
"author_id_arr" => $author_id_arr,
|
||||
"done_arr" => $done_arr
|
||||
);
|
||||
|
||||
//json 출력
|
||||
echo(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
?>
|
||||
54
eworks/load_listone.php
Normal file
54
eworks/load_listone.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
header("Content-Type: application/json"); //json을 사용하기 위해 필요한 구문
|
||||
|
||||
isset($_REQUEST["e_num"]) ? $e_num = $_REQUEST["e_num"] : $e_num="";
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try{
|
||||
$sql = "select * from {$DB}.eworks where num='$e_num' and is_deleted IS NULL ";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
$count = $stmh->rowCount();
|
||||
if($count<1){
|
||||
// print "검색결과가 없습니다.<br>";
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/eworks/_request.php";
|
||||
$eworks_item = '일반';
|
||||
|
||||
} else {
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/eworks/_row.php";
|
||||
if($eworks_item==='연차')
|
||||
$contents = urldecode($contents);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (PDOException $Exception) {
|
||||
print "오류: ".$Exception->getMessage();
|
||||
}
|
||||
|
||||
//각각의 정보를 하나의 배열 변수에 넣어준다.
|
||||
$data = array(
|
||||
"e_num" => $e_num,
|
||||
"eworks_item" => $eworks_item,
|
||||
"e_title" => $e_title,
|
||||
"contents" => $contents,
|
||||
"registdate" => $registdate,
|
||||
"status" => $status,
|
||||
"e_line" => $e_line,
|
||||
"e_line_id" => $e_line_id,
|
||||
"e_confirm" => $e_confirm,
|
||||
"e_confirm_id" => $e_confirm_id,
|
||||
"r_line" => $r_line,
|
||||
"r_line_id" => $r_line_id,
|
||||
"recordtime" => $recordtime,
|
||||
"author" => $author,
|
||||
"author_id" => $author_id,
|
||||
"done" => $done
|
||||
);
|
||||
//json 출력
|
||||
echo(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
?>
|
||||
210
eworks/process.php
Normal file
210
eworks/process.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/common.php';
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
|
||||
$pdo = db_connect();
|
||||
|
||||
function getPosition($userId, $pdo) {
|
||||
$query = "SELECT position FROM {$GLOBALS['DB']}.member WHERE id = ?"; // Assuming 'id' is the field for user ID and 'position' for the job title
|
||||
$position = '';
|
||||
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$userId]);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
$position = $row['position']; // Assuming 'position' is the field that contains the job title
|
||||
}
|
||||
|
||||
return $position; // Returns the position as a string
|
||||
}
|
||||
|
||||
function getRippleData($rippleId, $pdo) {
|
||||
$query = "SELECT * FROM {$GLOBALS['DB']}.eworks_ripple WHERE num = ?";
|
||||
$rippleData = array();
|
||||
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$rippleId]);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
// Assuming these are the fields in your e_works_ripple table
|
||||
$rippleData = [
|
||||
'num' => $row['num'],
|
||||
'content' => $row['content'],
|
||||
'author_id' => $row['author_id'],
|
||||
'author' => $row['author'],
|
||||
'regist_day' => $row['regist_day'],
|
||||
'parent' => $row['parent']
|
||||
];
|
||||
}
|
||||
|
||||
return $rippleData; // Returns an associative array with ripple data
|
||||
}
|
||||
|
||||
$e_num = isset($_REQUEST["e_num"]) ? $_REQUEST["e_num"] : '';
|
||||
$ripple_num = isset($_REQUEST["ripple_num"]) ? $_REQUEST["ripple_num"] : '';
|
||||
$SelectWork = isset($_REQUEST["SelectWork"]) ? $_REQUEST["SelectWork"] : "insert";
|
||||
$e_line = isset($_REQUEST["e_line"]) ? $_REQUEST["e_line"] : "";
|
||||
$e_line_id = isset($_REQUEST["e_line_id"]) ? $_REQUEST["e_line_id"] : "";
|
||||
$e_confirm = isset($_REQUEST["e_confirm"]) ? $_REQUEST["e_confirm"] : "";
|
||||
$eworks_item = isset($_REQUEST["eworks_item"]) ? $_REQUEST["eworks_item"] : "";
|
||||
$author = isset($_REQUEST["author"]) ? $_REQUEST["author"] : $user_name;
|
||||
$author_id = isset($_REQUEST["author_id"]) ? $_REQUEST["author_id"] : $user_id;
|
||||
$recent_num = $e_num; // 마지막 번호 임시 저장
|
||||
|
||||
$arr = explode("!", $e_line_id);
|
||||
$e_line_count = count($arr);
|
||||
// 결재시간 추출해서 조합하기
|
||||
$approval_time = explode("!", $e_confirm);
|
||||
$e_confirm_count = count($approval_time);
|
||||
|
||||
include "_request.php";
|
||||
|
||||
if($status == null) $status = 'draft'; // 최초 작성으로 설정함
|
||||
|
||||
$date = date('Y-m-d H:i:s'); // 현재 시간
|
||||
|
||||
if ($SelectWork == "update") {
|
||||
$query = "UPDATE {$DB}.eworks SET eworks_item=?, e_title=?, contents=?, registdate=?, status=?, e_line=?, e_line_id=?, e_confirm=?, e_confirm_id=?, r_line=?, r_line_id=?, recordtime=?, author=?, author_id=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$eworks_item, $e_title, $contents, $date, $status, $e_line, $e_line_id, $e_confirm, $e_confirm_id, $r_line, $r_line_id, $recordtime, $author, $author_id, $e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "insert") {
|
||||
$query = "INSERT INTO {$DB}.eworks (eworks_item, e_title, contents, registdate, status, e_line, e_line_id, e_confirm, e_confirm_id, r_line, r_line_id, recordtime, author, author_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$eworks_item, $e_title, $contents, $date, $status, $e_line, $e_line_id, $e_confirm, $e_confirm_id, $r_line, $r_line_id, $recordtime, $author, $author_id]);
|
||||
|
||||
$recent_num = $pdo->lastInsertId();
|
||||
}
|
||||
|
||||
if ($SelectWork == "send") {
|
||||
$status = 'send';
|
||||
$query = "UPDATE {$DB}.eworks SET status=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$status, $e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "approval") {
|
||||
$e_confirm_value = ($e_confirm === '' || $e_confirm === null) ? $user_name . " " . getPosition($user_id, $pdo) . " " . $date : $e_confirm . '!' . $user_name . " " . getPosition($user_id, $pdo) . " " . $date;
|
||||
$e_confirm_id_value = ($e_confirm_id === '' || $e_confirm_id === null) ? $user_id : $e_confirm_id . '!' . $user_id;
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET e_confirm=?, e_confirm_id=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$e_confirm_value, $e_confirm_id_value, $e_num]);
|
||||
|
||||
$arr = explode("!", $e_line_id);
|
||||
$approval_time = explode("!", $e_confirm_id_value);
|
||||
$e_line_count = count($arr);
|
||||
$e_confirm_count = count($approval_time);
|
||||
|
||||
if ($e_line_count > $e_confirm_count) {
|
||||
$status = 'ing';
|
||||
} else if ($e_line_count == $e_confirm_count) {
|
||||
$status = 'end';
|
||||
$done = 'done';
|
||||
$query = "UPDATE {$DB}.eworks SET done=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$done, $e_num]);
|
||||
}
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET status=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$status, $e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "restore") {
|
||||
$idArray = explode('!', $e_viewexcept_id);
|
||||
if (($key = array_search($user_id, $idArray)) !== false) {
|
||||
unset($idArray[$key]);
|
||||
}
|
||||
$e_viewexcept_id = implode('!', $idArray);
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET e_viewexcept_id=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$e_viewexcept_id, $e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "except") {
|
||||
$e_viewexcept_id = ($e_viewexcept_id === '' || $e_viewexcept_id === null) ? $user_id : $e_viewexcept_id . '!' . $user_id;
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET e_viewexcept_id=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$e_viewexcept_id, $e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "recall") {
|
||||
$status = 'draft';
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET status=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$status, $e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "reject") {
|
||||
$status = 'reject';
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET status=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$status, $e_num]);
|
||||
|
||||
$e_confirm_value = ($e_confirm === '' || $e_confirm === null) ? $user_name . " " . getPosition($user_id, $pdo) . " " . $date : $e_confirm . '!' . $user_name . " " . getPosition($user_id, $pdo) . " " . $date;
|
||||
$e_confirm_id_value = ($e_confirm_id === '' || $e_confirm_id === null) ? $user_id : $e_confirm_id . '!' . $user_id;
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET e_confirm=?, e_confirm_id=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$e_confirm_value, $e_confirm_id_value, $e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "wait") {
|
||||
$status = 'wait';
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET status=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$status, $e_num]);
|
||||
|
||||
$e_confirm_value = ($e_confirm === '' || $e_confirm === null) ? $user_name . " " . getPosition($user_id, $pdo) . " " . $date : $e_confirm . '!' . $user_name . " " . getPosition($user_id, $pdo) . " " . $date;
|
||||
$e_confirm_id_value = ($e_confirm_id === '' || $e_confirm_id === null) ? $user_id : $e_confirm_id . '!' . $user_id;
|
||||
|
||||
$query = "UPDATE {$DB}.eworks SET e_confirm=?, e_confirm_id=? WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$e_confirm_value, $e_confirm_id_value, $e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "delete_ripple") {
|
||||
$query = "UPDATE {$DB}.eworks_ripple SET is_deleted=1 WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$ripple_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork == "insert_ripple") {
|
||||
$ripple_content = $_REQUEST['ripple_content'];
|
||||
$ripple_author = $user_name;
|
||||
$ripple_author_id = $user_id;
|
||||
$parent_id = $e_num;
|
||||
$regist_day = date('Y-m-d H:i:s');
|
||||
|
||||
$query = "INSERT INTO {$DB}.eworks_ripple (content, author, author_id, parent, regist_day) VALUES (?, ?, ?, ?, ?)";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$ripple_content, $ripple_author, $ripple_author_id, $parent_id, $regist_day]);
|
||||
|
||||
$last_id = $pdo->lastInsertId();
|
||||
$ripple_data = getRippleData($last_id, $pdo);
|
||||
|
||||
echo json_encode($ripple_data, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
if ($SelectWork == "deldata") {
|
||||
$query = "UPDATE {$DB}.eworks SET is_deleted=1 WHERE num=?";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute([$e_num]);
|
||||
}
|
||||
|
||||
if ($SelectWork !== "insert_ripple") {
|
||||
$data = ['e_num' => $recent_num];
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
?>
|
||||
30
eworks/saveApprovalLine.php
Normal file
30
eworks/saveApprovalLine.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
// JSON 데이터 수신
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
// 파일 경로 설정
|
||||
$filePath = './approvalLine/approvalLine_' . $data['userId'] . '.json';
|
||||
|
||||
// 파일이 이미 존재하면 기존 데이터를 로드하고, 존재하지 않으면 새 배열을 생성
|
||||
if(file_exists($filePath)) {
|
||||
$existingData = json_decode(file_get_contents($filePath), true);
|
||||
if (!is_array($existingData)) { // 기존 데이터가 배열이 아니면 새 배열 생성
|
||||
$existingData = array();
|
||||
}
|
||||
} else {
|
||||
$existingData = array();
|
||||
}
|
||||
|
||||
// 새로운 결재라인 정보를 기존 데이터에 추가
|
||||
$existingData[] = array(
|
||||
'userId' => $data['userId'],
|
||||
'savedName' => $data['savedName'],
|
||||
'approvalOrder' => $data['approvalOrder']
|
||||
);
|
||||
|
||||
// 파일에 수정된 데이터 저장
|
||||
file_put_contents($filePath, json_encode($existingData));
|
||||
|
||||
echo json_encode(array('status' => 'success', 'message' => 'Approval line saved successfully.'));
|
||||
?>
|
||||
31
eworks/saveRefLine.php
Normal file
31
eworks/saveRefLine.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
// JSON 데이터 수신
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
// 파일 경로 설정
|
||||
$filePath = './RefLine/RefLine_' . $data['userId'] . '.json';
|
||||
|
||||
// 파일이 이미 존재하면 기존 데이터를 로드하고, 존재하지 않으면 새 배열을 생성
|
||||
if(file_exists($filePath)) {
|
||||
$existingData = json_decode(file_get_contents($filePath), true);
|
||||
if (!is_array($existingData)) { // 기존 데이터가 배열이 아니면 새 배열 생성
|
||||
$existingData = array();
|
||||
}
|
||||
} else {
|
||||
$existingData = array();
|
||||
}
|
||||
|
||||
// 새로운 결재라인 정보를 기존 데이터에 추가
|
||||
$existingData[] = array(
|
||||
'userId' => $data['userId'],
|
||||
'savedName' => $data['savedName'],
|
||||
'RefOrder' => $data['RefOrder']
|
||||
);
|
||||
|
||||
// 파일에 수정된 데이터 저장
|
||||
file_put_contents($filePath, json_encode($existingData));
|
||||
|
||||
echo json_encode(array('status' => 'success', 'message' => 'Ref line saved successfully.'));
|
||||
?>
|
||||
577
eworks/setRef.php
Normal file
577
eworks/setRef.php
Normal file
@@ -0,0 +1,577 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$r_line_id = isset($_GET['r_line_id']) ? $_GET['r_line_id'] : '';
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/common.php';
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
|
||||
$_SESSION["partsep"] = '';
|
||||
$pdo = db_connect();
|
||||
|
||||
$firstStep = array();
|
||||
$secondStep = array();
|
||||
|
||||
function getRefData($pdo) {
|
||||
// print ('tlfgod');
|
||||
$RefData = ['firstStep' => [], 'secondStep' => []];
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/session.php" ;
|
||||
|
||||
try {
|
||||
$sql = "SELECT id, name, position, part, eworks_level FROM {$DB}.member ";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
if($row["eworks_level"] !== null) {
|
||||
$RefData['firstStep'][] = $row;
|
||||
} elseif($row["eworks_level"] == "1") {
|
||||
$RefData['secondStep'][] = $row;
|
||||
}
|
||||
|
||||
// var_dump($row);
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
return $RefData;
|
||||
}
|
||||
|
||||
$RefData = getRefData($pdo);
|
||||
|
||||
// var_dump($RefData);
|
||||
|
||||
$title_message = "참조라인 지정";
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
||||
|
||||
|
||||
// JSON 파일 경로
|
||||
$filePath = './RefLine/RefLine_' . $user_id . '.json';
|
||||
|
||||
// print_r($filePath);
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
$data = json_decode(file_get_contents($filePath), true);
|
||||
|
||||
|
||||
// var_dump($data);
|
||||
// select 요소의 옵션 초기화
|
||||
$selectOptions = "";
|
||||
|
||||
// JSON 데이터가 배열인 경우 각 요소 처리
|
||||
if(is_array($data)) {
|
||||
foreach($data as $RefLine) {
|
||||
if(isset($RefLine['savedName'])) {
|
||||
$savedName = htmlspecialchars($RefLine['savedName'], ENT_QUOTES, 'UTF-8');
|
||||
$selectOptions .= "<option value='{$savedName}'>{$savedName}</option>";
|
||||
}
|
||||
}
|
||||
|
||||
// 참조라인이 없는 경우
|
||||
if(empty($selectOptions)) {
|
||||
$selectOptions = "<option> </option>";
|
||||
}
|
||||
} else {
|
||||
$selectOptions = "<option>Invalid data format in file</option>";
|
||||
}
|
||||
} else {
|
||||
$selectOptions = "<option> </option>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<style>
|
||||
.ui-state-highlight {
|
||||
background-color: #f0f0f0;
|
||||
height: 1.8em;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
#RefOrder {
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
#RefModal {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 1050;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #fefefe;
|
||||
margin: 15% auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #888;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.close {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.close:hover,
|
||||
.close:focus {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.Ref-line-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px; /* 줄 간격 조정 */
|
||||
}
|
||||
|
||||
.delete-button {
|
||||
border: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.delete-button ion-icon {
|
||||
font-size: 20px; /* 아이콘 크기 조정 */
|
||||
color: #ff0000; /* 아이콘 색상 조정 */
|
||||
}
|
||||
</style>
|
||||
|
||||
<title> <?=$title_message?> </title>
|
||||
|
||||
<form id="mainFrm" method="post" enctype="multipart/form-data" >
|
||||
<input type="hidden" id="SelectWork" name="SelectWork" value="<?=$SelectWork?>">
|
||||
<input type="hidden" id="vacancy" name="vacancy" >
|
||||
<input type="hidden" id="num" name="num" value=<?=$num?> >
|
||||
<input type="hidden" id="page" name="page" value=<?=$page?> >
|
||||
<input type="hidden" id="mode" name="mode" value=<?=$mode?> >
|
||||
<input type="hidden" id="partsep" name="partsep" value=<?=$partsep?> >
|
||||
|
||||
<div class="container">
|
||||
|
||||
<!-- 모달 -->
|
||||
<div id="RefModal" style="display:none;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">참조라인 관리</h5>
|
||||
<button type="button" class="close" onclick="closeModal();">×</button>
|
||||
</div>
|
||||
<!-- ... 기존 모달 내용 ... -->
|
||||
<div class="modal-body">
|
||||
<div class="d-flex mt-5 mb-5">
|
||||
<ul id="RefLineList"></ul> <!-- 참조라인 목록 컨테이너 -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-dark" onclick="closeModal();">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header mt-3 fs-5 ">
|
||||
참조라인 지정
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<h6>참조 List</h6>
|
||||
</th>
|
||||
<th>
|
||||
<h6>참조 순서</h6>
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col" style="width:50%;">
|
||||
<ul id="RefList" class="list-group">
|
||||
<?php foreach($RefData["firstStep"] as $approver): ?>
|
||||
<li class="list-group-item" data-user-id="<?= $approver['id'] ?>">
|
||||
<?= htmlspecialchars($approver['name'] . ' ' . $approver['position']) ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<!-- 더미 항목 추가 -->
|
||||
<li class="list-group-item dummy" style="display: none;"></li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
<td class="col" style="width:50%;">
|
||||
<ul id="RefOrder" class="list-group">
|
||||
<!-- 드래그 앤 드롭으로 이동된 참조권자가 여기에 표시됨 -->
|
||||
</ul>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="row ">
|
||||
<div class="col-sm-7">
|
||||
<div class="d-flex align-items-center p-2 text-left">
|
||||
<button type="button" class="btn btn-outline-success btn-sm" id="refreshBtn" > <ion-icon name="refresh-outline"></ion-icon> </button>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="newBtn" > <ion-icon name="document-outline"></ion-icon></button>
|
||||
<span class="text-center me-1"> Load </span>
|
||||
<select name="savedRefLines" id="savedRefLines" class="form-control" style="width:60%;">
|
||||
<?= $selectOptions ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-5" >
|
||||
<div class="d-flex align-items-center p-2 text-left">
|
||||
<input type="text" name="workprocessval" id="workprocessval" value='<?=$workprocessval?>' class="form-control" style="width:100%;" >
|
||||
<button type="button" class="btn btn-dark btn-sm" id="SavesettingsBtn" > <ion-icon name="save-outline"></ion-icon> </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="d-flex p-2 text-left" >
|
||||
<button type="button" class="btn btn-outline-dark btn-sm" onclick="self.close();" > <ion-icon name="exit-outline"></ion-icon> 창닫기 </button>
|
||||
<button type="button" class="btn btn-primary btn-sm" id="openModalButton"> <ion-icon name="construct-outline"></ion-icon> 관리 </button>
|
||||
<button type="button" class="btn btn-dark btn-sm" id="adaptBtn"> <ion-icon name="checkmark-outline"></ion-icon> 선택 </button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
// 기존 호출에 전달자가 있는 경우 값이 있어 호출하는 경우
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var r_line_id = '<?php echo $r_line_id ?>';
|
||||
if (r_line_id && r_line_id !== "") {
|
||||
var ids = r_line_id.split("!");
|
||||
var RefList = document.getElementById("RefList");
|
||||
var RefOrder = document.getElementById("RefOrder");
|
||||
|
||||
ids.forEach(function(id) {
|
||||
var element = RefList.querySelector('[data-user-id="' + id + '"]');
|
||||
if (element) {
|
||||
RefOrder.appendChild(element.cloneNode(true));
|
||||
element.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
// Select 옵션 변경 시 이벤트 핸들러
|
||||
$('#savedRefLines').change(function() {
|
||||
var selectedName = $(this).val();
|
||||
updateRefLine(selectedName);
|
||||
console.log(selectedName);
|
||||
});
|
||||
|
||||
var r_line_id = '<?php echo $r_line_id ?>';
|
||||
|
||||
// 페이지 로드 시 첫 번째 옵션을 선택하고 이벤트 트리거
|
||||
if(!r_line_id)
|
||||
$('#savedRefLines').prop('selectedIndex', 0).trigger('change');
|
||||
|
||||
|
||||
function updateRefLine(savedName) {
|
||||
$.ajax({
|
||||
url: './getRefLine.php', // 서버측 PHP 파일 경로
|
||||
type: 'POST',
|
||||
data: { savedName: savedName },
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
// 화면 업데이트 로직
|
||||
console.log(response);
|
||||
updateRefOrderList(response.RefOrder);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error); // 오류 처리
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateRefOrderList(RefOrder) {
|
||||
var RefOrderList = $('#RefOrder');
|
||||
var RefList = $('#RefList');
|
||||
RefOrderList.empty(); // 최종 참조 순서 목록 비우기
|
||||
|
||||
RefOrder.forEach(function(item) {
|
||||
var listItem = $('<li class="list-group-item"></li>')
|
||||
.text(item.name)
|
||||
.data('user-id', item['user-id']);
|
||||
RefOrderList.append(listItem);
|
||||
|
||||
// 같은 'user-id'를 가진 항목을 'RefList'에서 제거
|
||||
RefList.find('li').not('.dummy').each(function() {
|
||||
if ($(this).data('user-id') === item['user-id']) {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 모든 변경 사항 적용 후 'dummy' 항목 다시 추가
|
||||
if (!RefList.find('.dummy').length) {
|
||||
RefList.append('<li class="list-group-item dummy"></li>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$("#RefList, #RefOrder").sortable({
|
||||
connectWith: ".list-group",
|
||||
placeholder: "ui-state-highlight",
|
||||
receive: function(event, ui) {
|
||||
checkDummy($(this));
|
||||
},
|
||||
over: function(event, ui) {
|
||||
checkDummy($(this));
|
||||
},
|
||||
out: function(event, ui) {
|
||||
checkDummy($(this));
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
checkDummy($(this));
|
||||
}
|
||||
}).disableSelection();
|
||||
|
||||
function checkDummy(list) {
|
||||
// 리스트에 항목이 없으면 더미 항목을 표시
|
||||
if (list.children(':not(.dummy)').length === 0) {
|
||||
list.children('.dummy').show();
|
||||
} else {
|
||||
list.children('.dummy').hide();
|
||||
}
|
||||
}
|
||||
|
||||
$("#refreshBtn").click(function() {
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// 초기 상태에서 더미 항목의 상태를 확인
|
||||
$("#RefList, #RefOrder").each(function() {
|
||||
checkDummy($(this));
|
||||
});
|
||||
|
||||
|
||||
// 모달창 닫기
|
||||
$("#closeModalBtn").click(function(){
|
||||
$('#myModal').modal('hide');
|
||||
});
|
||||
|
||||
$("#closeBtn").click(function(){ // 저장하고 창닫기
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#SavesettingsBtn").click(function() {
|
||||
var inputName = $("#workprocessval").val().trim();
|
||||
if (!inputName) {
|
||||
alert('저장할 참조라인을 입력하세요');
|
||||
return; // 함수 실행 중단
|
||||
}
|
||||
|
||||
var selectedRefLine = getCurrentRefLine();
|
||||
|
||||
$.ajax({
|
||||
url: './saveRefLine.php',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({
|
||||
userId: '<?= $user_id ?>',
|
||||
savedName: inputName,
|
||||
RefOrder: selectedRefLine
|
||||
}),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
Toastify({
|
||||
text: "저장되었습니다.",
|
||||
duration: 2000,
|
||||
close: true,
|
||||
gravity: "top",
|
||||
position: 'center',
|
||||
}).showToast();
|
||||
|
||||
// 새로운 참조라인 옵션 추가 및 선택
|
||||
$('#savedRefLines').append($('<option>', {
|
||||
value: inputName,
|
||||
text: inputName
|
||||
})).val(inputName).trigger('change');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getCurrentRefLine() {
|
||||
var RefLine = [];
|
||||
$("#RefOrder li:not(.dummy)").each(function(index) {
|
||||
var userId = $(this).data('user-id');
|
||||
var name = $(this).text();
|
||||
var position = $(this).data('position');
|
||||
var order = index + 1;
|
||||
if (userId) {
|
||||
RefLine.push({
|
||||
'order': order,
|
||||
'user-id': userId,
|
||||
'name': name + (position ? ' ' + position : '')
|
||||
});
|
||||
}
|
||||
});
|
||||
return RefLine;
|
||||
}
|
||||
|
||||
// New 버튼 클릭 이벤트 핸들러
|
||||
$("#newBtn").click(function() {
|
||||
resetRefLists();
|
||||
});
|
||||
|
||||
// 모달 열기 이벤트
|
||||
$("#openModalButton").click(function() {
|
||||
fetchRefLines(); // 참조라인 목록 가져오기
|
||||
openModal();
|
||||
});
|
||||
|
||||
// 선택
|
||||
$("#adaptBtn").click(function() {
|
||||
var RefOrderTexts = $("#RefOrder li")
|
||||
.map(function() {
|
||||
return $(this).text().trim(); // 각 항목의 텍스트 추출
|
||||
}).get() // jQuery 객체를 일반 배열로 변환
|
||||
.join("!"); // 콤마로 구분하여 하나의 문자열로 결합
|
||||
|
||||
// 부모 창의 r_line input 요소에 값을 설정
|
||||
window.opener.$("#r_line").val(RefOrderTexts);
|
||||
|
||||
// id를 같은 형식으로 저장하기
|
||||
var RefOrderIDs = $("#RefOrder li")
|
||||
.map(function() {
|
||||
return $(this).data('user-id'); // 각 항목의 data-user-id 속성 추출
|
||||
}).get() // jQuery 객체를 일반 배열로 변환
|
||||
.join("!"); // "!" 문자로 구분하여 하나의 문자열로 결합
|
||||
|
||||
// 부모 창의 r_line_id input 요소에 값을 설정
|
||||
window.opener.$("#r_line_id").val(RefOrderIDs);
|
||||
|
||||
// 필요한 경우 현재 창을 닫음
|
||||
window.close();
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
function resetRefLists() {
|
||||
var RefList = $('#RefList');
|
||||
var RefOrderList = $('#RefOrder');
|
||||
|
||||
// RefList 초기화
|
||||
RefList.empty();
|
||||
<?php foreach($RefData["firstStep"] as $approver): ?>
|
||||
RefList.append('<li class="list-group-item" data-user-id="<?= $approver['id'] ?>"><?= htmlspecialchars($approver['name'] . ' ' . $approver['position']) ?></li>');
|
||||
<?php endforeach; ?>
|
||||
// 더미 항목 추가
|
||||
RefList.append('<li class="list-group-item dummy" style="display: none;"></li>');
|
||||
|
||||
// RefOrderList 비우기
|
||||
RefOrderList.empty();
|
||||
}
|
||||
|
||||
|
||||
// 서버에서 참조라인 목록 가져오기
|
||||
function fetchRefLines() {
|
||||
$.ajax({
|
||||
url: './getRefLines.php',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response); // 서버 응답 로깅
|
||||
renderRefLines(response);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 참조라인 목록 렌더링
|
||||
function renderRefLines(data) {
|
||||
var RefLines = Object.values(data);
|
||||
|
||||
if (!Array.isArray(RefLines)) {
|
||||
console.error("Invalid data type: ", RefLines);
|
||||
return;
|
||||
}
|
||||
|
||||
var listContainer = $('#RefLineList');
|
||||
listContainer.empty(); // 목록 초기화
|
||||
|
||||
var table = $('<table><tbody></tbody></table>').addClass('table table-hover table-bordered table-sm');
|
||||
listContainer.append(table);
|
||||
|
||||
RefLines.forEach(function(line) {
|
||||
var row = $('<tr></tr>').addClass('Ref-line-item');
|
||||
var nameCell = $('<td></td>').text(line.savedName);
|
||||
var deleteButtonCell = $('<td></td>').addClass('text-end');
|
||||
var deleteButton = $('<button></button>')
|
||||
.addClass('btn btn-danger btn-sm ')
|
||||
.append('<ion-icon name="trash-outline"></ion-icon>')
|
||||
.click(function(event) {
|
||||
event.preventDefault();
|
||||
deleteRefLine(line.savedName, row);
|
||||
});
|
||||
|
||||
deleteButtonCell.append(deleteButton);
|
||||
row.append(nameCell).append(deleteButtonCell);
|
||||
table.append(row);
|
||||
});
|
||||
}
|
||||
|
||||
// 참조라인 삭제
|
||||
function deleteRefLine(savedName, listItem) {
|
||||
$.ajax({
|
||||
url: './deleteRefLine.php',
|
||||
type: 'POST',
|
||||
data: { savedName: savedName },
|
||||
success: function(response) {
|
||||
// 성공적으로 삭제되면 항목을 화면에서 제거
|
||||
listItem.remove();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function openModal() {
|
||||
document.getElementById("RefModal").style.display = "block";
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
document.getElementById("RefModal").style.display = "none";
|
||||
location.reload(); // 현재 페이지 리로드
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
593
eworks/setline.php
Normal file
593
eworks/setline.php
Normal file
@@ -0,0 +1,593 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
$e_line_id = isset($_GET['e_line_id']) ? $_GET['e_line_id'] : '';
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/common.php';
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
|
||||
$_SESSION["partsep"] = '';
|
||||
$pdo = db_connect();
|
||||
|
||||
$firstStep = array();
|
||||
$secondStep = array();
|
||||
|
||||
function getApprovalData($pdo) {
|
||||
// print ('tlfgod');
|
||||
$approvalData = ['firstStep' => [], 'secondStep' => []];
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/session.php" ;
|
||||
|
||||
try {
|
||||
$sql = "SELECT id, name, position, part, eworks_lv FROM {$DB}.member ";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute();
|
||||
|
||||
while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
|
||||
if($row["eworks_lv"] == "2" or $row["eworks_lv"] == "1") {
|
||||
$approvalData['firstStep'][] = $row;
|
||||
} elseif($row["eworks_lv"] == "1") {
|
||||
$approvalData['secondStep'][] = $row;
|
||||
}
|
||||
|
||||
// var_dump($row);
|
||||
}
|
||||
} catch (PDOException $Exception) {
|
||||
print "오류: " . $Exception->getMessage();
|
||||
}
|
||||
return $approvalData;
|
||||
}
|
||||
|
||||
$approvalData = getApprovalData($pdo);
|
||||
|
||||
// var_dump($approvalData);
|
||||
|
||||
$title_message = "결재라인 지정";
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
||||
|
||||
|
||||
// // JSON 파일 경로
|
||||
// $filePath = './approvalLine/approvalLine_' . $user_id . '.json';
|
||||
|
||||
// JSON 파일 경로
|
||||
$filePath = $_SERVER['DOCUMENT_ROOT'] . '/member/Company_approvalLine_.json';
|
||||
|
||||
// print_r($filePath);
|
||||
|
||||
if(file_exists($filePath)) {
|
||||
$data = json_decode(file_get_contents($filePath), true);
|
||||
|
||||
|
||||
// var_dump($data);
|
||||
// select 요소의 옵션 초기화
|
||||
$selectOptions = "";
|
||||
|
||||
// JSON 데이터가 배열인 경우 각 요소 처리
|
||||
if(is_array($data)) {
|
||||
foreach($data as $approvalLine) {
|
||||
if(isset($approvalLine['savedName'])) {
|
||||
$savedName = htmlspecialchars($approvalLine['savedName'], ENT_QUOTES, 'UTF-8');
|
||||
$selectOptions .= "<option value='{$savedName}'>{$savedName}</option>";
|
||||
}
|
||||
}
|
||||
|
||||
// 결재라인이 없는 경우
|
||||
if(empty($selectOptions)) {
|
||||
$selectOptions = "<option> </option>";
|
||||
}
|
||||
} else {
|
||||
$selectOptions = "<option>Invalid data format in file</option>";
|
||||
}
|
||||
} else {
|
||||
$selectOptions = "<option> </option>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<style>
|
||||
.ui-state-highlight {
|
||||
background-color: #f0f0f0;
|
||||
height: 1.8em;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
#approvalOrder {
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
#approvalModal {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 1050;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #fefefe;
|
||||
margin: 15% auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #888;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.close {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.close:hover,
|
||||
.close:focus {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.approval-line-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px; /* 줄 간격 조정 */
|
||||
}
|
||||
|
||||
.delete-button {
|
||||
border: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.delete-button ion-icon {
|
||||
font-size: 20px; /* 아이콘 크기 조정 */
|
||||
color: #ff0000; /* 아이콘 색상 조정 */
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<title> <?=$title_message?> </title>
|
||||
|
||||
<form id="mainFrm" method="post" enctype="multipart/form-data" >
|
||||
<input type="hidden" id="SelectWork" name="SelectWork" value="<?=$SelectWork?>">
|
||||
<input type="hidden" id="vacancy" name="vacancy" >
|
||||
<input type="hidden" id="num" name="num" value=<?=$num?> >
|
||||
<input type="hidden" id="page" name="page" value=<?=$page?> >
|
||||
<input type="hidden" id="mode" name="mode" value=<?=$mode?> >
|
||||
<input type="hidden" id="partsep" name="partsep" value=<?=$partsep?> >
|
||||
|
||||
<div class="container">
|
||||
|
||||
<!-- 모달 -->
|
||||
<div id="approvalModal" style="display:none;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">결재라인 관리(회사이름으로 지정)</h5>
|
||||
<button type="button" class="close" onclick="closeModal();">×</button>
|
||||
</div>
|
||||
<!-- ... 기존 모달 내용 ... -->
|
||||
<div class="modal-body">
|
||||
<div class="d-flex mt-5 mb-5">
|
||||
<ul id="approvalLineList"></ul> <!-- 결재라인 목록 컨테이너 -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-dark" onclick="closeModal();">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="card-header mt-3 fs-5 ">
|
||||
결재라인 지정
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<h6>결재권자 목록</h6>
|
||||
</th>
|
||||
<th>
|
||||
<h6>결재 순서</h6>
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col" style="width:50%;">
|
||||
<ul id="approverList" class="list-group">
|
||||
<?php foreach($approvalData["firstStep"] as $approver): ?>
|
||||
<li class="list-group-item" data-user-id="<?= $approver['id'] ?>">
|
||||
<?= htmlspecialchars($approver['name'] . ' ' . $approver['position']) ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<!-- 더미 항목 추가 -->
|
||||
<li class="list-group-item dummy" style="display: none;"></li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
<td class="col" style="width:50%;">
|
||||
<ul id="approvalOrder" class="list-group">
|
||||
<!-- 드래그 앤 드롭으로 이동된 결재권자가 여기에 표시됨 -->
|
||||
</ul>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="row ">
|
||||
<div class="col-sm-7">
|
||||
<div class="d-flex align-items-center p-2 text-left">
|
||||
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" id="newBtn" > <ion-icon name="document-outline"></ion-icon></button>
|
||||
<span class="text-center me-1"> Load </span>
|
||||
<select name="savedApprovalLines" id="savedApprovalLines" class="form-control" style="width:60%;">
|
||||
<?= $selectOptions ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-5" >
|
||||
<div class="d-flex align-items-center p-2 text-left">
|
||||
<input type="text" name="workprocessval" id="workprocessval" value='<?=$workprocessval?>' class="form-control" style="width:100%;" >
|
||||
<button type="button" class="btn btn-dark btn-sm" id="SavesettingsBtn" > <ion-icon name="save-outline"></ion-icon> </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="d-flex p-2 text-left" >
|
||||
<button type="button" class="btn btn-outline-dark btn-sm" onclick="self.close();" > <ion-icon name="exit-outline"></ion-icon> 창닫기 </button>
|
||||
<button type="button" class="btn btn-primary btn-sm" id="openModalButton"> <ion-icon name="construct-outline"></ion-icon> 관리 </button>
|
||||
<button type="button" class="btn btn-dark btn-sm" id="adaptBtn"> <ion-icon name="checkmark-outline"></ion-icon> 선택 </button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
// 페이지 로딩
|
||||
$(document).ready(function(){
|
||||
var loader = document.getElementById('loadingOverlay');
|
||||
loader.style.display = 'none';
|
||||
});
|
||||
|
||||
// 기존 호출에 전달자가 있는 경우 값이 있어 호출하는 경우
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var e_line_id = '<?php echo $e_line_id ?>';
|
||||
if (e_line_id && e_line_id !== "") {
|
||||
var ids = e_line_id.split("!");
|
||||
var approverList = document.getElementById("approverList");
|
||||
var approvalOrder = document.getElementById("approvalOrder");
|
||||
|
||||
ids.forEach(function(id) {
|
||||
var element = approverList.querySelector('[data-user-id="' + id + '"]');
|
||||
if (element) {
|
||||
approvalOrder.appendChild(element.cloneNode(true));
|
||||
element.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
// Select 옵션 변경 시 이벤트 핸들러
|
||||
$('#savedApprovalLines').change(function() {
|
||||
var selectedName = $(this).val();
|
||||
updateApprovalLine(selectedName);
|
||||
console.log(selectedName);
|
||||
});
|
||||
|
||||
var e_line_id = '<?php echo $e_line_id ?>';
|
||||
|
||||
// 페이지 로드 시 첫 번째 옵션을 선택하고 이벤트 트리거
|
||||
if(!e_line_id)
|
||||
$('#savedApprovalLines').prop('selectedIndex', 0).trigger('change');
|
||||
|
||||
|
||||
function updateApprovalLine(savedName) {
|
||||
$.ajax({
|
||||
url: '/member/getApprovalLine.php', // 서버측 PHP 파일 경로
|
||||
type: 'POST',
|
||||
data: { savedName: savedName },
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
// 화면 업데이트 로직
|
||||
console.log(response);
|
||||
updateApprovalOrderList(response.approvalOrder);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error); // 오류 처리
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateApprovalOrderList(approvalOrder) {
|
||||
var approvalOrderList = $('#approvalOrder');
|
||||
var approverList = $('#approverList');
|
||||
approvalOrderList.empty(); // 최종 결재 순서 목록 비우기
|
||||
|
||||
approvalOrder.forEach(function(item) {
|
||||
var listItem = $('<li class="list-group-item"></li>')
|
||||
.text(item.name)
|
||||
.data('user-id', item['user-id']);
|
||||
approvalOrderList.append(listItem);
|
||||
|
||||
// 같은 'user-id'를 가진 항목을 'approverList'에서 제거
|
||||
approverList.find('li').not('.dummy').each(function() {
|
||||
if ($(this).data('user-id') === item['user-id']) {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 모든 변경 사항 적용 후 'dummy' 항목 다시 추가
|
||||
if (!approverList.find('.dummy').length) {
|
||||
approverList.append('<li class="list-group-item dummy"></li>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$("#approverList, #approvalOrder").sortable({
|
||||
connectWith: ".list-group",
|
||||
placeholder: "ui-state-highlight",
|
||||
receive: function(event, ui) {
|
||||
checkDummy($(this));
|
||||
},
|
||||
over: function(event, ui) {
|
||||
checkDummy($(this));
|
||||
},
|
||||
out: function(event, ui) {
|
||||
checkDummy($(this));
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
checkDummy($(this));
|
||||
}
|
||||
}).disableSelection();
|
||||
|
||||
function checkDummy(list) {
|
||||
// 리스트에 항목이 없으면 더미 항목을 표시
|
||||
if (list.children(':not(.dummy)').length === 0) {
|
||||
list.children('.dummy').show();
|
||||
} else {
|
||||
list.children('.dummy').hide();
|
||||
}
|
||||
}
|
||||
|
||||
// 초기 상태에서 더미 항목의 상태를 확인
|
||||
$("#approverList, #approvalOrder").each(function() {
|
||||
checkDummy($(this));
|
||||
});
|
||||
|
||||
|
||||
// 모달창 닫기
|
||||
$("#closeModalBtn").click(function(){
|
||||
$('#myModal').modal('hide');
|
||||
});
|
||||
|
||||
$("#closeBtn").click(function(){ // 저장하고 창닫기
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#SavesettingsBtn").click(function() {
|
||||
var inputName = $("#workprocessval").val().trim();
|
||||
if (!inputName) {
|
||||
alert('저장할 결재라인을 입력하세요');
|
||||
return; // 함수 실행 중단
|
||||
}
|
||||
|
||||
var selectedApprovalLine = getCurrentApprovalLine();
|
||||
|
||||
$.ajax({
|
||||
url: '/member/saveApprovalLine.php',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({
|
||||
userId: '<?= $user_id ?>',
|
||||
savedName: inputName,
|
||||
approvalOrder: selectedApprovalLine
|
||||
}),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
Toastify({
|
||||
text: "저장되었습니다.",
|
||||
duration: 2000,
|
||||
close: true,
|
||||
gravity: "top",
|
||||
position: 'center',
|
||||
}).showToast();
|
||||
|
||||
// 새로운 결재라인 옵션 추가 및 선택
|
||||
$('#savedApprovalLines').append($('<option>', {
|
||||
value: inputName,
|
||||
text: inputName
|
||||
})).val(inputName).trigger('change');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getCurrentApprovalLine() {
|
||||
var approvalLine = [];
|
||||
$("#approvalOrder li:not(.dummy)").each(function(index) {
|
||||
var userId = $(this).data('user-id');
|
||||
var name = $(this).text();
|
||||
var position = $(this).data('position');
|
||||
var order = index + 1;
|
||||
if (userId) {
|
||||
approvalLine.push({
|
||||
'order': order,
|
||||
'user-id': userId,
|
||||
'name': name + (position ? ' ' + position : '')
|
||||
});
|
||||
}
|
||||
});
|
||||
return approvalLine;
|
||||
}
|
||||
|
||||
|
||||
$("#refreshBtn").click(function() {
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// New 버튼 클릭 이벤트 핸들러
|
||||
$("#newBtn").click(function() {
|
||||
resetApprovalLists();
|
||||
});
|
||||
|
||||
// 모달 열기 이벤트
|
||||
$("#openModalButton").click(function() {
|
||||
fetchApprovalLines(); // 결재라인 목록 가져오기
|
||||
openModal();
|
||||
});
|
||||
|
||||
// 선택
|
||||
$("#adaptBtn").click(function() {
|
||||
var approvalOrderTexts = $("#approvalOrder li")
|
||||
.map(function() {
|
||||
return $(this).text().trim(); // 각 항목의 텍스트 추출
|
||||
}).get() // jQuery 객체를 일반 배열로 변환
|
||||
.join("!"); // 콤마로 구분하여 하나의 문자열로 결합
|
||||
|
||||
// 부모 창의 e_line input 요소에 값을 설정
|
||||
window.opener.$("#e_line").val(approvalOrderTexts);
|
||||
|
||||
// id를 같은 형식으로 저장하기
|
||||
var approvalOrderIDs = $("#approvalOrder li")
|
||||
.map(function() {
|
||||
return $(this).data('user-id'); // 각 항목의 data-user-id 속성 추출
|
||||
}).get() // jQuery 객체를 일반 배열로 변환
|
||||
.join("!"); // ":" 문자로 구분하여 하나의 문자열로 결합
|
||||
|
||||
// 부모 창의 e_line_id input 요소에 값을 설정
|
||||
window.opener.$("#e_line_id").val(approvalOrderIDs);
|
||||
|
||||
// 필요한 경우 현재 창을 닫음
|
||||
window.close();
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
function resetApprovalLists() {
|
||||
var approverList = $('#approverList');
|
||||
var approvalOrderList = $('#approvalOrder');
|
||||
|
||||
// approverList 초기화
|
||||
approverList.empty();
|
||||
<?php foreach($approvalData["firstStep"] as $approver): ?>
|
||||
approverList.append('<li class="list-group-item" data-user-id="<?= $approver['id'] ?>"><?= htmlspecialchars($approver['name'] . ' ' . $approver['position']) ?></li>');
|
||||
<?php endforeach; ?>
|
||||
// 더미 항목 추가
|
||||
approverList.append('<li class="list-group-item dummy" style="display: none;"></li>');
|
||||
|
||||
// approvalOrderList 비우기
|
||||
approvalOrderList.empty();
|
||||
}
|
||||
|
||||
|
||||
// 서버에서 결재라인 목록 가져오기
|
||||
function fetchApprovalLines() {
|
||||
$.ajax({
|
||||
url: '/member/getApprovalLines.php',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response); // 서버 응답 로깅
|
||||
renderApprovalLines(response);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 결재라인 목록 렌더링
|
||||
function renderApprovalLines(data) {
|
||||
var approvalLines = Object.values(data);
|
||||
|
||||
if (!Array.isArray(approvalLines)) {
|
||||
console.error("Invalid data type: ", approvalLines);
|
||||
return;
|
||||
}
|
||||
|
||||
var listContainer = $('#approvalLineList');
|
||||
listContainer.empty(); // 목록 초기화
|
||||
|
||||
var table = $('<table><tbody></tbody></table>').addClass('table table-hover table-bordered table-sm');
|
||||
listContainer.append(table);
|
||||
|
||||
approvalLines.forEach(function(line) {
|
||||
var row = $('<tr></tr>').addClass('approval-line-item');
|
||||
var nameCell = $('<td></td>').text(line.savedName);
|
||||
var deleteButtonCell = $('<td></td>').addClass('text-end');
|
||||
var deleteButton = $('<button></button>')
|
||||
.addClass('btn btn-danger btn-sm ')
|
||||
.append('<ion-icon name="trash-outline"></ion-icon>')
|
||||
.click(function(event) {
|
||||
event.preventDefault();
|
||||
deleteApprovalLine(line.savedName, row);
|
||||
});
|
||||
|
||||
deleteButtonCell.append(deleteButton);
|
||||
row.append(nameCell).append(deleteButtonCell);
|
||||
table.append(row);
|
||||
});
|
||||
}
|
||||
|
||||
// 결재라인 삭제
|
||||
function deleteApprovalLine(savedName, listItem) {
|
||||
$.ajax({
|
||||
url: '/member/deleteApprovalLine.php',
|
||||
type: 'POST',
|
||||
data: { savedName: savedName },
|
||||
success: function(response) {
|
||||
// 성공적으로 삭제되면 항목을 화면에서 제거
|
||||
listItem.remove();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function openModal() {
|
||||
document.getElementById("approvalModal").style.display = "block";
|
||||
|
||||
e.preventDefault(); // 기본 이벤트 동작 막기
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
document.getElementById("approvalModal").style.display = "none";
|
||||
location.reload(); // 현재 페이지 리로드
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
114
eworks/write_form.php
Normal file
114
eworks/write_form.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<!-- eworks에서 모달 위에 띄우는 모달 창 결재 상세내역 -->
|
||||
<div class="modal fade" id="eworks_viewmodal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-fullsm" role="document" >
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" title="e결재 창">
|
||||
<h6 class="modal-title"> <ion-icon name="medkit-outline"> </ion-icon> 결재 </h6>
|
||||
<button type="button" class="btn btn-light-secondary close" id="closeModaldetailBtn" >
|
||||
<span class="d-none d-sm-block"><i class="bi bi-x"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- 결재정보 -->
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
</div>
|
||||
<div id="approvalTable" class="col-sm-4">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body" id="eworks_viewcontents">
|
||||
<div class="table-reponsive mb-2 ">
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
|
||||
<tr class="align-items-center">
|
||||
<td class="text-center" > 구분 </td>
|
||||
<td>
|
||||
<?php
|
||||
// eworks_item 목록 정의
|
||||
$eworksItems = [
|
||||
'일반',
|
||||
'연차',
|
||||
'품의서',
|
||||
'지출결의서',
|
||||
'원자재구매',
|
||||
'부자재구매',
|
||||
'일일지출내역서',
|
||||
];
|
||||
|
||||
// 현재 선택된 값 (예: write_form.php 로딩 시)
|
||||
// $currentItem 에는 기존 데이터에서 불러온 $row['eworks_item'] 등을 할당합니다.
|
||||
$currentItem = $row['eworks_item'] ?? '일반';
|
||||
?>
|
||||
|
||||
<select class="form-select" id="eworks_item" name="eworks_item" style="font-size:12px; height:30px;" onchange="eworksItemChanged(this)">
|
||||
<?php foreach ($eworksItems as $item): ?>
|
||||
<option value="<?= htmlspecialchars($item, ENT_QUOTES) ?>"
|
||||
<?= $item === $currentItem ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($item) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
<td class="text-center" > 결제라인 </td>
|
||||
<td>
|
||||
<div class="d-flex justify-content-start">
|
||||
<input type="text" class="form-control" id="e_line" name="e_line" >
|
||||
<input type="hidden" id="e_line_id" name="e_line_id">
|
||||
<button type="button" class="form-control" id="setLineBtn" onclick = "setLine();" ><i class="bi bi-search"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center" > 작성일시 </td>
|
||||
<td >
|
||||
<input type="text" class="form-control" id="registdate" name="registdate" >
|
||||
</td>
|
||||
<td class="text-center" > 작성자 </td>
|
||||
<td>
|
||||
<input type="text" class="form-control" id="author" name="author" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="align-items-center">
|
||||
<td class="text-start" > 결제진행 </td>
|
||||
<td colspan="3">
|
||||
<input type="text" class="form-control text-start" readonly id="e_prograss" name="e_prograss" >
|
||||
</td>
|
||||
<td class="text-center" >참조 </td>
|
||||
<td colspan="3">
|
||||
<div class="d-flex">
|
||||
<input type="text" class="form-control" id="r_line" style="width:90%;" name="r_line" >
|
||||
<input type="hidden" id="r_line_id" name="r_line_id">
|
||||
<button type="button" class="form-control" onclick="setRef();" style="width:8%;" ><i class="bi bi-search" ></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="align-items-center">
|
||||
<td class="text-center" > 내용 </td>
|
||||
<td colspan="7">
|
||||
<div class="row d-flex justify-content-center " >
|
||||
<div id="htmlContainer">
|
||||
<textarea id="contents" class="form-control" name="contents" rows="10"><?= isset($contents) ? $contents : '' ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="eworksBtn">
|
||||
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/eworks/eworksBtn.php'); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<span id="numdisplay"> </span>
|
||||
<button type="button" class="btn btn-outline-dark btn-sm" id="closesecondModalBtn" > × 닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user