
<%= 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 " %>   

<div class="form-group">
  <label> <%= t("views.right_panel.detail.salutation") %> :</label><br>
  <label class="font-15"><%= t("views.right_panel.detail.mr") %>
    <%= f.radio_button :salutation,"Mr", :class => "salutation mr with-gap radio-col-indigo", :value=>"Mr", :style=>"width: 30px"%>
  </label>&nbsp;
  <label class="font-15"><%= t("views.right_panel.detail.miss") %>
    <%= f.radio_button :salutation,"Mrs", :class => "salutation mrs with-gap radio-col-indigo", :value=>"Mrs", :style=>"width: 30px"%>
  </label>&nbsp;
  <label class="font-15"><%= t("views.right_panel.detail.mrs") %>
    <%= f.radio_button :salutation,"Miss", :class => "salutation miss with-gap radio-col-indigo", :value=>"Miss", :style=>"width: 30px"%>
  </label>&nbsp;
  <label class="font-15">
    <%= t("views.right_panel.detail.mdm") %>
    <%= f.radio_button :salutation,"Mdm", :class => "salutation mdm with-gap radio-col-indigo", :value=>"Mdm", :style=>"width: 30px"%>
  </label>   
</div>

<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
  <%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
  <% flash.each do |test, msg| %>
  <% 
  str="[\"#{msg['name']}\"]"
  str.gsub!('["', '')
  str.gsub!('"]', '') %>
  <lable class="error col-red m-t--10" style="margin-top:-6px"><%= str %></lable>
  <% end -%>
</div>

<div class="form-group">
  <label><%= t("views.right_panel.detail.gender") %> :</label><br>
  <label><%= t("views.right_panel.detail.male") %>
  <%= f.radio_button :gender,"Male", :class => "gender male", :value=>"Male", :style=>"width: 30px"%></label>
  <label><%= t("views.right_panel.detail.female") %>
  <%= f.radio_button :gender,"Female", :class => "gender female", :value=>"Female", :style=>"width: 30px"%></label>
</div>

<div class="form-group">
  <%= f.input :nrc_no,:label => "NRC No", :class => "form-control nrc_no" %>
</div>

<div class="form-group">
  <%= f.input :company, :class => "form-control col-md-6 company"%>

  <%  flash.each do |name, msg| %>
  <% str="[\"#{msg['company']}\"]"
  str.gsub!('["', '')
  str.gsub!('"]', '') %>
  <lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
  <% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
  <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%>

  <%  flash.each do |name, msg| %>
  <% str="[\"#{msg['contact_no']}\"]"
  str.gsub!('["', '')
  str.gsub!('"]', '') %>
  <lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
  <% end %>
</div>

<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
  <%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>

  <% flash.each do |name, msg| %>
  <% str="[\"#{msg['email']}\"]"
  str.gsub!('["', '')
  str.gsub!('"]', '') %>
  <lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
  <% end %>
</div>

<div class="form-group">
  <%= f.input :address, :class => "form-control col-md-6 address" %>
</div>

<div class="form-group">
  <label><%= t("views.right_panel.detail.sr_no") %></label>
  <div class="form-line disabled">
    <input type="text" name="" value="<%=@count_customer%>" class="form-control" disabled="" >
  </div>
</div>

<div class="form-group">
  <label><%= t("views.right_panel.detail.date_of_birth") %></label>
  <%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%>
</div> 
   
<div class="form-group">
  <label><%= t("views.right_panel.detail.select_customer_type") %></label>
  <select class="form-control col-md-12 selectpicker  show-tick" id="customer_type" name="customer[customer_type]" style="height: " >
  <%  Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %>
  <option value="<%= ct.value %>">
    <%= ct.name %></option>
    <%end %>
  </select>            
</div>

<div class="form-group">
  <%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true },  :class => "form-control col-md-6 tax_profiles" %>
</div>

<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
  <%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
  <% flash.each do |name, msg| %>
  <% str="[\"#{msg['card_no']}\"]"
  str.gsub!('["', '')
  str.gsub!('"]', '') %>
  <lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
  <% end %>
</div>

<div class="form-group">
  <label><%= t("views.right_panel.detail.paypar_account_no") %>:</label>
  <div class="-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><%= t("views.right_panel.detail.select_membership_group") %></label>
 <select class="form-control col-md-12 selectpicker  show-tick"  name="member_group_id"  style="height: " >
  <option value=""><%= t("views.right_panel.detail.select_membership_group") %></option>
  <%  Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
  <option value="<%= member.value %>">
    <%= member.name %></option>
    <%end %>
  </select>   

</div>
  
<div class="form-group">
  <!-- <%= f.submit "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
  <%= f.submit "Update",:class => 'btn btn-info ', :disabled =>'', :id => 'update_customer' %> -->
  <button type="submit" class="btn btn-primary" id="submit_customer"><%= t("views.btn.submit") %></button>
  <button type="submit" class="btn btn-info" disabled id="update_customer"><%= t("views.btn.update") %></button>
  <button type="button" class="btn btn-danger" id="reset"><%= t("views.btn.reset") %></button>
</div>
<%end%>


<div id="sxModal">
  <div id="sxModal-Content"><h3><%= t :card_tap %></h3></div>
</div>
<!-- The modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="modalLabelLarge" aria-hidden="true">
  <div class="modal-dialog modal-lg" style="margin-left:-380px">
    <div class="modal-content">
      <div class="modal-body">
        <div id="container">
          <video autoplay="true" id="videoElement">

          </video>
        </div>
      </div>

    </div>
  </div>
</div>
<script type="text/javascript">
  $(function() {
// Read Card Reader
    $("#paypar_account_no").on('focus', function(e){               
      if($(this).val() == ''){
        $("#sxModal").show();
        setTimeout(function(){
          getCardNo();
          $("#sxModal").hide();
        },100); 
      }
    });

    // $("#customer_card_no").click(function(){
    //   var ab=$("#customer_tax_profiles").val();
    //   console.log(JSON.stringify(ab));
    // });
  });


  // 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);
      $("#search").val(cardNo);
      $("#type").val("card");
    }
  }
</script>