<!doctype html>
<html class="no-js" lang="en" xmlns:th="http://www.thymeleaf.org"
							  xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
    <head>
    	<meta name="_csrf" th:content="${_csrf.token}"/>
		<meta name="_csrf_header" th:content="${_csrf.headerName}"/>
        <meta charset="utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <title>Limited</title>
        <meta name="description" content=""/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <link rel="icon" href="images/favicon.png"/>
        <link rel="stylesheet" href="css/style.css" th:href="@{/css/style.css}"/>
        
        <!--[if lt IE 9]>
            <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
            <script>window.html5 || document.write('<script src="js/vendor/html5shiv.js"><\/script>')</script>
        <![endif]-->
    </head>
    <body>
        <div id="management_wrapper">
            <div id="sidebar">
                <div class="sidebar_title"><a th:href="@{http://localhost:8080/limited/top}">TOPへ戻る</a></div>
                <div class="sidebar_title"><button id="user_button" type="button">ユーザー管理</button></div>
                <div class="sidebar_title"><button id="shoe_button" type="button">商品管理</button></div>
            </div>
            <div id="mainbody">


                <!-- ユーザー管理 -->
                <div id="user_management">
                    <!-- ヘッダー -->
                    <div class="ma_header">
                        <p>ユーザー管理</p>
                    </div>
                    <div id="user_list">
                        <table id="user_list_table" border="1">
                            <tr>
                                <th>ID</th>
                                <th>名前</th>
                                <th>権限</th>
                                <th></th>
                            </tr>
                            <tr th:each="users : ${users}">
                                <td th:text="${users.id}">1</td>
                                <td th:text="${users.name}">demo</td>
                                <td name="roles" th:text="${users.roles}" class="userRoleForm"></td>
                                <td>
                                	<div th:object="${user}" th:switch="${user.id}">
                                	<div th:case="${users.id}">
										<a>ログイン中のため変更できません</a>
	                               	</div>
	                               	<div th:case="*">
	                                    <form>
	                                        <button type="button" name="form" value="権限変更" class="roleBtn">権限変更</button>
	                                    </form>
	                                    <!-- <form th:action="@{/limited/admin/management/{id}(id=${users.id})}" th:method="post">
	                                        <input type="submit" name="form" value="権限変更" class="roleBtn"/>
	                                        <input type="hidden" name="id" th:value="${users.id}"/>
	                                    </form> -->
	                               	</div>
	                                </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                

                <!-- 商品管理 -->
                <div id="shoe_management">
                    <!-- ヘッダー -->
                    <div class="ma_header">
                        <p>商品管理</p>
                    </div>
                    <!-- 新規登録フォーム -->
                    <div id="newShoesFormTitle">商品新規登録</div>
                    <form id="newShoesForm" th:action="@{/limited/admin/management/addShoes}" th:object="${shoesForm}" method="post" enctype="multipart/form-data"> 
                        <span for="name">商品名： 
                        	<input type="text" id="name" name="name" placeholder="name" th:field="*{name}" th:errorclass="error-input"/>
                        </span>
                        <span th:if="${#fields.hasErrors('name')}" th:errors="*{name}" class="error-messages">error!</span>
                       
                        <span for="price">価格：
                        	<input type="text" id="price" name="price" placeholder="price" th:field="*{price}" th:errorclass="error-input"/>
                        </span>
                        <span th:if="${#fields.hasErrors('price')}" th:errors="*{price}" class="error-messages">error!</span>
                        
                        <span>在庫数：
	                        <select id="stock" name="stock" th:field="*{stock}" th:errorclass="error-input"> 
	                            <option value="1">1</option>
	                            <option value="2">2</option>
	                            <option value="3">3</option>
	                            <option value="4">4</option>
	                            <option value="5">5</option>
	                            <option value="6">6</option>
	                            <option value="7">7</option>
	                            <option value="8">8</option>
	                            <option value="9">9</option>
	                            <option value="10">10</option>
	                        </select>
                        </span>
                        <span th:if="${#fields.hasErrors('stock')}" th:errors="*{stock}" class="error-messages">error!</span>
                        <!-- <span>在庫数：<input type="number" name="stock"/></span> -->
                        <span>サイズ：
	                        <select id="size" name="size" th:field="*{size}" th:errorclass="error-input">
	                            <option value="23">23</option>
	                            <option value="24">24</option>
	                            <option value="25">25</option>
	                            <option value="26">26</option>
	                            <option value="27">27</option>
	                            <option value="28">28</option>
	                            <option value="29">29</option>
	                            <option value="30">30</option>
	                        </select>
                        </span>
                        <span th:if="${#fields.hasErrors('size')}" th:errors="*{size}" class="error-messages">error!</span>
                        <span>公開範囲:
                        	<select id="productStatus" name="productStatus" th:field="*{productStatus}">
                        		<option value="0">通常公開</option>
                        		<option value="1">限定公開</option>
                        	</select>
                        </span>
                        <span th:if="${#fields.hasErrors('productStatus')}" th:errors="*{produntStatus}" class="error-messages">error!</span>
                        
                        <div>商品画像<input type="file" name="photo" th:field="*{multipartFile}" th:errorclass="error-input"/></div>
                        <span th:if="${#fields.hasErrors('multipartFile')}" th:errors="*{multipartFile}" class="error-messages">error!</span>
                        <input type="submit" id="newShoesFormBtn" value="新規登録"/>
                    </form>

                    <!-- 在庫一覧  eachで繰り返し -->
                    <div id="shoesListTitle">在庫一覧</div>
                    <div id="shoe_list">
                        <table id="show_list_table" border="1">
                            <tr>
                                <th>ID</th>
                                <th>商品名</th>
                                <th>サイズ</th>
                                <th>価格</th>
                                <th>在庫数</th>
                                <th>商品画像</th>
                                <th>編集</th>
                                <th>削除</th>
                            </tr>
                            <tr th:each="shoe : ${shoes}">
                                <td th:text="${shoe.id}">1</td>
                                <td th:text="${shoe.name}">AirMax</td>
                                <td th:text="${shoe.size}">27</td>
                                <td th:text="${shoe.price}">¥10,000</td>
                                <td th:text="${shoe.stock}">10</td>
                                <td><img class="shoeImage" th:src="@{/upload/{photo}(photo=${shoe.photo})}" alt="productImage" width="100" height="50"/></td>
                                
                                <td>
                                    <!-- <form th:action="@{/shoes/edit}" method="get">
                                        <input type="submit" name="form" value="編集"/>
                                        <input type="hidden" name="id" th:value="${shoe.id}"/>
                                    </form>-->
                                    <a th:href="@{/limited/admin/management/{id}/edit(id=${shoe.id})}" class="btn">編集</a>
                                </td>
                                <td>
                                    <form th:action="@{/limited/admin/management//{id}(id=${shoe.id})}" th:method="delete">
                                        <input type="submit" name="form" value="削除" class="shoeDeleteBtn"/>
                                        <input type="hidden" name="id" th:value="${shoe.id}"/>
                                    </form>
                                    
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>

            </div>
        </div>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>        
        <!-- <script src="js/vendor/bootstrap.min.js"></script>
        <script src="js/isotope.pkgd.min.js"></script>
        <script src="js/owl.carousel.min.js"></script>
        <script src="js/wow.min.js"></script>
        <script src="js/custom.js"></script> -->
        <script type="text/javascript" src="js/management.js" th:src="@{/js/management.js}"></script>
    </body>
</html>
