5) { sleep(1); header("Location:" . $WebSite . "login/login_form.php"); exit; } ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php'; $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : ''; $num = isset($_REQUEST["num"]) ? $_REQUEST["num"] : ""; $tablename = isset($_REQUEST["tablename"]) ? $_REQUEST["tablename"] : ""; require_once $_SERVER['DOCUMENT_ROOT'] . '/load_GoogleDriveSecond.php'; // attached, image에 대한 정보 불러오기 require_once $_SERVER['DOCUMENT_ROOT'].'/estimate/fetch_unitprice.php'; // 견적에 필요한 함수포함 slatPrice 함수 포함 // 절곡단가 가져오는 임시테이블 $tablename_tmp = 'price_bend'; try { // 최신 데이터를 가져오기 위해 ORDER BY와 LIMIT을 추가 $sql = "SELECT * FROM {$DB}.$tablename_tmp where (is_deleted IS NULL or is_deleted = '0') ORDER BY num DESC LIMIT 1"; $stmh = $pdo->prepare($sql); $stmh->execute(); $row = $stmh->fetch(PDO::FETCH_ASSOC); // $row 배열로 DB 정보를 불러온다. $itemList_bend = isset($row['itemList']) ? $row['itemList'] : []; $load_priceDate = $row['registedate'] ?? ''; // itemList 문자열일 때만 json_decode 실행 if (is_string($itemList_bend)) { $itemList_bend = json_decode($itemList_bend, true); } // itemList 유효한 배열이 아닐 경우 빈 배열로 초기화 if (!is_array($itemList_bend)) { $itemList_bend = []; } } catch (PDOException $Exception) { print "오류: ".$Exception->getMessage(); } // 주자재 단가 가져오기 $tablename_price_raw_materials = 'price_raw_materials'; $query = "SELECT itemList FROM $DB.$tablename_price_raw_materials WHERE is_deleted IS NULL OR is_deleted = 0"; $stmt = $pdo->prepare($query); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // 대상 자재 목록 (구분 항목) $materials = ['방화', '방범','조인트바', '실리카', '화이바', '와이어', '신설비상문','제연커튼','실리카원단','화이바원단','와이어원단','단열셔터','이중파이프']; // 자재 단가 저장용 배열 $materialBasePrice = []; // 자재 코드 $materialBaseCode = []; foreach ($materials as $material) { foreach ($rows as $row) { $itemList = json_decode($row['itemList'], true); $price = unapprovedSlatPrice($itemList, '', $material); // col1=스크린, col2=각 자재명 col15에서 비인정 불러옴 $code = unapprovedSlatCode($itemList, $material); // col1=스크린, col2=각 자재명 $materialBasePrice[$material] = floatval($price); $materialBaseCode[$material] = $code; } } // print_r($materialBasePrice); // print_r($materialBaseCode); // 자바스크립트에 단가 데이터 전달 echo ""; // 전동개폐기 등 Ecount 단가 가져오기 // (2) KDunitprice 테이블 전체 또는 필요한 prodcode만 조회 $prodcode_sql = " SELECT prodcode, item_name, spec, unitprice FROM {$DB}.KDunitprice WHERE is_deleted IS NULL "; $stmt = $pdo->prepare($prodcode_sql); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // (3) PHP associative 배열에 담기 $unitInfo = []; foreach ($rows as $r) { $unitInfo[$r['item_name']] = [ 'prodcode' => $r['prodcode'], 'item_name' => $r['item_name'], 'spec' => $r['spec'], 'price' => (float)$r['unitprice'], ]; } // print_r($unitInfo); // (4) JS 전역 변수로 내보내기 echo ""; if($mode === 'copy') $title_message = "(데이터복사) 수주내역"; else $title_message = "수주내역 " ; $authorities = ["개발자","전진","노완호","이세희","함신옥","손금주","이은진","이경호","김진호","이세희","함신옥"]; // 서버에서 날짜 값을 받아온다고 가정 $receivedCode = ""; // 예시값, 실제로는 서버에서 받아오는 값으로 대체 if(!empty($authority)) echo 'authority : ' . $authority ; ?>