add customer type and tax profile in customer

This commit is contained in:
Yan
2017-08-09 10:51:13 +06:30
parent 1685713ff5
commit cc6e422c8b
4 changed files with 16 additions and 7 deletions

View File

@@ -69,7 +69,9 @@ class Crm::CustomersController < BaseCrmController
# POST /crm/customers # POST /crm/customers
# POST /crm/customers.json # POST /crm/customers.json
def create def create
# Remove "" default first
params[:customer][:tax_profiles].delete_at(0)
@crm_customers = Customer.new(customer_params) @crm_customers = Customer.new(customer_params)
respond_to do |format| respond_to do |format|

View File

@@ -95,15 +95,14 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Select Customer Type</label> <label>Select Customer Type</label>
<select class="selectpicker form-control col-md-12" name="customer[customer_type]" style="height: 40px" > <select class="selectpicker form-control col-md-12" id="customer_type" name="customer[customer_type]" style="height: 40px" >
<% Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %> <% Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %>
<option value="<%= ct.value %>"> <option value="<%= ct.value %>">
<%= ct.name %></option> <%= ct.name %></option>
<%end %> <%end %>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %> <%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %>
</div> </div>

View File

@@ -129,7 +129,14 @@ $(document).on('click',".customer_tr",function(){
url: url, url: url,
data: {}, data: {},
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
// Selected for Taxes
//var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(data.tax_profiles);
$.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
});
$('#customer_id').val(data.id); $('#customer_id').val(data.id);
$('#customer_name').val(data.name); $('#customer_name').val(data.name);
$('#customer_company').val(data.company); $('#customer_company').val(data.company);
@@ -138,6 +145,7 @@ $(document).on('click',".customer_tr",function(){
$('#customer_salutation').val(data.salutation); $('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no); $('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no); $('#customer_card_no').val(data.card_no);
$('#customer_type').val(data.customer_type);
$('#paypar_account_no').val(data.paypar_account_no); $('#paypar_account_no').val(data.paypar_account_no);
$('#customer_address').val(data.address); $('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth); $('#customer_date_of_birth').val(data.date_of_birth);

View File

@@ -1,4 +1,4 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code, :membership_id, :membership_type, :membership_authentication_code,
:salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no :salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :tax_profiles
json.url crm_customer_url(@crm_customer, format: :json) json.url crm_customer_url(@crm_customer, format: :json)