prepare($sql); $stmh->bindValue(1, $num, PDO::PARAM_STR); $stmh->execute(); $row = $stmh->fetch(PDO::FETCH_ASSOC); // 자료수정 로그 $update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . "\n"; // 트랜잭션 시작 $pdo->beginTransaction(); $sql = "UPDATE $DB.$tablename SET indate=?, orderman=?, outworkplace=?, comment=?, con_num=?, "; $sql .= "model_name=?, update_log=?, secondord=?, secondordman=?, secondordmantel=?, estimateList=?, estimateList_auto=?, estimateSlatList=?, estimateSlatList_auto=?, pjnum=?, major_category=?, position=?, makeWidth=?, makeHeight=?, secondordnum=?, "; $sql .= "estimateTotal=?, EstimateFirstSum=?, EstimateUpdatetSum=?, EstimateDiffer=?, EstimateDiscountRate=?, EstimateDiscount=?, EstimateFinalSum=?, maguriWing=?, inspectionFee=?, estimateSurang=?, "; $sql .= "steel=?, motor=?, warranty=?, slatcheck=?, partscheck=? WHERE num=? LIMIT 1"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $indate, PDO::PARAM_STR); $stmh->bindValue(2, $orderman, PDO::PARAM_STR); $stmh->bindValue(3, $outworkplace, PDO::PARAM_STR); $stmh->bindValue(4, $comment, PDO::PARAM_STR); $stmh->bindValue(5, $con_num, PDO::PARAM_STR); $stmh->bindValue(6, $model_name, PDO::PARAM_STR); $stmh->bindValue(7, $update_log, PDO::PARAM_STR); $stmh->bindValue(8, $secondord, PDO::PARAM_STR); $stmh->bindValue(9, $secondordman, PDO::PARAM_STR); $stmh->bindValue(10, $secondordmantel, PDO::PARAM_STR); $stmh->bindValue(11, json_encode($estimateList_jsondata), PDO::PARAM_STR); $stmh->bindValue(12, json_encode($estimateList_auto_jsondata), PDO::PARAM_STR); $stmh->bindValue(13, json_encode($estimateSlatList_jsondata), PDO::PARAM_STR); $stmh->bindValue(14, json_encode($estimateSlatList_auto_jsondata), PDO::PARAM_STR); $stmh->bindValue(15, $pjnum, PDO::PARAM_STR); $stmh->bindValue(16, $major_category, PDO::PARAM_STR); $stmh->bindValue(17, $position, PDO::PARAM_STR); $stmh->bindValue(18, $makeWidth, PDO::PARAM_STR); $stmh->bindValue(19, $makeHeight, PDO::PARAM_STR); $stmh->bindValue(20, $secondordnum, PDO::PARAM_STR); $stmh->bindValue(21, intval(str_replace(',', '', $estimateTotal)), PDO::PARAM_INT); $stmh->bindValue(22, intval(str_replace(',', '', $EstimateFirstSum)), PDO::PARAM_INT); $stmh->bindValue(23, intval(str_replace(',', '', $EstimateUpdatetSum)), PDO::PARAM_INT); $stmh->bindValue(24, intval(str_replace(',', '', $EstimateDiffer)), PDO::PARAM_INT); $stmh->bindValue(25, intval(str_replace(',', '', $EstimateDiscountRate)), PDO::PARAM_INT); $stmh->bindValue(26, intval(str_replace(',', '', $EstimateDiscount)), PDO::PARAM_INT); $stmh->bindValue(27, intval(str_replace(',', '', $EstimateFinalSum)), PDO::PARAM_INT); $stmh->bindValue(28, $maguriWing, PDO::PARAM_STR); $stmh->bindValue(29, intval(str_replace(',', '', $inspectionFee)), PDO::PARAM_INT); $stmh->bindValue(30, intval(str_replace(',', '', $estimateSurang)), PDO::PARAM_INT); $stmh->bindValue(31, $steel, PDO::PARAM_STR); $stmh->bindValue(32, $motor, PDO::PARAM_STR); $stmh->bindValue(33, $warranty, PDO::PARAM_STR); $stmh->bindValue(34, $slatcheck, PDO::PARAM_STR); $stmh->bindValue(35, $partscheck, PDO::PARAM_STR); $stmh->bindValue(36, $num, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } if ($mode == "insert") { // 데이터 신규 등록하는 구간 $update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " "; $pdo->beginTransaction(); $sql = "INSERT INTO $DB.$tablename (indate, orderman, outworkplace, comment, con_num, model_name, update_log, secondord, secondordman, secondordmantel, estimateList, estimateList_auto, estimateSlatList, estimateSlatList_auto, pjnum, major_category, position, makeWidth, makeHeight, secondordnum, "; $sql .= " estimateTotal, EstimateFirstSum, EstimateUpdatetSum, EstimateDiffer, EstimateDiscountRate, EstimateDiscount, EstimateFinalSum, maguriWing, inspectionFee, estimateSurang, steel, motor, warranty, slatcheck, partscheck) "; $sql .= "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $indate, PDO::PARAM_STR); $stmh->bindValue(2, $orderman, PDO::PARAM_STR); $stmh->bindValue(3, $outworkplace, PDO::PARAM_STR); $stmh->bindValue(4, $comment, PDO::PARAM_STR); $stmh->bindValue(5, $con_num, PDO::PARAM_STR); $stmh->bindValue(6, $model_name, PDO::PARAM_STR); $stmh->bindValue(7, $update_log, PDO::PARAM_STR); $stmh->bindValue(8, $secondord, PDO::PARAM_STR); $stmh->bindValue(9, $secondordman, PDO::PARAM_STR); $stmh->bindValue(10, $secondordmantel, PDO::PARAM_STR); $stmh->bindValue(11, json_encode($estimateList_jsondata), PDO::PARAM_STR); $stmh->bindValue(12, json_encode($estimateList_auto_jsondata), PDO::PARAM_STR); $stmh->bindValue(13, json_encode($estimateSlatList_jsondata), PDO::PARAM_STR); $stmh->bindValue(14, json_encode($estimateSlatList_auto_jsondata), PDO::PARAM_STR); $stmh->bindValue(15, $pjnum, PDO::PARAM_STR); $stmh->bindValue(16, $major_category, PDO::PARAM_STR); $stmh->bindValue(17, $position, PDO::PARAM_STR); $stmh->bindValue(18, $makeWidth, PDO::PARAM_STR); $stmh->bindValue(19, $makeHeight, PDO::PARAM_STR); $stmh->bindValue(20, $secondordnum, PDO::PARAM_STR); $stmh->bindValue(21, intval(str_replace(',', '', $estimateTotal)), PDO::PARAM_INT); // int 형태로 저장 $stmh->bindValue(22, intval(str_replace(',', '', $EstimateFirstSum)), PDO::PARAM_INT); // 추가된 필드 $stmh->bindValue(23, intval(str_replace(',', '', $EstimateUpdatetSum)), PDO::PARAM_INT); // 추가된 필드 $stmh->bindValue(24, intval(str_replace(',', '', $EstimateDiffer)), PDO::PARAM_INT); // 추가된 필드 $stmh->bindValue(25, intval(str_replace(',', '', $EstimateDiscountRate)), PDO::PARAM_INT); $stmh->bindValue(26, intval(str_replace(',', '', $EstimateDiscount)), PDO::PARAM_INT); $stmh->bindValue(27, intval(str_replace(',', '', $EstimateFinalSum)), PDO::PARAM_INT); $stmh->bindValue(28, $maguriWing, PDO::PARAM_STR); $stmh->bindValue(29, intval(str_replace(',', '', $inspectionFee)), PDO::PARAM_INT); // int 형태로 저장 $stmh->bindValue(30, intval(str_replace(',', '', $estimateSurang)), PDO::PARAM_INT); // int 형태로 저장 $stmh->bindValue(31, $steel, PDO::PARAM_STR); $stmh->bindValue(32, $motor, PDO::PARAM_STR); $stmh->bindValue(33, $warranty, PDO::PARAM_STR); $stmh->bindValue(34, $slatcheck, PDO::PARAM_STR); $stmh->bindValue(35, $partscheck, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } if ($mode == "delete") { $pdo->beginTransaction(); $query = "UPDATE $DB.$tablename SET is_deleted='1' WHERE num=? LIMIT 1"; $stmh = $pdo->prepare($query); $params = [$num]; $stmh->execute($params); $pdo->commit(); } if ($mode == "insert" || $mode == "copy") { $sql = "SELECT * FROM $DB.$tablename ORDER BY num DESC LIMIT 1"; $stmh = $pdo->prepare($sql); $stmh->execute(); $row = $stmh->fetch(PDO::FETCH_ASSOC); $num = $row["num"]; } $data = [ 'num' => $num, 'mode' => $mode, 'is_deleted' => $is_deleted ]; echo json_encode($data, JSON_UNESCAPED_UNICODE); } catch (PDOException $Exception) { error_log("오류: " . $Exception->getMessage()); http_response_code(500); echo json_encode(['error' => $Exception->getMessage()]); } catch (Exception $e) { error_log("오류: " . $e->getMessage()); http_response_code(500); echo json_encode(['error' => $e->getMessage()]); } ?>