Commit 3262b5df authored by Chanelle Lunod's avatar Chanelle Lunod

Initial commit

parent d1dbca7c
class Product < ApplicationRecord
validates :name, presence: true
has_many :transactions
has_many :comments
end
This diff is collapsed.
<% if admin_user_signed_in? %>
<h1>Products</h1>
<h1>PRODUCTS</h1>
<div>
<%= link_to "Add new Product", new_product_path, class: "btn btn-primary" %>
</div>
......@@ -12,7 +12,7 @@
</small>
<% else %>
<table class = "table", cellspacing="0", cellpadding="0">
<thead style="background-color: #F08080">
<thead>
<th>Name</th>
<th>Description</th>
<th>Status</th>
......@@ -26,7 +26,7 @@
<% @products.each do |product| %>
<tr>
<td>
<%= product.name %>
<%= link_to product.name, product_path(product) %>
</td>
<td>
<%= product.description %>
......@@ -39,7 +39,7 @@
<% product.transactions.each do |trans| %>
<% if trans.mode == "Supply" %>
<% if trans.quantity == nil %>
<% trans.quantity == 0 %>
<% trans.quantity = 0 %>
<% end %>
<% @supplies += trans.quantity %>
<% end %>
......@@ -51,7 +51,7 @@
<% product.transactions.each do |trans| %>
<% if trans.mode == "Order" %>
<% if trans.quantity == nil %>
<% trans.quantity == 0 %>
<% trans.quantity = 0 %>
<% end %>
<% @orders += trans.quantity %>
<% end %>
......@@ -61,10 +61,17 @@
<td>
<% @total = 0 %>
<% product.transactions.each do |trans| %>
<% if trans.mode == "Supply" %>
<% if trans.quantity == nil %>
<% trans.quantity == 0 %>
<% trans.quantity = 0 %>
<% end %>
<% @total += trans.quantity %>
<% elsif trans.mode == "Order" %>
<% if trans.quantity == nil %>
<% trans.quantity = 0 %>
<% end %>
<% @total -= trans.quantity %>
<% end %>
<% end %>
<%= @total %>
</td>
......@@ -84,9 +91,6 @@
<!-- <td>
<%= link_to "Delete", product_path(product), class: "btn btn-danger", method: :post, data: { confirm: "Are you sure you want to delete?" } %>
</td> -->
<td>
<%= link_to "View", product_path(product), class: "btn btn-primary" %>
</td>
</tr>
<% end%>
</tbody>
......@@ -94,7 +98,7 @@
<% end %>
<% elsif user_signed_in? %>
<h1>Transactions</h1>
<h1>TRANSACTIONS</h1>
<br>
<% if @products.empty? %>
......@@ -103,7 +107,7 @@
</small>
<% else %>
<table class = "table", cellspacing="0", cellpadding="0">
<thead style="background-color: #76D7C4">
<thead>
<th>Name</th>
<th>Description</th>
<th>Status</th>
......@@ -129,7 +133,7 @@
<% product.transactions.each do |trans| %>
<% if trans.mode == "Supply" %>
<% if trans.quantity == nil %>
<% trans.quantity == 0 %>
<% trans.quantity = 0 %>
<% end %>
<% @supplies += trans.quantity %>
<% end %>
......@@ -141,7 +145,7 @@
<% product.transactions.each do |trans| %>
<% if trans.mode == "Order" %>
<% if trans.quantity == nil %>
<% trans.quantity == 0 %>
<% trans.quantity = 0 %>
<% end %>
<% @orders += trans.quantity %>
<% end %>
......@@ -151,10 +155,17 @@
<td>
<% @total = 0 %>
<% product.transactions.each do |trans| %>
<% if trans.mode == "Supply" %>
<% if trans.quantity == nil %>
<% trans.quantity == 0 %>
<% trans.quantity = 0 %>
<% end %>
<% @total += trans.quantity %>
<% elsif trans.mode == "Order" %>
<% if trans.quantity == nil %>
<% trans.quantity = 0 %>
<% end %>
<% @total -= trans.quantity %>
<% end %>
<% end %>
<%= @total %>
</td>
......
......@@ -4,10 +4,6 @@
<%= @product.description %>
</p>
<p>
Status: <%= @product.status %>
</p>
<p>
<small>
Created At: <%= @product.created_at.to_s :short %>
......
<h1>New Supply</h1>
<%= simple_form_for([@product, @supply], url: product_supplies_path) do |f| %>
<%= f.input :quantity %>
<%= f.button :submit, "Add Supply", class: "btn btn-primary" %>
<%= link_to "Back", authenticated_user_root_path, class: "btn-btn-default" %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment