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
9c21722b
Commit
9c21722b
authored
Jul 18, 2018
by
Chanelle Lunod
Browse files
Options
Browse Files
Download
Plain Diff
initial commit
parents
30167da0
1b0bc1c6
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
226 additions
and
219 deletions
+226
-219
transactions.coffee
app/assets/javascripts/transactions.coffee
+0
-3
application.css.scss
app/assets/stylesheets/application.css.scss
+4
-0
transactions.scss
app/assets/stylesheets/transactions.scss
+0
-0
orders_controller.rb
app/controllers/orders_controller.rb
+18
-13
supplies_controller.rb
app/controllers/supplies_controller.rb
+13
-11
transactions_controller.rb
app/controllers/transactions_controller.rb
+0
-41
transactions_helper.rb
app/helpers/transactions_helper.rb
+0
-2
transaction.rb
app/models/transaction.rb
+2
-0
application.html.erb
app/views/layouts/application.html.erb
+20
-2
create.html.erb
app/views/orders/create.html.erb
+0
-1
new.html.erb
app/views/orders/new.html.erb
+4
-6
index.html.erb
app/views/products/index.html.erb
+149
-40
index.html.erb
app/views/publics/index.html.erb
+2
-2
create.html.erb
app/views/supplies/create.html.erb
+0
-1
index.html.erb
app/views/supplies/index.html.erb
+0
-45
new.html.erb
app/views/supplies/new.html.erb
+4
-7
index.html.erb
app/views/transactions/index.html.erb
+0
-35
routes.rb
config/routes.rb
+1
-7
seeds.rb
db/seeds.rb
+2
-3
new.html.erb
new.html.erb
+7
-0
No files found.
app/assets/javascripts/transactions.coffee
deleted
100644 → 0
View file @
30167da0
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
app/assets/stylesheets/application.css.scss
View file @
9c21722b
...
@@ -4,3 +4,7 @@
...
@@ -4,3 +4,7 @@
*/
*/
@import
"bootstrap"
;
@import
"bootstrap"
;
#container
{
padding-top
:
5rem
;
}
#container
{
padding-top
:
5rem
;
}
body
{
background-color
:
#d9e6f2
;
}
app/assets/stylesheets/transactions.scss
deleted
100644 → 0
View file @
30167da0
app/controllers/orders_controller.rb
View file @
9c21722b
class
OrdersController
<
ApplicationController
class
OrdersController
<
ApplicationController
def
index
@products
=
Product
.
all
end
def
new
def
new
@orders
=
Order
.
new
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@order
=
@order
.
transactions
.
new
end
end
def
create
def
create
@orders
=
Order
.
new
(
product_params
)
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@order
=
@order
.
transactions
.
new
(
supply_params
)
@order
.
mode
=
"Order"
@order
.
user_id
=
current_user
.
id
@order
.
quantity
=
@order
.
quantity
*
-
1
if
@
orders
.
save
if
@
product
.
save
redirect_to
products
_path
,
notice:
"You have successfully placed a new order"
redirect_to
authenticated_user_root
_path
,
notice:
"You have successfully placed a new order"
else
else
render
'new'
render
'new'
end
end
end
end
def
show
private
if
params
[
:status
]
==
'Active'
def
order_params
@products
=
Product
.
Active
params
.
require
(
:transaction
).
permit!
else
@products
=
Product
.
Inactive
end
end
end
end
end
app/controllers/supplies_controller.rb
View file @
9c21722b
...
@@ -5,25 +5,27 @@ class SuppliesController < ApplicationController
...
@@ -5,25 +5,27 @@ class SuppliesController < ApplicationController
end
end
def
new
def
new
@supplies
=
Supply
.
new
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@supply
=
@product
.
transactions
.
new
end
end
def
create
def
create
@supplies
=
Supply
.
new
(
product_params
)
@product
=
Product
.
find_by
(
id:
params
[
:product_id
])
@supply
=
@product
.
transactions
.
new
(
supply_params
)
@supply
.
mode
=
"Supply"
@supply
.
user_id
=
current_user
.
id
@supply
.
quantity
=
@supply
.
quantity
if
@
supplies
.
save
if
@
product
.
save
redirect_to
products
_path
,
notice:
"You have successfully added a new supply."
redirect_to
authenticated_user_root
_path
,
notice:
"You have successfully added a new supply."
else
else
render
'new'
render
'new'
end
end
end
end
def
show
private
if
params
[
:status
]
==
'Active'
def
supply_params
@products
=
Product
.
Active
params
.
require
(
:transaction
).
permit!
else
@products
=
Product
.
Inactive
end
end
end
end
end
app/controllers/transactions_controller.rb
deleted
100644 → 0
View file @
30167da0
class
TransactionsController
<
ApplicationController
before_action
:authenticate_user!
def
index
@products
=
Product
.
all
end
def
display
@product
=
Product
.
find_by
(
product_id:
params
[
:product_id
])
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/helpers/transactions_helper.rb
deleted
100644 → 0
View file @
30167da0
module
TransactionsHelper
end
app/models/transaction.rb
View file @
9c21722b
class
Transaction
<
ApplicationRecord
class
Transaction
<
ApplicationRecord
belongs_to
:product
belongs_to
:product
belongs_to
:user
belongs_to
:user
has_many
:supplies
has_many
:orders
end
end
app/views/layouts/application.html.erb
View file @
9c21722b
...
@@ -12,24 +12,42 @@
...
@@ -12,24 +12,42 @@
</head>
</head>
<body>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-light bg-light"
>
<style>
<%=
link_to
"Main"
,
root_path
,
class:
"navbar-brand"
%>
background-color
:
#ccfff2
font-family
:
'Calibri'
;
</style>
<nav
class=
"navbar navbar-expand-xl navbar-dark bg-dark"
>
<%=
link_to
"HOME"
,
root_path
,
class:
"navbar-brand"
%>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarSupportedContent"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarSupportedContent"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
<span
class=
"navbar-toggler-icon"
></span>
</button>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarSupportedContent"
>
<div
class=
"collapse navbar-collapse"
id=
"navbarSupportedContent"
>
<ul
class=
"navbar-nav mr-auto"
>
<ul
class=
"navbar-nav mr-auto"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
Sign In
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
Inventory
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
Transactions
</a>
</li>
</ul>
</ul>
<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>
.
<br>
<%=
link_to
'Edit Profile'
,
edit_user_registration_path
,
:class
=>
'navbar-link'
%>
|
<%=
link_to
'Edit Profile'
,
edit_user_registration_path
,
:class
=>
'navbar-link'
%>
|
<%=
link_to
"Logout"
,
destroy_user_session_path
,
method: :delete
,
:class
=>
'navbar-link'
%>
<%=
link_to
"Logout"
,
destroy_user_session_path
,
method: :delete
,
:class
=>
'navbar-link'
%>
<%
elsif
admin_user_signed_in?
%>
<%
elsif
admin_user_signed_in?
%>
<%=
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
class=
"form-inline my-2 my-lg-0"
>
<input
class=
"form-control mr-sm-2"
type=
"search"
placeholder=
"Search"
>
<button
class=
"btn btn-outline-info my-2 my-sm-0"
type=
"submit"
>
Search
</button>
</form>
</div>
</div>
</nav>
</nav>
...
...
app/views/orders/create.html.erb
deleted
100644 → 0
View file @
30167da0
<h1>
Create Orders
</h1>
app/views/orders/new.html.erb
View file @
9c21722b
<h1>
New Order
</h1>
<h1>
New Order
</h1>
<%=
simple_form_for
@order
do
|
f
|
%>
<%=
simple_form_for
@post
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
button
:submit
,
"Add
Order"
,
class:
"btn btn-primary
"
%>
<%=
f
.
button
:submit
,
"Add
Supply"
,
class:
"btn btn-info
"
%>
<%=
link_to
"Back"
,
products
_path
,
class:
"btn btn-default"
%>
<%=
link_to
"Back"
,
transaction
_path
,
class:
"btn btn-default"
%>
<%
end
%>
<%
end
%>
\ No newline at end of file
app/views/products/index.html.erb
View file @
9c21722b
<
h1>
Inventory System
</h1
>
<
%=
if
admin_user_signed_in?
%
>
<div>
<h2>
Inventory System
</h1>
<div>
<%=
link_to
"Create new product"
,
new_product_path
,
class:
"btn btn-primary"
%>
<%=
link_to
"Create new product"
,
new_product_path
,
class:
"btn btn-primary"
%>
</div>
</div>
<br>
<br>
<%
if
@products
.
empty?
%>
<%
if
@products
.
empty?
%>
<small>
<small>
No products have been created.
No products have been created.
</small>
</small>
<%
else
%>
<%
else
%>
<table
class=
"table
"
>
<table
class=
"table"
,
cellspacing=
"0"
,
cellpadding=
"0
"
>
<thead>
<thead>
<th>
Name
</th>
<th>
Name
</th>
<th>
Description
</th>
<th>
Description
</th>
<th>
Status
</th>
<th>
Status
</th>
<th>
Time Created
</th>
<th>
Supply
</th>
<th
colspan=
"4"
></th>
<th>
Order
</th>
<th>
Total
</th>
<th>
Created
</th>
<th
colspan=
"7"
></th>
</thead>
</thead>
<tbody>
<tbody>
<%
@products
.
each
do
|
product
|
%>
<%
@products
.
each
do
|
product
|
%>
<%
if
product
.
status
==
"Active"
%>
<tr>
<tr>
<td>
<td>
<%=
link_to
product
.
name
,
product_path
(
product
)
%>
<%=
link_to
product
.
name
,
product_path
(
product
)
%>
...
@@ -34,11 +37,117 @@
...
@@ -34,11 +37,117 @@
<td>
<td>
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
<%=
time_ago_in_words
(
product
.
created_at
)
%>
ago
</td>
</td>
<td>
<%
supplies
=
0
%>
<%
product
.
transactions
.
each
do
|
transaction
|
<
% if
transaction
.
mode
==
"Supply"
%>
<%
supplies
=
supplies
+
transaction
.
quantity
%>
<%
end
%>
<%
end
%>
<%=
supplies
%>
</td>
<td>
<%
orders
=
0
%>
<%
product
.
transactions
.
each
do
|
transaction
|
<
% if
transaction
.
mode
==
"Order"
%>
<%
orders
=
orders
+
transaction
.
quantity
%>
<%
end
%>
<%
end
%>
<%=
orders
%>
</td>
<td>
<%=
link_to
"Add Supply"
,
new_product_supply_path
(
product
),
class:
"btn btn-info"
%>
</td>
<td>
<%=
link_to
"Add Order"
,
new_product_order_path
(
product
),
class:
"btn btn-info"
%>
</td>
<td>
<td>
<%=
link_to
"Edit"
,
edit_product_path
(
product
),
class:
"btn btn-primary"
%>
<%=
link_to
"Edit"
,
edit_product_path
(
product
),
class:
"btn btn-primary"
%>
</td>
</td>
</tr>
</tr>
</tbody>
</table>
<%
end
%>
<%
end
%>
<%
else
%>
<%
if
@products
.
empty?
%>
<small>
No products available.
</small>
<%
else
%>
<table
class=
"table"
,
cellspacing=
"0"
,
cellpadding=
"0"
>
<thead>
<th>
Name
</th>
<th>
Description
</th>
<th>
Status
</th>
<th>
Supply
</th>
<th>
Order
</th>
<th>
Total
</th>
<th>
Created
</th>
<th
colspan=
"7"
></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>
<%
supplies
=
0
%>
<%
product
.
transactions
.
each
do
|
transaction
|
<
% if
transaction
.
mode
==
"Supply"
%>
<%
if
transaction
.
quantity
==
nil
%>
<%
transaction
.
quantity
==
0
%>
<%
end
%>
<%
@supplies
=
@supplies
+
transaction
.
quantity
%>
<%
end
%>
<%
end
%>
<%=
supplies
%>
</td>
<td>
<%
orders
=
0
%>
<%
product
.
transactions
.
each
do
|
transaction
|
<
% if
transaction
.
mode
==
"Order"
%>
<%
if
transaction
.
quantity
==
nil
%>
<%
transaction
.
quantity
==
0
%>
<%
end
%>
<%
@orders
=
@orders
+
transaction
.
quantity
%>
<%
end
%>
<%
end
%>
<%
end
%>
<%=
"(
#{
@orders
.
abs
}
"
%>
</td>
<td>
<%
@total
=
0
%>
<%
product
.
transactions
.
each
do
|
transaction
|
%>
<%
if
transactions
.
quantity
==
nil
%>
<%
transaction
.
quantity
==
0
%>
<%
end
%>
<%
@total
=
@total
+
transaction
.
quantity
%>
<%
end
%>
<%=
@total
%>
</td>
<td>
<%=
product
.
comments
.
count
%>
</td>
<td>
<%=
link_to
"Add Supply"
,
new_product_supply_path
(
product
),
class:
"btn btn-info"
%>
</td>
<td>
<%=
link_to
"Add Order"
,
new_product_order_path
(
product
),
class:
"btn btn-info"
%>
</td>
<td>
<%=
link_to
"Add Comment"
,
edit_product_comment_path
(
product
),
class:
"btn btn-info"
%>
</td>
</tr>
</tbody>
</tbody>
</table>
</table>
<%
end
%>
<%
end
%>
<%
end
%>
app/views/publics/index.html.erb
View file @
9c21722b
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<%=
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
%>
<%=
f
.
button
:submit
,
"Log In"
%>
<%=
f
.
submit
'Log In'
,
class:
'btn btn-info'
%>
<%
end
%>
<%
end
%>
</div>
</div>
...
@@ -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
.
submit
'Log In'
,
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>
...
...
app/views/supplies/create.html.erb
deleted
100644 → 0
View file @
30167da0
<h1>
Create Supply
</h1>
app/views/supplies/index.html.erb
deleted
100644 → 0
View file @
30167da0
<h1>
Supplies
</h1>
<div>
<%=
link_to
"Add New Supply"
,
new_product_supply_path
,
class:
"btn btn-primary"
%>
</div>
<br>
<%
if
@supplies
.
empty?
%>
<small>
No supplies available.
</small>
<%
else
%>
<table
class=
"table"
>
<thead>
<th>
Name
</th>
<th>
Description
</th>
<th>
Date Added
</th>
<th>
Quantity
</th>
<th
colspan=
"4"
></th>
</thead>
<tbody>
<%
@supplies
.
each
do
|
supply
|
%>
<tr>
<td>
<%=
link_to
supply
.
name
,
supply_path
(
supply
)
%>
</td>
<td>
<%=
supply
.
description
%>
</td>
<td>
<%=
time_ago_in_words
(
supply
.
created_at
)
%>
ago
</td>
<td>
<%=
supply
.
quantity
%>
</td>
<td>
<%=
link_to
"Edit"
,
edit_product_path
(
product
),
class:
"btn btn-primary"
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<%
end
%>
app/views/supplies/new.html.erb
View file @
9c21722b
<h1>
New Supply
</h1>
<h1>
New Supply
</h1>
<%=
simple_form_for
@supply
do
|
f
|
%>
<%=
simple_form_for
@post
do
|
f
|
%>
<%=
f
.
input
:name
%>
<%=
f
.
input
:description
,
as: :text
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-primary
"
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-info
"
%>
<%=
link_to
"Back"
,
supplies
_path
,
class:
"btn btn-default"
%>
<%=
link_to
"Back"
,
transaction
_path
,
class:
"btn btn-default"
%>
<%
end
%>
<%
end
%>
app/views/transactions/index.html.erb
deleted
100644 → 0
View file @
30167da0
<h1>
Transactions
</h1>
<%
if
@products
.
empty?
%>
<small>
No products have been created.
</small>
<%
else
%>
<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>
</tr>
<%
end
%>
</tbody>
</table>
<%
end
%>
config/routes.rb
View file @
9c21722b
Rails
.
application
.
routes
.
draw
do
Rails
.
application
.
routes
.
draw
do
get
'orders/new'
get
'orders/create'
get
'supplies/index'
get
'supplies/new'
get
'supplies/create'
get
'comments/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
...
@@ -22,7 +16,7 @@ Rails.application.routes.draw do
...
@@ -22,7 +16,7 @@ Rails.application.routes.draw do
resources
:supplies
,
only:
[
:new
,
:create
]
resources
:supplies
,
only:
[
:new
,
:create
]
resources
:comments
,
only:
[
:new
,
:create
]
resources
:comments
,
only:
[
:new
,
:create
]
end
end
root
to:
'
supplie
s#index'
,
as: :authenticated_user_root
root
to:
'
product
s#index'
,
as: :authenticated_user_root
end
end
end
end
root
to:
'publics#index'
root
to:
'publics#index'
...
...
db/seeds.rb
View file @
9c21722b
if
AdminUser
.
count
==
0
if
AdminUser
.
count
==
0
AdminUser
.
add
AdminUser
.
create!
([
(
{
{
email:
'andrea.dolendo@obf.ateneo.edu'
,
email:
'andrea.dolendo@obf.ateneo.edu'
,
password:
'Andrea25'
password:
'Andrea25'
...
@@ -9,5 +8,5 @@ if AdminUser.count == 0
...
@@ -9,5 +8,5 @@ if AdminUser.count == 0
email:
'chanelle.lunod@obf.ateneo.edu'
,
email:
'chanelle.lunod@obf.ateneo.edu'
,
password:
'December5'
password:
'December5'
}
}
)
]
)
end
end
\ No newline at end of file
new.html.erb
0 → 100644
View file @
9c21722b
<h1>
New Order
</h1>
<%=
simple_form_for
@post
do
|
f
|
%>
<%=
f
.
input
:quantity
,
as: :integer
%>
<%=
f
.
button
:submit
,
"Add Supply"
,
class:
"btn btn-info"
%>
<%=
link_to
"Back"
,
transaction_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