|
|
|
|
@ -10,27 +10,40 @@ |
|
|
|
|
formCssClass: 'dynamic-form', |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var get_pair = function(model, class1, class2, param1, param2) { |
|
|
|
|
$('body').on('selectChoice change', '.' + class1 + ' input', function() { |
|
|
|
|
var $this = $(this); |
|
|
|
|
var this_val = $this.val(); |
|
|
|
|
var $other_input = $this.closest('.row_tbl_items').find('.' + class2 + ' input'); |
|
|
|
|
// units |
|
|
|
|
$('body').on('selectChoice change', '.units input', function(e, choice, autocomplete) { |
|
|
|
|
var name_input = $(this); |
|
|
|
|
var code_input = name_input.closest('.row_tbl_items').find('.units_kod input'); |
|
|
|
|
|
|
|
|
|
$.get('/my/docs/ajax_get_pair/' + model + '/' + param1 + '/' + param2 + '/' + this_val + '/', function(data) { |
|
|
|
|
if (data['val']) { |
|
|
|
|
$other_input.val(data['val']); |
|
|
|
|
$this.css('color', 'black') |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
$other_input.val('-'); |
|
|
|
|
$this.css('color', 'red') |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
{# model должна быть разрешена в docs.views.get_pair #} |
|
|
|
|
get_pair('Country', 'country_name', 'country_code', 'name', 'code'); |
|
|
|
|
get_pair('Measure', 'units', 'units_kod', 'name', 'code'); |
|
|
|
|
if (choice) { |
|
|
|
|
//console.log(choice.data()); |
|
|
|
|
name_input.val(choice.data('name')); // short name |
|
|
|
|
code_input.val(choice.data('code')); |
|
|
|
|
name_input.css('color', 'black') |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
//console.log(choice, 'No choice!'); |
|
|
|
|
code_input.val('-'); |
|
|
|
|
name_input.css('color', 'red') |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// country |
|
|
|
|
$('body').on('selectChoice change', '.country_name input', function(e, choice, autocomplete) { |
|
|
|
|
var name_input = $(this); |
|
|
|
|
var code_input = name_input.closest('.row_tbl_items').find('.country_code input'); |
|
|
|
|
|
|
|
|
|
if (choice) { |
|
|
|
|
//console.log(choice.data()); |
|
|
|
|
code_input.val(choice.data('code')); |
|
|
|
|
name_input.css('color', 'black') |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
//console.log(choice, 'No choice!'); |
|
|
|
|
code_input.val('-'); |
|
|
|
|
name_input.css('color', 'red') |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#id_client').on('change', function() { |
|
|
|
|
var client_id = $(this).val(); |
|
|
|
|
@ -50,7 +63,7 @@ |
|
|
|
|
}); |
|
|
|
|
select.prop('selectedIndex', 0); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#id_invoice').on('change', function() { |
|
|
|
|
var invoice_id = $(this).val(); |
|
|
|
|
|