finished customer form and update

This commit is contained in:
Aung Myo
2017-06-20 17:57:50 +06:30
parent faae996d5d
commit 33cb8b64a3
13 changed files with 235 additions and 84 deletions

View File

@@ -1 +1,3 @@
json.array! @customers, :id, :name, :company, :contact_no, :email, :membership_id, :membership_type
json.array! @customers, :id, :name, :company, :contact_no,:salution,
:gender,:nrc_no,:address,:card_no, :membership_type,
:membership_id, :created_at

View File

@@ -1,4 +1,6 @@
json.extract! @customer, :id, :name, :company, :contact_no, :membership_type, :membership_id, :created_at
json.extract! @customer, :id, :name, :company, :contact_no,:salution,
:gender,:nrc_no,:address,:card_no, :membership_type,
:membership_id, :created_at
json.invoices do
json.array! @customer.lastest_invoices ,:id, :receipt_no, :receipt_date, :sale_status, :payment_status
end

View File

@@ -34,6 +34,7 @@
</tr>
<tr>
<th>Select</th>
<th>Sr.no</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
@@ -43,11 +44,13 @@
<tbody>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td><%= @i += 1 %></td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.contact_no %></td>
@@ -75,32 +78,89 @@
<span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<label>Salutation :</label><br>
<label>
<input type="radio" value="Mr" name="salutation" class="salutation mr" style="width: 30px">Mr
</label>
<label>
<input type="radio" value="Miss" name="salutation" class="salutation miss" style="width: 30px">Miss
</label>
<label>
<input type="radio" value="Mrs" name="salutation" class="salutation mrs" style="width: 30px">Mrs
</label>
<label>
<input type="radio" value="Mdm" name="salutation" class="salutation mdm" style="width: 30px">Mdm
</label>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name" %>
<%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['name'] %></span>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %>
<label>Gender :</label><br>
<label>
<input type="radio" value="Male" name="gender" class="gender male" style="width:30px;">Male
</label>
<label>
<input type="radio" value="Female" name="gender" class="gender female" style="width:30px;">Female
</label>
</div>
<div class="form-group">
<%= f.input :nrc_no, :class => "form-control nrc_no" %>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company",:required => true%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['company']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['contact_no'] %></span>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :email, :class => "form-control col-md-6 email" %>
<%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['email'] %></span>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :address, :class => "form-control col-md-6 address" %>
</div>
<div class="form-group">
<label>Sr.No</label>
<input type="text" name="" value="<%=@count_customer%>" class="form-control" readonly="true">
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
@@ -137,12 +197,12 @@
<script type="text/javascript">
$(function() {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
});
$(document).on('click',".customer_tr",function(){
@@ -171,8 +231,27 @@ $(function() {
$('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email);
$('#customer_salution').val(data.salution);
$('#customer_nrc_no').val(data.nrc_no);
$('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type);
if (data.gender == 'Male') {
$('.male').prop( "checked", true )
}else{
$('.female').prop( "checked", true )
}
if(data.salution == 'Mr') {
$('.mr').prop( "checked", true )
}else if(data.salution == 'Miss') {
$('.miss').prop( "checked", true )
}else if(data.salution == 'Mrs'){
$('.mrs').prop( "checked", true )
}else{
$('.mdm').prop( "checked", true )
}
// $('.selectpicker > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);

View File

@@ -1,2 +1,5 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, :created_at, :updated_at
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code,
:created_at, :updated_at,
:salution, :gender,:nrc_no,:address,:card_no
json.url crm_customer_url(@crm_customer, format: :json)

View File

@@ -35,6 +35,7 @@
</tr>
<tr>
<th>Select</th>
<th>Sr.no</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
@@ -44,11 +45,13 @@
<tbody>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td><%= @i += 1 %></td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.contact_no %></td>
@@ -79,31 +82,86 @@
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<label>Salutation :</label><br>
<label>
<input type="radio" value="Mr" name="salutation" class="salutation mr" style="width: 30px">Mr
</label>
<label>
<input type="radio" value="Miss" name="salutation" class="salutation miss" style="width: 30px">Miss
</label>
<label>
<input type="radio" value="Mrs" name="salutation" class="salutation mrs" style="width: 30px">Mrs
</label>
<label>
<input type="radio" value="Mdm" name="salutation" class="salutation mdm" style="width: 30px">Mdm
</label>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name" %>
<%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['name'] %></span>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Gender :</label><br>
<label>
<input type="radio" value="Male" name="gender" class="gender male" style="width:30px;">Male
</label>
<label>
<input type="radio" value="Female" name="gender" class="gender female" style="width:30px;">Female
</label>
</div>
<div class="form-group">
<%= f.input :nrc_no, :class => "form-control nrc_no" %>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %>
<%= f.input :company, :class => "form-control col-md-6 company",:required => true%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['company']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['contact_no'] %></span>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :email, :class => "form-control col-md-6 email" %>
<%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['email'] %></span>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :address, :class => "form-control col-md-6 address" %>
</div>
<div class="form-group">
<label>Sr.No</label>
<input type="text" name="" value="<%=@count_customer%>" class="form-control" readonly="true">
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
@@ -176,6 +234,25 @@
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#customer_salution').val(data.salution);
$('#customer_nrc_no').val(data.nrc_no);
if (data.gender == 'Male') {
$('.male').prop( "checked", true )
}else{
$('.female').prop( "checked", true )
}
if (data.salution == 'Mr') {
$('.mr').prop( "checked", true )
} else if(data.salution == 'Miss') {
$('.miss').prop( "checked", true )
}else if(data.salution == 'Mrs'){
$('.mrs').prop( "checked", true )
}else{
$('.mdm').prop( "checked", true )
}
$('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled');

View File

@@ -30,7 +30,9 @@
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<th style='text-align:center;'>CT</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
@@ -48,7 +50,10 @@
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_tax.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>

View File

@@ -66,7 +66,7 @@
<td><%= @sale.receipt_no %></td>
<td><%= @sale.cashier_name rescue '-' %></td>
<td> <%= @sale.sale_status %> </td>
<td> <%= @sale.requested_at %> </td>
<td> <%= @sale.requested_at.strftime("%m-%d-%Y %H:%M %p") %> </td>
</tr>
<tr style="border-top:2px solid #000">
<th>Sale item name</th>