inventory.ejs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>The Subline</title>
  6. <link rel="icon" type="img/png" href="/shared/images/logo.png">
  7. <link rel="stylesheet" href="/inventoryPage/inventory.css">
  8. <link rel="stylesheet" href="/shared/shared.css">
  9. </head>
  10. <body>
  11. <% include ../shared/header %>
  12. <% include ../shared/banner %>
  13. <h1 id="title"><%=merchant.name%></h1>
  14. <strand-selector></strand-selector>
  15. <div id="inventoryStrand" class="strand">
  16. <div class="buttonBox">
  17. <button class="button" onclick="addIngredientObj.display()">Add Ingredient</button>
  18. <button class="button" onclick="enterPurchaseObj.display()">Enter Purchases</button>
  19. <% if(merchant.pos === "none"){ %>
  20. <button class="button" onclick="enterTransactionsObj.display()">Enter Transactions</button>
  21. <% } %>
  22. <a class="button" href="/data">Analyze data</a>
  23. </div>
  24. <input id="filter" onkeyup="inventoryObj.filter()" type="text" placeholder="FILTER INGREDIENTS">
  25. <table>
  26. <thead>
  27. <tr>
  28. <th onclick="inventoryObj.sortIngredients('name')">Item</th>
  29. <th onclick="inventoryObj.sortIngredients('category')">Category</th>
  30. <th onclick="inventoryObj.sortIngredients('quantity')">Quantity</th>
  31. <th onclick="inventoryObj.sortIngredients('unit')">Unit</th>
  32. <th>Actions</th>
  33. </tr>
  34. <tbody></tbody>
  35. </thead>
  36. </table>
  37. </div>
  38. <div id="recipesStrand" class="strand">
  39. <div>
  40. <% if(merchant.pos === "none"){ %>
  41. <button class="button" onclick="window.recipesObj.showInput()">Add a Recipe</button>
  42. <% }else{%>
  43. <button class="button" id="recipeUpdate" onclick="recipesObj.updateRecipes()">Update Recipes</button>
  44. <% } %>
  45. </div>
  46. <div id="newRecipe">
  47. <input type="text">
  48. <button class="button-small" onclick="window.recipesObj.submitNew()">Create</button>
  49. <button class="button-small" onclick="window.recipesObj.cancelAdd()">Cancel</button>
  50. </div>
  51. <div id="recipesContainer"></div>
  52. </div>
  53. <div id="accountStrand" class="strand">
  54. <form id="accountDisplay" onsubmit="accountObj.editAccount()">
  55. <label>Name:&nbsp;&nbsp;
  56. <p><%=merchant.name%></p>
  57. </label>
  58. <label>Email:&nbsp;&nbsp;
  59. <p><%=merchant.email%></p>
  60. </label>
  61. <button class="button" onclick="accountObj.editAccount()">Edit</button>
  62. </form>
  63. <form id="accountEdit">
  64. <label>Name:&nbsp;&nbsp;
  65. <input id="accountName" type="text" value="<%=merchant.name%>">
  66. </label>
  67. <label>Email:&nbsp;&nbsp;
  68. <input id="accountEmail" type="email" value="<%=merchant.email%>">
  69. </label>
  70. <div class="buttonBox">
  71. <button class="button" onclick="accountObj.updateAccount()">Save</button>
  72. <button class="button" onclick="accountObj.editAccountCancel()">Cancel</button>
  73. </div>
  74. </form>
  75. <form id="passwordEdit" onsubmit="accountObj.updatePassword()">
  76. <label>Old password:
  77. <input id="oldPass" type="password" required>
  78. </label>
  79. <label>New password:
  80. <input id="newPass" type="password" required>
  81. </label>
  82. <label>Confirm new password:
  83. <input id="confirmNewPass" type="password" required>
  84. </label>
  85. <div class="buttonBox">
  86. <input class="button" type="submit" value="Submit">
  87. <button class="button" onclick="accountObj.editPasswordCancel()">Cancel</button>
  88. </div>
  89. </form>
  90. <button class="button" onclick="accountObj.editPassword()">Change password</button>
  91. </div>
  92. <div id="addIngredientAction" class="action">
  93. <div class="container">
  94. <form onsubmit="addIngredientObj.submitAdd()">
  95. <h2>Select Ingredient</h2>
  96. <label>Ingredient
  97. <select id="addName"></select>
  98. </label>
  99. <label>Quantity
  100. <input id="addQuantity" type="number" step="0.01" required>
  101. </label>
  102. <input class="button" type="submit" value="Add Ingredient">
  103. </form>
  104. <form id="createIngredientInput" onsubmit="addIngredientObj.submitNew()">
  105. <h2>Create New Ingredient</h2>
  106. <label>Name
  107. <input id="newName" type="text" required>
  108. </label>
  109. <label>Category
  110. <input id="newCategory" type="text" required>
  111. </label>
  112. <label>Unit
  113. <input id="newUnit" type="text" required>
  114. </label>
  115. <label>Quantity
  116. <input id="newQuantity" type="number" step="0.01" required>
  117. </label>
  118. <button class="button">Create Ingredient</button>
  119. </form>
  120. </div>
  121. </div>
  122. <div id="enterTransactionsAction" class="action">
  123. <h1>Enter all sales</h1>
  124. <h3>Last updated: <span id="updated"></span></h3>
  125. <table>
  126. <thead>
  127. <tr>
  128. <th>Recipe</th>
  129. <th>Number sold</th>
  130. </tr>
  131. </thead>
  132. <tbody></tbody>
  133. </table>
  134. <button class="button" onclick="enterTransactionsObj.submit()">Submit</button>
  135. </div>
  136. <div id="enterPurchaseAction" class="action">
  137. <h1>Enter Purchases</h1>
  138. <table>
  139. <thead>
  140. <tr>
  141. <th>Ingredient</th>
  142. <th>Amount</th>
  143. </tr>
  144. </thead>
  145. <tbody></tbody>
  146. </table>
  147. <button class="button" onclick="enterPurchaseObj.submit()">Submit</button>
  148. </div>
  149. <div id="singleRecipeAction" class="action">
  150. <h2 id="recipeName"></h2>
  151. <div class="buttonsDiv">
  152. <button class="button" id="addButton">Add Ingredient</button>
  153. </div>
  154. <table>
  155. <thead>
  156. <tr>
  157. <th>Name</th>
  158. <th>Quantity</th>
  159. <th>Actions</th>
  160. </tr>
  161. </thead>
  162. <tbody></tbody>
  163. </table>
  164. </div>
  165. <%- include ../shared/footer %>
  166. <script>
  167. <% if(locals.error){ %>
  168. let error = <%- JSON.stringify(error) %>;
  169. <% }else{ %>
  170. let error = undefined;
  171. <% } %>
  172. </script>
  173. <script>let merchant = <%- JSON.stringify(merchant) %>;</script>
  174. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  175. <script src="../shared/validation.js"></script>
  176. <script src="/inventoryPage/inventory.js"></script>
  177. <script src="/inventoryPage/recipes.js"></script>
  178. <script src="/inventoryPage/account.js"></script>
  179. <script src="/inventoryPage/addIngredient.js"></script>
  180. <script src="/inventoryPage/enterTransactions.js"></script>
  181. <script src="/inventoryPage/enterPurchase.js"></script>
  182. <script src="/inventoryPage/singleRecipe.js"></script>
  183. <script src="/shared/controller.js"></script>
  184. </body>
  185. </html>