inventory.ejs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. <h2 id="month"></h2>
  47. <div class="tables">
  48. <!-- Ingredients used -->
  49. <div id="ingredientsData" class="dataTable">
  50. <h3>Ingredients</h3>
  51. <table>
  52. <thead>
  53. <tr>
  54. <th>Ingredient</th>
  55. <th>Used</th>
  56. <th>Remaining</th>
  57. </tr>
  58. </thead>
  59. <tbody></tbody>
  60. </table>
  61. </div>
  62. <!-- Recipes used -->
  63. <div id="recipesData" class="dataTable">
  64. <h3>Recipes</h3>
  65. <table>
  66. <thead>
  67. <tr>
  68. <th>Recipe</th>
  69. <th># sold</th>
  70. <th>Revenue</th>
  71. </tr>
  72. </thead>
  73. <tbody></tbody>
  74. </table>
  75. </div>
  76. <!-- Purchases -->
  77. <div id="purchasesData" class="dataTable">
  78. <h3>Purchases</h3>
  79. <table>
  80. <thead>
  81. <tr>
  82. <th>Ingredient</th>
  83. <th>Amount</th>
  84. </tr>
  85. </thead>
  86. <tbody></tbody>
  87. </table>
  88. </div>
  89. <!-- Totals -->
  90. </div>
  91. </div>
  92. <div id="accountStrand" class="strand">
  93. <form id="accountDisplay" onsubmit="accountObj.editAccount()">
  94. <label>Name:&nbsp;&nbsp;
  95. <p><%=merchant.name%></p>
  96. </label>
  97. <label>Email:&nbsp;&nbsp;
  98. <p><%=merchant.email%></p>
  99. </label>
  100. <button class="button" onclick="accountObj.editAccount()">Edit</button>
  101. </form>
  102. <form id="accountEdit" onsubmit="accountObj.updateAccount()">
  103. <label>Name:&nbsp;&nbsp;
  104. <input id="accountName" type="text" value="<%=merchant.name%>">
  105. </label>
  106. <label>Email:&nbsp;&nbsp;
  107. <input id="accountEmail" type="email" value="<%=merchant.email%>">
  108. </label>
  109. <div class="buttonBox">
  110. <button class="button" onclick="accountObj.updateAccount()">Save</button>
  111. <button class="button" onclick="accountObj.editAccountCancel()">Cancel</button>
  112. </div>
  113. </form>
  114. <form id="passwordEdit" onsubmit="accountObj.updatePassword()">
  115. <label>Old password:
  116. <input id="oldPass" type="password" required>
  117. </label>
  118. <label>New password:
  119. <input id="newPass" type="password" required>
  120. </label>
  121. <label>Confirm new password:
  122. <input id="confirmNewPass" type="password" required>
  123. </label>
  124. <div class="buttonBox">
  125. <input class="button" type="submit" value="Submit">
  126. <button class="button" onclick="accountObj.editPasswordCancel()">Cancel</button>
  127. </div>
  128. </form>
  129. <button class="button" onclick="accountObj.editPassword()">Change password</button>
  130. </div>
  131. <div id="addIngredientAction" class="action">
  132. <div class="container">
  133. <form onsubmit="addIngredientObj.submitAdd()">
  134. <h2>Select Ingredient</h2>
  135. <label>Ingredient
  136. <select id="addName"></select>
  137. </label>
  138. <label>Quantity
  139. <input id="addQuantity" type="number" step="0.01" required>
  140. </label>
  141. <input class="button" type="submit" value="Add Ingredient">
  142. </form>
  143. <form id="createIngredientInput" onsubmit="addIngredientObj.submitNew()">
  144. <h2>Create New Ingredient</h2>
  145. <label>Name
  146. <input id="newName" type="text" required>
  147. </label>
  148. <label>Category
  149. <input id="newCategory" type="text" required>
  150. </label>
  151. <label>Unit
  152. <input id="newUnit" type="text" required>
  153. </label>
  154. <label>Quantity
  155. <input id="newQuantity" type="number" step="0.01" required>
  156. </label>
  157. <button class="button">Create Ingredient</button>
  158. </form>
  159. </div>
  160. </div>
  161. <div id="enterTransactionsAction" class="action">
  162. <h1>Enter all sales</h1>
  163. <h3>Last updated: <span id="updated"></span></h3>
  164. <table>
  165. <thead>
  166. <tr>
  167. <th>Recipe</th>
  168. <th>Number sold</th>
  169. </tr>
  170. </thead>
  171. <tbody></tbody>
  172. </table>
  173. <button class="button" onclick="enterTransactionsObj.submit()">Submit</button>
  174. </div>
  175. <div id="enterPurchaseAction" class="action">
  176. <h1>Enter Purchases</h1>
  177. <table>
  178. <thead>
  179. <tr>
  180. <th>Ingredient</th>
  181. <th>Amount</th>
  182. </tr>
  183. </thead>
  184. <tbody></tbody>
  185. </table>
  186. <button class="button" onclick="enterPurchaseObj.submit()">Submit</button>
  187. </div>
  188. <div id="singleRecipeAction" class="action">
  189. <h2 id="recipeName"></h2>
  190. <div class="buttonsDiv">
  191. <button class="button" id="addButton">Add Ingredient</button>
  192. </div>
  193. <table>
  194. <thead>
  195. <tr>
  196. <th>Name</th>
  197. <th>Quantity</th>
  198. <th>Actions</th>
  199. </tr>
  200. </thead>
  201. <tbody></tbody>
  202. </table>
  203. </div>
  204. <%- include ../shared/footer %>
  205. <script>
  206. <% if(locals.error){ %>
  207. let error = <%- JSON.stringify(error) %>;
  208. <% }else{ %>
  209. let error = undefined;
  210. <% } %>
  211. </script>
  212. <script>
  213. let merchant = <%- JSON.stringify(merchant) %>;
  214. </script>
  215. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  216. <script src="../shared/validation.js"></script>
  217. <script src="/inventoryPage/inventory.js"></script>
  218. <script src="/inventoryPage/recipes.js"></script>
  219. <script src="/inventoryPage/data.js"></script>
  220. <script src="/inventoryPage/account.js"></script>
  221. <script src="/inventoryPage/addIngredient.js"></script>
  222. <script src="/inventoryPage/enterTransactions.js"></script>
  223. <script src="/inventoryPage/enterPurchase.js"></script>
  224. <script src="/inventoryPage/singleRecipe.js"></script>
  225. <script src="/shared/controller.js"></script>
  226. <script>
  227. axios.get("/transactions")
  228. .then((response)=>{
  229. if(typeof(response.data) === "string"){
  230. banner.createError(response.data);
  231. }else{
  232. dataObj.populate(response.data);
  233. }
  234. })
  235. .catch((err)=>{
  236. banner.createError("Error: unable to render sales data");
  237. });
  238. axios.get("/purchases")
  239. .then((response)=>{
  240. if(typeof(response.data) === "string"){
  241. banner.createError(response.data);
  242. }else{
  243. dataObj.populatePurchases(response.data);
  244. }
  245. })
  246. .catch((err)=>{
  247. banner.createError("Error: unable to render purchases data");
  248. })
  249. </script>
  250. </body>
  251. </html>