PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/webapp/accounts/viewing/update_account.jsp

https://github.com/jdbaltazar/CMSC-198-IAPPSAM-System
JavaServer Pages | 396 lines | 372 code | 24 blank | 0 comment | 65 complexity | ecb86664d6c806d515cfbfeb13bcc4bf MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  3. <%@page import="com.iappsam.Person"%>
  4. <%@page import="com.iappsam.ContactType"%>
  5. <%@page import="java.util.ArrayList"%>
  6. <%@page import="com.iappsam.Employee"%>
  7. <%@page import="com.iappsam.managers.sessions.PersonManagerSession"%>
  8. <%@page import="com.iappsam.managers.PersonManager"%>
  9. <%@page import="com.iappsam.Contact"%>
  10. <%@page import="com.iappsam.Account"%>
  11. <%@page import="com.iappsam.managers.sessions.AccountManagerSession"%>
  12. <%@page import="com.iappsam.managers.AccountManager"%>
  13. <%@page import="com.iappsam.AccountType"%>
  14. <%@page
  15. import="com.iappsam.managers.sessions.DivisionOfficeManagerSession"%>
  16. <%@page import="com.iappsam.DivisionOffice"%>
  17. <%@page import="com.iappsam.managers.DivisionOfficeManager"%>
  18. <%@page import="java.util.List"%>
  19. <html xmlns="http://www.w3.org/1999/xhtml">
  20. <head>
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  22. <%
  23. String userName = request.getParameter("username");
  24. if (userName == null)
  25. userName = (String) request.getAttribute("username");
  26. AccountManager aManager = new AccountManagerSession();
  27. Account account = aManager.getAccount(userName);
  28. PersonManager pManager = new PersonManagerSession();
  29. List<Employee> employees = pManager.getEmployeeByPerson(account.getPerson().getId());
  30. Person person = account.getPerson();
  31. String string = "";
  32. %>
  33. <title>IAPPSAM:: View Account:<%=userName%></title>
  34. <link href="../css/header.css" rel="stylesheet" type="text/css" />
  35. <link href="../css/form.css" rel="stylesheet" type="text/css" />
  36. </head>
  37. <body>
  38. <div id="headerBkgrnd">
  39. <img src="../images/headerbar.png" width="100%" height="129" />
  40. </div>
  41. <div id="logo">
  42. <img src="../images/headerlogo.png" width="124" height="128" />
  43. </div>
  44. <div id="headerName">
  45. <img src="../images/headertext.png" width="452" height="44" />
  46. </div>
  47. <p>&nbsp;</p>
  48. <p>&nbsp;</p>
  49. <p>&nbsp;</p>
  50. <p>&nbsp;</p>
  51. <table width="100%" border="0" cellspacing="0">
  52. <tr>
  53. <td width="32%">&nbsp;</td>
  54. <td width="68%">
  55. <form id="form2" name="form2" method="post" action="/logout">
  56. <input name="logoutBtn" type="submit" class="logout" id="logoutBtn"
  57. value="Logout" />
  58. </form></td>
  59. </tr>
  60. <tr>
  61. <td id="navigation"><a href="../menu" target="_top"
  62. class="links">Main Menu</a> &gt; <a
  63. href="accounts?account-action=view-accounts" target="_top"
  64. class="links">Account List</a> &gt; <em><strong>View
  65. Account</strong> </em><strong></strong>
  66. </td>
  67. <td>&nbsp;</td>
  68. </tr>
  69. </table>
  70. <div id="form_table">
  71. <form id="form1" name="form1" method="post" action="/accounts">
  72. <input type="hidden" name="username" value="<%=userName%>" /> <input
  73. type="hidden" name="account-action" value="save-edited-account" />
  74. <table width="100%" frame="box" cellspacing="0" id="table"
  75. style="table-layout: fixed">
  76. <tr>
  77. <td align="right" class="bkgrnd_white"><a
  78. href='accounts?account-action2=create-from-existing'
  79. target="_self" class="linkBtn">Create Account For Existing
  80. Employee>></a>
  81. </td>
  82. </tr>
  83. <tr>
  84. <tr>
  85. <td class="bkgrnd_white">&nbsp;</td>
  86. </tr>
  87. <tr>
  88. <td class="header_rows">
  89. <div class="header_1">Personal Information</div></td>
  90. </tr>
  91. <tr>
  92. <td>
  93. <table width="100%" cellspacing="9" frame="box"
  94. class="no_border_table">
  95. <tr>
  96. <%
  97. DivisionOfficeManager dManager = new DivisionOfficeManagerSession();
  98. List<DivisionOffice> dList = dManager.getAllDivisionOffice();
  99. AccountType[] accountTypes = AccountType.values();
  100. %>
  101. <td class="align_right" id="align_right">Title:</td>
  102. <td><input type="text" name="title" id="title"
  103. <%if (person.getTitle() != null) {%>
  104. value="<%=person.getTitle()%>" <%}%> />
  105. </td>
  106. </tr>
  107. <tr>
  108. <td class="align_right" id="align_right">Name:<br /></td>
  109. <td><input name="name" type="text" class="required"
  110. id="name" value="<%=person.getName()%>"
  111. <%String nameOK = (String) request.getAttribute("nameOK");
  112. String name = (String) request.getAttribute("name");
  113. if (nameOK != null && !nameOK.isEmpty() && !nameOK.equalsIgnoreCase("false")) {
  114. out.print("value=" + '"' + name + '"');
  115. } else {%>
  116. <%}%> /> <%
  117. if (nameOK != null && !nameOK.isEmpty() && nameOK.equalsIgnoreCase("false")) {
  118. out.print("*");
  119. }
  120. %> <br /></td>
  121. </tr>
  122. </table></td>
  123. </tr>
  124. <tr class="header_rows">
  125. <td>
  126. <div class="header_1">Work Information</div></td>
  127. </tr>
  128. <tr>
  129. <td>
  130. <table width="100%" border="0" cellspacing="5">
  131. <tr align="center" class="align_center">
  132. <td width="40%">Designation</td>
  133. <td width="25%">Employee No.</td>
  134. <td width="35%">Division/Office</td>
  135. </tr>
  136. <%
  137. int j = 0;
  138. for (int i = 0; i < employees.size(); i++) {
  139. %>
  140. <tr>
  141. <td>
  142. <div align="center">
  143. <label for="designation_1"></label> <input
  144. name="designation<%=i + 1%>" type="text" class="required"
  145. id="designation_1"
  146. <%if (employees != null && !employees.isEmpty())
  147. out.print("value=" + '"' + employees.get(i).getDesignation() + '"');%> />
  148. </div></td>
  149. <td>
  150. <div align="center">
  151. <input name="employeeNo<%=i + 1%>" type="text"
  152. id="employeeNo._1" size="4"
  153. <%if (employees != null && !employees.isEmpty() && employees.get(i).getEmployeeNumber() != null)
  154. out.print("value=" + '"' + employees.get(i).getEmployeeNumber() + '"');%> />
  155. </div></td>
  156. <td>
  157. <div align="center">
  158. <select name="divisionOffice<%=i + 1%>"
  159. class="required_menulist" id="divisionOffice">
  160. <%
  161. for (j = 0; j < dList.size(); j++) {
  162. %>
  163. <option
  164. <%if (employees.get(i).getDivisionOffice() != null && dList.get(j).getId() == employees.get(i).getDivisionOffice().getId()) {%>
  165. selected="selected"
  166. <%}
  167. if (employees.get(i).getDivisionOffice() != null && employees.get(i).getDivisionOffice().getOfficeName() != null)
  168. string = "/" + employees.get(i).getDivisionOffice().getOfficeName();%>
  169. value="<%=dList.get(j).getId()%>"><%=dList.get(j).getDivisionName()%></option>
  170. <%
  171. }
  172. %>
  173. <%
  174. if (employees.get(i).getDivisionOffice() != null)
  175. out.print(employees.get(i).getDivisionOffice().getDivisionName() + string);
  176. %>
  177. </select>
  178. </div></td>
  179. </tr>
  180. <%
  181. j = i + 1;
  182. }
  183. String[] designation = (String[]) request.getAttribute("designation");
  184. String[] employeeNo = (String[]) request.getAttribute("employeeNo");
  185. %>
  186. <tr>
  187. <td>
  188. <div align="center">
  189. <label for="designation_1"></label> <input
  190. name="designation<%=j + 1%>" type="text" class="required"
  191. id="designation_1"
  192. <%String designation1OK = (String) request.getAttribute("designation" + (j + 1) + "OK");
  193. if (designation != null && !designation[j].isEmpty()) {
  194. out.print("value=" + '"' + designation[j] + '"');
  195. } else if (designation1OK != null)
  196. out.print("value=" + '"' + "**" + '"');%> />
  197. </div></td>
  198. <td>
  199. <div align="center">
  200. <input name="employeeNo<%=j + 1%>" type="text"
  201. id="employeeNo._1" size="4"
  202. <%if (employeeNo != null && employeeNo[j] != null && !employeeNo[j].isEmpty())
  203. out.print("value=" + '"' + employeeNo[j] + '"');%> />
  204. </div></td>
  205. <td>
  206. <div align="center">
  207. <select name="divisionOffice<%=j + 1%>"
  208. class="required_menulist" id="divisionOfficeDropdown">
  209. <%
  210. for (int i = 0; i < dList.size(); i++) {
  211. %>
  212. <option value="<%=dList.get(i).getId()%>">
  213. <%
  214. if (dList.get(i).getOfficeName() != null)
  215. out.print(dList.get(i).getDivisionName() + "," + dList.get(i).getOfficeName());
  216. else
  217. out.print(dList.get(i).getDivisionName());
  218. %>
  219. </option>
  220. <%
  221. }
  222. %>
  223. </select>
  224. </div></td>
  225. </tr>
  226. <tr>
  227. </tr>
  228. </table></td>
  229. </tr>
  230. <tr class="header_rows">
  231. <td>
  232. <div class="header_1">Contact Information</div></td>
  233. </tr>
  234. <tr>
  235. <td>
  236. <table width="100%" cellspacing="9" frame="box"
  237. class="no_border_table">
  238. <tr>
  239. <%
  240. Contact[] contacts = new Contact[account.getPerson().getContacts().size()];
  241. account.getPerson().getContacts().toArray(contacts);
  242. ArrayList<Contact> mobile = new ArrayList<Contact>();
  243. ArrayList<Contact> landline = new ArrayList<Contact>();
  244. ArrayList<Contact> email = new ArrayList<Contact>();
  245. if (contacts != null) {
  246. for (int i = 0; i < contacts.length; i++) {
  247. if (contacts[i].getType().equals(ContactType.EMAIL))
  248. email.add(contacts[i]);
  249. if (contacts[i].getType().equals(ContactType.MOBILE))
  250. mobile.add(contacts[i]);
  251. if (contacts[i].getType().equals(ContactType.LANDLINE))
  252. landline.add(contacts[i]);
  253. }
  254. }
  255. %>
  256. <td class="align_right">Cellphone Number:</td>
  257. <td>
  258. <%
  259. if (!mobile.isEmpty()) {
  260. for (int i = 0; i < mobile.size(); i++) {
  261. %> <input type="text" name="cellphoneNumber"
  262. id="cellphoneNumber" value="<%=mobile.get(i).getData()%>"></input>
  263. <%
  264. }
  265. } else {
  266. %> <input name="cellphoneNumber" size="20" maxlength="20"
  267. id="cellphoneNumber" /> <%
  268. }
  269. %>
  270. </td>
  271. </tr>
  272. <tr>
  273. <td class="align_right">Landline:</td>
  274. <td>
  275. <%
  276. if (!landline.isEmpty()) {
  277. for (int i = 0; i < landline.size(); i++) {
  278. %> <input type="text" name="landline" id="landline"
  279. value="<%=landline.get(i).getData()%>" size="20"
  280. maxlength="20"></input> <%
  281. }
  282. } else {
  283. %> <input name="landline" size="20" maxlength="20" /> <%
  284. }
  285. %>
  286. </td>
  287. </tr>
  288. <tr>
  289. <td class="align_right">E-mail Add:</td>
  290. <td>
  291. <%
  292. if (!email.isEmpty()) {
  293. for (int i = 0; i < email.size(); i++) {
  294. %> <input name="e-mail_ad" id="e-mail_ad"
  295. value="<%=email.get(i).getData()%>" size="20" maxlength="20"></input>
  296. <%
  297. }
  298. } else {
  299. %> <input name="e-mail_ad" size="20" maxlength="20" /> <%
  300. }
  301. %>
  302. </td>
  303. </tr>
  304. </table></td>
  305. </tr>
  306. <tr>
  307. <td class="header_rows">
  308. <div class="header_1">Account Information</div></td>
  309. </tr>
  310. <tr>
  311. <td>
  312. <table width="100%" border="0" cellspacing="9">
  313. <tr>
  314. <td class="align_right">Username:</td>
  315. <td><input type="text" name="username" id="username2"
  316. input type="text" name="username" id="username"
  317. value="<%=account.getUsername()%>" disabled="disabled" />
  318. </td>
  319. </tr>
  320. <tr>
  321. <td class="align_right">New Password:</td>
  322. <td><input name="password" type="password"
  323. class="required" id="password"
  324. <%String passwordOk = (String) request.getAttribute("passwordOK");%> />
  325. <%
  326. if (passwordOk != null && !passwordOk.isEmpty() && passwordOk.equalsIgnoreCase("false")) {
  327. out.print("*");
  328. }
  329. %>
  330. </td>
  331. </tr>
  332. <tr>
  333. <td class="align_right">Reenter Password:</td>
  334. <td><input name="reenterPassword" type="password"
  335. class="required" id="newPassword" /> <%
  336. if (passwordOk != null && !passwordOk.isEmpty() && passwordOk.equalsIgnoreCase("false")) {
  337. out.print("*");
  338. }
  339. %>
  340. </td>
  341. </tr>
  342. <tr>
  343. <td class="align_right">Account Type:</td>
  344. <td><select name="accountType" class="required_menulist"
  345. id="accountType">
  346. <option selected="selected">${account.type}</option>
  347. <c:forEach var="type" items="${accountTypes}">
  348. <c:if test="${type ne account.type}"></c:if>
  349. </c:forEach>
  350. </select>
  351. </td>
  352. </tr>
  353. <tr>
  354. <td class="align_right">&nbsp;</td>
  355. <td><input name="createBtn" type="submit" class="button"
  356. id="createBtn" value="UPDATE" />
  357. </td>
  358. </tr>
  359. </table></td>
  360. </tr>
  361. <tr>
  362. <td class="table_footer"></td>
  363. </tr>
  364. <tr>
  365. <td class="bkgrnd_white">&nbsp;</td>
  366. </tr>
  367. </table>
  368. </form>
  369. </div>
  370. <!--<div id="footer"></div>-->
  371. </body>
  372. </html>