CRUDcommission
This commit is contained in:
@@ -28,7 +28,7 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
|
||||
respond_to do |format|
|
||||
if @commission.save
|
||||
format.html { redirect_to @commission, notice: 'Commission was successfully created.' }
|
||||
format.html { redirect_to origami_commissions_path , notice: 'Commission was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @commission }
|
||||
else
|
||||
format.html { render :new }
|
||||
@@ -42,7 +42,7 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @commission.update(commission_params)
|
||||
format.html { redirect_to @commission, notice: 'Commission was successfully updated.' }
|
||||
format.html { redirect_to origami_commission_path(@commission), notice: 'Commission was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @commission }
|
||||
else
|
||||
format.html { render :edit }
|
||||
@@ -69,6 +69,6 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commission_params
|
||||
params.fetch(:commission, {})
|
||||
params.require(:commission).permit(:product_id,:amount,:commission_type, :is_active)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<li><%= link_to "Print Setting", print_settings_path, :tabindex =>"-1" %></li>
|
||||
<hr class="hr_advance" />
|
||||
<li><%= link_to "Employees", settings_employees_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Commissions", origami_commissions_path , :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Commissioners", origami_commissioners_path , :tabindex =>"-1" %></li>
|
||||
<hr class="hr_advance" />
|
||||
<li><%= link_to "Accounts", settings_accounts_path, :tabindex =>"-1" %></li>
|
||||
|
||||
@@ -2,9 +2,14 @@
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.collection_select :product_id, Product.all.order('name asc'), :id, :name, {prompt: "Select a Product"}, {class: "form-control"} %>
|
||||
<%= f.input :amount %>
|
||||
<%= f.input :commission_type, :collection => [:percentage,:net_amount] %>
|
||||
<label><%= f.check_box :is_active %> Active </label>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<h1>Editing Commission</h1>
|
||||
|
||||
<%= render 'form', commission: @commission %>
|
||||
|
||||
<%= link_to 'Show', @commission %> |
|
||||
<%= link_to 'Back', commissions_path %>
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', commission: @commission %>
|
||||
</div>
|
||||
@@ -1,25 +1,44 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= %>">Home</a></li>
|
||||
<li>Commissions</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commission_path ,:class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h1>Commissions</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product Name</th>
|
||||
<th>Amount</th>
|
||||
<th>Commission type</th>
|
||||
<th>Active</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tbody>
|
||||
<% @commissions.each do |commission| %>
|
||||
<tr>
|
||||
<td><%= link_to 'Show', commission %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Destroy', commission, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
<td>
|
||||
<% if Product.exists? %>
|
||||
<% product = Product.find(commission.product_id) %>
|
||||
<%= product.name %>
|
||||
<% end %>
|
||||
|
||||
</td>
|
||||
<td><%= commission.amount %></td>
|
||||
<td><%= commission.commission_type %></td>
|
||||
<td><%= commission.is_active %></td>
|
||||
<td><%= link_to 'Show', origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Commission', new_origami_commission_path %>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<h1>New Commission</h1>
|
||||
|
||||
<%= render 'form', commission: @commission %>
|
||||
|
||||
<%= link_to 'Back', origami_commissions_path %>
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', commission: @commission %>
|
||||
</div>
|
||||
@@ -2,3 +2,43 @@
|
||||
|
||||
<%= link_to 'Edit', edit_commission_path(@commission) %> |
|
||||
<%= link_to 'Back', commissions_path %>
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
|
||||
|
||||
<span style="float: right">
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Commission</h4>
|
||||
<table class="table">
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr><td style="width:20%">Product Name</td>
|
||||
<td>
|
||||
<% if Product.exists? %>
|
||||
<% product = Product.find(@commission.product_id) %>
|
||||
<%= product.name %>
|
||||
<% end %>
|
||||
|
||||
</td></tr>
|
||||
<tr><td style="width:20%">Amount</td><td><%= @commission.amount %></td></tr>
|
||||
<tr><td style="width:20%">Commission Type</td><td><%= @commission.commission_type %></td></tr>
|
||||
<tr><td style="width:20%">Active</td><td><%= @commission.is_active %></td></tr>
|
||||
|
||||
|
||||
<tr><td style="width:20%"><%= link_to 'Edit', edit_origami_commission_path(@commission) %></td><td><%= link_to 'Destroy', origami_commission_path(@commission), method: :delete, data: { confirm: 'Are you sure?' } %></td></tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user