InJutyUpdate
This commit is contained in:
@@ -8,9 +8,10 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index_in_juty
|
def index_in_juty
|
||||||
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
|
@juty_in= InJuty.where("dinning_id=?",params[:table_id])
|
||||||
@table = DiningFacility.find(params[:table_id])
|
@table = DiningFacility.find(params[:table_id])
|
||||||
@in_juty = InJuty.new
|
@in_juty = InJuty.new
|
||||||
|
@juties_in = Kaminari.paginate_array(@juty_in).page(params[:page]).per(10)
|
||||||
|
|
||||||
end
|
end
|
||||||
# GET /in_juties/1
|
# GET /in_juties/1
|
||||||
@@ -31,6 +32,9 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
def edit_in_juty
|
def edit_in_juty
|
||||||
@in_juty = InJuty.find(params[:id])
|
@in_juty = InJuty.find(params[:id])
|
||||||
@table = DiningFacility.find(params[:table_id])
|
@table = DiningFacility.find(params[:table_id])
|
||||||
|
@commissioner = @in_juty.commissioner
|
||||||
|
|
||||||
|
render json: {in_juty: @in_juty, commissioner: @commissioner}
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_in_juty
|
def assign_in_juty
|
||||||
@@ -89,12 +93,19 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def update_for_in_juty
|
def update_for_in_juty
|
||||||
@in_juty.dinning_id = params[:dining_id]
|
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
@in_juty.in_time = in_juty_params[:in_time]
|
||||||
@in_juty.in_time = params[:in_time]
|
@in_juty.out_time = in_juty_params[:out_time]
|
||||||
@in_juty.out_time = params[:out_time]
|
respond_to do |format|
|
||||||
@in_juty.save
|
if @in_juty.save
|
||||||
|
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
|
||||||
|
format.json { render :show, status: :ok, location: @in_juty }
|
||||||
|
else
|
||||||
|
format.html { render :edit }
|
||||||
|
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /in_juties/1
|
# DELETE /in_juties/1
|
||||||
@@ -125,6 +136,6 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def in_juty_params
|
def in_juty_params
|
||||||
params.require(:in_juty).permit(:dinning_id,:commissioner_ids,:in_time,:out_time)
|
params.require(:in_juty).permit(:id,:dinning_id,:commissioner_ids,:in_time,:out_time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
<%= simple_form_for @in_juty,:url => origami_create_for_in_juty_path, :method => :post do |f| %>
|
<%= simple_form_for @in_juty,:url => origami_index_in_juty_path(@table.id), :method => :post do |f| %>
|
||||||
<span class="patch_method"></span>
|
<span class="patch_method"></span>
|
||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
|
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||||
|
|
||||||
<div class="form-inputs">
|
<div class="form-inputs">
|
||||||
|
|
||||||
<%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %>
|
<%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %>
|
||||||
|
|
||||||
<label>Dining Name:</label>
|
<label>Dining Name:</label>
|
||||||
<%= @table.name %>
|
<%= @table.name %>
|
||||||
<br/>
|
<br/>
|
||||||
@@ -12,14 +15,14 @@
|
|||||||
<label>Commissioner Name:</label>
|
<label>Commissioner Name:</label>
|
||||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
|
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
|
||||||
<label>In time</label>
|
<label>In time</label>
|
||||||
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
|
<%= f.text_field :in_time, :value=>'',:class=>"form-control datepicker"%><br/>
|
||||||
<label>Out time</label>
|
<label>Out time</label>
|
||||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
|
<%= f.text_field :out_time, :value=>'',:class=>"form-control datepicker"%>
|
||||||
</div><br>
|
</div><br>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
|
<%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
|
||||||
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'disabled', :id => 'update' %>
|
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update' %>
|
||||||
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
|
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -30,11 +33,18 @@
|
|||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$('.datepicker').datepicker({
|
$('.datepicker').datepicker({
|
||||||
format : 'dd-mm-yyyy',
|
format : 'yyyy-mm-dd',
|
||||||
autoclose: true
|
autoclose: true
|
||||||
});
|
});
|
||||||
$('.datepicker').attr('ReadOnly','true');
|
$('.datepicker').attr('ReadOnly','true');
|
||||||
$('.datepicker').css('cursor','pointer');
|
$('.datepicker').css('cursor','pointer');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#reset').click(function() {
|
||||||
|
|
||||||
|
// window.location.href = '/origami/assign_in_juty/'+ table_id;
|
||||||
|
location.reload();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -2,8 +2,7 @@
|
|||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
|
|
||||||
<div class="form-inputs">
|
<div class="form-inputs">
|
||||||
<%= f.input :dinning_id %>
|
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
|
||||||
<%= f.input :commissioner_ids %>
|
|
||||||
<%= f.input :in_time %>
|
<%= f.input :in_time %>
|
||||||
<%= f.input :out_time %>
|
<%= f.input :out_time %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Select</th>
|
||||||
<th>Dining Facility Name</th>
|
<th>Dining Facility Name</th>
|
||||||
<th>Commissioner Ids</th>
|
<th>Commissioner Ids</th>
|
||||||
<th>In time</th>
|
<th>In time</th>
|
||||||
@@ -21,13 +22,12 @@
|
|||||||
<td><%= in_juty.commissioner.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.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><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||||
<td><%= link_to 'Back', origami_path(in_juty.dining_facility.id) %></td>
|
|
||||||
<td><%= link_to 'Edit', origami_edit_in_juty_path(in_juty.dining_facility.id,in_juty) %></td>
|
|
||||||
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id,in_juty),method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id,in_juty),method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<%= paginate @juties_in %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
@@ -35,40 +35,45 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-1">
|
||||||
|
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).on('click',".injuty_tr",function(){
|
$(document).on('click',".injuty_tr",function(){
|
||||||
debugger;
|
|
||||||
// if(this.checked){
|
// if(this.checked){
|
||||||
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
||||||
//$( "#checkbox_check" ).prop( "checked", true );
|
//$( "#checkbox_check" ).prop( "checked", true );
|
||||||
|
|
||||||
var in_juty_id = $(this).attr('data-ref');
|
var in_juty_id = $(this).attr('data-ref');
|
||||||
var table_id = "<%= @table.id %>";
|
var table_id = "<%= @table.id %>";
|
||||||
var url = "/origami/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
|
var url = "/origami/assign_in_juty/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
data: {},
|
data: {},
|
||||||
dataType: "json",
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
// Selected for Taxes
|
// Selected for Taxes
|
||||||
$('#in_juty_commissioner_ids').val(data.commissioner.name);
|
|
||||||
$('#in_juty_in_time').val(data.in_time);
|
$('#in_juty_id').val(data.in_juty.id);
|
||||||
$('#in_juty_out_time').val(data.out_time);
|
$('#in_juty_commissioner_ids').val(data.commissioner.id);
|
||||||
|
$('#in_juty_in_time').val(data.in_juty.in_time.split('T')[0]);
|
||||||
|
$('#in_juty_out_time').val(data.in_juty.out_time.split('T')[0]);
|
||||||
|
|
||||||
$('#update').removeAttr('disabled');
|
$('#update').removeAttr('disabled').val('');
|
||||||
$('#update').attr('value', 'Update');
|
$('#update').attr('value', 'Update');
|
||||||
$('#create').attr('disabled','disabled');
|
$('#create').attr('disabled','disabled');
|
||||||
|
|
||||||
$("#new_in_juty").attr('class', 'simple_form new_in_juty');
|
$("#new_in_juty").attr('class', 'simple_form edit_in_juty');
|
||||||
var id = customer_id;
|
var id = "edit_in_juty_" + in_juty_id;
|
||||||
$("#new_customer").attr('id', id);
|
$("#new_in_juty").attr('id', id);
|
||||||
|
|
||||||
$(".edit_customer").attr('id', id);
|
$(".edit_in_juty").attr('id', id);
|
||||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
|
||||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
|
||||||
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
|
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -76,4 +81,9 @@ $(document).on('click',".injuty_tr",function(){
|
|||||||
|
|
||||||
// }
|
// }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
$('#back').on('click', function () {
|
||||||
|
window.location.href = '/origami/table/'+ "<%= @table.id %>";
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -94,10 +94,11 @@ Rails.application.routes.draw do
|
|||||||
post 'select_commissioner' => 'product_commissions#set_commissioner_to_sale_item'
|
post 'select_commissioner' => 'product_commissions#set_commissioner_to_sale_item'
|
||||||
# in_juties
|
# in_juties
|
||||||
get '/table/:table_id/assign_in_juty' => 'in_juties#assign_in_juty', as: 'assign_in_juty'
|
get '/table/:table_id/assign_in_juty' => 'in_juties#assign_in_juty', as: 'assign_in_juty'
|
||||||
post 'assign_in_juty' => 'in_juties#create_for_in_juty', as: 'create_for_in_juty'
|
|
||||||
get 'assign_in_juty/:table_id' => 'in_juties#index_in_juty', as: 'index_in_juty'
|
get 'assign_in_juty/:table_id' => 'in_juties#index_in_juty', as: 'index_in_juty'
|
||||||
get 'table/:table_id/in_juty/:id/edit' => 'in_juties#edit_in_juty' ,as: 'edit_in_juty'
|
post 'assign_in_juty/:table_id' => 'in_juties#create_for_in_juty'
|
||||||
put '/edit_in_juty/:id' => 'in_juties#update_for_in_juty', as: 'update_for_in_juty'
|
|
||||||
|
get 'assign_in_juty/table/:table_id/in_juty/:id/edit' => 'in_juties#edit_in_juty' ,as: 'edit_in_juty'
|
||||||
|
patch 'edit_in_juty/:id' => 'in_juties#update_for_in_juty', as: 'update_for_in_juty'
|
||||||
delete 'table/:table_id/destroy_in_juty/:id' => 'in_juties#destroy_in_juty', as: 'destroy_in_juty'
|
delete 'table/:table_id/destroy_in_juty/:id' => 'in_juties#destroy_in_juty', as: 'destroy_in_juty'
|
||||||
|
|
||||||
get 'table/:dining_id/movetable' => "movetable#move_dining"
|
get 'table/:dining_id/movetable' => "movetable#move_dining"
|
||||||
|
|||||||
Reference in New Issue
Block a user