update customer amount

This commit is contained in:
Aung Myo
2017-06-13 10:36:40 +06:30
parent 92f1f80acb
commit c05a64bae7
13 changed files with 105 additions and 130 deletions

View File

@@ -66,37 +66,32 @@
</div>
</div>
<div class="col-lg-4">
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<%= f.input :name, :class => "form-control col-md-6 name" %>
</div>
<div class="form-group">
<%= 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" %>
<%= 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 "%>
<%= f.input :date_of_birth,:class=>"form-control date_of_birth"%>
</div>
<div class="form-group">
<div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id">
<option>Select Member Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
@@ -104,7 +99,7 @@
<%= member.name %></option>
<%end %>
</select>
</div>
</div>
<div class="form-group">
@@ -115,21 +110,8 @@
</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) {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
}
});
$(document).on('click',".checkbox_check",function(){
if(this.checked){
@@ -137,13 +119,13 @@
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{
// if(sale_id != 0){
// // var url = "/"+customer_id;
// update_sale(customer_id,sale_id);
// }else{
var url = "customers/"+customer_id;
}
// var url = "customers/"+customer_id;
// }
$.ajax({
type: "GET",
@@ -179,43 +161,43 @@
}
})
function update_sale(customer_id,sale_id) {
$.confirm({
title: 'Confirm!',
content: 'Are You Sure to assign this customer!',
buttons: {
// function update_sale(customer_id,sale_id) {
// $.confirm({
// title: 'Confirm!',
// content: 'Are You Sure to assign this customer!',
// buttons: {
cancel: function () {
// 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();
}
// },
// 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();
// }
}
});
}
}
// }
// });
// }
// }
}
});
}
// }
// });
// }
</script>

View File

@@ -38,6 +38,7 @@
<th>Company</th>
<th>Contact no</th>
<th>Email</th>
<th>Date of Birth</th>
</tr>
</thead>
@@ -47,11 +48,11 @@
<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.company rescue '-' %></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?' } %>
<%= crm_customer.date_of_birth rescue '-' %>
</td>
@@ -84,8 +85,6 @@
</div>
<div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
</div>
<div class="form-group">
@@ -93,11 +92,11 @@
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
<%= f.input :date_of_birth,:class=>"form-control date_of_birth"%>
</div>
<div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id">
<option>Select Member Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
@@ -105,21 +104,11 @@
<%= member.name %></option>
<%end %>
</select>
</div>
<!-- <div class="form-group">
<%= 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 membership_authentication_code" %>
</div> -->
<div class="form-group">
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
<!-- <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> -->
</div>
<%end%>
</div>
@@ -128,17 +117,6 @@
<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) {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
}
});
$(document).on('click',".checkbox_check",function(){
if(this.checked){

View File

@@ -14,8 +14,8 @@
<td><strong>Sale Id</strong> </span><span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></td>
</tr>
<tr>
<td><strong>Customer :</strong> Default Customer</td>
<td><strong>Points :</strong> 1234 </td>
<td><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
<td><strong>Points :</strong> <%= @balance %> </td>
</tr>
</table>
</div>