inventory.ejs 11 KB

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