finished customer to sale assign in crm
This commit is contained in:
@@ -16,3 +16,5 @@
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- -->
|
||||
|
||||
@@ -55,7 +55,8 @@
|
||||
|
||||
<div class="col-lg-4">
|
||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||
<span class="patch_method"></span>
|
||||
<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">
|
||||
@@ -80,7 +81,6 @@
|
||||
<%= 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>
|
||||
@@ -106,6 +106,8 @@
|
||||
<%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) {
|
||||
@@ -120,11 +122,22 @@
|
||||
});
|
||||
|
||||
$(document).on('click',".checkbox_check",function(){
|
||||
if(this.checked){
|
||||
var customer_id = $(this).val();
|
||||
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: "customers/"+customer_id,
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
@@ -156,6 +169,46 @@
|
||||
}
|
||||
})
|
||||
|
||||
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');
|
||||
}*/
|
||||
|
||||
Reference in New Issue
Block a user