Commit 1b0bc1c6 authored by Chanelle Lunod's avatar Chanelle Lunod

Initial commit

parent cafc98c4
class OrdersController < ApplicationController
def new
@orders = Order.new
end
def create
@orders = Order.new(product_params)
if @orders.save
redirect_to products_path, notice: "You have successfully placed a new order"
else
render 'new'
end
end
def show
if params [:status] == 'Active'
@products = Product.Active
else
@products = Product.Inactive
end
end
end
\ No newline at end of file
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
</head> </head>
<body> <body>
<style>
background-color: #ccfff2
font-family:'Calibri';
</style>
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<%= link_to "Main", root_path, class: "navbar-brand" %> <%= link_to "Main", 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">
......
<h1>New Order</h1>
<%= simple_form_for @order do |f| %>
<%= f.input :name %>
<%= f.input :description, as: :text %>
<%= f.input :quantity, as: :integer %>
<%= f.button :submit, "Add Order", class: "btn btn-primary" %>
<% end %>
\ No newline at end of file
<h1>Supplies</h1> <h1>Transactions</h1>
<div>
<%= link_to "Add New Supply", new_product_supply_path, class: "btn btn-primary" %>
</div>
<br> <br>
<% if @supplies.empty? %> <% if @products.empty? %>
<small> <small>
No supplies available. No products have been created.
</small> </small>
<% else %> <% else %>
<table class="table"> <table class="table">
<thead> <thead>
<th>Name</th> <th>Name</th>
<th>Description</th> <th>Description</th>
<th>Date Added</th> <th>Status</th>
<th>Quantity</th> <th>Time Created</th>
<th colspan="4"></th> <th colspan="4"></th>
</thead> </thead>
<tbody> <tbody>
<% @supplies.each do |supply| %> <% @products.each do |product| %>
<tr> <tr>
<td> <td>
<%= link_to supply.name, supply_path(supply) %> <%= link_to product.name, product_path(product) %>
</td>
<td>
<%= supply.description %>
</td> </td>
<td> <td>
<%= time_ago_in_words(supply.created_at) %> ago <%= product.description %>
</td> </td>
<td> <td>
<%= supply.quantity %> <%= product.status %>
</td> </td>
<td> <td>
<%= link_to "Edit", edit_product_path(product), class: "btn btn-primary" %> <%= time_ago_in_words(product.created_at) %> ago
</td> </td>
</tr> </tr>
<% end %> <% end %>
......
<h1>New Supply</h1>
<%= simple_form_for @supply do |f| %>
<%= f.input :name %>
<%= f.input :description, as: :text %>
<%= f.input :quantity, as: :integer %>
<%= f.button :submit, "Add Supply", class: "btn btn-primary" %>
<%= link_to "Back", supplies_path, class: "btn btn-default" %>
<% end %>
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment