FIX_RTO Details in Policy

This commit is contained in:
venba-Inspriron-3558 2025-10-14 17:10:23 +05:30
parent fb2bf1fb56
commit 2dd0fe7a07
4 changed files with 49 additions and 0 deletions

View File

@ -4816,6 +4816,7 @@ class ClientController extends AdminController
'vehicle_no' => $data['vehicle_no'],
'type' => $data['type'],
'rc' => $data['rc'],
'rto_id' => $data['rto_id'],
'branch_id' => $branch_insert,
'owner' => $client_insert,
];
@ -4861,6 +4862,7 @@ class ClientController extends AdminController
'vehicle_no' => $data['vehicle_no'],
'type' => $data['type'],
'rc' => $data['rc'],
'rto_id' => $data['rto_id'],
'branch_id' => $data['branch_id'] ?? null,
'owner' => $data['owner'],
];

View File

@ -151,6 +151,8 @@ class PolicyTransactionController extends BaseController
// 'bicycle' => 'Bicycle'
// ];
$data['vehicle_type'] = db_connect()->table('vehicle_type')->where('is_active', 1)->get()->getResultArray();
$data['rto_details'] = db_connect()->table('rto_master')->where('is_active', 1)->get()->getResultArray();
$data['vehicle_des'] = [
'commercial' => 'Commercial',
'private' => 'Private',

View File

@ -25,6 +25,7 @@ class VehicleModel extends Model
'is_active',
'created_by',
'updated_by',
'rto_id',
];

View File

@ -5640,6 +5640,20 @@
</div>
</div>
<div class="form-group col-md-3">
<label for="rto_id">RTO</label>
<select class="form-control readonly-color readonly-select" id="rto_id" name="rto_id" style="appearance:none;-webkit-appearance:none;-moz-appearance:none;cursor:not-allowed;">
<option value=""></option>
<?php
if (isset($rto_details) && count($rto_details)) {
foreach ($rto_details as $key => $value) {
echo '<option value="' . $value['id'] . '" data-state="' . $value['rto_state'] . '" data-code="' . $value['rto_code'] . '">' . $value['rto_name'] . '</option>';
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="rc">Chassis No</label>
<input type="text" class="form-control" id="rc" name="rc"
@ -6008,6 +6022,9 @@
// resultDiv.classList.add('show');
$('#vehicle_no_validation').val('1');
}
// call here
autoFetchRtoName(input);
}
// Custom Parsley validator for vehicle format
@ -6338,5 +6355,32 @@
console.log("✅ total[] changed:", val);
});
function autoFetchRtoName(val) {
console.log(`i am here ${val}`);
val = val.toUpperCase().trim();
let stateCode = val.slice(0, 2); // 1st 2 here i am split the state code
let numberCode = val.slice(2, 4); // 2nd 2 here i am split the number code
console.log(`Ln ST: ${stateCode} | NC: ${numberCode}`);
let matched = false;
$('#rto_id option').each(function() {
let optionState = $(this).attr('data-state');
let optionCode = $(this).attr('data-code');
console.log(`Ln optionState : ${optionState} | optionCode : ${optionCode}`);
if (stateCode === optionState && numberCode === optionCode) {
$('#rto_id').val($(this).val()).trigger('change'); // ✅ select it
matched = true;
return false; // break the loop
}
});
if (!matched) {
$('#rto_id').val('').trigger('change'); // reset select
}
}
</script>