

<div class="row">
  <div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
    <div class="card">
      <div class="body">
        <%= simple_form_for([:settings, @settings_tax_profile ]) do |f| %>
        <%= f.error_notification %>

        <div class="form-inputs p-l-15">
          <%= f.input :group_type, :collection => Lookup.collection_of("tax_profiles"),:input_html=>{:class=>"col-md-10"},:required=>true %>
          <%= f.input :name, :input_html=>{:onchange=>"checkDuplicate(this.value);"} %>
          <span id="tax_profile_nameErr" style="color:red;"></span>
          <%= f.input :rate %>
          <%= f.input :inclusive %>
          <%= f.input :order_by %>
        </div>

        <div class="form-actions p-l-15">
          <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect btn_submit' %>
        </div>
        <% end %>
      </div>
    </div>
  </div>
  <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
    <div class="card">
      <div class="body">
        <h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
        <p>
        1) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.tax_profiles_txt") %> <%= t("views.right_panel.detail.name_txt2") %> <br>
        2) <%= t("views.right_panel.detail.rate") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.rate_txt") %> <br>
        3) <%= t("views.right_panel.detail.inclusive") %> - <%= t("views.right_panel.detail.checkbox") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.inclusive_txt") %> <br>
        4) <%= t("views.right_panel.detail.order_by") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.order_txt") %> <br>
        </p>
        <h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
        <p>
        1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.tax_profiles_txt") %> <br>
        </p>
        <h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
        <p>
          1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
          2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.tax_profiles_txt") %> <br>
        </p>
      </div>
    </div>  
  </div>
</div>

<script type="text/javascript">
  function checkDuplicate(obj){
    // $("#tax_profile_nameErr").html("");
    var name = '<%= @name %>';
    var tax_profiles = JSON.parse('<%= @tax_profiles.to_json.html_safe %>');
    var group_type = $("#tax_profile_group_type").val();
    if(tax_profiles!=undefined && tax_profiles!=null && tax_profiles!=""){
      $.each(tax_profiles,function(key,value){
        if(value.group_type == group_type){
          if(name.trim().toLowerCase()!=value.name.trim().toLowerCase()){
            if(value.name.trim().toLowerCase() == obj.trim().toLowerCase()){
              $("#tax_profile_name").val("");
              $("#tax_profile_nameErr").html("duplicate group type and name");
            }
          }
          return;
        }
      });
    }
  }
</script>

