queue and crm view updated

This commit is contained in:
Aung Myo
2017-06-09 09:29:25 +06:30
parent ea4f50e779
commit 35277ac000
41 changed files with 685 additions and 318 deletions

View File

@@ -0,0 +1,38 @@
if (@customer)
json.id @customer.customer_id
json.name @customer.name
json.email @customer.email
json.contact_no @customer.contact_no
json.date_of_birth @customer.date_of_birth
@total_amount = 0.00
@total_tax = 0.00
if @customer.orders
order_items = []
@customer.orders.each do |bo|
order = Order.find(bo.order_id)
#if (order.status == "new")
order_items = order_items + order.order_items
#end
end
json.order_items order_items do |item|
json.item_instance_code item.item_code
json.item_name item.item_name
json.price item.price
json.qty item.qty
json.options item.options
json.remark item.remark
json.item_status item.order_item_status
@total_amount = @total_amount + (item.price * item.qty)
end
end
json.sub_total @total_amount
json.commerical_tax @total_amount * 0.05
json.total @total_amount + (@total_amount * 0.05)
end

View File

@@ -16,5 +16,13 @@
<%= f.button :submit %>
</div>
<% end %>
<!-- -->
<!-- <div class="form-group">
<select class="selectpicker form-control col-md-12" name="membership_id">
<option>Select Member Group</option>
<% @member_group.each do |member| %>
<option value="<%= member["id"] %>">
<%= member["name"] %></option>
<%end %>
</select>
</div> -->

View File

@@ -11,7 +11,7 @@
</ol>
</div>
</div>
<br/>
<div class="row">
<div class="col-lg-8">
@@ -21,6 +21,17 @@
<table class="table table-striped">
<thead>
<tr>
<td colspan="6">
<%= form_tag crm_customers_path, :method => :get do %>
<div class="input-append form-group pull-left">
<input type="text" name="filter" placeholder="Search" class="form-control input-sm col-md-8">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
</div>
<% end %>
</td>
</tr>
<tr>
<th>Select</th>
<th>Name</th>
@@ -48,6 +59,9 @@
<% end %>
</tbody>
</table>
<br>
<p>asdfj;l</p>
<%= paginate @crm_customers %>
</div>
</div>
@@ -81,15 +95,7 @@
<%= f.text_field :date_of_birth,:class=>"form-control datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%>
</div>
<div class="form-group">
<select class="selectpicker form-control col-md-12" name="membership_id">
<option>Select Member Group</option>
<% @member_group.each do |member| %>
<option value="<%= member["id"] %>">
<%= member["name"] %></option>
<%end %>
</select>
</div>
<div class="form-group">

View File

@@ -0,0 +1,2 @@
json.extract! crm_dining_queue, :id, :name, :contact, :queue_no, :created_at, :updated_at
json.url crm_dining_queue_url(crm_dining_queue, format: :json)

View File

@@ -0,0 +1,16 @@
<%= simple_form_for([:crm,@dining_queue]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :name %>
<%= f.input :contact_no %>
<%= f.input :queue_no %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>

View File

@@ -0,0 +1,11 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= crm_dining_queues_path %>">Queue</a></li>
<li>Edit</li>
</ul>
</div>
<%= render 'form', dining_queue: @dining_queue %>
</div>

View File

@@ -0,0 +1,38 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Queue</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")),new_crm_dining_queue_path,:class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
<br>
<div class="card">
<table class="table table-striped">
<thead>
<tr>
<th style="width:25%">Name</th>
<th style="width:25%">Contact No</th>
<th style="width:25%">Queue No</th>
<th style="width:25%">Action</th>
</tr>
</thead>
<tbody>
<% @dining_queues.each do |dining_queue| %>
<tr>
<td><%= dining_queue.name %></td>
<td><%= dining_queue.contact_no %></td>
<td><%= dining_queue.queue_no %></td>
<td>
<%= link_to 'Edit', edit_crm_dining_queue_path(dining_queue) %> | <%= link_to 'Destroy', crm_dining_queue_path(dining_queue), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -0,0 +1 @@
json.array! @crm_dining_queues, partial: 'crm_dining_queues/crm_dining_queue', as: :crm_dining_queue

View File

@@ -0,0 +1,11 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= crm_dining_queues_path %>">Queue</a></li>
<li>New</li>
</ul>
</div>
<%= render 'form', dining_queue: @dining_queue %>
</div>

View File

@@ -0,0 +1,19 @@
<p id="notice"><%= notice %></p>
<p>
<strong>Name:</strong>
<%= @crm_dining_queue.name %>
</p>
<p>
<strong>Contact:</strong>
<%= @crm_dining_queue.contact %>
</p>
<p>
<strong>Queue no:</strong>
<%= @crm_dining_queue.queue_no %>
</p>
<%= link_to 'Edit', edit_crm_dining_queue_path(@crm_dining_queue) %> |
<%= link_to 'Back', crm_dining_queues_path %>

View File

@@ -0,0 +1 @@
json.partial! "crm_dining_queues/crm_dining_queue", crm_dining_queue: @crm_dining_queue

View File

@@ -6,29 +6,29 @@
<% @booking.each do |booking| %>
<% if booking.booking_status == "new" %>
<div class="card">
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" >
<p class="hidden booking-id"><%= booking.id %></p>
<h4 class="card-title">
<%= @i += 1 %> . <%= booking.dining_facility.name %>
- <%= booking.id %>
</h4>
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
<p class="card-text">
<small class="text-muted">
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
</small>
</p>
</div>
<div class="card-footer">
<div class="row">
<div class="col-md-6">
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" >
<p class="hidden booking-id"><%= booking.id %></p>
<h4 class="card-title">
<%= @i += 1 %> . <%= booking.dining_facility.name %>
- <%= booking.id %>
</h4>
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
<p class="card-text">
<small class="text-muted">
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
</small>
</p>
</div>
<div class="col-md-6">
<div class="card-footer">
<div class="row">
<div class="col-md-6">
</div>
<div class="col-md-6">
</div>
</div>
</div>
</div>
</div>
</div>
<% end %>
<% end %>
@@ -38,67 +38,95 @@
$(function(){
$(".booking_click").on("click", function(){
$(".summary-items tbody tr").remove();
$("#cancel").removeAttr("disabled");
$("#assign").removeAttr("disabled");
var booking_id = $(this).find(".booking-id").text();
$("#crm_print").val(booking_id);
$("#crm_print").removeAttr("disabled");
$(this).css('background-color', '#CCC');
$(".summary-items tbody tr").remove();
$("#cancel").removeAttr("disabled");
$("#assign").removeAttr("disabled");
var url = $(this).attr('data-ref');
show_details(url);
var booking_id = $(this).find(".booking-id").text();
$("#crm_print").val(booking_id);
$("#crm_print").removeAttr("disabled");
});
var url = $(this).attr('data-ref');
show_details(url);
}); //End Booking Click
$('.nav-link').click(function () {
var href = $(this).attr('href');
if(href== "#customer" || href == "#queue"){
$("#cancel").attr("disabled","disabled");
$("#assign").attr("disabled","disabled");
}
});
//End nav-liik
$('.crm_print').click(function() {
var booking_id = $('#crm_print').val();
var booking_id = $('#crm_print').val();
$.ajax({
type: "GET",
url: "crm/print/"+booking_id,
data: {},
dataType: "json",
success: function(data) {
}
});
$.ajax({
type: "GET",
url: "crm/print/"+booking_id,
data: {},
dataType: "json",
success: function(data) {
}
});
});
//End Print Click
$('.assign').click(function(e){
var booking_id = $(this).val()
var type = $(this).attr("data-type")
var booking_id = $(this).val()
var type = $(this).attr("data-type")
update_booking(booking_id,type)
update_booking(booking_id,type)
});
//End Assing Click
$('.cancel').click(function(e){
var booking_id = $(this).val()
var type = $(this).attr("data-type")
var booking_id = $(this).val()
var type = $(this).attr("data-type")
update_booking(booking_id,type)
update_booking(booking_id,type)
});
//End cancle Click
$(".customer_detail").on("click", function(){
$(this).css('background-color', '#CCC');
$(".summary-items tbody tr").remove();
$("#crm_print").removeAttr("disabled");
var id = $(this).attr('data-ref');
$('.customer_detail').removeClass('selected-item');
$(this).addClass('selected-item');
customer_details(id);
});
//end customer click
});
function show_details(url_item){
//Start Ajax
$.ajax({
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
item_data = data.order_items;
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
item_data = data.order_items;
//console.log(item_data.length);
$("#table").text(data.table_name)
$("#order_at").text(data.checkin_at)
$("#order_by").text(data.checkin_by)
$("#assign").val(data.id)
$("#cancel").val(data.id)
for(var field in item_data) {
if (item_data[field].item_name){
if (item_data[field].item_name){
var price = parseFloat(item_data[field].price).toFixed(2);
row = "<tr>"
@@ -106,32 +134,80 @@ function show_details(url_item){
+'<td style="width:33%; text-align:center">' + item_data[field].qty + '</td>'
+'<td style="width:33%; text-align:right">' + price + '</td>'
+'</tr>';
}
$(".summary-items tbody").append(row);
}
$(".summary-items tbody").append(row);
}
}
}
});
//end Ajax
$('.booking_click').removeClass('selected-item');
$(this).addClass('selected-item');
}
function customer_details(id){
//Start Ajax
$.ajax({
type: "GET",
url: "api/customers/get_order/"+id,
data: {},
dataType: "json",
success: function(data) {
item_data = data.order_items;
$("#for-booking").remove();
var div_data = "<strong>CUSTOMER DETAILS</strong>";
$("#order-title").replaceWith(div_data);
$('.customer-detail').removeClass('hide') ;
$("#cus_name").text(data.name)
$("#cus_email").text(data.email)
$("#cus_contact_no").text(data.contact_no)
if(item_data.length>0){
for(var field in item_data) {
if (item_data[field].item_name){
var price = parseFloat(item_data[field].price).toFixed(2);
row = "<tr>"
+'<td style="width:33%; text-align:left">' + item_data[field].item_name +'</td>'
+'<td style="width:33%; text-align:center">' + item_data[field].qty + '</td>'
+'<td style="width:33%; text-align:right">' + price + '</td>'
+'</tr>';
}
$(".summary-items tbody").append(row);
}
}else{
}
}
});
//End Ajax
}
function update_booking(booking_id,type) {
//Start Ajax
$.ajax({
type: "POST",
url: "update_booking/" ,
data: {booking_id:booking_id,type:type},
dataType: "json",
success: function(data) {
if(data.status == true && data.type == "cancel")
{
alert('Booking has canceled!');
}else{
alert('Booking has completed!');
}
location.reload();
}
});
type: "POST",
url: "update_booking/" ,
data: {booking_id:booking_id,type:type},
dataType: "json",
success: function(data) {
if(data.status == true && data.type == "cancel")
{
alert('Booking has canceled!');
}else{
alert('Booking has completed!');
}
location.reload();
}
});//End Ajax
}
</script>
</script>
<style type="text/css">
.selected-item {
background-color: #ccc;
}
</style>

View File

@@ -1,7 +1,7 @@
<!--- Booking Items -->
<div class="card-columns" style="padding-top:10px">
<% @customer.each do |customer| %>
<div class="card">
<div class="card customer_detail" data-ref="<%= customer.id%>">
<div class="card-block">
<!-- <h4 class="card-title">Customer Name : <%= customer.name %></h4> -->
<p class="card-text">Name : <%= customer.name %></p>

View File

@@ -1,33 +1,21 @@
<div class="card-columns" style="padding-top:10px">
<% @i = 0 %>
<% @booking.each do |booking| %>
<% if booking.booking_status == "assign" %>
<div class="card booking_click" data-ref="<%= api_booking_path booking.id%>" id="booking_block">
<div class="card-block" id="card-block" style="width:100%;">
<p class="hidden booking-id"><%= booking.id %></p>
<% @queue.each do |queue| %>
<div class="card">
<div class="card-block" style="width:100%;">
<h4 class="card-title">
<%= @i += 1 %> . <%= booking.dining_facility.name %>
- <%= booking.id %>
<%= @i += 1 %> . <%= queue.name %>
</h4>
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
<p class="card-text">
<small class="text-muted">
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
</small>
Contact No - <%= queue.contact_no %>
</p>
</div>
<!-- <div class="card-footer">
<div class="row">
<div class="col-md-6">
<button id="assign" data-ref="<%= booking.id%>" data-type="complete" class="btn assign btn-primary btn-sm btn-block">ASSIGN</button>
</div>
<div class="col-md-6">
<button id="cancel" data-ref="<%= booking.id%>" data-type="cancel" class="btn btn-danger cancel btn-sm btn-block">CANCLE</button>
</div>
</div>
</div> -->
</div>
<% end %>
<% end %>
</div>

View File

@@ -5,32 +5,32 @@
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Queue <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","assign").count %></span></a>
<a class="nav-link" data-toggle="tab" href="#queue" role="tab">Queue <span class="badge badge-pill badge-default"><%= @queue.count %></span></a>
</li>
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Bookings <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","new").count %></span></a>
<a class="nav-link active" data-toggle="tab" href="#booking" role="tab">Bookings <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","new").count %></span></a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Customers</a>
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Customers</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
<!--- Panel 0 - Completed -->
<div class="tab-pane" id="completed" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
<div class="tab-pane" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
<%= render :partial => 'queue' %>
</div>
<!-- Panel 1 - Tables -->
<div class="tab-pane active" id="tables" role="tabpanel">
<div class="tab-pane active" id="booking" role="tabpanel">
<%= render :partial => 'booking' %>
</div>
<!-- Panel 1 - Tables - End -->
<!-- Panel 2 - Rooms -->
<div class="tab-pane" id="rooms" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
<div class="tab-pane" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
<%= render :partial => 'customer' %>
</div>
<!-- Panel 2 - Rooms - End -->
@@ -47,12 +47,12 @@
<div id="station"></div>
<div class="card-block">
<div class="card-title">
<table class="table" >
<table class="table for-booking" id="for-booking">
<thead>
<tr>
<th style="width:33%; text-align:left">Order By</th>
<th style="width:33%; text-align:center;">Order At</td>
<th style="width:33%; text-align:right">Customer</td>
<th style="width:33%; text-align:center;">Order At</th>
<th style="width:33%; text-align:right">Customer</th>
</tr>
</thead>
<tbody>
@@ -67,17 +67,35 @@
</tr>
</tbody>
</table>
<table class="table customer-detail hide">
<thead>
<tr>
<td style="width:44%; text-align:center"><strong>Name</strong></td>
<td style="width:44%; text-align:" id="cus_name"></td>
</tr>
<tr>
<td style="width:44%; text-align:center"><strong>Email</strong></td>
<td style="width:44%; text-align:" id="cus_email"></td>
</tr>
<tr>
<td style="width:44%; text-align:center"><strong>Contact No</strong></td>
<td style="width:44%; text-align:" id="cus_contact_no"></td>
</tr>
</thead>
</table>
<table class="table">
<thead>
<tr>
<th style="width:33%; text-align:left">Items</th>
<th style="width:33%; text-align:center">Qty</th>
<th style="width:33%; text-align:right">Price</td>
<th style="width:33%; text-align:right">Price</th>
</tr>
</thead>
</table>
</div>
<div class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
<table class="table summary-items">
<tbody>
@@ -102,5 +120,3 @@
</div>
</div>
</script>