Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MIS21_Final_Project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chanelle Lunod
MIS21_Final_Project
Commits
3262b5df
Commit
3262b5df
authored
Jul 20, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
d1dbca7c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
248 additions
and
88 deletions
+248
-88
product.rb
app/models/product.rb
+1
-0
application.html.erb
app/views/layouts/application.html.erb
+189
-38
index.html.erb
app/views/products/index.html.erb
+57
-46
show.html.erb
app/views/products/show.html.erb
+0
-4
new.html.erb
app/views/supplies/new.html.erb
+1
-0
No files found.
app/models/product.rb
View file @
3262b5df
class
Product
<
ApplicationRecord
class
Product
<
ApplicationRecord
validates
:name
,
presence:
true
has_many
:transactions
has_many
:transactions
has_many
:comments
has_many
:comments
end
end
app/views/layouts/application.html.erb
View file @
3262b5df
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
>
<link
rel=
"stylesheet"
href=
"https://www.w3schools.com/w3css/4/w3.css"
>
<link
rel=
"stylesheet"
href=
"https://fonts.googleapis.com/css?family=Montserrat"
>
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
>
<title>
PRODUCTS
</title>
<title>
PRODUCTS
</title>
<%=
csrf_meta_tags
%>
<%=
csrf_meta_tags
%>
<%=
csp_meta_tag
%>
<%=
csp_meta_tag
%>
...
@@ -13,27 +16,63 @@
...
@@ -13,27 +16,63 @@
<body>
<body>
<style>
<style>
body
,
h2
,
h3
,
h4
,
h5
,
h6
{
font-family
:
"Montserrat"
,
sans-serif
}
h1
{
font-family
:
"Impact"
,
sans-serif
}
.w3-row-padding
img
{
margin-bottom
:
12px
}
.w3-sidebar
{
width
:
120px
;
background
:
#222
;}
#main
{
margin-left
:
120px
}
@media
only
screen
and
(
max-width
:
600px
)
{
#main
{
margin-left
:
0
}}
</style>
<!-- <style>
background-color: #ccfff2
background-color: #ccfff2
font-family:'Calibri';
font-family:'Calibri';
</style>
</style> -->
<nav
class=
"navbar navbar-expand-xl navbar-dark bg-dark"
>
<body
class=
"w3-black"
>
<%=
link_to
"HOME"
,
root_path
,
class:
"navbar-brand"
%>
<nav
class=
"w3-sidebar w3-bar-block w3-small w3-hide-small w3-center"
>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarSupportedContent"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<!-- Avatar image in top left corner -->
<span
class=
"navbar-toggler-icon"
></span>
<img
src=
"https://218run.com/wp-content/uploads/2013/10/yonex_logo_wp-300x300.jpg"
style=
"width:100%"
>
</button>
<a
href=
"#"
class=
"w3-bar-item w3-button w3-padding-large w3-black"
>
<i
class=
"fa fa-home w3-xxlarge"
></i>
<div
class=
"collapse navbar-collapse"
id=
"navbarSupportedContent"
>
<p>
HOME
</p>
<ul
class=
"navbar-nav mr-auto"
>
</a>
<li
class=
"nav-item"
>
<a
href=
"#signin"
class=
"w3-bar-item w3-button w3-padding-large w3-hover-black"
>
<a
class=
"nav-link"
href=
"#"
>
Sign In
</a>
<i
class=
"fa fa-user w3-xxlarge"
></i>
</li>
<p>
SIGN IN
</p>
<li
class=
"nav-item"
>
</a>
<a
class=
"nav-link"
href=
"#"
>
Inventory
</a>
<a
href=
"#products"
class=
"w3-bar-item w3-button w3-padding-large w3-hover-black"
>
</li>
<i
class=
"fa fa-eye w3-xxlarge"
></i>
<li
class=
"nav-item"
>
<p>
PRODUCTS
</p>
<a
class=
"nav-link"
href=
"#"
>
Transactions
</a>
</a>
</li>
<a
href=
"#contact"
class=
"w3-bar-item w3-button w3-padding-large w3-hover-black"
>
</ul>
<i
class=
"fa fa-envelope w3-xxlarge"
></i>
<p>
CONTACT
</p>
</a>
<a
href=
"#search"
class=
"w3-bar-item w3-button w3-padding-large w3-hover-black"
>
<i
class=
"fa fa-search w3-xxlarge"
></i>
<p>
SEARCH
</p>
</a>
</nav>
<div
class=
"w3-top w3-hide-large w3-hide-medium"
id=
"myNavbar"
>
<div
class=
"w3-bar w3-black w3-opacity w3-hover-opacity-off w3-center w3-small"
>
<a
href=
"#"
class=
"w3-bar-item w3-button"
style=
"width:25% !important"
>
HOME
</a>
<a
href=
"#signin"
class=
"w3-bar-item w3-button"
style=
"width:25% !important"
>
SIGN IN
</a>
<a
href=
"#products"
class=
"w3-bar-item w3-button"
style=
"width:25% !important"
>
PRODUCTS
</a>
<a
href=
"#contact"
class=
"w3-bar-item w3-button"
style=
"width:25% !important"
>
CONTACT
</a>
<a
href=
"#search"
class=
"w3-bar-item w3-button"
style=
"width:25% !important"
>
SEARCH
</a>
</div>
</div>
<div
class=
"w3-padding-large"
id=
"main"
>
<!-- Header/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>
<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"
>
</header>
</span>
<div
class=
"w3-content w3-justify w3-text-white w3-padding-64"
id=
"signin"
>
<span
class=
"navbar-text"
>
<span
class=
"navbar-text"
>
<%
if
user_signed_in?
%>
<%
if
user_signed_in?
%>
Logged in as
<strong>
<%=
current_user
.
email
%>
</strong>
.
Logged in as
<strong>
<%=
current_user
.
email
%>
</strong>
.
...
@@ -44,27 +83,139 @@
...
@@ -44,27 +83,139 @@
<%=
link_to
"Logout"
,
destroy_admin_user_session_path
,
method: :delete
,
:class
=>
'navbar-link'
%>
<%=
link_to
"Logout"
,
destroy_admin_user_session_path
,
method: :delete
,
:class
=>
'navbar-link'
%>
<%
end
%>
<%
end
%>
</span>
</span>
<%=
form_tag
products_path
,
:method
=>
'get'
do
%>
<%=
text_field_tag
:search
,
params
[
:search
]
%>
<div
class=
"container"
id=
"container"
>
<%=
submit_tag
"Search"
%>
<%
if
notice
%>
<p
class=
"alert alert-success"
>
<%=
notice
%>
</p>
<%
end
%>
<%
end
%>
<%
if
alert
%>
<p
class=
"alert alert-danger"
>
<%=
alert
%>
</p>
<%
end
%>
<%=
yield
%>
</div><br>
<br>
<br>
<h3
class=
"w3-padding-16 w3-text-light-grey"
>
Our Ratings
</h3>
<p
class=
"w3-wide"
>
Badminton
</p>
<div
class=
"w3-white"
>
<div
class=
"w3-dark-grey"
style=
"height:28px;width:95%"
></div>
</div>
</div>
</nav>
<p
class=
"w3-wide"
>
Golf
</p>
<div
class=
"w3-white"
>
<div
id=
"google_translate_element"
></div><script
type=
"text/javascript"
>
<div
class=
"w3-dark-grey"
style=
"height:28px;width:90%"
></div>
function
googleTranslateElementInit
()
{
</div>
new
google
.
translate
.
TranslateElement
({
pageLanguage
:
'en'
,
includedLanguages
:
'af,ar,da,de,en,es,fi,fr,hi,id,is,ja,ko,mi,ms,my,nl,no,pt,sw,tl,zh-CN'
,
layout
:
google
.
translate
.
TranslateElement
.
InlineLayout
.
HORIZONTAL
},
'google_translate_element'
);
<p
class=
"w3-wide"
>
Tennis
</p>
}
<div
class=
"w3-white"
>
</script><script
type=
"text/javascript"
src=
"//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"
></script>
<div
class=
"w3-dark-grey"
style=
"height:28px;width:85%"
></div>
</div><br>
<div
class=
"container"
id=
"container"
>
<%
if
notice
%>
<div
class=
"w3-row w3-center w3-padding-16 w3-section w3-light-grey"
>
<p
class=
"alert alert-success"
>
<%=
notice
%>
</p>
<div
class=
"w3-quarter w3-section"
>
<%
end
%>
<span
class=
"w3-xlarge"
>
500+
</span><br>
<%
if
alert
%>
Partners
<p
class=
"alert alert-danger"
>
<%=
alert
%>
</p>
</div>
<%
end
%>
<div
class=
"w3-quarter w3-section"
>
<%=
yield
%>
<span
class=
"w3-xlarge"
>
800
</span><br>
Stores Worldwide
</div>
<div
class=
"w3-quarter w3-section"
>
<span
class=
"w3-xlarge"
>
1M++
</span><br>
Happy Athletes
</div>
<div
class=
"w3-quarter w3-section"
>
<span
class=
"w3-xlarge"
>
650+
</span><br>
Distributors
</div>
</div>
</div>
<!-- Portfolio Section -->
<div
class=
"w3-padding-64 w3-content"
id=
"products"
>
<h2
class=
"w3-text-light-grey"
>
Featured
</h2>
<hr
style=
"width:200px"
class=
"w3-opacity"
>
<!-- Grid for photos -->
<div
class=
"w3-row-padding"
style=
"margin:0 -16px"
>
<div
class=
"w3-half"
>
<img
src=
"http://www.sunrisecatalogue.com/uploads/posters/DUORA%20Series%20Ad.jpg"
style=
"width:100%"
>
<img
src=
"http://www.sunrisecatalogue.com/uploads/posters/Tour%20Racquets%202016.png"
style=
"width:100%"
>
<img
src=
"http://www.sunrisecatalogue.com/uploads/posters/NR95DX%20and%20NR70DX%20final.jpg"
style=
"width:100%"
>
</div>
<div
class=
"w3-half"
>
<img
src=
"http://www.sunrisecatalogue.com/uploads/posters/duovsvt_version_YYSRSRC.jpg"
style=
"width:100%"
>
<img
src=
"http://www.sunrisecatalogue.com/uploads/posters/VTDG-10-and-7.jpg"
style=
"width:100%"
>
<img
src=
"http://www.sunrisecatalogue.com/uploads/posters/ARC10%20Poster.jpg"
style=
"width:100%"
>
</div>
<!-- End photo grid -->
</div>
<!-- End Portfolio Section -->
</div>
<!-- Contact Section -->
<div
class=
"w3-padding-64 w3-content w3-text-grey"
id=
"contact"
>
<h2
class=
"w3-text-light-grey"
>
Contact Us
</h2>
<hr
style=
"width:200px"
class=
"w3-opacity"
>
<div
class=
"w3-section"
>
<p><i
class=
"fa fa-map-marker fa-fw w3-text-white w3-xxlarge w3-margin-right"
></i>
3-23-13 Yushima, Bunkyo-ku, Tokyo 113-8543, Japan
</p>
<p><i
class=
"fa fa-phone fa-fw w3-text-white w3-xxlarge w3-margin-right"
></i>
Phone: +00 12345
</p>
<p><i
class=
"fa fa-envelope fa-fw w3-text-white w3-xxlarge w3-margin-right"
>
</i>
Email: yonex@obf.ateneo.edu
</p>
</div><br>
<p>
If you have any questions, send us an email:
</p>
<form
action=
"/action_page.php"
target=
"_blank"
>
<p><input
class=
"w3-input w3-padding-16"
type=
"text"
placeholder=
"Name"
required
name=
"Name"
></p>
<p><input
class=
"w3-input w3-padding-16"
type=
"text"
placeholder=
"Email"
required
name=
"Email"
></p>
<p><input
class=
"w3-input w3-padding-16"
type=
"text"
placeholder=
"Subject"
required
name=
"Subject"
></p>
<p><input
class=
"w3-input w3-padding-16"
type=
"text"
placeholder=
"Message"
required
name=
"Message"
></p>
<p>
<button
class=
"w3-button w3-light-grey w3-padding-large"
type=
"submit"
>
<i
class=
"fa fa-paper-plane"
></i>
SEND EMAIL
</button>
</p>
</form>
</div>
</div>
<!-- End Contact Section -->
<div
class=
"w3-padding-64 w3-content w3-text-white"
>
<h2>
Our Founders
</h2>
<br>
<img
src=
"https://scontent.fmnl4-4.fna.fbcdn.net/v/t31.0-8/26758507_10208855439018286_1377917175667961785_o.jpg?_nc_cat=0&oh=ff30e6770ff054370e1fa725ffe1580d&oe=5BD55DF1"
alt=
"Avatar"
class=
"w3-left w3-circle w3-margin-right"
style=
"width:80px"
>
<p><span
class=
"w3-large w3-margin-right"
>
Andrea Dolendo -
</span>
Chief Executive Officer
</p><br>
<img
src=
"https://scontent.fmnl4-4.fna.fbcdn.net/v/t31.0-8/26232467_10204296200921706_5390473562677293564_o.jpg?_nc_cat=0&oh=e91a4fb887a4bd2437830cb9bb5999f0&oe=5C126350"
alt=
"Avatar"
class=
"w3-left w3-circle w3-margin-right"
style=
"width:80px"
>
<p><span
class=
"w3-large w3-margin-right"
>
Chanelle Lunod -
</span>
Chief Operating Officer
</p>
</div>
<!-- End About Section -->
<!-- Footer -->
<footer
class=
"w3-content w3-padding-64 w3-text-grey w3-xlarge"
>
<i
class=
"fa fa-facebook-official w3-hover-opacity"
></i>
<i
class=
"fa fa-instagram w3-hover-opacity"
></i>
<i
class=
"fa fa-snapchat w3-hover-opacity"
></i>
<i
class=
"fa fa-pinterest-p w3-hover-opacity"
></i>
<i
class=
"fa fa-twitter w3-hover-opacity"
></i>
<i
class=
"fa fa-linkedin w3-hover-opacity"
></i>
<p
class=
"w3-medium"
>
Powered by
<a
href=
"https://www.w3schools.com/w3css/default.asp"
target=
"_blank"
class=
"w3-hover-text-green"
>
w3.css
</a></p>
<!-- End footer -->
<div
id=
"google_translate_element"
></div><script
type=
"text/javascript"
>
function
googleTranslateElementInit
()
{
new
google
.
translate
.
TranslateElement
({
pageLanguage
:
'en'
,
includedLanguages
:
'af,ar,da,de,en,es,fi,fr,hi,id,is,ja,ko,mi,ms,my,nl,no,pt,sw,tl,zh-CN'
,
layout
:
google
.
translate
.
TranslateElement
.
InlineLayout
.
HORIZONTAL
},
'google_translate_element'
);
}
</script><script
type=
"text/javascript"
src=
"//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"
></script>
</footer>
</div>
</nav>
<!-- Search Section -->
<div
class=
"w3-padding-64 w3-content w3-text-grey"
id=
"search"
>
<h2
class=
"w3-text-light-grey"
>
Search Products
</h2>
<%=
form_tag
products_path
,
:method
=>
'get'
do
%>
<%=
text_field_tag
:search
,
params
[
:search
]
%>
<%=
submit_tag
"Search"
,
class:
'btn btn-outline-info my-2 my-sm-0'
%>
<%
end
%>
</div>
</body>
</body>
</html>
</html>
app/views/products/index.html.erb
View file @
3262b5df
<%
if
admin_user_signed_in?
%>
<%
if
admin_user_signed_in?
%>
<h1>
P
roducts
</h1>
<h1>
P
RODUCTS
</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>
...
@@ -84,9 +91,6 @@
...
@@ -84,9 +91,6 @@
<!-- <td>
<!-- <td>
<%=
link_to
"Delete"
,
product_path
(
product
),
class:
"btn btn-danger"
,
method: :post
,
data:
{
confirm:
"Are you sure you want to delete?"
}
%>
<%=
link_to
"Delete"
,
product_path
(
product
),
class:
"btn btn-danger"
,
method: :post
,
data:
{
confirm:
"Are you sure you want to delete?"
}
%>
</td> -->
</td> -->
<td>
<%=
link_to
"View"
,
product_path
(
product
),
class:
"btn btn-primary"
%>
</td>
</tr>
</tr>
<%
end
%>
<%
end
%>
</tbody>
</tbody>
...
@@ -94,7 +98,7 @@
...
@@ -94,7 +98,7 @@
<%
end
%>
<%
end
%>
<%
elsif
user_signed_in?
%>
<%
elsif
user_signed_in?
%>
<h1>
T
ransactions
</h1>
<h1>
T
RANSACTIONS
</h1>
<br>
<br>
<%
if
@products
.
empty?
%>
<%
if
@products
.
empty?
%>
...
@@ -103,7 +107,7 @@
...
@@ -103,7 +107,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 +133,55 @@
...
@@ -129,48 +133,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
%>
...
...
app/views/products/show.html.erb
View file @
3262b5df
...
@@ -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
%>
...
...
app/views/supplies/new.html.erb
View file @
3262b5df
<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"
%>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment