Browse Source

Sale form: add condition to disabled the action on type sale click. there was apparently disabled, but the action occurs

Nadia Lizeth 9 năm trước cách đây
mục cha
commit
57cc0503e0
1 tập tin đã thay đổi với 17 bổ sung16 xóa
  1. 17 16
      app/views/sales/_form.html.erb

+ 17 - 16
app/views/sales/_form.html.erb

@@ -292,24 +292,25 @@
 		});
 
 		$('input:radio[name=types]').change(function() {
-			<% if @pre_sales.count == 0 %>
-				if (!$(this).closest('label').hasClass('disabled')) {
-					$('#sale_saletype').val($(this).val());
-				} else {
-					var type = $('#sale_saletype').val();
+			if (!$(this).closest('label').hasClass('disabled')) {
+				<% if @pre_sales.count == 0 %>
+					if (!$(this).closest('label').hasClass('disabled')) {
+						$('#sale_saletype').val($(this).val());
+					} else {
+						var type = $('#sale_saletype').val();
+						$(":radio[value=" + type + "]").closest('label').addClass('active');
+					}
+				<% else %>
+					var type  = '<%= @sale.saletype %>';
 					$(":radio[value=" + type + "]").closest('label').addClass('active');
+				<% end %>
+				//Si es tipo crédito, aparecer input de vale
+				if ($(this).val() == 'credit') {
+					$('#credit_note_div').removeClass('hidden');
+				} else {
+					$('#credit_note_div').addClass('hidden');
+					$('#sale_credit_note').val('');
 				}
-			<% else %>
-				var type  = '<%= @sale.saletype %>';
-				$(":radio[value=" + type + "]").closest('label').addClass('active');
-			<% end %>
-
-			//Si es tipo credito, aparecer input de vale
-			if ($(this).val() == 'credit') {
-				$('#credit_note_div').removeClass('hidden');
-			} else {
-				$('#credit_note_div').addClass('hidden');
-				$('#sale_credit_note').val('');
 			}
 		});