- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
88 lines
3.6 KiB
PHP
88 lines
3.6 KiB
PHP
<?php
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
|
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
|
|
|
if(empty($DB))
|
|
$DB = 'chandj';
|
|
|
|
$pdo = db_connect();
|
|
|
|
$item_name = isset($_POST['item_name']) ? trim($_POST['item_name']) : '';
|
|
$tablename = 'instock';
|
|
|
|
$lot_type = $_POST['lot_type'];
|
|
$usesurang = $_POST['usesurang'];
|
|
|
|
echo "품목 : " . $item_name . " 로트 ";
|
|
|
|
if (empty($item_name)) {
|
|
echo '<div class="alert alert-danger">품목명이 없습니다.</div>';
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
// 로트 번호를 품목명에 따라 조회
|
|
$sql = "select * FROM {$DB}.instock
|
|
WHERE prodcode = :search AND (is_deleted IS NULL or is_deleted = '' ) AND (lotDone IS NULL or lotDone = '')
|
|
ORDER BY inspection_date DESC, lot_no ASC limit 12 ";
|
|
|
|
$stmh = $pdo->prepare($sql);
|
|
$stmh->bindValue(':search', $item_name , PDO::PARAM_STR); // 와일드카드 추가
|
|
$stmh->execute();
|
|
$rows = $stmh->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if (count($rows) > 0) {
|
|
echo '<div style="max-height: 400px; overflow-y: auto;">'; // 스크롤 컨테이너 시작
|
|
echo '<table class="table table-hover">';
|
|
echo '<thead class="table-primary">';
|
|
echo '<tr>';
|
|
echo '<th class="text-center">로트 번호</th>';
|
|
echo '<th class="text-center">품명 </th>';
|
|
echo '<th class="text-center">규격 </th>';
|
|
echo '<th class="text-center">품목코드 </th>';
|
|
echo '<th class="text-center">입고량 </th>';
|
|
echo '<th class="text-center">납품업체</th>';
|
|
echo '<th class="text-center">검사일</th>';
|
|
echo '<th class="text-center">로트소진</th>';
|
|
echo '</tr>';
|
|
echo '</thead>';
|
|
echo '<tbody id="lotModalBody">';
|
|
|
|
foreach ($rows as $row) {
|
|
$lot_no = htmlspecialchars($row['lot_no']);
|
|
$received_qty = number_format((int)$row['received_qty']);
|
|
$supplier = htmlspecialchars($row['supplier']);
|
|
$inspection_date = htmlspecialchars($row['inspection_date']);
|
|
$num = htmlspecialchars($row['num']);
|
|
$item_name = htmlspecialchars($row['item_name']);
|
|
$specification = htmlspecialchars($row['specification']);
|
|
$prodcode = htmlspecialchars($row['prodcode']);
|
|
|
|
echo '<tr>';
|
|
echo '<td class="text-center" onclick="selectLotNumber(\'' . $lot_no . '\')"> ' . $lot_no . '</td>';
|
|
echo '<td class="text-center" onclick="selectLotNumber(\'' . $lot_no . '\')"> ' . $item_name . '</td>';
|
|
echo '<td class="text-center" onclick="selectLotNumber(\'' . $lot_no . '\')"> ' . $specification . '</td>';
|
|
echo '<td class="text-center" onclick="selectLotNumber(\'' . $lot_no . '\')"> ' . $prodcode . '</td>';
|
|
echo '<td class="text-center" onclick="selectLotNumber(\'' . $lot_no . '\')"> ' . $received_qty . '</td>';
|
|
echo '<td class="text-center" onclick="selectLotNumber(\'' . $lot_no . '\')"> ' . $supplier . '</td>';
|
|
echo '<td class="text-center" onclick="selectLotNumber(\'' . $lot_no . '\')"> ' . $inspection_date . '</td>';
|
|
// '소진' 버튼 추가
|
|
echo '<td class="text-center">';
|
|
echo '<button type="button" class="btn btn-sm btn-danger lot-done-btn" data-num="' . $num . '" data-tablename="' . $tablename . '" data-item_name="' . $item_name . '" data-lottype="' . $lot_type . '" >소진</button>';
|
|
echo '</td>';
|
|
echo '</tr>';
|
|
}
|
|
|
|
echo '</tbody>';
|
|
echo '</table>';
|
|
echo '</div>'; // 스크롤 컨테이너 종료
|
|
} else {
|
|
echo '<div class="alert alert-warning">해당 품목명에 대한 로트 번호가 없습니다. item_name : ' . $item_name . '</div>';
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
echo '<div class="alert alert-danger">오류: ' . htmlspecialchars($e->getMessage()) . '</div>';
|
|
}
|
|
?>
|