+
`;
$('#vehicle_row_div').append(html);
+ appendOwner(client_list);
+ $('#owner').select2();
+ $('#owner_branch').select2();
+
+ $("#vehicle_form_row_div").on("input change", "input, select, textarea", function () {
+ if ($("#client_type").val() === "") {
+ alert("Please select the client type first");
+ if ($(this).is(":checkbox")) {
+ // uncheck checkbox
+ $(this).prop("checked", false);
+ } else {
+ // clear text/select/textarea
+ $(this).val("");
+ }
+ $("#client_type").focus(); // focus back to client_type
+ }
+ });
+
+ $('#owner').change(function(){
+
+ let owner_id = $(this).val();
+ console.log('owner_id', owner_id);
+ if(branch_list != '') {
+ // console.log(branch_list[client_id]);
+ let data = branch_list[owner_id];
+ appendOwnerBranch(data);
+ }
+
+ })
+
}
function appendClientForm(){
@@ -5294,24 +5363,6 @@ function appendClientForm(){
}
}
-$('#client_type').on('change', function() {
-
- let client_type = $(this).val();
-
- if(client_type == 1){
- $('.group_client').show();
- $('.individual_client').hide();
- $(".group_client").find("select, input, textarea").val("").prop("required", true);
- $(".individual_client").find("select, input, textarea").val("").prop("required", false);
- }else{
- $('.group_client').hide();
- $('.individual_client').show();
- $(".group_client").find("select, input, textarea").val("").prop("required", false);
- $(".individual_client").find("select, input, textarea").val("").prop("required", true);
- }
-
-});
-
function validateInputForClient(input, table, field) {
let owner_type = $('#Owner_type').val();
@@ -5351,4 +5402,85 @@ function validateInputForClient(input, table, field) {
$('#hide_smbt_btn button').prop('disabled', false);
}
+$('#client_type').on('change', function() {
+
+ let client_type = $(this).val();
+
+ if(client_type == 1){
+ $('.group_client').show();
+ $('.individual_client').hide();
+ $(".group_client").find("select, input, textarea").val("").prop("required", true);
+ $(".individual_client").find("select, input, textarea").val("").prop("required", false);
+ }else{
+ $('.group_client').hide();
+ $('.individual_client').show();
+ $(".group_client").find("select, input, textarea").val("").prop("required", false);
+ $(".individual_client").find("select, input, textarea").val("").prop("required", true);
+ }
+
+});
+
+$('#client_type').on('change', function() {
+
+ let btn = $("#vehicle_client_btn");
+ let client_type = $(this).val();
+
+ if(client_type == 1){
+
+ if(btn.is(':checked')){
+ $('.v_group_client').show();
+ $('.v_individual_client').hide();
+ $(".v_group_client").find("select, input, textarea").val("").prop("required", true);
+ $(".v_individual_client").find("select, input, textarea").val("").prop("required", false);
+ }else{
+ $('.v_group_client').hide();
+ $('.v_individual_client').hide();
+ $(".v_group_client").find("select, input, textarea").val("").prop("required", false);
+ $(".v_individual_client").find("select, input, textarea").val("").prop("required", false);
+
+ $('.old_group_client').show();
+ $(".old_group_client").find("select, input, textarea").val("").prop("required", true);
+ $(".v_common").find("select, input, textarea").val("").prop("required", false);
+ }
+
+ }else{
+
+ if(btn.is(':checked')){
+ $('.v_group_client').hide();
+ $('.v_individual_client').show();
+ $(".v_group_client").find("select, input, textarea").val("").prop("required", false);
+ $(".v_individual_client").find("select, input, textarea").val("").prop("required", true);
+ }else{
+ $('.v_group_client').hide();
+ $('.v_individual_client').hide();
+ $(".v_group_client").find("select, input, textarea").val("").prop("required", false);
+ $(".v_individual_client").find("select, input, textarea").val("").prop("required", false);
+
+ $('.old_group_client').hide();
+ $(".old_group_client").find("select, input, textarea").val("").prop("required", false);
+ $(".v_common").find("select, input, textarea").val("").prop("required", false);
+
+ }
+ }
+
+ $.each(client_list, function(index, item) {
+ if (item.client_type == client_type) {
+
+ let client_show_name = item.client_name;
+ if (item.client_type == 2) {
+ // client_show_name = item.client_name + ' - ' + (item.dob ?? '') + (item.pan ?? '');
+ client_show_name = item.client_name + (item.dob ? ('- (' + item.dob + ' )' ) : '') + (item.pan ? ('- ' + item.pan ) : '');
+ }
+ var option = $('