add paypar acc for nfc

This commit is contained in:
Yan
2017-07-16 18:16:52 +06:30
parent 7a036b8c0a
commit b2ccc12e17
12 changed files with 148 additions and 11 deletions

View File

@@ -52,4 +52,33 @@
@include media-breakpoint-only(xl) {
column-count: 5;
}
}
#sxModal {
display: none;
overflow: auto;
width: 100%;
height: 100%;
background-color: #000;
background-color: rgba(0,0,0,0.4);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1100;
}
#sxModal-Content {
position: relative;
left: 42%;
top: 30%;
background-color: #d9534f;
color: #fff;
text-align: center;
width: 200px;
height: 200px;
padding-top: 5%;
border-radius: 100px;
z-index: 1101;
}

View File

@@ -24,4 +24,4 @@
width: 49%;
font-size: 18px;
margin: 0px 0px 5px 0px;
}
}

View File

@@ -211,3 +211,32 @@ tr.discount-item-row:hover {
margin-left:-40px !important;
margin-top:-40px !important;
}
#sxModal {
display: none;
overflow: auto;
width: 100%;
height: 100%;
background-color: #000;
background-color: rgba(0,0,0,0.4);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1100;
}
#sxModal-Content {
position: relative;
left: 42%;
top: 30%;
background-color: #d9534f;
color: #fff;
text-align: center;
width: 200px;
height: 200px;
padding-top: 5%;
border-radius: 100px;
z-index: 1101;
}

View File

@@ -81,6 +81,7 @@ class Crm::CustomersController < BaseCrmController
address = customer_params[:address]
nrc = customer_params[:nrc_no]
card_no = customer_params[:card_no]
paypar_account_no = customer_params[:paypar_account_no]
member_group_id = params[:member_group_id]
if member_group_id.present?
@@ -95,6 +96,7 @@ class Crm::CustomersController < BaseCrmController
response = HTTParty.post(url,
:body => {name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
paypar_account_no: paypar_account_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
@@ -172,6 +174,7 @@ end
address = customer_params[:address]
nrc = customer_params[:nrc_no]
card_no = customer_params[:card_no]
paypar_account_no = customer_params[:paypar_account_no]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
@@ -187,6 +190,7 @@ end
response = HTTParty.post(url,
:body => { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,
paypar_account_no: paypar_account_no,
card_no:card_no,member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
@@ -231,6 +235,7 @@ end
response = HTTParty.post(url,
:body => {name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
paypar_account_no: paypar_account_no,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
@@ -287,6 +292,6 @@ end
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email,
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no)
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no)
end
end

View File

@@ -84,7 +84,7 @@ class HomeController < ApplicationController
if !shift.nil?
redirect_to origami_root_path
else
redirect_to dashboard_path
redirect_to crm_customers_path
end
elsif employee.role == "cashier"
#check if cashier has existing open cashier

View File

@@ -10,6 +10,7 @@ class Customer < ApplicationRecord
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
validates :card_no, uniqueness: true
validates :paypar_account_no, uniqueness: true
paginates_per 50

View File

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

View File

@@ -1,7 +1,5 @@
<div class="col-lg-4 col-md-4 col-sm-4" style="min-height:600px; max-height:600px; overflow-x:scroll">
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
@@ -15,6 +13,14 @@
<% end -%>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group">
<label>Salutation :</label><br>
<label>Mr</label>
@@ -107,11 +113,40 @@
</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 :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
</div>
<%end%>
</div>
</div>
<div id="sxModal">
<div id="sxModal-Content"><h3>Card Tap</h3></div>
</div>
<script type="text/javascript">
$(function() {
// Read Card Reader
$("#paypar_account_no").on('focus', function(e){
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
},100);
});
});
// Read NFC card no from java
function getCardNo(){
code2lab.readNFC();
}
// get CardNo from Java
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
}
}
</script>

View File

@@ -119,7 +119,7 @@ $(document).on('click',".customer_tr",function(){
url: url,
data: {},
dataType: "json",
success: function(data) {
success: function(data) {
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
@@ -128,6 +128,7 @@ $(document).on('click',".customer_tr",function(){
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no);
$('#paypar_account_no').val(data.paypar_account_no);
$('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type);

View File

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

View File

@@ -34,6 +34,7 @@
<th>Company</th>
<th>Contact no</th>
<th>Email</th>
<!-- <th>Paypar No</th> -->
</tr>
</thead>
@@ -54,7 +55,7 @@
<td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td>
<!-- <td><%= crm_customer.paypar_account_no %></td> -->
</tr>
<% end %>
@@ -89,6 +90,14 @@
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-group">
<%= #f.input :paypar_account_no, :id => "paypar_account_no", :class => "form-control" %>
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group">
<label>Salutation :</label><br>
<label>Mr</label>
@@ -192,6 +201,10 @@
</div>
</div>
<div id="sxModal">
<div id="sxModal-Content"><h3>Card Tap</h3></div>
</div>
<script type="text/javascript">
$(function() {
$('.datepicker').datepicker({
@@ -201,8 +214,30 @@
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
// Read Card Reader
$("#paypar_account_no").on('focus', function(e){
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
},100);
});
});
// Read NFC card no from java
function getCardNo(){
code2lab.readNFC();
}
// get CardNo from Java
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
}
}
$(document).on('click',".customer_tr",function(){
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
@@ -235,6 +270,7 @@
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#paypar_account_no').val(data.paypar_account_no);
if (data.gender == 'Male') {
$('.male').prop( "checked", true )

View File

@@ -12,6 +12,7 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
t.string :nrc_no
t.string :address
t.string :card_no, :unique => true
t.string :paypar_account_no, :unique => true
t.string :membership_id
t.string :membership_type
t.string :membership_authentication_code