268 lines
9.8 KiB
Plaintext
Executable File
268 lines
9.8 KiB
Plaintext
Executable File
<div class="container-fluid">
|
|
<div class="page-header">
|
|
<ul class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
|
|
<li class="breadcrumb-item active">CRM</li>
|
|
<!-- <li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li> -->
|
|
<span class="float-right">
|
|
<%= link_to 'Back', dashboard_path %>
|
|
</span>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="row clearfix">
|
|
<div class="col-lg-8 col-md-8 col-sm-8">
|
|
<!-- <div class="main-box-body clearfix"> -->
|
|
<div class="body table-responsive">
|
|
<table class="table table-hover table-striped">
|
|
<!-- <div class="table-responsive">
|
|
<table class="table table-striped"> -->
|
|
<thead>
|
|
<tr>
|
|
<td colspan="7">
|
|
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
|
|
<!-- <div class=" col-md-7 form-group float-left">
|
|
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control input-xs col-md-9">
|
|
<input type="hidden" name="type" id="type" value="">
|
|
<button type="submit" class="float-right btn btn-primary btn-md">Search</button>
|
|
</div> -->
|
|
<% end %>
|
|
<!-- <button id="member_acc_no" class="btn btn-success btn-md"><span class="fa fa-credit-card"></span> Member Card</button>
|
|
<button id="qr_code" class="btn btn-danger btn-md">
|
|
<span class="fa fa-credit-card"></span> QR CODE
|
|
</button> -->
|
|
<div class="body">
|
|
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
|
|
<div class="row clearfix">
|
|
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
|
|
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control">
|
|
<input type="hidden" name="type" id="type" value="">
|
|
</div>
|
|
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
|
|
<button type="submit" class="btn bg-blue waves-effect" style="margin-right: 10px;">Search</button>
|
|
<!-- </div> -->
|
|
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="margin-right: 10px;">Member Card</button>
|
|
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="margin-right: 10px;">QR CODE</button>
|
|
</div>
|
|
<% end %>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th></th>
|
|
<th>Sr.no</th>
|
|
<th>Name</th>
|
|
<th>Card No</th>
|
|
<th>Contact no</th>
|
|
<th>Email</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<% @i = 0 %>
|
|
<% @crm_customers.each do |crm_customer| %>
|
|
|
|
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
|
|
<td>
|
|
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
|
|
<td>
|
|
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
|
|
<%= @i += 1 %>
|
|
<%else%>
|
|
-
|
|
<% end %>
|
|
</td>
|
|
<td><%= crm_customer.name %></td>
|
|
<td><%= crm_customer.card_no rescue '-' %></td>
|
|
<td><%= crm_customer.contact_no %></td>
|
|
<td><%= crm_customer.email %></td>
|
|
<td><%= link_to t("views.btn.show"), crm_customer_path(crm_customer) %></td>
|
|
|
|
</tr>
|
|
|
|
<% end %>
|
|
|
|
</tbody>
|
|
</table>
|
|
<br>
|
|
<%= paginate @crm_customers %>
|
|
</div>
|
|
<!-- </div> -->
|
|
</div>
|
|
<div class="col-lg-4 col-md-4 col-sm-4">
|
|
<div id="custom-slimscroll">
|
|
<%= render 'new_form', crm_customer: @crm_customer, taxes: @taxes %>
|
|
</div>
|
|
<!-- <div class="col-lg-1 col-md-1 col-sm-1 ">
|
|
<br>
|
|
<a href="<%= dashboard_path%>" class="btn btn-primary">
|
|
<i class="fa fa-arrow-left fa-lg"></i> Back
|
|
</a>
|
|
</div> -->
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
|
|
$(function() {
|
|
|
|
/*$('.datepicker').datepicker({
|
|
format : 'dd-mm-yyyy',
|
|
autoclose: true
|
|
});
|
|
$('.datepicker').attr('ReadOnly','true');
|
|
$('.datepicker').css('cursor','pointer');*/
|
|
|
|
// Read Card Reader
|
|
$("#member_acc_no").on('click', function(e){
|
|
var cardNo = "";
|
|
$("#sxModal").show();
|
|
setTimeout(function(){
|
|
getCardNo();
|
|
$("#sxModal").hide();
|
|
$("#filter_form").submit();
|
|
},100);
|
|
});
|
|
|
|
// QR Code Reader
|
|
$("#qr_code").on('click', function(e){
|
|
var code = "";
|
|
setTimeout(function(){
|
|
var hi=getQRCode();
|
|
},100);
|
|
});
|
|
|
|
// Read qrcode from java
|
|
function getQRCode(){
|
|
return code2lab.readQRCode();
|
|
}
|
|
|
|
// get QRCode from Java
|
|
function setQRCode(code){
|
|
$("#qr_code").text(code);
|
|
$("#search").val(code);
|
|
}
|
|
|
|
});
|
|
|
|
$(document).on('click',".customer_tr",function(){
|
|
// if(this.checked){
|
|
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
|
//$( "#checkbox_check" ).prop( "checked", true );
|
|
var sale_id = $("#sale_id").val() || 0;
|
|
var customer_id = $(this).attr('data-ref');
|
|
|
|
if(sale_id != 0){
|
|
// var url = "/"+customer_id;
|
|
update_sale(customer_id,sale_id);
|
|
}else{
|
|
|
|
var url = "customers/" + customer_id + "/edit";
|
|
}
|
|
|
|
$("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'});
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
url: url,
|
|
data: {},
|
|
dataType: "json",
|
|
success: function(data) {
|
|
// Selected for Taxes
|
|
var taxes = JSON.stringify(data.tax_profiles);
|
|
var parse_taxes = JSON.parse(taxes);
|
|
$.each(parse_taxes, function(i, value){
|
|
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
|
|
});
|
|
|
|
$('#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_salutation').val(data.salutation);
|
|
$('#customer_nrc_no').val(data.nrc_no);
|
|
$('#customer_card_no').val(data.card_no);
|
|
$('#customer_type').val(data.customer_type);
|
|
$('#paypar_account_no').val(data.paypar_account_no);
|
|
$('#customer_address').val(data.address);
|
|
$('#customer_date_of_birth').val(data.date_of_birth);
|
|
$('#customer_membership_type').val(data.membership_type);
|
|
$('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected');
|
|
if (data.gender == 'Male') {
|
|
$('.male').prop( "checked", true )
|
|
}else{
|
|
$('.female').prop( "checked", true )
|
|
}
|
|
|
|
if(data.salutation == 'Mr') {
|
|
$('.mr').prop( "checked", true )
|
|
}else if(data.salutation == 'Miss') {
|
|
$('.miss').prop( "checked", true )
|
|
}else if(data.salutation == 'Mrs'){
|
|
$('.mrs').prop( "checked", true )
|
|
}else{
|
|
$('.mdm').prop( "checked", true )
|
|
}
|
|
|
|
$('.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;
|
|
$("#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">');
|
|
//$(".edit_customer").attr('method', 'PATCH');
|
|
}
|
|
});
|
|
// }else{
|
|
|
|
// }
|
|
})
|
|
|
|
function update_sale(customer_id,sale_id) {
|
|
swal({
|
|
title: "Confirmation",
|
|
text: "Are You Sure to assign this customer!",
|
|
type: "success",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "green",
|
|
confirmButtonText: "Yes, delete it!",
|
|
closeOnConfirm: false
|
|
}, 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)
|
|
{
|
|
window.location.href = '/origami'
|
|
}else{
|
|
swal("Alert!", "Record not found!", "error");
|
|
location.reload();
|
|
}
|
|
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
$('#reset').click(function() {
|
|
|
|
window.location.href = '/crm/customers'
|
|
|
|
return false;
|
|
});
|
|
|
|
</script>
|