Files
Learning-Hub/webroot/js/client_form.js
2026-06-29 14:51:56 +06:00

116 lines
4.6 KiB
JavaScript

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$('#client-address').on('change keyup input', function () {
$('#client-credit-bureau-address').val($(this).val())
})
$('#contact-first-name, #contact-edit-first-name, #creditreport-first-name').on('change keyup input', function () {
$('#client-portal-sincerely,#client-name,input[name="creditreport[sincerely]"]').val($.trim($(this).val() + " " + $('#contact-last-name,#contact-edit-last-name,input[name="creditreport[last_name]"]').val()));
if ($('input[name=is_client_portal]').prop('checked')) {
$('#client-sincerely').val($.trim($(this).val() + " " + $('#contact-last-name').val()));
}
})
$('#contact-last-name, #contact-edit-last-name,input[name="creditreport[last_name]"]').on('change keyup input', function () {
$('#client-portal-sincerely,#client-name, input[name="creditreport[sincerely]"]').val($.trim($('#contact-first-name,#contact-edit-first-name,#creditreport-first-name').val() + " " + $(this).val()));
if ($('input[name=is_client_portal]').prop('checked')) {
$('#client-sincerely').val($.trim($('#contact-first-name').val() + " " + $(this).val()));
}
})
$('#client-street-no,#contact-street-no').on('change keyup input', function () {
$('#client-portal-street-no').val($.trim($(this).val()));
if ($('input[name=is_client_portal]').prop('checked')) {
$('#client-street-no').val($.trim($(this).val()));
}
})
$('#client-street-name,#contact-street-name').on('change keyup input', function () {
$('#client-portal-street-name').val($.trim($(this).val()));
if ($('input[name=is_client_portal]').prop('checked')) {
$('#client-street-name').val($.trim($(this).val()));
}
});
function comapnychange(elem,set_value_tag = "") {
$('#company-link').hide();
var credit_report_company_name = REPORT_SOURCE_TYPES[$(elem).val()];
var credit_report_company_tag = $('input[name="client_portal[credit_report_company_name]"]')
if(set_value_tag){
credit_report_company_tag = $(set_value_tag)
}
credit_report_company_tag.val(credit_report_company_name);
if ($(elem).val() == 1) {
var link = 'Please click <a target="_blank" href="' + identity_iq_link + '">here</a> to get user/pass';
$('#company-link').html(link);
$('#company-link').show();
} else if ($(elem).val() == 2) {
var link = 'Please click <a target="_blank" href="' + privacy_guard_link + '">here</a> to get user/pass';
$('#company-link').html(link);
$('#company-link').show();
} else if ($(elem).val() == 3) {
var link = 'Please click <a target="_blank" href="' + smart_credit_link + '">here</a> to get user/pass';
$('#company-link').html(link);
$('#company-link').show();
}
}
function showPlainPassword(elem,input_tag = ""){
var selector = $(elem).children('i');
selector.toggleClass("fa-eye fa-eye-slash");
var input = $('input[name="creditreport[credit_report_company_password]"]');
if(input_tag){
input = $(input_tag);
}
if (input.attr("type") == "password") {
input.attr("type", "text");
} else {
input.attr("type", "password");
}
}
function copyCompanyPassword(elem,input_tag = ""){
event.preventDefault();
var input = $('input[name="creditreport[credit_report_company_password]"]');
if(input_tag){
input = $(input_tag);
}
var text = input.val();
var el = $(elem);
copyToClipboard(text, el);
}
function copyToClipboard(text, el) {
var copyTest = document.queryCommandSupported('copy');
var elOriginalText = el.attr('data-original-title');
if (copyTest === true) {
var copyTextArea = document.createElement("textarea");
copyTextArea.value = text;
document.body.appendChild(copyTextArea);
copyTextArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'Copied!' : 'Whoops, not copied!';
el.attr('data-original-title', msg).tooltip('show');
} catch (err) {
console.log('Oops, unable to copy');
}
document.body.removeChild(copyTextArea);
el.attr('data-original-title', elOriginalText);
} else {
// Fallback if browser doesn't support .execCommand('copy')
window.prompt("Copy to clipboard: Ctrl+C or Command+C, Enter", text);
}
}