Advertisement
Guest User

Untitled

a guest
Apr 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.14 KB | None | 0 0
  1. <!--
  2. Author: Gianpiero Beraldin
  3. Class: Industrial application dev
  4. Project: Ishina web app
  5. Teacher: Ed Strange
  6. Date: 14/02/2018
  7. File: Customers.jsp
  8. Purpose: users can register or sign in
  9. -->
  10.  
  11. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  12. pageEncoding="ISO-8859-1"%>
  13. <%@ page import="model.Constants"%>
  14. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  15. <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
  16. <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
  17. <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
  18. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  19. <html>
  20. <head>
  21. <meta charset="utf-8">
  22. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  23. <meta name="viewport" content="width=device-width, initial-scale=1">
  24. <title>Customers</title>
  25.  
  26. <!-- CSS -->
  27. <link rel="stylesheet"
  28. href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  29. <script
  30. src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  31. <script
  32. src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  33. <link rel="stylesheet"
  34. href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
  35. <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  36. <link rel="stylesheet"
  37. href="assets/font-awesome/css/font-awesome.min.css">
  38. <link rel="stylesheet" href="assets/css/form-elements.css">
  39. <link rel="stylesheet" href="assets/css/style.css">
  40.  
  41. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  42. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  43. <!--[if lt IE 9]>
  44. <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  45. <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  46. <![endif]-->
  47. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  48. </head>
  49. <body>
  50.  
  51. <jsp:include page="Shared/_Banner.jsp" />
  52.  
  53. <c:choose>
  54. <c:when
  55. test="${sessionScope.userType == Constants.USER_TYPE_ID_CUSTOMER ||
  56. sessionScope.userType == Constants.USER_TYPE_ID_EMPLOYEE}">
  57. <jsp:include page="Shared/_SideBar.jsp" />
  58. </c:when>
  59.  
  60. <c:otherwise>
  61. <jsp:include page="Shared/_AdminSideBar.jsp" />
  62. </c:otherwise>
  63. </c:choose>
  64.  
  65. <div style="margin-left: 23%; padding: 1px 16px; height: 1000px;">
  66. <div class="container">
  67. <h2>Customers</h2>
  68. <form action="AlterCustomers" method="post">
  69. <table class="table table-striped">
  70. <thead>
  71. <tr>
  72. <th><center>Manager Name</center></th>
  73. <th><center>Email</center></th>
  74. <th><center>Phone Number</center></th>
  75. <th><center>Extension</center></th>
  76. <th><center>Store Name</center></th>
  77. <th><center>Address</center></th>
  78. <th><center>Postal Code</center></th>
  79. <th><center>Edit</center></th>
  80. <th><center>Toggle Status</center></th>
  81. </tr>
  82. </thead>
  83. <tbody>
  84. <sql:setDataSource driver="${Constants.DB_DRIVER}"
  85. url="${Constants.DB_URL}" user="${Constants.DB_LOGIN}"
  86. password="${Constants.DB_PASSWORD}" />
  87.  
  88. <sql:query var="users">
  89. SELECT user_id, email_address, inactive FROM users WHERE user_type_id=${Constants.USER_TYPE_ID_CUSTOMER}
  90. </sql:query>
  91.  
  92. <c:forEach var="user" begin="0" items="${users.rows}">
  93. <sql:query var="storeManagers">
  94. SELECT * FROM store_managers WHERE email_address="${user.email_address}"
  95. </sql:query>
  96.  
  97. <c:forEach var="storeManager" items="${storeManagers.rows}">
  98. <sql:query var="stores">
  99. SELECT * FROM stores WHERE store_id=${storeManager.store_id}
  100. </sql:query>
  101.  
  102.  
  103. <tr>
  104. <td>${storeManager.name}</td>
  105. <td>${storeManager.email_address}</td>
  106. <td>${storeManager.phone_number}</td>
  107. <td><c:if
  108. test="${not empty storeManager.phone_number_extension}">
  109. <c:out value="${storeManager.phone_number_extension}" />
  110. </c:if></td>
  111. <c:forEach var="store" items="${stores.rows}">
  112. <td>${store.name}</td>
  113. <td>${store.address}</td>
  114. <td>${store.postal_code}</td>
  115. <td><button type="submit" class="btn"
  116. data-toggle="modal" data-target="#editModal">Edit</button></td>
  117. <c:choose>
  118. <c:when test="${user.inactive == true}">
  119. <td><button name="makeActive" type="submit" class="btn"
  120. value="${user.user_id}">Make active</button></td>
  121. </c:when>
  122. <c:otherwise>
  123. <td><button name="makeInactive" type="submit"
  124. class="btn" value="${user.user_id}">Make inactive</button></td>
  125. </c:otherwise>
  126. </c:choose>
  127. <div class="modal fade" id="editModal" tabindex="-1"
  128. role="dialog" aria-labelledby="myModalLabel"
  129. aria-hidden="true">
  130. <div class="modal-dialog">
  131. <div class="modal-content">
  132. <!-- Modal Header -->
  133. <div class="modal-header">
  134. <button type="button" class="close" data-dismiss="modal">
  135. <span aria-hidden="true">&times;</span> <span
  136. class="sr-only">Close</span>
  137. </button>
  138. <h4 class="modal-title" id="myModalLabel">Edit
  139. Customer/Store Information</h4>
  140. </div>
  141. <c:set var="names"
  142. value="${fn:split(storeManager.name, ' ')}" />
  143. <!-- Modal Body -->
  144. <div class="modal-body">
  145.  
  146.  
  147. <form role="form" action="AlterCustomers" method="post">
  148.  
  149. <div class="form-group">
  150. <label for="customer-first-name">First Name</label> <input
  151. type="text" class="form-control"
  152. name="customer-first-name"
  153. id="form-customer-first-name" placeholder="First Name"
  154. value="${names[0]}" />
  155. </div>
  156. <div class="form-group">
  157. <label for="customer-last-name">Last Name</label> <input
  158. type="text" class="form-control"
  159. id="form-customer-last-name" name="customer-last-name"
  160. placeholder="Last Name" value="${names[1]}" />
  161. </div>
  162. <div class="form-group">
  163. <label for="customer-email">Email</label> <input
  164. type="email" class="form-control"
  165. id="form-employee-email" name="customer-email-address"
  166. placeholder="Email"
  167. value="${storeManager.email_address}" />
  168. </div>
  169. <div class="form-group">
  170. <label for="customer-phone-number">Phone Number</label>
  171. <input type="email" class="form-control"
  172. id="form-customer-phone-number"
  173. name="customer-phone-number" placeholder="Phone Number"
  174. value="${storeManager.phone_number}" />
  175. </div>
  176. <div class="form-group">
  177. <label for="customer-extension">Extension</label> <input
  178. type="email" class="form-control"
  179. id="form-customer-extension" name="customer-extension"
  180. placeholder="Extension"
  181. value="${storeManager.phone_number_extension}" />
  182. </div>
  183. <div class="form-group">
  184. <label for="customer-store-name">Store Name</label> <input
  185. type="email" class="form-control"
  186. id="form-customer-name" name="customer-store-name"
  187. placeholder="Store Name" value="${store.name}" />
  188. </div>
  189. <div class="form-group">
  190. <label for="customer-store-address">Store
  191. Address</label> <input type="email" class="form-control"
  192. id="form-customer-store-address"
  193. name="customer-store-address"
  194. placeholder="Store Address" value="${store.address}" />
  195. </div>
  196. <div class="form-group">
  197. <label for="customer-store-postal-code">Store
  198. Postal Code</label> <input type="email" class="form-control"
  199. id="form-customer-store-postal-code"
  200. name="customer-store-postal-code"
  201. placeholder="Store Postal Code"
  202. value="${store.postal_code}" />
  203. </div>
  204. <input type="hidden"
  205. value="${storeManager.store_manager_id}">
  206. <button value="${user.user_id}" type="submit"
  207. class="btn btn-default" name="edit">Submit</button>
  208. <button type="button" class="btn btn-default"
  209. data-dismiss="modal">Close</button>
  210. </form>
  211.  
  212. </div>
  213.  
  214. </div>
  215. </div>
  216. </div>
  217. </c:forEach>
  218. </tr>
  219. </c:forEach>
  220. </c:forEach>
  221. </tbody>
  222. </table>
  223. </form>
  224. </div>
  225. </div>
  226. </body>
  227. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement