merge crm
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
<%= f.input :contact_no %>
|
||||
<%= f.input :email %>
|
||||
<%= f.input :date_of_birth %>
|
||||
<%= f.input :membership_id, :collection => @membership %>
|
||||
<%= f.input :membership_type %>
|
||||
<%= f.input :membership_authentication_code %>
|
||||
</div>
|
||||
@@ -17,3 +16,5 @@
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- -->
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="<%= dashboard_path %>">Home</a></li>
|
||||
<li><a href="<%= crm_root_path %>">Home</a></li>
|
||||
<li class="active">
|
||||
<a href="<%= crm_customers_path %>">Customer</a>
|
||||
</li>
|
||||
<a href="<%= new_crm_customer_path%>" class="btn btn-primary pull-right">
|
||||
<!-- <a href="<%= new_crm_customer_path%>" class="btn btn-primary pull-right">
|
||||
<i class="fa fa-plus-circle fa-lg"></i> Add Customer
|
||||
</a>
|
||||
</a> -->
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-7">
|
||||
<div class="col-lg-8">
|
||||
|
||||
<div class="main-box-body clearfix">
|
||||
<div class="table-responsive">
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Select</th>
|
||||
<th>Name</th>
|
||||
<th>Company</th>
|
||||
<th>Contact no</th>
|
||||
@@ -32,10 +33,16 @@
|
||||
<tbody>
|
||||
<% @crm_customers.each do |crm_customer| %>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
|
||||
<td><%= crm_customer.name %></td>
|
||||
<td><%= crm_customer.company %></td>
|
||||
<td><%= crm_customer.contact_no %></td>
|
||||
<td><%= crm_customer.email %></td>
|
||||
<td>
|
||||
<%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -46,55 +53,61 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-5">
|
||||
<%= simple_form_for crm_customers_path, :html => { :class => 'form-horizontal' } do |f| %>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||
<span class="patch_method"></span>
|
||||
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
|
||||
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :name, :class => "form-control col-md-6" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :company, :class => "form-control col-md-6" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :contact_no, :class => "form-control col-md-6" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :email, :class => "form-control col-md-6" %>
|
||||
</div>
|
||||
<%= f.input :name, :class => "form-control col-md-6 name" %>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="date_of_birth" class="col-md-6 control-label">Date Of Birth</label>
|
||||
<%= f.text_field :date_of_birth,:class=>"form-control datepicker",:readonly =>true, :value => @date_of_birth%>
|
||||
<%= f.input :company, :class => "form-control col-md-6 company" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :email, :class => "form-control col-md-6 email" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Date Of Birth</label>
|
||||
<%= f.text_field :date_of_birth,:class=>"form-control datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.select :membership_id, options_for_select(@membership.collect { |member|
|
||||
[member["id"].name.titleize, member["id"].id] }, 1), {}, { id: 'countries_select' } %>
|
||||
<select class="selectpicker form-control col-md-6" name="membership_id">
|
||||
<select class="selectpicker form-control col-md-12" name="membership_id">
|
||||
<option>Select Member Group</option>
|
||||
<% @membership.each do |member| %>
|
||||
<% @member_group.each do |member| %>
|
||||
<option value="<%= member["id"] %>">
|
||||
<%= member["name"] %></option>
|
||||
<%end %>
|
||||
</select>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :membership_type, :class => "form-control col-md-6" %>
|
||||
<%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :membership_authentication_code, :class => "form-control col-md-6" %>
|
||||
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.button :submit, "Submit", :class => 'btn btn-primary' , :id => 'submit_account' %>
|
||||
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
|
||||
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
|
||||
</div>
|
||||
<%end%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
if (jQuery().datepicker) {
|
||||
@@ -107,4 +120,112 @@
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(document).on('click',".checkbox_check",function(){
|
||||
if(this.checked){
|
||||
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var customer_id = $(this).val();
|
||||
|
||||
if(sale_id != 0){
|
||||
var url = "../"+customer_id;
|
||||
update_sale(customer_id,sale_id);
|
||||
}else{
|
||||
|
||||
var url = "customers/"+customer_id;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
$('#customer_id').val(data.id);
|
||||
$('#customer_name').val(data.name);
|
||||
$('#customer_company').val(data.company);
|
||||
$('#customer_contact_no').val(data.contact_no);
|
||||
$('#customer_email').val(data.email);
|
||||
$('#customer_date_of_birth').val(data.date_of_birth);
|
||||
$('#customer_membership_type').val(data.membership_type);
|
||||
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
|
||||
$('.membership_authentication_code').val(data.membership_authentication_code);
|
||||
|
||||
$('#update_customer').removeAttr('disabled').val('');
|
||||
$('#update_customer').attr('value', 'Update');
|
||||
$('#submit_customer').attr('disabled','disabled');
|
||||
|
||||
$("#new_customer").attr('class', 'simple_form edit_customer');
|
||||
var id = "edit_customer_"+$('#customer_id').val();
|
||||
$("#new_customer").attr('id', id);
|
||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||
$(".patch_method").append('<input type="hidden" name="_method" value="patch">');
|
||||
//$(".edit_customer").attr('method', 'PATCH');
|
||||
}
|
||||
});
|
||||
}else{
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
function update_sale(customer_id,sale_id) {
|
||||
$.confirm({
|
||||
title: 'Confirm!',
|
||||
content: 'Are You Sure to assign this customer!',
|
||||
buttons: {
|
||||
|
||||
cancel: function () {
|
||||
|
||||
},
|
||||
confirm: {
|
||||
text: 'Confirm',
|
||||
btnClass: 'btn-green',
|
||||
keys: ['enter', 'shift'],
|
||||
action: function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "../../update_sale/" ,
|
||||
data: {customer_id:customer_id,sale_id:sale_id},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == true)
|
||||
{
|
||||
alert('Customer has assigned');
|
||||
window.location.href = '/origami'
|
||||
}else{
|
||||
alert('Record not found!');
|
||||
location.reload();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*function changeMethod() {
|
||||
$("#update_customer").attr('method', 'put');
|
||||
}*/
|
||||
|
||||
|
||||
/* $("#update_customer").click(function() {
|
||||
$("#new_customer").attr('class', 'edit_customer');
|
||||
var id = "edit_customer_"+$('#customer_id').val();alert(id);
|
||||
$("#new_customer").attr('id', id);
|
||||
alert(";;")
|
||||
//$('#new_customer').removeClass('new_customer');
|
||||
//$('#new_customer').addClass('edit_customer')
|
||||
}); */
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
<%= @crm_customer.date_of_birth %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Membership:</strong>
|
||||
<%= @crm_customer.membership %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Membership type:</strong>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
json.partial! "crm_customers/crm_customer", crm_customer: @crm_customer
|
||||
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, :created_at, :updated_at
|
||||
json.url crm_customer_url(@crm_customer, format: :json)
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
<% @i = 0 %>
|
||||
<% @booking.each do |booking| %>
|
||||
<% if booking.booking_status == "assign" %>
|
||||
<% if booking.booking_status == "new" %>
|
||||
<div class="card">
|
||||
<div class="card-block booking_click" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" style="width:100%;">
|
||||
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" style="width:100%;" >
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
@@ -36,14 +36,21 @@
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
|
||||
|
||||
$(".booking_click").on("click", function(){
|
||||
$(".summary-items tbody tr").remove();
|
||||
$("#cancel").removeAttr("disabled");
|
||||
$("#assign").removeAttr("disabled");
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
//$("#crm_print").val($(this).attr('data'));
|
||||
|
||||
var url = $(this).attr('data-ref');
|
||||
show_details(url);
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('.assign').click(function(e){
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
@@ -58,6 +65,7 @@ $(function(){
|
||||
update_booking(booking_id,type)
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
function show_details(url_item){
|
||||
@@ -97,7 +105,7 @@ function show_details(url_item){
|
||||
function update_booking(booking_id,type) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "crm/update_booking/" ,
|
||||
url: "update_booking/" ,
|
||||
data: {booking_id:booking_id,type:type},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
@@ -92,10 +92,37 @@
|
||||
<!-- Column Three--->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- OQS Buttons -->
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button>
|
||||
<button id="crm_print" value="" disabled="disabled" data-type="assign" class="btn crm_print btn-primary btn-lg btn-block" >
|
||||
Print
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button>
|
||||
<button id="assign" value="" disabled="disabled" data-type="assign" class="btn assign btn-primary btn-lg btn-block">ASSIGN</button>
|
||||
<button id="cancel" value="" disabled="disabled" data-type="cancel" class="btn btn-danger cancel btn-lg btn-block">CANCLE</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$( document ).ready(function() {
|
||||
$('.crm_print').click(function() {
|
||||
var id = "BKI-000000000004"
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "crm/print/"+id,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
/*if(data.status == true && data.type == "cancel")
|
||||
{
|
||||
alert('Booking has canceled!');
|
||||
}else{
|
||||
alert('Booking has completed!');
|
||||
}
|
||||
location.reload();*/
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<%= render 'layouts/header_crm' %>
|
||||
<div class="container-fluid">
|
||||
<% flash.each do |type, message| %>
|
||||
<div class="alert fade in">
|
||||
<div class="alert-danger fade in">
|
||||
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
|
||||
<%= message %>
|
||||
</div>
|
||||
|
||||
@@ -206,15 +206,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><p id="sale" value=""></p>
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Add Order</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Customer</button>
|
||||
<button type="button" id="customer" value="SAL-000000000001" class="btn btn-primary btn-lg btn-block">Customer</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button>
|
||||
<!-- Cashier Buttons -->
|
||||
<button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button>
|
||||
@@ -223,3 +222,146 @@
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var old_order_id = 0
|
||||
var old_table_name = ""
|
||||
var table_or_order_id = 0
|
||||
var pay_sale_id = 0
|
||||
|
||||
function callOrderDetails(sale_order_id){
|
||||
|
||||
var order_id = 0
|
||||
var sale_id = 0
|
||||
var data_val = ""
|
||||
sale_order = sale_order_id.split("_")[0]
|
||||
|
||||
if (sale_order == 'sale') {
|
||||
order_id = sale_order_id.split("_")[1]
|
||||
url = "origami/"+sale_order_id.split("_")[1]
|
||||
data_val = { sale_id: sale_order_id.split("_")[1]}
|
||||
$("#pay").prop('disabled',false);
|
||||
$("#customer").prop('disabled',false);
|
||||
$("#request_bills").prop('disabled',true);
|
||||
}else{
|
||||
order_id = sale_order_id.split("_")[1]
|
||||
url = "origami/"+order_id
|
||||
data_val = { order_id: sale_order_id.split("_")[1]}
|
||||
$("#request_bills").prop('disabled',false);
|
||||
$("#pay").prop('disabled',true);
|
||||
$("#customer").prop('disabled',true);
|
||||
}
|
||||
|
||||
table_or_order_id = order_id
|
||||
pay_sale_id = sale_id
|
||||
alert(table_or_order_id)
|
||||
var tbody = ""
|
||||
$("#append-table").html("")
|
||||
if (old_order_id != order_id){
|
||||
$("#table-order-"+old_order_id).removeClass("selected_color")
|
||||
$("#table-order-"+order_id).addClass("selected_color")
|
||||
old_order_id = order_id
|
||||
}
|
||||
|
||||
$("#order-detail-header").html("")
|
||||
$("#order-detail-header").append("Table Name : "+document.getElementById("table-name-"+order_id).innerHTML)
|
||||
$("#sub-total").html("")
|
||||
$.ajax({type: "GET",
|
||||
url: url,
|
||||
data: data_val,
|
||||
success:function(result){
|
||||
var sub_total = 0
|
||||
var discount_amount = 0
|
||||
var receipt_no = ""
|
||||
var cashier_name = ""
|
||||
var receipt_date = ""
|
||||
var tax_amount = 0
|
||||
var grand_total_amount = 0
|
||||
row = "<tbody>"
|
||||
for (i = 0; i < result.length; i++) {
|
||||
var data = JSON.stringify(result[i]);
|
||||
var parse_data = JSON.parse(data)
|
||||
sub_total += (parse_data.qty*parse_data.price)
|
||||
row = '<tr><td style="width:60%; text-align:left"><span id="item-name-price">'+parse_data.item_name+"@"+(parse_data.price*1)+'</span></td>'
|
||||
+'<td style="width:20%; text-align:right"><span id="item-qty">'+(parse_data.qty*1)+'</span></td>s'
|
||||
+'<td style="width:20%; text-align:right"><span id="item-total-price">'+(parse_data.qty*parse_data.price)+'</span></td>'
|
||||
+'</tr>>'
|
||||
tbody += row
|
||||
|
||||
discount_amount = result[i].discount_amount;
|
||||
|
||||
tax_amount = result[i].tax_amount;
|
||||
grand_total_amount = result[i].grand_total_amount;
|
||||
|
||||
receipt_no = result[i].receipt_no;
|
||||
cashier_name = result[i].cashier_name;
|
||||
receipt_date = result[i].receipt_date;
|
||||
}
|
||||
row = "</tbody>"
|
||||
$("#append-table").append(tbody)
|
||||
|
||||
$("#sub-total").append((sub_total)+"<br/>")
|
||||
|
||||
if (discount_amount > 0 ) {
|
||||
$("#discount-header").html("(Discount)")
|
||||
$("#discount_amount").html("("+discount_amount+")")
|
||||
}
|
||||
|
||||
if (tax_amount > 0 ) {
|
||||
$("#tax-header").html("Tax")
|
||||
$("#tax_amount").html(tax_amount)
|
||||
}
|
||||
|
||||
if (grand_total_amount > 0 ) {
|
||||
$("#grand-total-header").html("Grand Total")
|
||||
$("#grand_total_amount").html(grand_total_amount)
|
||||
}
|
||||
|
||||
if (cashier_name == null){
|
||||
cashier_name = ""
|
||||
}
|
||||
if(receipt_no != null){
|
||||
$("#receipt-no").html("Receipt No : "+receipt_no)
|
||||
}
|
||||
if (receipt_date != null) {
|
||||
$("#receipt-date").html("Receipt Date : "+receipt_date);
|
||||
}
|
||||
if (cashier_name != null) {
|
||||
$("#cashier-name").html("Cashier Name : "+cashier_name);
|
||||
}
|
||||
},
|
||||
error:function(result){
|
||||
// alert('error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
$('#request_bills').click(function() {
|
||||
window.location.href = '/origami/request_bills/'+ table_or_order_id
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#pay').click(function() {
|
||||
window.location.href = '/origami/sale/'+ pay_sale_id + "/payment"
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#customer').click(function() {
|
||||
var sale_id = $(this).val();
|
||||
window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id"
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.selected_color{
|
||||
color:white;
|
||||
background-color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user