inventory.ejs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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="options">
  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. </div>
  23. <input id="filter" onkeyup="inventoryObj.filter()" type="text" placeholder="FILTER INGREDIENTS">
  24. <table>
  25. <thead>
  26. <tr>
  27. <th onclick="inventoryObj.sortIngredients('name')">Item</th>
  28. <th onclick="inventoryObj.sortIngredients('category')">Category</th>
  29. <th onclick="inventoryObj.sortIngredients('quantity')">Quantity</th>
  30. <th onclick="inventoryObj.sortIngredients('unit')">Unit</th>
  31. <th>Actions</th>
  32. </tr>
  33. <tbody></tbody>
  34. </thead>
  35. </table>
  36. </div>
  37. <div id="recipesStrand" class="strand">
  38. <div>
  39. <% if(merchant.pos !== "none"){ %>
  40. <button class="button" id="recipeUpdate" onclick="recipesObj.updateRecipes()">Update Recipes</button>
  41. <% } %>
  42. </div>
  43. <div id="recipesContainer"></div>
  44. </div>
  45. <div id="dataStrand" class="strand">
  46. <!-- Ingredients used -->
  47. <table>
  48. <thead>
  49. <tr>
  50. <th>Ingredient</th>
  51. <th>Amount used</th>
  52. <th>Amount remaining</th>
  53. </tr>
  54. </thead>
  55. <tbody></tbody>
  56. </table>
  57. <!-- Recipes used -->
  58. <!-- Purchases -->
  59. <!-- Totals -->
  60. </div>
  61. <div id="accountStrand" class="strand">
  62. <form id="accountDisplay" onsubmit="accountObj.editAccount()">
  63. <label>Name:&nbsp;&nbsp;
  64. <p><%=merchant.name%></p>
  65. </label>
  66. <label>Email:&nbsp;&nbsp;
  67. <p><%=merchant.email%></p>
  68. </label>
  69. <button class="button" onclick="accountObj.editAccount()">Edit</button>
  70. </form>
  71. <form id="accountEdit" onsubmit="accountObj.updateAccount()">
  72. <label>Name:&nbsp;&nbsp;
  73. <input id="accountName" type="text" value="<%=merchant.name%>">
  74. </label>
  75. <label>Email:&nbsp;&nbsp;
  76. <input id="accountEmail" type="email" value="<%=merchant.email%>">
  77. </label>
  78. <div class="buttonBox">
  79. <button class="button" onclick="accountObj.updateAccount()">Save</button>
  80. <button class="button" onclick="accountObj.editAccountCancel()">Cancel</button>
  81. </div>
  82. </form>
  83. <form id="passwordEdit" onsubmit="accountObj.updatePassword()">
  84. <label>Old password:
  85. <input id="oldPass" type="password" required>
  86. </label>
  87. <label>New password:
  88. <input id="newPass" type="password" required>
  89. </label>
  90. <label>Confirm new password:
  91. <input id="confirmNewPass" type="password" required>
  92. </label>
  93. <div class="buttonBox">
  94. <input class="button" type="submit" value="Submit">
  95. <button class="button" onclick="accountObj.editPasswordCancel()">Cancel</button>
  96. </div>
  97. </form>
  98. <button class="button" onclick="accountObj.editPassword()">Change password</button>
  99. </div>
  100. <div id="addIngredientAction" class="action">
  101. <div class="container">
  102. <form onsubmit="addIngredientObj.submitAdd()">
  103. <h2>Select Ingredient</h2>
  104. <label>Ingredient
  105. <select id="addName"></select>
  106. </label>
  107. <label>Quantity
  108. <input id="addQuantity" type="number" step="0.01" required>
  109. </label>
  110. <input class="button" type="submit" value="Add Ingredient">
  111. </form>
  112. <form id="createIngredientInput" onsubmit="addIngredientObj.submitNew()">
  113. <h2>Create New Ingredient</h2>
  114. <label>Name
  115. <input id="newName" type="text" required>
  116. </label>
  117. <label>Category
  118. <input id="newCategory" type="text" required>
  119. </label>
  120. <label>Unit
  121. <input id="newUnit" type="text" required>
  122. </label>
  123. <label>Quantity
  124. <input id="newQuantity" type="number" step="0.01" required>
  125. </label>
  126. <button class="button">Create Ingredient</button>
  127. </form>
  128. </div>
  129. </div>
  130. <div id="enterTransactionsAction" class="action">
  131. <h1>Enter all sales</h1>
  132. <h3>Last updated: <span id="updated"></span></h3>
  133. <table>
  134. <thead>
  135. <tr>
  136. <th>Recipe</th>
  137. <th>Number sold</th>
  138. </tr>
  139. </thead>
  140. <tbody></tbody>
  141. </table>
  142. <button class="button" onclick="enterTransactionsObj.submit()">Submit</button>
  143. </div>
  144. <div id="enterPurchaseAction" class="action">
  145. <h1>Enter Purchases</h1>
  146. <table>
  147. <thead>
  148. <tr>
  149. <th>Ingredient</th>
  150. <th>Amount</th>
  151. </tr>
  152. </thead>
  153. <tbody></tbody>
  154. </table>
  155. <button class="button" onclick="enterPurchaseObj.submit()">Submit</button>
  156. </div>
  157. <div id="singleRecipeAction" class="action">
  158. <h2 id="recipeName"></h2>
  159. <div class="buttonsDiv">
  160. <button class="button" id="addButton">Add Ingredient</button>
  161. </div>
  162. <table>
  163. <thead>
  164. <tr>
  165. <th>Name</th>
  166. <th>Quantity</th>
  167. <th>Actions</th>
  168. </tr>
  169. </thead>
  170. <tbody></tbody>
  171. </table>
  172. </div>
  173. <%- include ../shared/footer %>
  174. <script>
  175. <% if(locals.error){ %>
  176. let error = <%- JSON.stringify(error) %>;
  177. <% }else{ %>
  178. let error = undefined;
  179. <% } %>
  180. </script>
  181. <script>
  182. let merchant = <%- JSON.stringify(merchant) %>;
  183. </script>
  184. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  185. <script src="../shared/validation.js"></script>
  186. <script src="/inventoryPage/inventory.js"></script>
  187. <script src="/inventoryPage/recipes.js"></script>
  188. <script src="/inventoryPage/data.js"></script>
  189. <script src="/inventoryPage/account.js"></script>
  190. <script src="/inventoryPage/addIngredient.js"></script>
  191. <script src="/inventoryPage/enterTransactions.js"></script>
  192. <script src="/inventoryPage/enterPurchase.js"></script>
  193. <script src="/inventoryPage/singleRecipe.js"></script>
  194. <script src="/shared/controller.js"></script>
  195. <script>
  196. axios.get("/transactions")
  197. .then((response)=>{
  198. if(typeof(response.data) === "string"){
  199. banner.createError(response.data);
  200. }else{
  201. dataObj.populate(response.data);
  202. }
  203. })
  204. .catch((err)=>{
  205. banner.createError("Error: unable to render sales data");
  206. });
  207. </script>
  208. </body>
  209. </html>