- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
1548 lines
56 KiB
PHP
1548 lines
56 KiB
PHP
<?php
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
|
$title_message = '절곡품-중간검사 성적서';
|
|
$tablename = 'output';
|
|
$item ='절곡품중간검사성적서';
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
|
// 출고담당자관리자 명단
|
|
$QCadmin = false ;
|
|
if($user_name=='이세희' || $user_name=='개발자' || $user_name=='함신옥' || $user_name=='이경호' || $user_name=='노완호' )
|
|
$QCadmin = true ;
|
|
?>
|
|
<title> <?=$title_message?> </title>
|
|
<link rel="stylesheet" href="css/style.css">
|
|
</head>
|
|
|
|
<body>
|
|
<?php
|
|
// JavaScript에서 전달된 변수들 받기
|
|
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
|
|
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/estimate/fetch_unitprice.php");
|
|
$pdo = db_connect();
|
|
try {
|
|
$sql = "select * from {$DB}.{$tablename} where num = ? ";
|
|
$stmh = $pdo->prepare($sql);
|
|
$stmh->bindValue(1, $num, PDO::PARAM_STR);
|
|
$stmh->execute();
|
|
$count = $stmh->rowCount();
|
|
if ($count < 1) {
|
|
print "검색결과가 없습니다.<br>";
|
|
} else {
|
|
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
|
include "_row.php";
|
|
// output_extra 테이블에서 데이터 불러오기
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/output/load_output_extraTable.php';
|
|
}
|
|
} catch (PDOException $Exception) {
|
|
print "오류: " . $Exception->getMessage();
|
|
}
|
|
|
|
// JSON 문자열을 PHP 배열로 디코딩합니다.
|
|
//스크린발주서 읽기
|
|
$eList = json_decode($estimateSlatList, true);
|
|
|
|
// 행의 수는 배열의 크기와 동일하므로, count() 함수를 사용하여 구합니다.
|
|
$surang = count($eList);
|
|
|
|
// recordbendingMid 출고증 certificate of delivery
|
|
$recordbendingMid = isset($recordbendingMid) ? json_decode($recordbendingMid, true) : [];
|
|
|
|
// print_r($recordbendingMid);
|
|
|
|
// JSON 데이터를 JavaScript 변수로 변환
|
|
echo "<script>";
|
|
echo "var recordbendingMidData = " . json_encode($recordbendingMid) . ";";
|
|
echo "</script>";
|
|
|
|
$THscreenSu = $surang + 2 ;
|
|
|
|
// 디코딩된 데이터가 배열인지 확인합니다.
|
|
if (!is_array($eList)) {
|
|
echo "데이터가 정상적이지 않습니다. 확인바랍니다.";
|
|
exit;
|
|
}
|
|
|
|
else {
|
|
foreach ($eList as $item) {
|
|
$prodcode = $item['col4'];
|
|
$finishMat = $item['col7'];
|
|
$GuiderailType = $item['col6'];
|
|
$prodFinish = $item['col7'];
|
|
$items1 = ['KQTS01'];
|
|
$items2 = ['KTE01'];
|
|
|
|
// 마감형태에 따른 정의
|
|
$prodType = '';
|
|
if($prodcode == 'KQTS01')
|
|
{
|
|
$prodType = 'S1';
|
|
}
|
|
else if( ( strpos($finishMat, 'SUS') !== false and $prodcode == 'KTE01' ) or (strpos($finishMat, 'SUS') !== false and $prodcode == 'KTE01')) // sus포함
|
|
{
|
|
$prodType = 'S3'; // 별도마감형태
|
|
}
|
|
else
|
|
{
|
|
$prodType = 'S2'; // EGI 마감 형상은 S1과 같음 별도마감 없는 형태
|
|
}
|
|
|
|
// $prodcode가 $items1 배열에 있는 경우
|
|
if (in_array($prodcode, $items1)) {
|
|
$prodname = '국민방화 투시형 스틸 셔터';
|
|
}
|
|
// $prodcode가 $items2 배열에 있는 경우
|
|
elseif (in_array($prodcode, $items2)) {
|
|
$prodname = '국민방화 스틸 셔터';
|
|
} else {
|
|
$prodname = 'Unknown'; // $prodcode가 어느 배열에도 없는 경우
|
|
}
|
|
|
|
// print_r($prodcode);
|
|
// print_r($prodType);
|
|
|
|
}
|
|
}
|
|
|
|
$indateStr = date("m/d", strtotime($indate));
|
|
$todayStr = date("m/d");
|
|
$inspectdate = date("Y-m-d");
|
|
|
|
// 가이드레일 데이터 초기화
|
|
$row3_data = [
|
|
['length' => 2438, 'sum' => 0],
|
|
['length' => 3000, 'sum' => 0],
|
|
['length' => 3500, 'sum' => 0],
|
|
['length' => 4000, 'sum' => 0],
|
|
['length' => 4300, 'sum' => 0]
|
|
];
|
|
// 하장바크기에 의한 데이터 초기화
|
|
$bottombar_data = [
|
|
['length' => 3000, 'sum' => 0],
|
|
['length' => 4000, 'sum' => 0],
|
|
];
|
|
|
|
$wall_rows = [];
|
|
$side_rows = [];
|
|
|
|
// 가이드레일 정보 추출
|
|
// $eList 순회하여 데이터 추출
|
|
foreach ($eList as $item) {
|
|
$validLength = floatval($item['col24']); // 가이드레일 size
|
|
$railType = trim($item['col6']); // 레일 타입 (혼합형, 벽면형, 측면형)
|
|
|
|
//가이드레일
|
|
foreach ($row3_data as &$row) {
|
|
if ($validLength <= $row['length']) {
|
|
if ($railType == '혼합형(130*75)(130*125)') {
|
|
$row['sum'] = 1;
|
|
$wall_rows[] = ['length' => $row['length'], 'sum' => 1];
|
|
$side_rows[] = ['length' => $row['length'], 'sum' => 1];
|
|
} elseif ($railType == '벽면형(130*75)') {
|
|
$row['sum'] = 1;
|
|
$wall_rows[] = ['length' => $row['length'], 'sum' => $row['sum']];
|
|
} elseif ($railType == '측면형(130*125)') {
|
|
$row['sum'] = 1;
|
|
$side_rows[] = ['length' => $row['length'], 'sum' => $row['sum']];
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
//하단마감재
|
|
}
|
|
unset($row); // 참조 제거
|
|
|
|
// 중간검사에 대한 모델별 선언
|
|
$guiderailArray = []; // 최종적으로 데이터를 누적할 배열
|
|
// 벽면형
|
|
if(!empty($wall_rows)) {
|
|
foreach ($wall_rows as $index => $item) {
|
|
// 항목별 누적이 있어야 이미지를 한열에 통합할 수 있다.
|
|
switch ($prodType) { // 마감형태에 따른 정의
|
|
case 'S1':
|
|
case 'S2':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '가이드레일',
|
|
'타입' => '벽면형',
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => 30 , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => 78 , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => 25 , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => 45 , '측정값' => null],
|
|
['POINT' => '(5)', '도면치수' => 40 , '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'guiderail_wall_mid_slat',
|
|
]
|
|
];
|
|
|
|
if($prodcode == 'KQTS01') // KQTS01은 D형이 빠진다. 주의 검사항목도 1개 줄어듬 이미지 변경
|
|
{
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '가이드레일',
|
|
'타입' => '벽면형',
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => 30 , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => 78 , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => 25 , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => 45 , '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'guiderail_wall_mid_slatKQTS01',
|
|
]
|
|
];
|
|
}
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
case 'S3':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '가이드레일',
|
|
'타입' => '벽면형(별도마감)',
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => 30 , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => 78 , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => 25 , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => 45 , '측정값' => null],
|
|
['POINT' => '(5)', '도면치수' => 40 , '측정값' => null],
|
|
['POINT' => '(6)', '도면치수' => 29 , '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'guiderail_wall_mid_add_slat',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
// 측면형
|
|
if(!empty($side_rows)) {
|
|
foreach ($side_rows as $index => $item) {
|
|
switch ($prodType) { // 마감형태에 따른 정의
|
|
case 'S1':
|
|
case 'S2':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '가이드레일',
|
|
'타입' => '측면형',
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => 30 , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => 78 , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => 25 , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => 65 , '측정값' => null],
|
|
['POINT' => '(5)', '도면치수' => 105 , '측정값' => null],
|
|
['POINT' => '(6)', '도면치수' => 100 , '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'guiderail_side_mid_slat',
|
|
]
|
|
];
|
|
if($prodcode == 'KQTS01') // KQTS01은 D형이 빠진다. 주의 검사항목도 1개 줄어듬 이미지 변경
|
|
{
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '가이드레일',
|
|
'타입' => '측면형',
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => 30 , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => 78 , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => 25 , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => 65 , '측정값' => null],
|
|
['POINT' => '(5)', '도면치수' => 105 , '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'guiderail_side_mid_slatKQTS01',
|
|
]
|
|
];
|
|
}
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
case 'S3':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '가이드레일',
|
|
'타입' => '측면형(별도마감)',
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => 30 , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => 78 , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => 25 , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => 65 , '측정값' => null],
|
|
['POINT' => '(5)', '도면치수' => 105 , '측정값' => null],
|
|
['POINT' => '(6)', '도면치수' => 100 , '측정값' => null],
|
|
['POINT' => '(7)', '도면치수' => 29 , '측정값' => null],
|
|
['POINT' => '(8)', '도면치수' => 69 , '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'guiderail_side_mid_add_slat',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
unset($row); // 참조 제거
|
|
// 가이드레일 중복 제거
|
|
$guiderailArray = array_map('unserialize', array_unique(array_map('serialize', $guiderailArray)));
|
|
|
|
// 하단 마감재, 하단 보강엘바, 하단 보강평철, 하단 무게평철의 데이터를 저장할 배열
|
|
$item_data = [
|
|
['size' => '60x40', 'length' => 3000, 'sum' => 0],
|
|
['size' => '60x40', 'length' => 4000, 'sum' => 0],
|
|
];
|
|
|
|
$bottombar_rows = [];
|
|
|
|
// echo '<pre>';
|
|
// print_r($bottombar_rows);
|
|
// echo '</pre>';
|
|
|
|
// echo '<pre>';
|
|
// print_r($eList);
|
|
// echo '</pre>';
|
|
|
|
foreach ($eList as $item) {
|
|
// col50 (3000 길이) 처리
|
|
if(intval($item['col50']) > 0) {
|
|
$bottombar_rows[] = [
|
|
'size' => '60x40',
|
|
'length' => 3000,
|
|
'sum' => intval($item['col50'])
|
|
];
|
|
}
|
|
|
|
// col51 (4000 길이) 처리
|
|
if(intval($item['col51']) > 0) {
|
|
$bottombar_rows[] = [
|
|
'size' => '60x40',
|
|
'length' => 4000,
|
|
'sum' => intval($item['col51'])
|
|
];
|
|
}
|
|
}
|
|
|
|
unset($row); // 참조 제거
|
|
|
|
// 중복 제거
|
|
$bottombar_rows = array_map('unserialize', array_unique(array_map('serialize', $bottombar_rows)));
|
|
|
|
// 하단마감재
|
|
if(!empty($bottombar_rows)) {
|
|
foreach ($bottombar_rows as $index => $item) {
|
|
switch ($prodType) { // 마감형태에 따른 정의
|
|
case 'S1':
|
|
case 'S2':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '하단마감재',
|
|
'타입' => $item['size'],
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => 60 , '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'bottombar_KTE01KQTS01',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
case 'S3':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '하단마감재',
|
|
'타입' => '(별도마감형태) '. $item['size'],
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null],
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A'],
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => 60 , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => 64 , '측정값' => null],
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'bottombar_KTE01KQTS01_add',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
<?php
|
|
// 셔터박스 데이터 초기화
|
|
$box_data = [];
|
|
foreach ($eList as $item) {
|
|
$boxSize = trim($item['col37']); // 셔터박스 크기
|
|
if ($boxSize == 'custom') {
|
|
$boxSize = trim($item['col37_custom']);
|
|
}
|
|
|
|
$boxdirection = $item['col37_boxdirection'];
|
|
$frontbottom = $item['col37_frontbottom'];
|
|
$railwidth = $item['col37_railwidth'];
|
|
$cover = intval($item['col45']); // 상부덮개 수량
|
|
$fincover = intval($item['col47']); // 측면부 수량
|
|
$boxLengths = [
|
|
['length' => '1219', 'quantity' => intval($item['col39'])],
|
|
['length' => '2438', 'quantity' => intval($item['col40'])],
|
|
['length' => '3000', 'quantity' => intval($item['col41'])],
|
|
['length' => '3500', 'quantity' => intval($item['col42'])],
|
|
['length' => '4000', 'quantity' => intval($item['col43'])],
|
|
['length' => '4150', 'quantity' => intval($item['col44'])]
|
|
];
|
|
|
|
$existingKey = array_search($boxSize, array_column($box_data, 'size'));
|
|
|
|
if ($existingKey === false) {
|
|
// 새로운 사이즈 추가
|
|
$box_data[] = [
|
|
'size' => $boxSize,
|
|
'sum' => 1,
|
|
'cover' => $cover,
|
|
'fincover' => $fincover,
|
|
'boxdirection' => $boxdirection,
|
|
'frontbottom' => $frontbottom,
|
|
'railwidth' => $railwidth,
|
|
'length' => array_map(function ($length) {
|
|
return ['length' => $length['length'], 'sum' => $length['quantity']];
|
|
}, $boxLengths)
|
|
];
|
|
} else {
|
|
// 기존 데이터에 값 누적
|
|
$box_data[$existingKey]['sum'] += 1;
|
|
$box_data[$existingKey]['cover'] += $cover;
|
|
$box_data[$existingKey]['fincover'] += $fincover;
|
|
|
|
// 길이 데이터 누적
|
|
foreach ($boxLengths as $length) {
|
|
// $box_data에서 해당 길이 찾기
|
|
$key = array_search($length['length'], array_column($box_data[$existingKey]['length'], 'length'));
|
|
if ($key !== false) {
|
|
$box_data[$existingKey]['length'][$key]['sum'] += $length['quantity'];
|
|
} else {
|
|
echo "길이 {$length['length']}를 찾을 수 없습니다.\n"; // 디버깅 메시지
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// echo '<pre>';
|
|
// print_r($box_data);
|
|
// echo '</pre>';
|
|
|
|
// length에서 sum이 0인 항목 제거
|
|
foreach ($box_data as $key => &$box) {
|
|
$box['length'] = array_filter($box['length'], function ($lengthItem) {
|
|
return $lengthItem['sum'] > 0; // sum 값이 0보다 큰 항목만 유지
|
|
});
|
|
}
|
|
|
|
// // 결과 출력
|
|
// echo '<pre>';
|
|
// print_r($box_data);
|
|
// echo '</pre>';
|
|
|
|
if(!empty($box_data)) {
|
|
foreach ($box_data as $index => $item) {
|
|
list($boxwidth, $boxheight) = explode('*', $item['size']);
|
|
foreach ($item['length'] as $index => $lengths) {
|
|
switch ($item['boxdirection']) { // 박스 점검구 방향에 따라
|
|
case '양면':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '케이스',
|
|
'타입' => $item['size'] . ' ' . $item['boxdirection'] . ' 점검구' ,
|
|
'길이' => [
|
|
['도면치수' => $lengths['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => $boxheight , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => $frontbottom , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => ($boxwidth - $frontbottom - $railwidth - 140) , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => $frontbottom , '측정값' => null],
|
|
['POINT' => '(5)', '도면치수' => ($boxheight - 140) , '측정값' => null],
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'box_both',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
case '밑면':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '케이스',
|
|
'타입' => $item['size'] . ' ' . $item['boxdirection'] . ' 점검구' ,
|
|
'길이' => [
|
|
['도면치수' => $lengths['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => $boxheight , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => 50 , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => ($boxwidth - $frontbottom - $railwidth - 140) , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => $boxheight , '측정값' => null],
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'box_bottom',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
case '후면':
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '케이스',
|
|
'타입' => $item['size'] . ' ' . $item['boxdirection'] . ' 점검구' ,
|
|
'길이' => [
|
|
['도면치수' => $lengths['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => 'N/A', '측정값' => 'N/A']
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(1)', '도면치수' => $boxheight , '측정값' => null],
|
|
['POINT' => '(2)', '도면치수' => ($boxwidth - $frontbottom - $railwidth ) , '측정값' => null],
|
|
['POINT' => '(3)', '도면치수' => ($boxheight - 140) , '측정값' => null],
|
|
['POINT' => '(4)', '도면치수' => 50 , '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'box_rear',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
// 가이드레일용 연기차단재
|
|
$smoke_data = [
|
|
['length' => 2438, 'sum' => 0],
|
|
['length' => 3000, 'sum' => 0],
|
|
['length' => 3500, 'sum' => 0],
|
|
['length' => 4000, 'sum' => 0],
|
|
['length' => 4300, 'sum' => 0]
|
|
];
|
|
|
|
$smoke_rows = [];
|
|
|
|
foreach ($eList as $item) {
|
|
$validLength = floatval($item['col24']); // 가이드레일 유효 길이
|
|
|
|
foreach ($smoke_data as &$row) {
|
|
if ($validLength <= $row['length']) {
|
|
$row['sum'] = 1;
|
|
$smoke_rows[] = ['length' => $row['length'], 'sum' => 1];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
unset($row); // 참조 제거
|
|
|
|
// echo '<pre>';
|
|
// print_r($smoke_rows);
|
|
// echo '</pre>';
|
|
|
|
// 가장 큰 length 값을 가진 배열 요소 추출
|
|
$max_length_row = array_reduce($smoke_rows, function ($carry, $item) {
|
|
return $item['length'] > ($carry['length'] ?? 0) ? $item : $carry;
|
|
}, []);
|
|
|
|
|
|
// 가장 큰 length 값을 가진 요소의 인덱스 찾기
|
|
$max_length_index = null;
|
|
$max_length_value = 0;
|
|
|
|
foreach ($smoke_rows as $index => $item) {
|
|
if ($item['length'] > $max_length_value) {
|
|
$max_length_value = $item['length'];
|
|
$max_length_index = $index; // 최대값의 인덱스 저장
|
|
}
|
|
}
|
|
|
|
if ($max_length_index !== null) {
|
|
$item = $smoke_rows[$max_length_index];
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode,
|
|
'품명' => '연기차단재',
|
|
'타입' => 'W50(가이드레일용)',
|
|
'길이' => [
|
|
['도면치수' => $item['length'], '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => '(1) 50', '측정값' => null]
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(2)', '도면치수' => 12, '측정값' => null]
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'smoke',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
$smoke_data = [
|
|
['length' => 3000, 'sum' => 0],
|
|
];
|
|
|
|
$smoke_rows = [];
|
|
|
|
foreach ($eList as $item) {
|
|
$validSurang = floatval($item['col48']); // 셔터박스용 연기차단제 수량
|
|
|
|
foreach ($smoke_data as &$row) {
|
|
$row['sum'] = $validSurang;
|
|
$smoke_rows[] = ['length' => $row['length'], 'sum' => $row['sum'] ];
|
|
}
|
|
}
|
|
|
|
unset($row); // 참조 제거
|
|
|
|
// 중복 제거
|
|
$unique_smoke_rows = array_values(array_reduce($smoke_rows, function ($carry, $item) {
|
|
$carry[$item['length']] = $item; // length를 키로 사용
|
|
return $carry;
|
|
}, []));
|
|
|
|
if(!empty($unique_smoke_rows)) {
|
|
foreach ($unique_smoke_rows as $index => $item) {
|
|
|
|
$tempData = [
|
|
[
|
|
'분류' => $prodCode ,
|
|
'품명' => '연기차단재',
|
|
'타입' => 'W80(케이스용)',
|
|
'길이' => [
|
|
['도면치수' => $item['length'] , '측정값' => null]
|
|
],
|
|
'너비' => [
|
|
['도면치수' => '(1) 80', '측정값' => null ]
|
|
],
|
|
'간격' => [
|
|
['POINT' => '(2)', '도면치수' => 12 , '측정값' => null],
|
|
],
|
|
'판정' => null, // 적합 여부 (적/부)
|
|
'이미지' => 'smoke',
|
|
]
|
|
];
|
|
$guiderailArray = array_merge($guiderailArray, $tempData);
|
|
|
|
}
|
|
}
|
|
?>
|
|
|
|
|
|
<style>
|
|
|
|
/* 기본 스타일 설정 */
|
|
input[type="checkbox"] {
|
|
transform: scale(1.0); /* 크기 확대 */
|
|
margin: 3px; /* 여백 추가 */
|
|
}
|
|
#inspectionTable table, th, td {
|
|
font-size: 11px!important;
|
|
padding:2!important;
|
|
}
|
|
</style>
|
|
|
|
<div class="container mt-2">
|
|
<div class="d-flex align-items-center justify-content-end mt-1 m-2">
|
|
<button type="button" class="btn btn-dark btn-sm mx-3" onclick='location.reload();' title="새로고침"> <i class="bi bi-arrow-clockwise"></i> </button>
|
|
<button type="button" class="btn btn-danger btn-sm me-1 ms-1 initialBtn" > <i class="bi bi-trash3-fill"></i> 초기화 </button>
|
|
<button class="btn btn-dark btn-sm me-1 ms-1 saveData" > <i class="bi bi-floppy2-fill"></i> 서버 저장 </button>
|
|
<button class="btn btn-dark btn-sm me-1" onclick="generatePDF()"> PDF 저장 </button>
|
|
<!-- <button class="btn btn-dark btn-sm me-1" onclick="sendmail();"> <i class="bi bi-envelope-arrow-up"></i> 전송 </button> -->
|
|
<button type="button" class="btn btn-secondary btn-sm ms-5 " onclick="self.close();"> <i class="bi bi-x-lg"></i> 닫기 </button>
|
|
</div>
|
|
</div>
|
|
|
|
<form id="board_form" name="board_form" method="post" enctype="multipart/form-data" onkeydown="return captureReturnKey(event)" >
|
|
|
|
<input type="hidden" id="mode" name="mode" value="<?= isset($mode) ? $mode : '' ?>">
|
|
<input type="hidden" id="num" name="num" value="<?= isset($num) ? $num : '' ?>">
|
|
<input type="hidden" id="user_name" name="user_name" value="<?= isset($user_name) ? $user_name : '' ?>">
|
|
<input type="hidden" id="update_log" name="update_log" value="<?= isset($update_log) ? $update_log : NULL ?>">
|
|
<input type="hidden" id="tablename" name="tablename" value="<?= isset($tablename) ? $tablename : '' ?>">
|
|
<input type="hidden" id="item_name" name="item_name" value="<?= isset($item_name) ? $item_name : '' ?>">
|
|
<input type="hidden" id="recordbendingMid" name="recordbendingMid">
|
|
|
|
<div id="content-to-print">
|
|
<br>
|
|
<div class="container mt-3">
|
|
<div class="row">
|
|
<div class="d-flex align-items-center justify-content-center">
|
|
<table class="table " style="border-collapse: collapse;">
|
|
<thead>
|
|
<tr>
|
|
<th rowspan="3" class="text-center" style="width:70%;">
|
|
<div class="row">
|
|
<div class="col-sm-2">
|
|
<img src="../img/kdlogo.png" alt="경동기업" class="me-1" style="width:100%; height:auto;">
|
|
</div>
|
|
<div class="col-sm-10">
|
|
<div class="d-flex align-items-center justify-content-center m-1">
|
|
<span class="text-dark ms-2 me-2 fs-2" > 절곡품-중간 검사성적서 </span>
|
|
</div>
|
|
<br>
|
|
</div>
|
|
</div>
|
|
</th>
|
|
<th rowspan="3" class="text-center fw-bold" style="height:100px;">결 재</th>
|
|
<th class="text-center p-1 clickable" style="width : 70px; height:22px; padding:2px; cursor:pointer;" id="writer">작성</th>
|
|
<th class="text-center p-1 clickable" style="width : 70px; height:22px; padding:2px; cursor:pointer;" id="reviewer">검토</th>
|
|
<th class="text-center p-1 clickable approval-only" style="width : 90px; height:22px; padding:2px; cursor:pointer;" id="approver">승인</th>
|
|
</tr>
|
|
<tr style="height:40px;">
|
|
<th class="text-center" id="writerDisplay"></th>
|
|
<th class="text-center" id="reviewerDisplay"></th>
|
|
<th class="text-center" id="approvalDisplay"></th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center" style="height:22px; padding:2px;">판매/<?=$orderman?></th>
|
|
<th class="text-center" style="height:22px; padding:2px;">생산</th>
|
|
<th class="text-center text-primary fw-bold" style="height:22px; padding:2px;">품질</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="d-flex align-items-center justify-content-center">
|
|
<table id="myTable" class="table table-bordered" style="border-collapse: collapse;">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-center align-middle ">품명</th>
|
|
<th class="text-center">절곡품</th>
|
|
<th class="text-center align-middle blueBold">제품 LOT NO</th>
|
|
<th class="text-center fw-bold text-primary"><?=$lotNum?></th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle "> 규격 </th>
|
|
<th class="text-center">☑ 철재 □ 스크린 </th>
|
|
<th class="text-center align-middle lightgray">로트크기 </th>
|
|
<th colspan="1" class="text-center text-dark fw-bold"> <?=$surang ?> (개소) </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle ">발주처</th>
|
|
<th class="text-center"><?=$secondord?> </th>
|
|
<th class="text-center align-middle ">검사일자</th>
|
|
<th class="text-center"> <input type="date" id="inspectdate" name="inspectdate" class="form-control inputValue" value="<?= isset($inspectdate) ? $inspectdate : '' ?>" > </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle ">현장명</th>
|
|
<th class="text-center orangeBlackBold "><?=$outworkplace?> </th>
|
|
<th class="text-center align-middle ">검사자</th>
|
|
<th class="text-center" > <input type="text" class="form-control text-center inputValue noborder-input" id="reviewer_sub" name="reviewer_sub" > </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle yellowblackBold">제품명</th>
|
|
<th class="text-center text-danger fw-bold "><?=$prodcode?> </th>
|
|
<th class="text-center align-middle yellowblackBold">마감유형</th>
|
|
<th class="text-center text-danger fw-bold"> <?=$prodFinish?> </th>
|
|
</tr>
|
|
</thead>
|
|
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="d-flex align-items-center justify-content-center">
|
|
<table class="table " style="border-collapse: collapse;">
|
|
<tbody>
|
|
<tr>
|
|
<td rowspan="2" class="text-center align-middle orangeBlackBold ">중간 <br> 검사 <br> 기준서</td>
|
|
<td class="text-center align-middle orangeBlackBold "> 가이드레일 <br> 케이스 <br> 하단마감재 </td>
|
|
<td class="text-center align-middle"> <img src="../img/inspection/bending_inspection1.jpg" alt="중간검사" style="width:90%; height:auto;"> </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="text-center align-middle orangeBlackBold "> 연기차단재 </td>
|
|
<td class="text-center align-middle"> <img src="../img/inspection/bending_inspection2.jpg" alt="중간검사" style="width:90%; height:auto;"> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="d-flex align-items-center justify-content-center">
|
|
<table class="table mainTable" style="border-collapse: collapse;" >
|
|
<thead>
|
|
<tr>
|
|
<th rowspan="4" class="text-center align-middle"> <span id="allclick"> 분류 <br> 제품명 </span> </th>
|
|
<th rowspan="4" class="text-center align-middle">타입</th>
|
|
<th colspan="8" class="text-center align-middle orangeBlackBold"> 중간검사 DATA</th>
|
|
<th rowspan="4" class="text-center align-middle">판정 <br> (적/부) </th>
|
|
</tr>
|
|
<tr>
|
|
<th colspan="1" class="text-center align-middle orangeBlackBold"> 겉모양 </th>
|
|
<th colspan="7" class="text-center align-middle orangeBlackBold"> 치수(mm) </th>
|
|
</tr>
|
|
<tr>
|
|
<th rowspan="2" class="text-center align-middle orangeBlackBold"> 절곡상태 </th>
|
|
<th colspan="2" class="text-center align-middle orangeBlackBold"> 길이 </th>
|
|
<th colspan="2" class="text-center align-middle orangeBlackBold"> 너비 </th>
|
|
<th colspan="3" class="text-center align-middle orangeBlackBold"> 간격 </th>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-center align-middle orangeBlackBold"> 도면치수 </th>
|
|
<th class="text-center align-middle orangeBlackBold"> 측정값 </th>
|
|
<th class="text-center align-middle orangeBlackBold"> 도면치수 </th>
|
|
<th class="text-center align-middle orangeBlackBold"> 측정값 </th>
|
|
<th class="text-center align-middle orangeBlackBold"> POINT </th>
|
|
<th class="text-center align-middle orangeBlackBold"> 도면치수 </th>
|
|
<th class="text-center align-middle orangeBlackBold"> 측정값 </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
// 동일한 '제품명'과 '타입'을 그룹화
|
|
$groupedData = [];
|
|
foreach ($guiderailArray as $index => $item) {
|
|
$key = $item['분류'] . '_' . $item['타입']; // '제품명'과 '타입'을 조합한 키 생성
|
|
if (!isset($groupedData[$key])) {
|
|
$groupedData[$key] = [
|
|
'count' => 0, // 동일 그룹의 행 개수
|
|
'data' => []
|
|
];
|
|
}
|
|
$groupedData[$key]['count'] += count($item['간격']);
|
|
$groupedData[$key]['data'][] = $item;
|
|
}
|
|
|
|
// 테이블 출력
|
|
$innerCount = 0;
|
|
foreach ($groupedData as $groupKey => $group) {
|
|
$rowspan = $group['count'] ; // 현재 그룹의 행 개수
|
|
$firstItem = true; // 그룹의 첫 번째 행 여부 확인
|
|
|
|
foreach ($group['data'] as $index => $item) {
|
|
$gapRowspan = count($item['간격']); // 간격 항목의 개수
|
|
|
|
// 첫 번째 행에 '제품명', '타입'을 rowspan으로 출력
|
|
echo '<tr class="row-unique rowIndex' . $innerCount. ' gap-row-' . $innerCount. '">';
|
|
if ($firstItem) {
|
|
echo '<td rowspan="' . $rowspan . '" class="text-center align-middle">' . htmlspecialchars($item['분류']) . '<br>';
|
|
echo htmlspecialchars($item['품명']) . '</td>';
|
|
echo '<td rowspan="' . $rowspan . '" class="text-center align-middle">';
|
|
echo '<img src="../img/inspection/' . htmlspecialchars($item['이미지']) . '.jpg" style="max-width:200px; max-height:160px; width:auto; height:auto;"> <br>';
|
|
echo htmlspecialchars($item['타입']) . '</td>';
|
|
$firstItem = false; // 이후 행에서는 출력하지 않음
|
|
}
|
|
|
|
// 3열 이후 데이터
|
|
echo '<td rowspan="' . $gapRowspan . '" class="text-center">';
|
|
echo '<label>';
|
|
echo '<input type="checkbox" class="check-good" name="col1_status_' . $innerCount. '_good" value="양호"> 양호';
|
|
echo '</label>';
|
|
echo '<label>';
|
|
echo '<input type="checkbox" class="check-bad" name="col1_status_' . $innerCount. '_bad" value="불량"> 불량';
|
|
echo '</label>';
|
|
echo '</td>';
|
|
|
|
echo '<td rowspan="' . $gapRowspan . '" class="text-center lengthdwg fw-bold text-primary ">' . htmlspecialchars($item['길이'][0]['도면치수']) . '</td>';
|
|
echo '<td rowspan="' . $gapRowspan . '" class="text-center">';
|
|
echo '<input type="text" name="lengthMeasurement[]" class="form-control noborder-input text-center SpecialinputValue inputValue" autocomplete="off">';
|
|
echo '</td>';
|
|
|
|
echo '<td rowspan="' . $gapRowspan . '" class="text-center widthdwg fw-bold text-primary ">' . htmlspecialchars($item['너비'][0]['도면치수']) . '</td>';
|
|
echo '<td rowspan="' . $gapRowspan . '" class="text-center">';
|
|
echo '<input type="text" name="widthMeasurement[]" class="form-control noborder-input text-center SpecialinputValue inputValue" autocomplete="off" value="' . htmlspecialchars($item['너비'][0]['측정값']) . '">';
|
|
echo '</td>';
|
|
|
|
// 첫 번째 간격 데이터
|
|
echo '<td class="text-center ">' . htmlspecialchars($item['간격'][0]['POINT']) . '</td>';
|
|
echo '<td class="text-center fw-bold text-primary gapdwg"> ' . htmlspecialchars($item['간격'][0]['도면치수']) . '</td>';
|
|
echo '<td class="text-center ">';
|
|
echo '<input type="text" name="gapMeasurement[]" class="form-control noborder-input text-center SpecialinputValue inputValue" autocomplete="off">';
|
|
echo '</td>';
|
|
|
|
echo '<td rowspan="' . $gapRowspan . '" class="text-center align-middle judgement judge-' . $innerCount. '"></td>';
|
|
echo '</tr>';
|
|
|
|
// 나머지 간격 데이터 출력
|
|
for ($i = 1; $i < count($item['간격']); $i++) {
|
|
echo '<tr class="gap-row-' . $innerCount. '">';
|
|
echo '<td class="text-center">' . htmlspecialchars($item['간격'][$i]['POINT']) . '</td>';
|
|
echo '<td class="text-center fw-bold text-primary gapdwg"> ' . htmlspecialchars($item['간격'][$i]['도면치수']) . '</td>';
|
|
echo '<td class="text-center">';
|
|
echo '<input type="text" name="gapMeasurement[]" class="form-control noborder-input text-center SpecialinputValue inputValue" autocomplete="off">';
|
|
echo '</td>';
|
|
echo '</tr>';
|
|
}
|
|
|
|
$innerCount++ ;
|
|
}
|
|
}
|
|
// 부적합 내용란
|
|
echo '</tbody>';
|
|
echo '<tfoot>';
|
|
echo '<tr>';
|
|
echo '<td colspan="7" rowspan="4" class="text-start align-top fs-6"> [부적합 내용] <br>';
|
|
echo ' <input type="text" name="bending_false_comment" class="form-control inputValue noborder-input text-start" > ';
|
|
echo '</td>';
|
|
echo '<td colspan="4" rowspan="2" class="text-center yellowredBold fs-6"> 종합판정 <br>';
|
|
echo '<input type="text" class="form-control fs-3 text-center inputValue noborder-input" style="height:40px;" id="resultJudgement" name="resultJudgement" >';
|
|
echo '</td>';
|
|
echo '</tr>';
|
|
|
|
echo '</tfoot>';
|
|
echo '</table>';
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<div class="container mb-5 mt-2">
|
|
<div class="d-flex align-items-center justify-content-center mb-5">
|
|
</div>
|
|
</div>
|
|
|
|
</div> <!-- end of container -->
|
|
|
|
<!-- 페이지로딩 -->
|
|
<script>
|
|
function generatePDF() {
|
|
var workplace = '<?php echo $outworkplace; ?>';
|
|
var deadline = '<?php echo $indate; ?>';
|
|
var deadlineDate = new Date(deadline);
|
|
var formattedDate = "(" + String(deadlineDate.getFullYear()).slice(-2) + "." + ("0" + (deadlineDate.getMonth() + 1)).slice(-2) + "." + ("0" + deadlineDate.getDate()).slice(-2) + ")";
|
|
var result = 'KD절곡중간검사(' + workplace +')' + formattedDate + '.pdf';
|
|
|
|
var element = document.getElementById('content-to-print');
|
|
var opt = {
|
|
margin: [10, 3, 12, 3], // Top, right, bottom, left margins
|
|
filename: result,
|
|
image: { type: 'jpeg', quality: 0.98 },
|
|
html2canvas: { scale: 1 },
|
|
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
|
|
pagebreak: { mode: [''] }
|
|
};
|
|
html2pdf().from(element).set(opt).save();
|
|
}
|
|
|
|
$(document).on('click', '.saveData', function() {
|
|
saveData();
|
|
});
|
|
|
|
// 결재 취소 기능
|
|
$(document).on('click', '.remove-approval', function() {
|
|
// 승인자 정보를 지우고 화면에서 숨김
|
|
$('#approvalDisplay').html('').hide();
|
|
|
|
// JSON 데이터에서 승인자의 정보 제거
|
|
let formData = JSON.parse($('#recordbendingMid').val() || '[]');
|
|
const approvalIndex = formData.findIndex(item => item.approval);
|
|
|
|
if (approvalIndex !== -1) {
|
|
formData[approvalIndex].approval.approver.name = '';
|
|
formData[approvalIndex].approval.approver.date = '';
|
|
}
|
|
|
|
// JSON 문자열로 다시 저장
|
|
$('#recordbendingMid').val(JSON.stringify(formData));
|
|
|
|
Toastify({
|
|
text: "승인 정보가 삭제되었습니다.",
|
|
duration: 2000,
|
|
close: true,
|
|
gravity: "top",
|
|
position: "center",
|
|
style: {
|
|
background: "linear-gradient(to right, #ff5f6d, #ffc371)"
|
|
},
|
|
}).showToast();
|
|
|
|
saveData();
|
|
});
|
|
|
|
function saveData() {
|
|
// 결재 부분 정보 저장
|
|
let approvalData = {
|
|
writer: {
|
|
name: $('#writerDisplay').html().split('<br>')[0] || '',
|
|
date: $('#writerDisplay').html().split('<br>')[1] || ''
|
|
},
|
|
reviewer: {
|
|
name: $('#reviewerDisplay').html().split('<br>')[0] || '',
|
|
date: $('#reviewerDisplay').html().split('<br>')[1] || ''
|
|
},
|
|
approver: {
|
|
name: $('#approvalDisplay').clone().children('i').remove().end().html().split('<br>')[0] || '',
|
|
date: $('#approvalDisplay').clone().children('i').remove().end().html().split('<br>')[1] || ''
|
|
}
|
|
};
|
|
|
|
let formData = [];
|
|
formData.push({ approval: approvalData });
|
|
|
|
// Class 'inputValue' 값 저장
|
|
let inputValue = {};
|
|
$('.inputValue').each(function() {
|
|
let inputName = $(this).attr('name');
|
|
|
|
// 배열 형식의 이름인지 확인 (예: gapMeasurement[])
|
|
if (inputName.endsWith('[]')) {
|
|
inputName = inputName.slice(0, -2); // '[]' 부분 제거하여 이름만 추출
|
|
if (!inputValue[inputName]) {
|
|
inputValue[inputName] = []; // 배열이 없으면 초기화
|
|
}
|
|
inputValue[inputName].push($(this).val()); // 배열에 값 추가
|
|
} else {
|
|
inputValue[inputName] = $(this).val();
|
|
}
|
|
});
|
|
formData.push({ inputValue: inputValue });
|
|
|
|
// 추가 정보 저장
|
|
formData.push({ num: $('#num').val() });
|
|
formData.push({ tablename: $('#tablename').val() });
|
|
formData.push({ update_log: $('#update_log').val() });
|
|
|
|
// 체크박스 상태 저장
|
|
let checkboxData = [];
|
|
$('.mainTable tbody tr').each(function(index) {
|
|
let rowCheckboxes = {
|
|
good: [],
|
|
bad: [],
|
|
judgement: $(this).find('.judgement').text()
|
|
};
|
|
|
|
$(this).find('.check-good').each(function() {
|
|
rowCheckboxes.good.push($(this).prop('checked'));
|
|
});
|
|
|
|
$(this).find('.check-bad').each(function() {
|
|
rowCheckboxes.bad.push($(this).prop('checked'));
|
|
});
|
|
|
|
checkboxData.push(rowCheckboxes);
|
|
});
|
|
|
|
formData.push({ checkboxData: checkboxData });
|
|
|
|
// JSON 문자열로 변환
|
|
let jsonString = JSON.stringify(formData);
|
|
|
|
// 숨겨진 필드에 JSON 데이터 설정
|
|
$('#recordbendingMid').val(jsonString);
|
|
|
|
$("#overlay").show(); // 오버레이 표시
|
|
$("button").prop("disabled", true); // 모든 버튼 비활성화
|
|
|
|
showMsgModal(2); // 파일저장중
|
|
|
|
// 폼데이터 전송시 사용함 Get form
|
|
var form = $('#board_form')[0];
|
|
var datasource = new FormData(form);
|
|
|
|
$.ajax({
|
|
enctype: 'multipart/form-data',
|
|
processData: false,
|
|
contentType: false,
|
|
cache: false,
|
|
timeout: 600000,
|
|
url: "insert_bendingMid.php",
|
|
type: "post",
|
|
data: datasource,
|
|
dataType: "json",
|
|
success: function(data) {
|
|
// console.log(data);
|
|
setTimeout(function() {
|
|
$("button").prop("disabled", false); // 모든 버튼 활성화
|
|
hideMsgModal();
|
|
$("#overlay").hide(); // 오버레이 숨김
|
|
|
|
Toastify({
|
|
text: "저장완료",
|
|
duration: 3000,
|
|
close: true,
|
|
gravity: "top",
|
|
position: "center",
|
|
style: {
|
|
background: "linear-gradient(to right, #00b09b, #96c93d)"
|
|
},
|
|
}).showToast();
|
|
|
|
}, 1000);
|
|
},
|
|
error: function(jqxhr, status, error) {
|
|
console.log(jqxhr, status, error);
|
|
alert("An error occurred: " + error);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 부트스트랩 툴팁
|
|
$(document).ready(function() {
|
|
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
|
|
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
|
return new bootstrap.Tooltip(tooltipTriggerEl);
|
|
});
|
|
});
|
|
|
|
// 결재부분 클릭처리
|
|
$(document).on('click', '.clickable', function() {
|
|
const isQCadmin = <?= json_encode($QCadmin); ?>; // 관리자인 경우 true
|
|
const userName = <?= json_encode($user_name); ?>; // 현재 사용자 이름
|
|
const todayStr = <?= json_encode($todayStr); ?>; // 오늘 날짜
|
|
const todayDate = <?= json_encode(date('Y-m-d')); ?>; // 오늘 날짜 (YYYY-MM-DD 형식)
|
|
|
|
let targetId = $(this).attr('id') + 'Display';
|
|
|
|
// 작성과 검토는 누구나 가능
|
|
if ($(this).attr('id') === 'writer' ) {
|
|
$('#' + targetId).html(userName + '<br>' + todayStr);
|
|
}
|
|
else if ($(this).attr('id') === 'reviewer') {
|
|
$('#' + targetId).html(userName + '<br>' + todayStr);
|
|
$('#reviewer_sub').val(userName );
|
|
$('#inspectdate').val(todayDate); // 검사일자 검사자 기록
|
|
}
|
|
// 승인 버튼은 관리자만 가능
|
|
else if ($(this).attr('id') === 'approver') {
|
|
if (!isQCadmin) {
|
|
alert('승인 권한이 없습니다.');
|
|
return;
|
|
}
|
|
|
|
// 승인자의 이름과 오늘 날짜 표시
|
|
$('#approvalDisplay').html(
|
|
userName + '<br>' + todayStr +
|
|
' <i class="bi bi-x-circle remove-approval" style="cursor: pointer;"></i>'
|
|
);
|
|
$('#approvalDisplay').show();
|
|
|
|
// 결재 정보를 업데이트하여 저장 로직에 반영
|
|
updateApprovalData(userName, todayStr);
|
|
saveData(); // 저장까지 실행하기
|
|
}
|
|
});
|
|
|
|
// 결재 정보 업데이트 함수
|
|
function updateApprovalData(userName, date) {
|
|
let approvalData = {
|
|
writer: {
|
|
name: $('#writerDisplay').text().split('<br>')[0] || '',
|
|
date: $('#writerDisplay').text().split('<br>')[1] || ''
|
|
},
|
|
reviewer: {
|
|
name: $('#reviewerDisplay').text().split('<br>')[0] || '',
|
|
date: $('#reviewerDisplay').text().split('<br>')[1] || ''
|
|
},
|
|
approver: {
|
|
name: $('#approvalDisplay').text().split('<br>')[0] || '',
|
|
date: $('#approvalDisplay').text().split('<br>')[1] || ''
|
|
}
|
|
};
|
|
|
|
let formData = JSON.parse($('#recordbendingMid').val() || '[]');
|
|
const approvalIndex = formData.findIndex(item => item.approval);
|
|
|
|
if (approvalIndex !== -1) {
|
|
formData[approvalIndex].approval = approvalData;
|
|
} else {
|
|
formData.push({ approval: approvalData });
|
|
}
|
|
|
|
$('#recordbendingMid').val(JSON.stringify(formData));
|
|
}
|
|
|
|
// 팝업 창에서 데이터 저장 및 닫기 함수
|
|
function saveAndClose() {
|
|
const updatedData = {
|
|
resultJudgement: $("#resultJudgement").val(),
|
|
// author: $("#author").val(),
|
|
// remark: $("#remark").val()
|
|
};
|
|
|
|
hideMsgModal();
|
|
// 부모 창에 데이터 업데이트 호출
|
|
// window.opener.closePopupAndUpdateRow(updatedData);
|
|
|
|
// 팝업 창 닫기
|
|
// window.close();
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
// 초기화 버튼 클릭 이벤트
|
|
$('.initialBtn').on('click', function() {
|
|
// 초기화 확인 알림
|
|
Swal.fire({
|
|
title: '초기화',
|
|
text: "모든 데이터를 초기화하시겠습니까?",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: '예, 초기화합니다',
|
|
cancelButtonText: '취소'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
// recordbendingMid 값을 빈 배열로 초기화
|
|
const initialData = JSON.stringify([]); // 빈 배열로 초기화
|
|
|
|
// recordbendingMid hidden input에 초기화된 데이터 설정
|
|
$('#recordbendingMid').val(initialData);
|
|
|
|
// 초기화된 데이터 저장 요청
|
|
$.ajax({
|
|
url: 'insert_bendingMid.php', // 데이터를 저장할 PHP 파일 경로
|
|
type: 'POST',
|
|
data: {
|
|
num: $('#num').val() ,
|
|
tablename: $('#tablename').val() ,
|
|
update_log: $('#update_log').val() ,
|
|
recordbendingMid: initialData },
|
|
success: function(response) {
|
|
Swal.fire({
|
|
title: '초기화 완료',
|
|
text: "모든 데이터가 초기화되었습니다.",
|
|
icon: 'success',
|
|
confirmButtonText: '확인'
|
|
}).then(() => {
|
|
saveAndClose();
|
|
// 페이지 새로고침
|
|
location.reload();
|
|
});
|
|
},
|
|
error: function(jqxhr, status, error) {
|
|
Swal.fire({
|
|
title: '오류',
|
|
text: "초기화 중 오류가 발생했습니다.",
|
|
icon: 'error',
|
|
confirmButtonText: '확인'
|
|
});
|
|
console.log("AJAX Error: ", status, error);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
// 최초프로그램 로딩부터 동적 로직 구현
|
|
$(document).ready(function() {
|
|
if (recordbendingMidData.length > 0) {
|
|
console.log(recordbendingMidData);
|
|
|
|
// 결재 부분 정보 설정
|
|
const approval = recordbendingMidData.find(item => item.approval);
|
|
if (approval) {
|
|
$('#writerDisplay').html((approval.approval.writer.name || '') + '<br>' + (approval.approval.writer.date || ''));
|
|
$('#reviewerDisplay').html((approval.approval.reviewer.name || '') + '<br>' + (approval.approval.reviewer.date || ''));
|
|
if (approval.approval.approver.name && approval.approval.approver.date) {
|
|
$('#approvalDisplay').show();
|
|
$('#approvalDisplay').html(
|
|
approval.approval.approver.name + '<br>' + approval.approval.approver.date +
|
|
' <i class="bi bi-x-circle remove-approval" style="cursor: pointer;"></i>'
|
|
);
|
|
} else {
|
|
$('#approvalDisplay').hide().html('');
|
|
}
|
|
}
|
|
|
|
// input 정보 설정 (배열로 저장된 input 처리)
|
|
const inputValues = recordbendingMidData.find(item => item.inputValue);
|
|
if (inputValues) {
|
|
// 각 input 요소에 대해 값 설정
|
|
$('.inputValue').each(function() {
|
|
let inputName = $(this).attr('name').replace('[]', '');
|
|
|
|
// 배열 형식일 경우 각 요소를 올바르게 배치
|
|
if (Array.isArray(inputValues.inputValue[inputName])) {
|
|
const values = inputValues.inputValue[inputName];
|
|
|
|
// 이름이 같은 모든 요소에 값을 순서대로 할당
|
|
$(`input[name="${inputName}[]"]`).each(function(index) {
|
|
$(this).val(values[index] || '');
|
|
});
|
|
} else {
|
|
// 단일 값일 경우 바로 설정
|
|
$(this).val(inputValues.inputValue[inputName] || '');
|
|
}
|
|
});
|
|
}
|
|
|
|
// 체크박스 상태 설정 및 초기 판정
|
|
const checkboxData = recordbendingMidData.find(item => item.checkboxData)?.checkboxData || [];
|
|
if (checkboxData) {
|
|
$('.mainTable tbody tr').each(function(index) {
|
|
const rowCheckboxData = checkboxData[index] || { good: [], bad: [], judgement: "" };
|
|
const $row = $(this);
|
|
|
|
// 각 행의 체크박스 설정
|
|
$row.find('.check-good').each(function(goodIndex) {
|
|
$(this).prop('checked', rowCheckboxData.good[goodIndex] || false);
|
|
});
|
|
$row.find('.check-bad').each(function(badIndex) {
|
|
$(this).prop('checked', rowCheckboxData.bad[badIndex] || false);
|
|
});
|
|
|
|
// 판정 설정
|
|
$row.find('.judgement').text(rowCheckboxData.judgement);
|
|
});
|
|
}
|
|
|
|
// 초기 판정 수행
|
|
$('.mainTable tbody tr').each(function() {
|
|
updateJudgement($(this));
|
|
});
|
|
updateFinalJudgement(); // 최종 판정 업데이트
|
|
}
|
|
|
|
// 판정 업데이트 함수
|
|
function updateJudgement($row) {
|
|
const lengthTolerance = 4;
|
|
const gapTolerance = 2;
|
|
|
|
// 각 아이템(row-unique) 기준으로 처리
|
|
$('.mainTable tbody tr.row-unique').each(function(index) {
|
|
const $itemRow = $(this); // 현재 아이템의 첫 번째 행
|
|
var isWidthValid = true;
|
|
|
|
let isAllGapValid = true; // 간격 검사 결과
|
|
let allGood = true; // 모든 양호 체크박스 상태
|
|
let anyBad = false; // 불량 체크 여부
|
|
|
|
// 양호/불량 체크박스 상태 검사
|
|
$itemRow.find('.check-good').each(function() {
|
|
if (!$(this).is(':checked')) allGood = false;
|
|
});
|
|
$itemRow.find('.check-bad').each(function() {
|
|
if ($(this).is(':checked')) anyBad = true;
|
|
});
|
|
|
|
const lengthDrawingValue = parseFloat($itemRow.find('.lengthdwg').text()) || 0;
|
|
const lengthMeasuredValue = parseFloat($itemRow.find('input[name="lengthMeasurement[]"]').val()) || 0;
|
|
|
|
// 길이 적합성 검사
|
|
const isLengthValid = Math.abs(lengthMeasuredValue - lengthDrawingValue) <= lengthTolerance;
|
|
|
|
// 너비 검사 (N/A 처리)
|
|
const widthDrawingValue = $itemRow.find('.widthdwg').text().replace(/\(.*?\)\s*/, '').trim();
|
|
if (widthDrawingValue !== 'N/A') {
|
|
const widthMeasuredValue = parseFloat(
|
|
($itemRow.find('input[name="widthMeasurement[]"]').val() || '').replace(/\(.*?\)\s*/, '')
|
|
) || 0;
|
|
isWidthValid = Math.abs(widthMeasuredValue - parseFloat(widthDrawingValue)) <= lengthTolerance;
|
|
}
|
|
|
|
// 현재 아이템의 모든 gap-row 검사
|
|
let gapRows = $itemRow.nextUntil('tr.row-unique').filter(`.gap-row-${index}`);
|
|
|
|
// 첫 번째 행도 포함하도록 gapRows를 수정 (중요함.. 1시간동안 버그 찾음)
|
|
gapRows = $itemRow.add(gapRows);
|
|
|
|
// if (gapRows.length === 0) {
|
|
// console.warn(`.gap-row-${index} 요소를 찾을 수 없음`);
|
|
// } else {
|
|
// console.log(`gapRows.length: ${gapRows.length}`);
|
|
// }
|
|
|
|
gapRows.each(function (idx) {
|
|
const $gapRow = $(this);
|
|
const gapDrawingValue = parseFloat($gapRow.find('.gapdwg').text()) || 0;
|
|
const gapMeasuredValue = parseFloat($gapRow.find('input[name="gapMeasurement[]"]').val()) || 0;
|
|
const isGapValid = Math.abs(gapMeasuredValue - gapDrawingValue) <= gapTolerance;
|
|
|
|
// console.log(`gap-row ${idx + 1}: 측정값=${gapMeasuredValue}, 도면치수=${gapDrawingValue}, 적합=${isGapValid}`);
|
|
if (!isGapValid) {
|
|
isAllGapValid = false;
|
|
}
|
|
});
|
|
|
|
// 아이템 전체 적합성 검사
|
|
const isRowValid = isAllGapValid && allGood && !anyBad && isLengthValid && isWidthValid;
|
|
|
|
// 판정 결과를 judgement 셀에 적용
|
|
$itemRow.find(`.judge-${index}`).text(isRowValid ? '적' : '부');
|
|
// console.log(`.judge-${index} : isRowValid ${isRowValid}`);
|
|
});
|
|
}
|
|
|
|
// 종합판정 업데이트 함수
|
|
function updateFinalJudgement() {
|
|
let isAllRowsValid = true;
|
|
|
|
// 모든 `judgement` 요소를 확인
|
|
$('.mainTable .judgement').each(function() {
|
|
if ($(this).text().trim() !== '적') {
|
|
isAllRowsValid = false;
|
|
return false; // 하나라도 '적'이 아니면 루프 중단
|
|
}
|
|
});
|
|
|
|
|
|
// 모든 judgement 클래스를 탐색
|
|
$('.judgement').each(function() {
|
|
// 텍스트가 '적'인지 확인
|
|
if ($(this).text().trim() === '부') {
|
|
// 배경색 변경
|
|
$(this).css('background-color', '#f8d7da');
|
|
}
|
|
else
|
|
// 배경색 변경
|
|
$(this).css('background-color', '#FFFFFF');
|
|
|
|
});
|
|
|
|
// 종합판정 결과 설정
|
|
if (isAllRowsValid) {
|
|
$('#resultJudgement').val('합격');
|
|
$('#resultJudgement').css('background-color', '#ffff');
|
|
} else {
|
|
$('#resultJudgement').val('불합격');
|
|
$('#resultJudgement').css('background-color', '#f8d7da');
|
|
}
|
|
|
|
}
|
|
|
|
// 체크박스 토글 설정 및 변경 시 판정 업데이트
|
|
$('.mainTable').on('change', '.check-good, .check-bad', function() {
|
|
const $row = $(this).closest('tr');
|
|
|
|
// '양호'와 '불량' 체크박스 토글
|
|
if ($(this).hasClass('check-good') && $(this).is(':checked')) {
|
|
$row.find('.check-bad').prop('checked', false);
|
|
} else if ($(this).hasClass('check-bad') && $(this).is(':checked')) {
|
|
$row.find('.check-good').prop('checked', false);
|
|
}
|
|
|
|
updateJudgement($row);
|
|
updateFinalJudgement();
|
|
});
|
|
|
|
// 측정값 변경 시 판정 업데이트
|
|
$('.mainTable').on('input change', 'input[name="lengthMeasurement[]"], input[name="widthMeasurement[]"], input[name="gapMeasurement[]"]', function() {
|
|
const $row = $(this).closest('tr');
|
|
console.clear();
|
|
updateJudgement($row);
|
|
updateFinalJudgement();
|
|
});
|
|
|
|
// 초기화
|
|
updateFinalJudgement();
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
// 'allclick' ID를 가진 요소를 클릭했을 때 실행
|
|
$('#allclick').on('click', function() {
|
|
// 1. 모든 체크박스를 체크 상태로 설정
|
|
$('.check-good').prop('checked', true);
|
|
$('.check-bad').prop('checked', false);
|
|
|
|
// 2. input 요소 근처의 텍스트를 읽어서 input 값에 넣기
|
|
$('input.SpecialinputValue').each(function() {
|
|
// input 요소의 부모(td)의 이전 형제(td)에서 텍스트 읽기
|
|
let adjacentText = $(this).closest('td').prev().text().trim();
|
|
|
|
// (1)과 같은 텍스트 제거 및 공백 제거
|
|
let cleanedText = adjacentText.replace(/\(.*?\)\s*/, '').trim();
|
|
|
|
// 처리된 텍스트를 input 값으로 설정
|
|
$(this).val(cleanedText);
|
|
});
|
|
|
|
// 3. 강제로 input 요소의 input/change 이벤트 발생
|
|
$('input[name="lengthMeasurement[]"], input[name="widthMeasurement[]"], input[name="gapMeasurement[]"]').each(function() {
|
|
$(this).trigger('input'); // 또는 'change' 이벤트
|
|
});
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
<?php include $_SERVER['DOCUMENT_ROOT'] . '/' . $tablename . '/common/basicJS.php'; ?> <!-- loader 및 기본 JS 공통 -->
|
|
|
|
</body>
|
|
</html>
|