77 lines
2.3 KiB
Plaintext
77 lines
2.3 KiB
Plaintext
<div class="content-holder">
|
|
<h2><%= t("bus_booking.booking_details_for") %> <%= @bus.bus_route %></h2>
|
|
<table class="table table-striped table-bordered">
|
|
<thead>
|
|
<th class="span1"><input type="checkbox" id="checkall"> All</th>
|
|
<th><%= t("bus_booking.registered_date") %></th>
|
|
<th><%= t("bus_booking.email") %></th>
|
|
<th><%= t("bus_booking.name") %></th>
|
|
<th><%= t("bus_booking.department") %></th>
|
|
<th><%= t("bus_booking.dorm_number") %></th>
|
|
</thead>
|
|
<tbody>
|
|
<% @bus.bookings.desc(:created_at).each do |booking| %>
|
|
<tr>
|
|
<td><input type="checkbox" value="<%= booking.id.to_s %>" name="bookings_to_delete[]" class="check-this"></td>
|
|
<td><%= booking.created_at.strftime("%Y/%m/%d") %></td>
|
|
<td><%= booking.email %></td>
|
|
<td><%= booking.name %></td>
|
|
<td><%= booking.department %></td>
|
|
<td><%= booking.dorm_number %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<div class="pull-right">
|
|
<a href="#" id="delete-selected" style="display:none;" class="btn btn-danger"><%= t("bus_booking.delete") %></a>
|
|
<a href="<%= admin_bus_booking_export_path(@bus, :format => "xlsx") %>" class="btn btn-info"><%= t("bus_booking.export") %></a>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var deleteBtn = $("#delete-selected"),
|
|
checkAllBtn = $("#checkall"),
|
|
bookings = $("input.check-this");
|
|
|
|
checkAllBtn.on("click",function(){
|
|
if($(this).is(":checked")){
|
|
bookings.prop("checked",true);
|
|
}else{
|
|
bookings.prop("checked",false);
|
|
}
|
|
showHideDeleteFn();
|
|
})
|
|
|
|
bookings.on("click",function(){
|
|
if($("input.check-this:checked").length == bookings.length){
|
|
checkAllBtn.prop("checked",true);
|
|
}else{
|
|
checkAllBtn.prop("checked",false);
|
|
}
|
|
showHideDeleteFn();
|
|
})
|
|
|
|
deleteBtn.on("click",function(){
|
|
var b = $("input.check-this:checked");
|
|
if (b.length){
|
|
var values = b.map(function(i,x){return x.value}).toArray();
|
|
console.log(values);
|
|
$.ajax({
|
|
url : "/admin/bus_bookings/deletebookings",
|
|
data : {"bus_id" : "<%= @bus.id.to_s %>", "bookings" : values},
|
|
type : "post"
|
|
}).done(function(){
|
|
window.location.reload();
|
|
})
|
|
}
|
|
return false;
|
|
})
|
|
|
|
var showHideDeleteFn = function(){
|
|
if($("input.check-this:checked").length){
|
|
deleteBtn.show();
|
|
}else{
|
|
deleteBtn.hide();
|
|
}
|
|
}
|
|
showHideDeleteFn();
|
|
</script> |