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 @@
</head>
<body>
<style>
background-color: #ccfff2
font-family:'Calibri';
</style>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<%= 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">
......
<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>
<div>
<%= link_to "Add New Supply", new_product_supply_path, class: "btn btn-primary" %>
</div>
<h1>Transactions</h1>
<br>
<% if @supplies.empty? %>
<% if @products.empty? %>
<small>
No supplies available.
No products have been created.
</small>
<% else %>
<table class="table">
<thead>
<th>Name</th>
<th>Description</th>
<th>Date Added</th>
<th>Quantity</th>
<th>Status</th>
<th>Time Created</th>
<th colspan="4"></th>
</thead>
<tbody>
<% @supplies.each do |supply| %>
<% @products.each do |product| %>
<tr>
<td>
<%= link_to supply.name, supply_path(supply) %>
<%= link_to product.name, product_path(product) %>
</td>
<td>
<%= supply.description %>
</td>
<td>
<%= time_ago_in_words(supply.created_at) %> ago
<%= product.description %>
</td>
<td>
<%= supply.quantity %>
</td>
<%= product.status %>
</td>
<td>
<%= link_to "Edit", edit_product_path(product), class: "btn btn-primary" %>
<%= time_ago_in_words(product.created_at) %> ago
</td>
</tr>
<% 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
get 'orders/new'
get 'orders/create'
get 'supplies/index'
get 'supplies/new'
get 'supplies/create'
get 'comments/new'
devise_for :admin_users
devise_scope :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