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
Expand all
Show 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
validates
:name
,
presence:
true
has_many
:transactions
has_many
:comments
end
app/views/layouts/application.html.erb
View file @
3262b5df
This diff is collapsed.
Click to expand it.
app/views/products/index.html.erb
View file @
3262b5df
<%
if
admin_user_signed_in?
%>
<h1>
P
roducts
</h1>
<h1>
P
RODUCTS
</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>
T
ransactions
</h1>
<h1>
T
RANSACTIONS
</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>
...
...
app/views/products/show.html.erb
View file @
3262b5df
...
...
@@ -4,10 +4,6 @@
<%=
@product
.
description
%>
</p>
<p>
Status:
<%=
@product
.
status
%>
</p>
<p>
<small>
Created At:
<%=
@product
.
created_at
.
to_s
:short
%>
...
...
app/views/supplies/new.html.erb
View file @
3262b5df
<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"
%>
...
...
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