add customer type and tax profile in customer
This commit is contained in:
@@ -70,6 +70,8 @@ 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|
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -130,6 +130,13 @@ $(document).on('click',".customer_tr",function(){
|
|||||||
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);
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user