<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>식당등록</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
<script src='main.js'></script>
</head>
<body>
<div>
<h3>메뉴 관리</h3>
<a th:href="@{/restaurant1/selectlist.food?page=1&type=phone&text=}"><button>식당목록</button></a>
식당연락처: <label th:text="${rphone}"></label></br>
<hr/>
<h3>현재 등록된 메뉴목록</h3>
<table border="1">
<tr>
<td>이미지</td>
<td>메뉴번호</td>
<td>메뉴명</td>
<td>메뉴가격</td>
</tr>
<tr th:each="obj : ${list}">
<td><img th:src="@{/menu1/image(no=${obj.no})}" style="width: 50px; height: 50px;"/> </td>
<td th:text = "${obj.no}"></td>
<td th:text = "${obj.name}"></td>
<td th:text = "${obj.price}"></td>
<td>
<a th:href="@{/menu1/update.food(no=${obj.no}, rphone=${rphone})}"><button>수정</button></a>
<button th:onclick="deleteAction([[${obj.no}]])">삭제</button>
</td>
</tr>
</table>
<hr />
<hr/>
<h3>메뉴등록</h3>
<hr />
<form th:action="@{/menu1/insert.food}" method="post" enctype="multipart/form-data">
메뉴명 <input type="text" name="name"><br />
가격 <input type="number" name="price"><br />
식당연락처 <input type="text" name="rphone" th:value=${param.rphone} readonly><br />
이미지 <input type="file" name="tmpFile"><br />
<input type="submit" value="메뉴등록">
</form>
<form th:action="@{/menu1/delete.food}" method="post" id="form2" style="display: none">
<input type="hidden" name="no" id="hidden_no"/>
<input type="hidden" name="rphone" th:value="${rphone}"/>
</form>
<script th:inline="javascript">
function deleteAction(no){
if( confirm('삭제할까요?')){
document.getElementById("hidden_no").value = no;
document.getElementById('form2').submit();
form.submit(); // form 전송
}
}
</script>
</div>
</body>
</html>
이미지에 DB에 들어갈 수 있게 menu1컬럼에 알맞게 date, size, name,type을 넣어준다.
식당에 메뉴를 추가하기 때문에 식당번호(rphone)를 name값으로 받아서 넣어준다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h3>메뉴변경</h3>
<a th:href="@{/menu1/insert.food(rphone=${rphone})}"><button>메뉴관리</button></a>
<form th:action="@{/menu1/update.food}" method="post" enctype="multipart/form-data" th:object="${obj}">
메뉴번호 : <input type="text" th:field="${obj.no}" readonly/>
메뉴명 : <input type="text" th:field="${obj.name}" ><br />
가격 : <input type="number" th:field="${obj.price}"><br />
식당연락처 : <input type="text" name="restaurant1.phone" th:value="${rphone}" readonly><br />
현재이미지 : <img th:src="@{/menu1/image(no=${obj.no})}" style="width: 50px; height: 50px;">
이미지 <input type="file" name="tmpFile"><br />
<input type="submit" value="메뉴변경">
</form>
</body>
</html>