InJutyIndexform
This commit is contained in:
@@ -9,7 +9,8 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
|
|
||||||
def index_in_juty
|
def index_in_juty
|
||||||
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
|
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
|
||||||
@table = params[:table_id]
|
@table = DiningFacility.find(params[:table_id])
|
||||||
|
@in_juty = InJuty.new
|
||||||
|
|
||||||
end
|
end
|
||||||
# GET /in_juties/1
|
# GET /in_juties/1
|
||||||
@@ -24,9 +25,11 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
|
|
||||||
# GET /in_juties/1/edit
|
# GET /in_juties/1/edit
|
||||||
def edit
|
def edit
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_in_juty
|
def edit_in_juty
|
||||||
|
@in_juty = InJuty.find(params[:id])
|
||||||
@table = DiningFacility.find(params[:table_id])
|
@table = DiningFacility.find(params[:table_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -52,11 +55,23 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
|
|
||||||
def create_for_in_juty
|
def create_for_in_juty
|
||||||
@in_juty = InJuty.new
|
@in_juty = InJuty.new
|
||||||
@in_juty.dinning_id = params[:dining_id]
|
|
||||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
@in_juty.dinning_id = in_juty_params[:dinning_id]
|
||||||
@in_juty.in_time = params[:in_time]
|
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||||
@in_juty.out_time = params[:out_time]
|
@in_juty.in_time = in_juty_params[:in_time]
|
||||||
@in_juty.save
|
@in_juty.out_time = in_juty_params[:out_time]
|
||||||
|
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @in_juty.save
|
||||||
|
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully created.' }
|
||||||
|
format.json { render :show, status: :created, location: @in_juty }
|
||||||
|
else
|
||||||
|
format.html { render :new }
|
||||||
|
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# PATCH/PUT /in_juties/1
|
# PATCH/PUT /in_juties/1
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<div class="col-md-3">
|
<%= simple_form_for @in_juty,:url => origami_create_for_in_juty_path, :method => :post do |f| %>
|
||||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
<span class="patch_method"></span>
|
||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
|
|
||||||
<div class="form-inputs">
|
<div class="form-inputs">
|
||||||
|
<%= 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/>
|
||||||
@@ -15,18 +16,15 @@
|
|||||||
<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=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
|
||||||
</div><br>
|
</div><br>
|
||||||
<div class="form-actions">
|
|
||||||
<div class='row'>
|
<div class="form-group">
|
||||||
<div class="col-md-2">
|
<%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
|
||||||
<%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %>
|
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'disabled', :id => 'update' %>
|
||||||
</div>
|
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
|
||||||
<div class="col-md-10">
|
|
||||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Create In Juty</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
@@ -39,20 +37,4 @@ $(function() {
|
|||||||
$('.datepicker').css('cursor','pointer');
|
$('.datepicker').css('cursor','pointer');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#in_juty').on('click', function () {
|
|
||||||
var ajax_url = "/origami/assign_in_juty";
|
|
||||||
var commissioner_ids = $('#in_juty_commissioner_ids').val();
|
|
||||||
var in_time = $('#in_juty_in_time').val();
|
|
||||||
var out_time = $('#in_juty_out_time').val();
|
|
||||||
var dining_id = '<%= @table.id %>'
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: ajax_url,
|
|
||||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
|
||||||
success: function (result) {
|
|
||||||
window.location.href = '/origami/assign_in_juty/'+ dining_id;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -1,59 +1,14 @@
|
|||||||
<div class="col-md-3">
|
|
||||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
|
|
||||||
<div class="form-inputs">
|
<div class="form-inputs">
|
||||||
<label>Dining Name:</label>
|
<%= f.input :dinning_id %>
|
||||||
<%= @table.name %>
|
<%= f.input :commissioner_ids %>
|
||||||
<br/>
|
<%= f.input :in_time %>
|
||||||
<br/>
|
<%= f.input :out_time %>
|
||||||
|
</div>
|
||||||
<label>Commissioner Name:</label>
|
|
||||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {class: 'form-control'} ,:value => @in_juty.commissioner.name %><br/><br/>
|
|
||||||
<label>In time</label>
|
|
||||||
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker" ,:value => @in_juty.in_time %><br/>
|
|
||||||
<label>Out time</label>
|
|
||||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker" ,:value => @in_juty.out_time %>
|
|
||||||
</div><br>
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<div class='row'>
|
<%= f.button :submit %>
|
||||||
<div class="col-md-2">
|
|
||||||
<%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-10">
|
|
||||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Update In Juty</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
$('.datepicker').datepicker({
|
|
||||||
format : 'dd-mm-yyyy',
|
|
||||||
autoclose: true
|
|
||||||
});
|
|
||||||
$('.datepicker').attr('ReadOnly','true');
|
|
||||||
$('.datepicker').css('cursor','pointer');
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#in_juty').on('click', function () {
|
|
||||||
var id = '<%= @in_juty.id %>'
|
|
||||||
var ajax_url = "/origami/edit_in_juty/" + id;
|
|
||||||
var commissioner_ids = $('#in_juty_commissioner_ids').val();
|
|
||||||
var in_time = $('#in_juty_in_time').val();
|
|
||||||
var out_time = $('#in_juty_out_time').val();
|
|
||||||
var dining_id = '<%= @table.id %>'
|
|
||||||
$.ajax({
|
|
||||||
type: "PUT",
|
|
||||||
url: ajax_url,
|
|
||||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time + "&table_id=" + dining_id,
|
|
||||||
success: function (result) {
|
|
||||||
window.location.href = '/origami/assign_in_juty/'+ dining_id;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
|
||||||
@@ -2,5 +2,63 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h3>Create In Juty</h3>
|
<h3>Create In Juty</h3>
|
||||||
</div>
|
</div>
|
||||||
<%= render 'assign_in_juty', in_juty: @in_juty %>
|
<div class="col-md-3">
|
||||||
</div>
|
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||||
|
<%= f.error_notification %>
|
||||||
|
|
||||||
|
<div class="form-inputs">
|
||||||
|
<label>Dining Name:</label>
|
||||||
|
<%= @table.name %>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<label>Commissioner Name:</label>
|
||||||
|
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><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">
|
||||||
|
<div class='row'>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Create In Juty</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$('.datepicker').datepicker({
|
||||||
|
format : 'dd-mm-yyyy',
|
||||||
|
autoclose: true
|
||||||
|
});
|
||||||
|
$('.datepicker').attr('ReadOnly','true');
|
||||||
|
$('.datepicker').css('cursor','pointer');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#in_juty').on('click', function () {
|
||||||
|
var ajax_url = "/origami/assign_in_juty";
|
||||||
|
var commissioner_ids = $('#in_juty_commissioner_ids').val();
|
||||||
|
var in_time = $('#in_juty_in_time').val();
|
||||||
|
var out_time = $('#in_juty_out_time').val();
|
||||||
|
var dining_id = '<%= @table.id %>'
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: ajax_url,
|
||||||
|
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||||
|
success: function (result) {
|
||||||
|
window.location.href = '/origami/assign_in_juty/'+ dining_id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -1,48 +1,79 @@
|
|||||||
<div class="page-header">
|
<div class="row">
|
||||||
<ul class="breadcrumb">
|
|
||||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
<div class="col-md-8">
|
||||||
<li>In Juties</li>
|
<table class="table table-striped">
|
||||||
<span style="float: right">
|
<thead>
|
||||||
<%= link_to t('.new', :default => t("helpers.links.new")), origami_assign_in_juty_path, :class => 'btn btn-primary btn-sm', :flag => 'new' %>
|
<tr>
|
||||||
</span>
|
<th>Dining Facility Name</th>
|
||||||
</ul>
|
<th>Commissioner Ids</th>
|
||||||
|
<th>In time</th>
|
||||||
|
<th>Out time</th>
|
||||||
|
<th colspan="2"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @juties_in.each do |in_juty| %>
|
||||||
|
<tr class="injuty_tr" data-ref="<%= in_juty.id %>">
|
||||||
|
<td>
|
||||||
|
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
|
||||||
|
<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 '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>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
<%= render 'assign_in_juty', in_juty: @in_juty ,table: @table %>
|
||||||
|
</div>
|
||||||
</div>
|
</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="2"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<% @juties_in.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 '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>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
$(document).on('click',".injuty_tr",function(){
|
||||||
|
debugger;
|
||||||
|
// if(this.checked){
|
||||||
|
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
||||||
|
//$( "#checkbox_check" ).prop( "checked", true );
|
||||||
|
|
||||||
|
var in_juty_id = $(this).attr('data-ref');
|
||||||
|
var table_id = "<%= @table.id %>";
|
||||||
|
var url = "/origami/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
|
||||||
|
|
||||||
$('#destroy').on('click', function () {
|
$.ajax({
|
||||||
var dining_id = '<%= @table %>'
|
type: "GET",
|
||||||
alert(dining_id);
|
url: url,
|
||||||
|
data: {},
|
||||||
})
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
// Selected for Taxes
|
||||||
|
$('#in_juty_commissioner_ids').val(data.commissioner.name);
|
||||||
|
$('#in_juty_in_time').val(data.in_time);
|
||||||
|
$('#in_juty_out_time').val(data.out_time);
|
||||||
|
|
||||||
|
$('#update').removeAttr('disabled');
|
||||||
|
$('#update').attr('value', 'Update');
|
||||||
|
$('#create').attr('disabled','disabled');
|
||||||
|
|
||||||
|
$("#new_in_juty").attr('class', 'simple_form new_in_juty');
|
||||||
|
var id = customer_id;
|
||||||
|
$("#new_customer").attr('id', id);
|
||||||
|
|
||||||
|
$(".edit_customer").attr('id', id);
|
||||||
|
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||||
|
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||||
|
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// }else{
|
||||||
|
|
||||||
|
// }
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user