Commit a8011e07 authored by Chanelle Lunod's avatar Chanelle Lunod

initial commit

parents 34538002 3262b5df
File added
class Product < ApplicationRecord class Product < ApplicationRecord
validates :name, presence: true
has_many :transactions has_many :transactions
has_many :comments has_many :comments
end end
...@@ -17,20 +17,16 @@ ...@@ -17,20 +17,16 @@
<body> <body>
<style> <style>
body,h2,h3,h4,h5,h6 {font-family: "Montserrat", sans-serif} body,h2,h3,h4,h5,h6 {font-family: "Montserrat", sans-serif}
h1 {font-family: "Clibri", sans-serif} h1 {font-family: "Impact", sans-serif}
.w3-row-padding img {margin-bottom: 12px} .w3-row-padding img {margin-bottom: 12px}
.w3-sidebar {width: 120px;background: #222;} .w3-sidebar {width: 120px;background: #222;}
#main {margin-left: 120px} #main {margin-left: 120px}
@media only screen and (max-width: 600px) {#main {margin-left: 0}} @media only screen and (max-width: 600px) {#main {margin-left: 0}}
</style> </style>
<!-- <style>
background-color: #ccfff2
font-family:'Calibri';
</style> -->
<body class="w3-black"> <body class="w3-black">
<nav class="w3-sidebar w3-bar-block w3-small w3-hide-small w3-center"> <nav class="w3-sidebar w3-bar-block w3-small w3-hide-small w3-center">
<!-- Avatar image in top left corner --> <!-- Avatar image in top left corner -->
<img src="https://218run.com/wp-content/uploads/2013/10/yonex_logo_wp-300x300.jpg" style="width:100%"> <img src="https://lh3.googleusercontent.com/PYzkAZJEGDPjS9BMr-haoxCo5X3bCX_EVkDsua3Tc6Il29mjbWO6pBrS6URoR6KF86NjU_t1Io9Y0kJPW7cebTEbe-ZkBUHIvlN8rTUi0fHa4rtnRtR4CTF8QHyOLU6TPqotE0SeuOVTwkN4qkJqMHcjqHH0IRQgrjA186OdjdidOfwNu0zFEx2N5jWXML02mfCgtSpTlxxc7gMHT1p-e1zrFvJ7h6QXpGmNIU3OYcJanMqB-NZuDPrSOMFVCujy0ruWqBcIVaUyn_hwe9_GxRTUx1w1bpnWctWjv-KzsiW2xsB9PuRqlp3SvVfeEwh3oBg7f4WfrpHZWSLWsneVNhnpw9xfHCFwh3ayA7DD0DjhoKOAzwAZKRfJ3vU7dBA8OiadZ3XKq30p4QNBjbWTvB72SKPuBH8amFvyAisLdrMlAEA74tighN_ne8SWDT_hHtR1JOsJ039iDcfyH2L5rzz9L8s2sPbsZbko4ffShwLohhCnq3G8gX9P0ISEvcMocZJimTS0xaupkvXmHyKDLxbpMw1_gDm9-B7cRIOxfSs--oddVyggQjj7PukDkwqqb32Vn9EvfaM4glMJx_iLI1Bm5wWhZlpbyc0P9g=s300-no" style="width:100%">
<a href="#" class="w3-bar-item w3-button w3-padding-large w3-black"> <a href="#" class="w3-bar-item w3-button w3-padding-large w3-black">
<i class="fa fa-home w3-xxlarge"></i> <i class="fa fa-home w3-xxlarge"></i>
<p>HOME</p> <p>HOME</p>
...@@ -67,7 +63,7 @@ ...@@ -67,7 +63,7 @@
<!-- Header/Home --> <!-- Header/Home -->
<header class="w3-container w3-padding-32 w3-center w3-black" id="home"> <header class="w3-container w3-padding-32 w3-center w3-black" id="home">
<h1 class="w3-jumbo"><span class="w3-hide-small">YONEX</h1> <h1 class="w3-jumbo"><span class="w3-hide-small">YONEX</h1>
<p>"The #1 trusted brand by all athletes accross the globe."</p> <i>"The #1 trusted brand by all athletes accross the globe."</i>
<img src="http://www.sunrisecatalogue.com/uploads/posters/duovsvt_ldlcw_YYSRSRC.jpg" alt="boy" class="w3-image" width="992" height="1108"> <img src="http://www.sunrisecatalogue.com/uploads/posters/duovsvt_ldlcw_YYSRSRC.jpg" alt="boy" class="w3-image" width="992" height="1108">
</header> </header>
</span> </span>
...@@ -98,15 +94,15 @@ ...@@ -98,15 +94,15 @@
<h3 class="w3-padding-16 w3-text-light-grey">Our Ratings</h3> <h3 class="w3-padding-16 w3-text-light-grey">Our Ratings</h3>
<p class="w3-wide">Badminton</p> <p class="w3-wide">Badminton</p>
<div class="w3-white"> <div class="w3-white">
<div class="w3-dark-grey" style="height:28px;width:99%"></div> <div class="w3-dark-grey" style="height:28px;width:95%"></div>
</div> </div>
<p class="w3-wide">Golf</p> <p class="w3-wide">Golf</p>
<div class="w3-white"> <div class="w3-white">
<div class="w3-dark-grey" style="height:28px;width:97%"></div> <div class="w3-dark-grey" style="height:28px;width:90%"></div>
</div> </div>
<p class="w3-wide">Tennis</p> <p class="w3-wide">Tennis</p>
<div class="w3-white"> <div class="w3-white">
<div class="w3-dark-grey" style="height:28px;width:95%"></div> <div class="w3-dark-grey" style="height:28px;width:85%"></div>
</div><br> </div><br>
<div class="w3-row w3-center w3-padding-16 w3-section w3-light-grey"> <div class="w3-row w3-center w3-padding-16 w3-section w3-light-grey">
......
<% if admin_user_signed_in? %> <% if admin_user_signed_in? %>
<h1>Products</h1> <h1>PRODUCTS</h1>
<div> <div>
<%= link_to "Add new Product", new_product_path, class: "btn btn-primary" %> <%= link_to "Add new Product", new_product_path, class: "btn btn-primary" %>
</div> </div>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</small> </small>
<% else %> <% else %>
<table class = "table", cellspacing="0", cellpadding="0"> <table class = "table", cellspacing="0", cellpadding="0">
<thead style="background-color: #F08080"> <thead>
<th>Name</th> <th>Name</th>
<th>Description</th> <th>Description</th>
<th>Status</th> <th>Status</th>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<% @products.each do |product| %> <% @products.each do |product| %>
<tr> <tr>
<td> <td>
<%= product.name %> <%= link_to product.name, product_path(product) %>
</td> </td>
<td> <td>
<%= product.description %> <%= product.description %>
...@@ -39,35 +39,42 @@ ...@@ -39,35 +39,42 @@
<% product.transactions.each do |trans| %> <% product.transactions.each do |trans| %>
<% if trans.mode == "Supply" %> <% if trans.mode == "Supply" %>
<% if trans.quantity == nil %> <% if trans.quantity == nil %>
<% trans.quantity == 0 %> <% trans.quantity = 0 %>
<% end %> <% end %>
<% @supplies += trans.quantity %> <% @supplies += trans.quantity %>
<% end %>
<% end %> <% end %>
<% end %>
<%= @supplies %> <%= @supplies %>
</td> </td>
<td> <td>
<% @orders = 0 %> <% @orders = 0 %>
<% product.transactions.each do |trans| %> <% product.transactions.each do |trans| %>
<% if trans.mode == "Order" %> <% if trans.mode == "Order" %>
<% if trans.quantity == nil %> <% if trans.quantity == nil %>
<% trans.quantity == 0 %> <% trans.quantity = 0 %>
<% end %> <% end %>
<% @orders += trans.quantity %> <% @orders += trans.quantity %>
<% end %> <% end %>
<% end %> <% end %>
<%= @orders %> <%= @orders %>
</td> </td>
<td> <td>
<% @total = 0 %> <% @total = 0 %>
<% product.transactions.each do |trans| %> <% product.transactions.each do |trans| %>
<% if trans.mode == "Supply" %>
<% if trans.quantity == nil %> <% if trans.quantity == nil %>
<% trans.quantity == 0 %> <% trans.quantity = 0 %>
<% end %> <% end %>
<% @total += trans.quantity %> <% @total += trans.quantity %>
<% elsif trans.mode == "Order" %>
<% if trans.quantity == nil %>
<% trans.quantity = 0 %>
<% end %>
<% @total -= trans.quantity %>
<% end %>
<% end %> <% end %>
<%= @total %> <%= @total %>
</td> </td>
<td> <td>
<%= time_ago_in_words(product.created_at) %> ago <%= time_ago_in_words(product.created_at) %> ago
</td> </td>
...@@ -81,12 +88,6 @@ ...@@ -81,12 +88,6 @@
<%= link_to "Activate", product_path(product), method: :delete, class: "btn btn-success"%> <%= link_to "Activate", product_path(product), method: :delete, class: "btn btn-success"%>
<% end %> <% end %>
</td> </td>
<!-- <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> </tr>
<% end%> <% end%>
</tbody> </tbody>
...@@ -94,7 +95,7 @@ ...@@ -94,7 +95,7 @@
<% end %> <% end %>
<% elsif user_signed_in? %> <% elsif user_signed_in? %>
<h1>Transactions</h1> <h1>TRANSACTIONS</h1>
<br> <br>
<% if @products.empty? %> <% if @products.empty? %>
...@@ -103,7 +104,7 @@ ...@@ -103,7 +104,7 @@
</small> </small>
<% else %> <% else %>
<table class = "table", cellspacing="0", cellpadding="0"> <table class = "table", cellspacing="0", cellpadding="0">
<thead style="background-color: #76D7C4"> <thead>
<th>Name</th> <th>Name</th>
<th>Description</th> <th>Description</th>
<th>Status</th> <th>Status</th>
...@@ -129,48 +130,55 @@ ...@@ -129,48 +130,55 @@
<% product.transactions.each do |trans| %> <% product.transactions.each do |trans| %>
<% if trans.mode == "Supply" %> <% if trans.mode == "Supply" %>
<% if trans.quantity == nil %> <% if trans.quantity == nil %>
<% trans.quantity == 0 %> <% trans.quantity = 0 %>
<% end %> <% end %>
<% @supplies += trans.quantity %> <% @supplies += trans.quantity %>
<% end %>
<% end %> <% end %>
<% end %>
<%= @supplies %> <%= @supplies %>
</td> </td>
<td> <td>
<% @orders = 0 %> <% @orders = 0 %>
<% product.transactions.each do |trans| %> <% product.transactions.each do |trans| %>
<% if trans.mode == "Order" %> <% if trans.mode == "Order" %>
<% if trans.quantity == nil %> <% if trans.quantity == nil %>
<% trans.quantity == 0 %> <% trans.quantity = 0 %>
<% end %> <% end %>
<% @orders += trans.quantity %> <% @orders += trans.quantity %>
<% end %> <% end %>
<% end %> <% end %>
<%= @orders %> <%= @orders %>
</td> </td>
<td> <td>
<% @total = 0 %> <% @total = 0 %>
<% product.transactions.each do |trans| %> <% product.transactions.each do |trans| %>
<% if trans.mode == "Supply" %>
<% if trans.quantity == nil %> <% if trans.quantity == nil %>
<% trans.quantity == 0 %> <% trans.quantity = 0 %>
<% end %> <% end %>
<% @total += trans.quantity %> <% @total += trans.quantity %>
<% elsif trans.mode == "Order" %>
<% if trans.quantity == nil %>
<% trans.quantity = 0 %>
<% end %>
<% @total -= trans.quantity %>
<% end %>
<% end %> <% end %>
<%= @total %> <%= @total %>
</td> </td>
<td>
<% if product.status == "Active" %>
<td> <td>
<% if product.status == "Active" %> <%= link_to "Add Supply", new_product_supply_path(product), class: "btn btn-primary" %>
<td>
<%= link_to "Add Supply", new_product_supply_path(product), class: "btn btn-primary" %>
</td>
<td>
<%= link_to "Add Order", new_product_order_path(product), class: "btn btn-primary" %>
</td>
<% else %>
<% end %>
</td> </td>
</tr> <td>
<% end%> <%= link_to "Add Order", new_product_order_path(product), class: "btn btn-primary" %>
</td>
<% else %>
<% end %>
</td>
</tr>
<% end%>
</tbody> </tbody>
</table> </table>
<% end %> <% end %>
......
...@@ -4,10 +4,6 @@ ...@@ -4,10 +4,6 @@
<%= @product.description %> <%= @product.description %>
</p> </p>
<p>
Status: <%= @product.status %>
</p>
<p> <p>
<small> <small>
Created At: <%= @product.created_at.to_s :short %> Created At: <%= @product.created_at.to_s :short %>
......
<h1>New Supply</h1> <h1>New Supply</h1>
<%= simple_form_for([@product, @supply], url: product_supplies_path) do |f| %> <%= simple_form_for([@product, @supply], url: product_supplies_path) do |f| %>
<%= f.input :quantity %> <%= f.input :quantity %>
<%= f.button :submit, "Add Supply", class: "btn btn-primary" %> <%= f.button :submit, "Add Supply", class: "btn btn-primary" %>
<%= link_to "Back", authenticated_user_root_path, class: "btn-btn-default" %> <%= 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