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
e67ef1de
Commit
e67ef1de
authored
Jul 15, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
a53e92a3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
14 deletions
+106
-14
transactions.scss
app/assets/stylesheets/transactions.scss
+0
-3
transactions_controller.rb
app/controllers/transactions_controller.rb
+41
-7
application.html.erb
app/views/layouts/application.html.erb
+0
-1
index.html.erb
app/views/products/index.html.erb
+1
-1
index.html.erb
app/views/transactions/index.html.erb
+42
-2
order.html.erb
app/views/transactions/order.html.erb
+11
-0
supply.html.erb
app/views/transactions/supply.html.erb
+11
-0
No files found.
app/assets/stylesheets/transactions.scss
View file @
e67ef1de
// Place all the styles related to the Transactions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
app/controllers/transactions_controller.rb
View file @
e67ef1de
...
...
@@ -2,9 +2,43 @@ class TransactionsController < ApplicationController
before_action
:authenticate_user!
def
index
@products
=
Product
.
all
end
def
show
def
display
if
@product
.
status
==
active
Products
.
find_by
(
id:
[
pramas
[
:id
])
else
#dont display
end
def
new
@product
.
order
=
Order
.
new
@products
.
supply
=
Supply
.
new
end
def
order
@product
.
order
=
Order
.
new
(
transaction_params
)
if
@product
.
order
.
save
redirect_to
transaction_path
,
notice:
"You have successfuly placed a new order."
else
render
'new'
end
end
def
supply
@product
.
supply
=
Supply
.
new
(
transaction_params
)
if
@product
.
supply
.
save
redirect_to
transaction_path
,
notice:
"You have successfully placed a new supply."
else
render
'new'
end
end
private
def
product_params
params
.
require
(
:product
).
permit!
end
end
\ No newline at end of file
app/views/layouts/application.html.erb
View file @
e67ef1de
...
...
@@ -34,7 +34,6 @@
</nav>
<div
class=
"container"
id=
"container"
>
<%
if
notice
%>
<p
class=
"alert alert-success"
>
<%=
notice
%>
</p>
...
...
app/views/products/index.html.erb
View file @
e67ef1de
app/views/transactions/index.html.erb
View file @
e67ef1de
<h1>
Transactions#index
</h1>
<p>
Find me in app/views/transactions/index.html.erb
</p>
<h1>
Transactions
</h1>
<%
if
@products
.
empty?
%>
<small>
No products have been created.
</small>
<%
elsif
@products
.
status
==
active
%>
<table
class=
"table"
>
<thead>
<th>
Name
</th>
<th>
Description
</th>
<th>
Status
</th>
<th>
Time Created
</th>
<th
colspan=
"4"
></th>
</thead>
<tbody>
<%
@products
.
each
do
|
product
|
%>
<tr>
<td>
<%=
link_to
product
.
name
,
product_path
(
product
)
%>
</td>
<td>
<%=
product
.
description
%>
</td>
<td>
<%=
product
.
status
%>
</td>
<td>
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
</td>
<td>
<%=
link_to
"Add Order"
,
order_transaction_path
(
product
),
class:
"btn btn-primary"
%>
</td>
<td>
<%=
link_to
"Add Supply"
,
supply_transaction_path
(
product
),
class:
"btn btn-primary"
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<%
end
%>
app/views/transactions/order.html.erb
0 → 100644
View file @
e67ef1de
<h1>
Add Order
</h1>
<%=
simple_form_for
@product
do
|
f
|
%>
<%=
f
.
input
:product_id
,
as: :integer
%>
<%=
f
.
input
:user_id
,
as: :integer
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:mode
,
as: :string
,
collection:
[[
'Active'
,
'Active'
],
[
'Inactive'
,
'Inactive'
]],
value_method: :first
,
label_method: :second
%>
<%=
f
.
button
:submit
,
"Add Order"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back"
,
products_path
,
class:
"btn btn-default"
%>
<%
end
%>
\ No newline at end of file
app/views/transactions/supply.html.erb
0 → 100644
View file @
e67ef1de
<h1>
Add Supply
</h1>
<%=
simple_form_for
@product
do
|
f
|
%>
<%=
f
.
input
:product_id
,
as: :integer
%>
<%=
f
.
input
:user_id
,
as: :integer
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:mode
,
as: :string
,
collection:
[[
'Active'
,
'Active'
],
[
'Inactive'
,
'Inactive'
]],
value_method: :first
,
label_method: :second
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back"
,
products_path
,
class:
"btn btn-default"
%>
<%
end
%>
\ No newline at end of file
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