CRUDIn_Juties

This commit is contained in:
yamin
2017-08-23 18:14:31 +06:30
parent 784da2cf09
commit d88199150e
10 changed files with 133 additions and 44 deletions

View File

@@ -28,7 +28,7 @@ class Origami::InJutiesController < BaseOrigamiController
respond_to do |format|
if @in_juty.save
format.html { redirect_to @in_juty, notice: 'In juty was successfully created.' }
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully created.' }
format.json { render :show, status: :created, location: @in_juty }
else
format.html { render :new }
@@ -42,7 +42,7 @@ class Origami::InJutiesController < BaseOrigamiController
def update
respond_to do |format|
if @in_juty.update(in_juty_params)
format.html { redirect_to @in_juty, notice: 'In juty was successfully updated.' }
format.html { redirect_to origami_in_juty_path(@in_juty), notice: 'In juty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_juty }
else
format.html { render :edit }
@@ -56,7 +56,7 @@ class Origami::InJutiesController < BaseOrigamiController
def destroy
@in_juty.destroy
respond_to do |format|
format.html { redirect_to in_juties_url, notice: 'In juty was successfully destroyed.' }
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully destroyed.' }
format.json { head :no_content }
end
end
@@ -69,6 +69,6 @@ class Origami::InJutiesController < BaseOrigamiController
# Never trust parameters from the scary internet, only allow the white list through.
def in_juty_params
params.fetch(:in_juty, {})
params.require(:in_juty).permit(:dinning_id,:commissioner_ids,:in_time,:out_time)
end
end

View File

@@ -1,5 +1,6 @@
class Commissioner < ApplicationRecord
belongs_to :employee, foreign_key: 'emp_id'
belongs_to :commission, foreign_key: 'commission_type'
has_many :in_juties
scope :active, -> { where(is_active: true) }
end

View File

@@ -1,6 +1,7 @@
class DiningFacility < ApplicationRecord
belongs_to :zone
has_many :dining_charges
has_many :in_juties
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"

View File

@@ -1,2 +1,4 @@
class InJuty < ApplicationRecord
belongs_to :dining_facility, foreign_key: 'dinning_id'
belongs_to :commissioner, foreign_key: 'commissioner_ids'
end

View File

@@ -8,6 +8,7 @@
<%= f.input :amount %>
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
<label><%= f.check_box :is_active %> Active </label>
</div><br>
<div class="form-actions">
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>

View File

@@ -1,10 +1,33 @@
<%= simple_form_for(@in_juty) do |f| %>
<div class="col-md-3">
<%= simple_form_for([:origami,@in_juty]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
</div>
<%= f.label :dinning_id %>
<%= f.collection_select :dinning_id, DiningFacility.all, :id, :name, {prompt: 'Select Dining Facilities'}, {class: 'form-control'} %><br/>
<%= f.label :commissioner_ids %>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/>
<label>In time</label>
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
<label>Out time</label>
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
</div><br>
<div class="form-actions">
<%= f.button :submit %>
<%= link_to 'Back', origami_in_juties_path, class: 'btn btn-success' %>
<%= f.button :submit, class: 'btn btn-info' %>
</div>
<% end %>
</div>
<script type="text/javascript">
$(function() {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
});
</script>

View File

@@ -1,6 +1,10 @@
<h1>Editing In Juty</h1>
<%= render 'form', in_juty: @in_juty %>
<%= link_to 'Show', @in_juty %> |
<%= link_to 'Back', in_juties_path %>
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
<li>Edit</li>
</ul>
</div>
<%= render 'form', in_juty: @in_juty %>
</div>

View File

@@ -1,25 +1,38 @@
<p id="notice"><%= notice %></p>
<h1>In Juties</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @in_juties.each do |in_juty| %>
<tr>
<td><%= link_to 'Show', in_juty %></td>
<td><%= link_to 'Edit', edit_in_juty_path(in_juty) %></td>
<td><%= link_to 'Destroy', in_juty, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li>In Juties</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_in_juty_path, :class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
<br>
<div class="card">
<table class="table table-striped">
<thead>
<tr>
<th>Dining Facility Name</th>
<th>Commissioner Ids</th>
<th>In time</th>
<th>Out time</th>
<th colspan="3"></th>
</tr>
</thead>
<%= link_to 'New In Juty', new_in_juty_path %>
<tbody>
<% @in_juties.each do |in_juty| %>
<tr>
<td><%= in_juty.dining_facility.name rescue '-' %></td>
<td><%= in_juty.commissioner.name rescue '-' %></td>
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= link_to 'Show', origami_in_juty_path(in_juty) %></td>
<td><%= link_to 'Edit', edit_origami_in_juty_path(in_juty) %></td>
<td><%= link_to 'Destroy', origami_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -1,5 +1,10 @@
<h1>New In Juty</h1>
<%= render 'form', in_juty: @in_juty %>
<%= link_to 'Back', in_juties_path %>
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
<li>New</li>
</ul>
</div>
<%= render 'form', in_juty: @in_juty %>
</div>

View File

@@ -1,4 +1,43 @@
<p id="notice"><%= notice %></p>
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
<%= link_to 'Edit', edit_in_juty_path(@in_juty) %> |
<%= link_to 'Back', in_juties_path %>
<span style="float: right">
</span>
</ul>
</div>
<div class="card">
<div class="card-block">
<h4 class="card-title">In Juty</h4>
<table class="table">
<tbody>
<tr>
<td style="width:20%">Dining Facility Name</td>
<td><%= @in_juty.dining_facility.name%></td>
</tr>
<tr>
<td style="width:20%">Commissioner Name</td>
<td>
<%= @in_juty.commissioner.name rescue '-' %>
</td>
</tr>
<tr>
<td style="width:20%">In Time</td>
<td><%= @in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Out Time</td>
<td><%= @in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
</tr>
</tbody>
</table>
<%= link_to 'Back', origami_in_juties_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_origami_in_juty_path(@in_juty), class: 'btn btn-info' %>
<%= link_to 'Destroy', origami_in_juty_path(@in_juty), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
</div>
</div>
</div>