tax profiles

This commit is contained in:
phyusin
2018-03-16 17:21:55 +06:30
parent acc5d737fa
commit b16483708a
4 changed files with 59 additions and 7 deletions

View File

@@ -9,14 +9,15 @@
<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 %>
<%= 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' %>
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect btn_submit' %>
</div>
<% end %>
</div>
@@ -46,5 +47,25 @@
</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>