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
7e168abf
Commit
7e168abf
authored
Jul 19, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
6e675488
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
48 additions
and
64 deletions
+48
-64
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
+10
-9
application.html.erb
app/views/layouts/application.html.erb
+1
-1
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
+16
-18
new.html.erb
app/views/products/new.html.erb
+0
-1
index.html.erb
app/views/publics/index.html.erb
+1
-1
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/controllers/orders_controller.rb
View file @
7e168abf
...
@@ -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 @
7e168abf
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 @
7e168abf
...
@@ -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."
...
@@ -28,3 +28,4 @@ class SuppliesController < ApplicationController
...
@@ -28,3 +28,4 @@ class SuppliesController < ApplicationController
params
.
require
(
:transaction
).
permit!
params
.
require
(
:transaction
).
permit!
end
end
end
end
app/views/layouts/application.html.erb
View file @
7e168abf
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +55,7 @@
function
googleTranslateElementInit
()
{
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'
);
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>
>
</script><script
type=
"text/javascript"
src=
"//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"
></script>
<div
class=
"container"
id=
"container"
>
<div
class=
"container"
id=
"container"
>
<%
if
notice
%>
<%
if
notice
%>
...
...
app/views/orders/new.html.erb
View file @
7e168abf
<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 @
7e168abf
...
@@ -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 @
7e168abf
...
@@ -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,7 +36,7 @@
...
@@ -36,7 +36,7 @@
</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
%>
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
</td>
</td>
<td>
<td>
<%
@orders
=
0
%>
<%
@orders
=
0
%>
<%
product
.
transactions
.
each
do
|
trans
action
|
%>
<%
product
.
transactions
.
each
do
|
trans
|
%>
<%
if
trans
.
mode
==
"ORDER"
%>
<%
if
trans
.
mode
==
"ORDER"
%>
<%
if
trans
.
quantity
==
nil
%>
<%
if
trans
.
quantity
==
nil
%>
...
@@ -63,7 +63,7 @@
...
@@ -63,7 +63,7 @@
</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 +94,9 @@
...
@@ -94,9 +94,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,7 +106,7 @@
...
@@ -106,7 +106,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: #
76D7C4
"
>
<th>
Name
</th>
<th>
Name
</th>
<th>
Description
</th>
<th>
Description
</th>
<th>
Status
</th>
<th>
Status
</th>
...
@@ -135,7 +135,6 @@
...
@@ -135,7 +135,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 +143,14 @@
...
@@ -144,15 +143,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
%>
...
@@ -171,7 +169,7 @@
...
@@ -171,7 +169,7 @@
<%=
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>
</tr>
<%
end
%>
<%
end
%>
</tbody>
</tbody>
</table>
</table>
<%
end
%>
<%
end
%>
...
...
app/views/products/new.html.erb
View file @
7e168abf
...
@@ -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 @
7e168abf
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<%=
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
.
button
:submit
,
"Log In"
%>
<%=
f
.
button
:submit
,
"Log In"
,
as: :authenticated_user
%>
<%=
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>
...
...
app/views/supplies/new.html.erb
View file @
7e168abf
<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 @
7e168abf
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 @
7e168abf
...
@@ -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 @
7e168abf
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