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
34538002
Commit
34538002
authored
Jul 20, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Plain Diff
initial commit
parents
7eb1cfec
d1dbca7c
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
256 additions
and
121 deletions
+256
-121
application.css.scss
app/assets/stylesheets/application.css.scss
+3
-1
orders_controller.rb
app/controllers/orders_controller.rb
+8
-8
products_controller.rb
app/controllers/products_controller.rb
+0
-2
supplies_controller.rb
app/controllers/supplies_controller.rb
+9
-9
application.html.erb
app/views/layouts/application.html.erb
+189
-42
new.html.erb
app/views/orders/new.html.erb
+4
-4
edit.html.erb
app/views/products/edit.html.erb
+0
-1
index.html.erb
app/views/products/index.html.erb
+29
-30
new.html.erb
app/views/products/new.html.erb
+0
-1
index.html.erb
app/views/publics/index.html.erb
+6
-4
new.html.erb
app/views/supplies/new.html.erb
+6
-4
routes.rb
config/routes.rb
+2
-0
orders_controller_test.rb
test/controllers/orders_controller_test.rb
+0
-5
supplies_controller_test.rb
test/controllers/supplies_controller_test.rb
+0
-10
No files found.
app/assets/stylesheets/application.css.scss
View file @
34538002
...
@@ -5,4 +5,6 @@
...
@@ -5,4 +5,6 @@
@import
"bootstrap"
;
@import
"bootstrap"
;
#container
{
padding-top
:
5rem
;
}
#container
{
padding-top
:
5rem
;
}
body
{
background-color
:
#d9e6f2
;}
body
{
background-color
:
#000000
;
}
app/controllers/orders_controller.rb
View file @
34538002
...
@@ -6,15 +6,15 @@ class OrdersController < ApplicationController
...
@@ -6,15 +6,15 @@ class OrdersController < ApplicationController
def
new
def
new
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@order
=
@order
.
transactions
.
new
@order
=
@product
.
transactions
.
new
end
end
def
create
def
create
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@order
=
@order
.
transactions
.
new
(
supply
_params
)
@order
=
@product
.
transactions
.
new
(
order
_params
)
@order
.
mode
=
"Order"
@order
.
mode
=
"Order"
@order
.
user_id
=
current_user
.
id
@order
.
user_id
=
current_user
.
id
@order
.
quantity
=
@order
.
quantity
*
-
1
@order
.
quantity
=
@order
.
quantity
if
@product
.
save
if
@product
.
save
redirect_to
authenticated_user_root_path
,
notice:
"You have successfully placed a new order"
redirect_to
authenticated_user_root_path
,
notice:
"You have successfully placed a new order"
...
...
app/controllers/products_controller.rb
View file @
34538002
class
ProductsController
<
ApplicationController
class
ProductsController
<
ApplicationController
before_action
:authenticate_admin_user!
def
index
def
index
@products
=
Product
.
all
@products
=
Product
.
all
@products
=
Product
.
where
([
"name LIKE ?"
,
"%
#{
params
[
:search
]
}
%"
])
@products
=
Product
.
where
([
"name LIKE ?"
,
"%
#{
params
[
:search
]
}
%"
])
...
...
app/controllers/supplies_controller.rb
View file @
34538002
...
@@ -14,7 +14,7 @@ class SuppliesController < ApplicationController
...
@@ -14,7 +14,7 @@ class SuppliesController < ApplicationController
@supply
=
@product
.
transactions
.
new
(
supply_params
)
@supply
=
@product
.
transactions
.
new
(
supply_params
)
@supply
.
mode
=
"Supply"
@supply
.
mode
=
"Supply"
@supply
.
user_id
=
current_user
.
id
@supply
.
user_id
=
current_user
.
id
@supply
.
quantity
=
@supply
.
quantity
@supply
.
quantity
=
@supply
.
quantity
if
@product
.
save
if
@product
.
save
redirect_to
authenticated_user_root_path
,
notice:
"You have successfully added a new supply."
redirect_to
authenticated_user_root_path
,
notice:
"You have successfully added a new supply."
...
...
app/views/layouts/application.html.erb
View file @
34538002
This diff is collapsed.
Click to expand it.
app/views/orders/new.html.erb
View file @
34538002
<h1>
New Order
</h1>
<h1>
New Order
</h1>
<%=
simple_form_for
@post
do
|
f
|
%>
<%=
simple_form_for
([
@product
,
@order
],
url:
product_orders_path
)
do
|
f
|
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:quantity
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-info
"
%>
<%=
f
.
button
:submit
,
"Add Order"
,
class:
"btn btn-primary
"
%>
<%=
link_to
"Back"
,
transaction_path
,
class:
"btn
btn-default"
%>
<%=
link_to
"Back"
,
authenticated_user_root_path
,
class:
"btn-
btn-default"
%>
<%
end
%>
<%
end
%>
\ No newline at end of file
app/views/products/edit.html.erb
View file @
34538002
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
<%=
simple_form_for
@product
do
|
f
|
%>
<%=
simple_form_for
@product
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:status
,
as: :radio_buttons
,
collection:
[[
'Active'
,
'Active'
],
[
'Inactive'
,
'Inactive'
]],
value_method: :first
,
label_method: :second
%>
<%=
f
.
button
:submit
,
"Save"
,
class:
"btn btn-primary"
%>
<%=
f
.
button
:submit
,
"Save"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back"
,
products_path
,
class:
"btn btn-default"
%>
<%=
link_to
"Back"
,
products_path
,
class:
"btn btn-default"
%>
<%
end
%>
<%
end
%>
app/views/products/index.html.erb
View file @
34538002
...
@@ -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: #
333
"
>
<thead
style=
"background-color: #
F08080
"
>
<th>
Name
</th>
<th>
Name
</th>
<th>
Description
</th>
<th>
Description
</th>
<th>
Status
</th>
<th>
Status
</th>
...
@@ -36,12 +36,11 @@
...
@@ -36,12 +36,11 @@
</td>
</td>
<td>
<td>
<%
@supplies
=
0
%>
<%
@supplies
=
0
%>
<%
product
.
transactions
.
each
do
|
trans
action
|
%>
<%
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
%>
...
@@ -49,21 +48,19 @@
...
@@ -49,21 +48,19 @@
</td>
</td>
<td>
<td>
<%
@orders
=
0
%>
<%
@orders
=
0
%>
<%
product
.
transactions
.
each
do
|
transaction
|
%>
<%
product
.
transactions
.
each
do
|
trans
|
%>
<%
if
trans
.
mode
==
"ORDER"
%>
<%
if
trans
.
mode
==
"Order"
%>
<%
if
trans
.
quantity
==
nil
%>
<%
if
trans
.
quantity
==
nil
%>
<%
trans
action
.
quantity
==
0
%>
<%
trans
.
quantity
==
0
%>
<%
end
%>
<%
end
%>
<%
@orders
+=
trans
.
quantity
%>
<%
@orders
+=
trans
.
quantity
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%=
"(
#{
@orders
.
abs
}
)"
%>
<%=
@orders
%>
</td>
</td>
<td>
<td>
<%
@total
=
0
%>
<%
@total
=
0
%>
<%
product
.
transactions
.
each
do
|
trans
action
|
%>
<%
product
.
transactions
.
each
do
|
trans
|
%>
<%
if
trans
.
quantity
==
nil
%>
<%
if
trans
.
quantity
==
nil
%>
<%
trans
.
quantity
==
0
%>
<%
trans
.
quantity
==
0
%>
<%
end
%>
<%
end
%>
...
@@ -94,9 +91,9 @@
...
@@ -94,9 +91,9 @@
<%
end
%>
<%
end
%>
</tbody>
</tbody>
</table>
</table>
<%
end
%>
<%
end
%>
<%
els
e
%>
<%
els
if
user_signed_in?
%>
<h1>
Transactions
</h1>
<h1>
Transactions
</h1>
<br>
<br>
...
@@ -106,14 +103,13 @@
...
@@ -106,14 +103,13 @@
</small>
</small>
<%
else
%>
<%
else
%>
<table
class =
"table"
,
cellspacing=
"0"
,
cellpadding=
"0"
>
<table
class =
"table"
,
cellspacing=
"0"
,
cellpadding=
"0"
>
<thead
style=
"background-color: #
333
"
>
<thead
style=
"background-color: #
76D7C4
"
>
<th>
Name
</th>
<th>
Name
</th>
<th>
Description
</th>
<th>
Description
</th>
<th>
Status
</th>
<th>
Status
</th>
<th>
Supply
</th>
<th>
Supply
</th>
<th>
Order
</th>
<th>
Order
</th>
<th>
Total
</th>
<th>
Total
</th>
<th>
Created At
</th>
<th
colspan=
"6"
></th>
<th
colspan=
"6"
></th>
</thead>
</thead>
<tbody>
<tbody>
...
@@ -135,7 +131,6 @@
...
@@ -135,7 +131,6 @@
<%
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
%>
...
@@ -144,15 +139,14 @@
...
@@ -144,15 +139,14 @@
<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
action
.
quantity
==
0
%>
<%
trans
.
quantity
==
0
%>
<%
end
%>
<%
end
%>
<%
@orders
+=
trans
.
quantity
%>
<%
@orders
+=
trans
.
quantity
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%=
"(
#{
@orders
.
abs
}
)"
%>
<%=
@orders
%>
</td>
</td>
<td>
<td>
<%
@total
=
0
%>
<%
@total
=
0
%>
...
@@ -164,16 +158,21 @@
...
@@ -164,16 +158,21 @@
<%
end
%>
<%
end
%>
<%=
@total
%>
<%=
@total
%>
</td>
</td>
<td>
<%
if
product
.
status
==
"Active"
%>
<td>
<td>
<%=
link_to
"Add Supply"
,
new_product_supply_path
(
product
),
class:
"btn btn-primary"
%>
<%=
link_to
"Add Supply"
,
new_product_supply_path
(
product
),
class:
"btn btn-primary"
%>
</td>
</td>
<td>
<td>
<%=
link_to
"Add Order"
,
new_product_order_path
(
product
),
class:
"btn btn-primary"
%>
<%=
link_to
"Add Order"
,
new_product_order_path
(
product
),
class:
"btn btn-primary"
%>
</td>
</td>
</tr
>
<%
else
%
>
<%
end
%>
<%
end
%>
</td>
</tr>
<%
end
%>
</tbody>
</tbody>
</table>
</table>
<%
end
%>
<%
end
%>
<%
end
%>
<%
end
%>
>>>>>>> 6e6754882451c54a2f4e7f2bf5f24cb6d6b1d826
app/views/products/new.html.erb
View file @
34538002
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
<%=
simple_form_for
@product
do
|
f
|
%>
<%=
simple_form_for
@product
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:status
,
as: :radio_buttons
,
collection:
[[
'Active'
,
'Active'
],
[
'Inactive'
,
'Inactive'
]],
value_method: :first
,
label_method: :second
%>
<%=
f
.
button
:submit
,
"Create Product"
,
class:
"btn btn-primary"
%>
<%=
f
.
button
:submit
,
"Create Product"
,
class:
"btn btn-primary"
%>
<%=
link_to
"Back"
,
products_path
,
class:
"btn btn-default"
%>
<%=
link_to
"Back"
,
products_path
,
class:
"btn btn-default"
%>
<%
end
%>
<%
end
%>
app/views/publics/index.html.erb
View file @
34538002
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col"
>
<div
class=
"col"
>
<h3>
Admin
User Log In
</h3>
<h3>
Admin
</h3>
<%=
simple_form_for
:admin_user
,
url:
session_path
(
:admin_user
)
do
|
f
|
%>
<%=
simple_form_for
:admin_user
,
url:
session_path
(
:admin_user
)
do
|
f
|
%>
<%=
f
.
input
:email
%>
<%=
f
.
input
:email
%>
<%=
f
.
input
:password
%>
<%=
f
.
input
:password
%>
...
@@ -10,16 +10,18 @@
...
@@ -10,16 +10,18 @@
</div>
</div>
<div
class=
"col"
>
<div
class=
"col"
>
<h3>
User
Log In
</h3>
<h3>
User
</h3>
<%=
simple_form_for
:user
,
url:
session_path
(
:user
)
do
|
f
|
%>
<%=
simple_form_for
:user
,
url:
session_path
(
:user
)
do
|
f
|
%>
<%=
f
.
input
:email
%>
<%=
f
.
input
:email
%>
<%=
f
.
input
:password
%>
<%=
f
.
input
:password
%>
<%=
f
.
submit
'Log In'
,
class:
'btn btn-info'
%>
<%=
f
.
button
:submit
,
"Log In"
,
as: :authenticated_user
,
class:
'btn btn-info'
%>
<%=
link_to
"Sign Up"
,
new_user_registration_path
,
:class
=>
'navbar-link'
%>
<%=
link_to
"Sign Up"
,
new_user_registration_path
,
:class
=>
'navbar-link'
%>
<%
end
%>
<%
end
%>
</div>
</div>
</div>
<!-- <body style = "background-image: url(http://www.sunrisecatalogue.com/uploads/posters/duovsvt_ldlcw_YYSRSRC.jpg); background-size: 100%">
</body> -->
</div>
...
...
app/views/supplies/new.html.erb
View file @
34538002
<h1>
New Supply
</h1>
<h1>
New Supply
</h1>
<%=
simple_form_for
@post
do
|
f
|
%>
<%=
simple_form_for
([
@product
,
@supply
],
url:
product_supplies_path
)
do
|
f
|
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:quantity
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-info
"
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-primary
"
%>
<%=
link_to
"Back"
,
transaction_path
,
class:
"btn
btn-default"
%>
<%=
link_to
"Back"
,
authenticated_user_root_path
,
class:
"btn-
btn-default"
%>
<%
end
%>
<%
end
%>
config/routes.rb
View file @
34538002
Rails
.
application
.
routes
.
draw
do
Rails
.
application
.
routes
.
draw
do
get
'orders/new'
get
'supplies/new'
devise_for
:admin_users
devise_for
:admin_users
devise_scope
:admin_user
do
devise_scope
:admin_user
do
authenticated
:admin_user
do
authenticated
:admin_user
do
...
...
test/controllers/orders_controller_test.rb
View file @
34538002
...
@@ -6,9 +6,4 @@ class OrdersControllerTest < ActionDispatch::IntegrationTest
...
@@ -6,9 +6,4 @@ class OrdersControllerTest < ActionDispatch::IntegrationTest
assert_response
:success
assert_response
:success
end
end
test
"should get create"
do
get
orders_create_url
assert_response
:success
end
end
end
test/controllers/supplies_controller_test.rb
View file @
34538002
require
'test_helper'
require
'test_helper'
class
SuppliesControllerTest
<
ActionDispatch
::
IntegrationTest
class
SuppliesControllerTest
<
ActionDispatch
::
IntegrationTest
test
"should get index"
do
get
supplies_index_url
assert_response
:success
end
test
"should get new"
do
test
"should get new"
do
get
supplies_new_url
get
supplies_new_url
assert_response
:success
assert_response
:success
end
end
test
"should get create"
do
get
supplies_create_url
assert_response
:success
end
end
end
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