InJutiesUpdate
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class Origami::InJutiesController < BaseOrigamiController
|
class Origami::InJutiesController < BaseOrigamiController
|
||||||
before_action :set_in_juty, only: [:show, :edit, :update,:edit_in_juty, :update_for_in_juty , :destroy ,:destroy_in_juty]
|
before_action :set_in_juty, only: [:show, :edit, :update, :edit_in_juty, :update_for_in_juty , :destroy ,:destroy_in_juty]
|
||||||
|
|
||||||
# GET /in_juties
|
# GET /in_juties
|
||||||
# GET /in_juties.json
|
# GET /in_juties.json
|
||||||
@@ -9,6 +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]
|
||||||
|
|
||||||
end
|
end
|
||||||
# GET /in_juties/1
|
# GET /in_juties/1
|
||||||
# GET /in_juties/1.json
|
# GET /in_juties/1.json
|
||||||
@@ -49,7 +51,7 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_for_in_juty
|
def create_for_in_juty
|
||||||
|
@in_juty = InJuty.new
|
||||||
@in_juty.dinning_id = params[:dining_id]
|
@in_juty.dinning_id = params[:dining_id]
|
||||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
@in_juty.commissioner_ids = params[:commissioner_ids]
|
||||||
@in_juty.in_time = params[:in_time]
|
@in_juty.in_time = params[:in_time]
|
||||||
@@ -77,7 +79,7 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
@in_juty.commissioner_ids = params[:commissioner_ids]
|
||||||
@in_juty.in_time = params[:in_time]
|
@in_juty.in_time = params[:in_time]
|
||||||
@in_juty.out_time = params[:out_time]
|
@in_juty.out_time = params[:out_time]
|
||||||
@in_juty.update
|
@in_juty.save
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /in_juties/1
|
# DELETE /in_juties/1
|
||||||
@@ -91,9 +93,11 @@ class Origami::InJutiesController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy_in_juty
|
def destroy_in_juty
|
||||||
|
@table_id = params[:table_id]
|
||||||
@in_juty.destroy
|
@in_juty.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully destroyed.' }
|
format.html { redirect_to origami_index_in_juty_path(@table_id), notice: 'In juty was successfully destroyed.' }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
|
|
||||||
<div class="form-inputs">
|
<div class="form-inputs">
|
||||||
<%= f.label :dinning_id %>
|
<label>Dining Name:</label>
|
||||||
<br/>
|
|
||||||
<%= @table.name %>
|
<%= @table.name %>
|
||||||
<br/>
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<%= f.label :commissioner_ids %>
|
<label>Commissioner Name:</label>
|
||||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><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=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
|
||||||
<label>Out time</label>
|
<label>Out time</label>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<%= link_to 'Back', origami_path(@table.id), class: 'btn btn-success' %>
|
<%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Create In Juty</button>
|
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Create In Juty</button>
|
||||||
@@ -50,7 +50,7 @@ $(function() {
|
|||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
window.location.href = '/origami/table/' + dining_id;
|
window.location.href = '/origami/assign_in_juty/'+ dining_id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
|
|
||||||
<div class="form-inputs">
|
<div class="form-inputs">
|
||||||
<%= f.label :dinning_id %>
|
<label>Dining Name:</label>
|
||||||
<br/>
|
|
||||||
<%= @table.name %>
|
<%= @table.name %>
|
||||||
<br/>
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<%= f.label :commissioner_ids %>
|
<label>Commissioner Name:</label>
|
||||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} ,:value => @in_juty.commissioner.name %><br/>
|
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {class: 'form-control'} ,:value => @in_juty.commissioner.name %><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" ,:value => @in_juty.in_time %><br/>
|
<%= 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>
|
<label>Out time</label>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<%= link_to 'Back', origami_index_in_juty_path, class: 'btn btn-success' %>
|
<%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Update In Juty</button>
|
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Update In Juty</button>
|
||||||
@@ -49,9 +49,9 @@ $(function() {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time + "&table_id=" + dining_id,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
window.location.href = '/origami/assign_in_juty';
|
window.location.href = '/origami/assign_in_juty/'+ dining_id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
<div class="span12">
|
<div class="span12">
|
||||||
|
<div class="page-header">
|
||||||
|
<h3>Create In Juty</h3>
|
||||||
|
</div>
|
||||||
<%= render 'assign_in_juty', in_juty: @in_juty %>
|
<%= render 'assign_in_juty', in_juty: @in_juty %>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<ul class="breadcrumb">
|
<h3>Update In Juty</h3>
|
||||||
<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>
|
</div>
|
||||||
<%= render 'form', in_juty: @in_juty %>
|
<%= render 'edit_in_juty', in_juty: @in_juty %>
|
||||||
</div>
|
</div>
|
||||||
@@ -28,10 +28,21 @@
|
|||||||
<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 'Edit', origami_edit_in_juty_path(in_juty) %></td>
|
<td><%= link_to 'Back', origami_path(in_juty.dining_facility.id) %></td>
|
||||||
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %></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>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
$('#destroy').on('click', function () {
|
||||||
|
var dining_id = '<%= @table %>'
|
||||||
|
alert(dining_id);
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -94,9 +94,9 @@ Rails.application.routes.draw do
|
|||||||
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'
|
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 '/in_juty/:in_juty_id/edit' => 'in_juties#edit_in_juty' ,as: 'edit_in_juty'
|
get 'table/:table_id/in_juty/:id/edit' => 'in_juties#edit_in_juty' ,as: 'edit_in_juty'
|
||||||
put '/edit_in_juty/:in_juty_id' => 'in_juties#update_for_in_juty', as: 'update_for_in_juty'
|
put '/edit_in_juty/:id' => 'in_juties#update_for_in_juty', as: 'update_for_in_juty'
|
||||||
delete '/destroy_in_juty/: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'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user