0){
if(moment(installment_date,momentSqlDateFormat).isBefore(moment(global.general.installment_json[global.general.installment_json.length-1].DATEOFPAYMENT,momentSqlDateFormat)) || moment(installment_date,momentSqlDateFormat).isSame(moment(global.general.installment_json[global.general.installment_json.length-1].DATEOFPAYMENT,momentSqlDateFormat)) ){
global.general.installment_json = [];
}else if(moment(installment_date,momentSqlDateFormat).isAfter(moment(global.general.installment_json[global.general.installment_json.length-1].DATEOFPAYMENT,momentSqlDateFormat)) ){
calculate_subtype = "append";
}
}
installment_count = installment_no_of_repayment;
if(calculator_type == "repayment")
installment_count += 1;
}
var remainamount = installment_proposal_amount;
// var installment_json = [];
// global.general.installment_json = [];
var temp_counter = 0;
if(calculate_subtype == "new"){
temp_counter = 0;
}else if(calculate_subtype == "append"){
temp_counter = global.general.installment_json.length;
remainamount = global.general.installment_json[global.general.installment_json.length-1].ESTBALANCE;
}
var repayment_each_amount = 0;
var repayment_start_amount = 0;
if(calculator_type == "repayment"){
repayment_each_amount = getDecimal(
Decimal(
getDecimal(installment_proposal_amount)
).minus(
Decimal(
getDecimal(
installment_amount
)
)
).dividedBy(installment_no_of_repayment).ceil().toString()
);
}
for (var i = 0; i < installment_count; i++) {
if(remainamount <= 0){
break;
}
var target_installment_amount = installment_amount;
if(calculator_type == "repayment"){
if(i == 0){
target_installment_amount = installment_amount;
}else{
if(i == 1)
installment_date = installment_first_payment_date;
target_installment_amount = repayment_each_amount;
}
}
var thisamount = 0;
if(remainamount >= target_installment_amount){
// remainamount -= target_installment_amount;
remainamount = getDecimal( Decimal(getDecimal(remainamount)).minus(Decimal(getDecimal(target_installment_amount))).toString() ) ;
thisamount = target_installment_amount;
}else{
thisamount = remainamount;
remainamount = 0;
}
temp_counter++;
debtor_detail_installment_calculator_preview_tr_var.index = temp_counter;
debtor_detail_installment_calculator_preview_tr_var.date = moment(installment_date,momentSqlDateFormat).format(momentDateFormat);
debtor_detail_installment_calculator_preview_tr_var.amount = thisamount;
debtor_detail_installment_calculator_preview_tr_var.balance = remainamount;
installment_preview_data += debtor_detail_installment_calculator_preview_tr(debtor_detail_installment_calculator_preview_tr_var);
// installment_json.push({ "SNO": i+1, "DATEOFPAYMENT": moment(installment_date).format(momentSqlDateFormat), "AMOUNT": thisamount, "ESTBALANCE": remainamount });
global.general.installment_json.push({ "SNO": temp_counter, "DATEOFPAYMENT": moment(installment_date).format(momentSqlDateFormat), "AMOUNT": thisamount, "ESTBALANCE": remainamount });
if(recurring_period == "0"){
installment_date = moment(installment_date).add(1, 'months').format(momentSqlDateFormat);
if(lastdayofmonth)
installment_date = moment(installment_date).endOf('month').format(momentSqlDateFormat);
}else if(recurring_period == "1"){
installment_date = moment(installment_date).add(2, 'weeks').format(momentSqlDateFormat);
}else if(recurring_period == "2"){
installment_date = moment(installment_date).add(1, 'weeks').format(momentSqlDateFormat);
}
}
if(subaction == ""){
$('#'+uid+" .debtor_detail_installment_calculator_installment_request").removeClass('hideMe');
if(calculate_subtype == "new"){
$('#'+uid+" .debtor_detail_installment_calculator_preview_tbody").html(installment_preview_data);
}else{
$('#'+uid+" .debtor_detail_installment_calculator_preview_tbody").append(installment_preview_data);
}
}else if(subaction == "jsononly"){
// return installment_json;
// return global.general.installment_json;
}
}
function validateInstallmentCalculator(uid){
var error = false;
var calculator_type = $('#'+uid+' .debtor_detail_installment_calculator_type').is(":checked") ? "auto":"manual";
var installment_date = moment($('#'+uid+' .debtor_detail_installment_calculator_first_installment_date').val(),momentDateFormat).format(momentSqlDateFormat);
var installment_amount = $('#'+uid+' .debtor_detail_installment_calculator_installment_amount').maskMoney('unmasked')[0];
var installment_no_of_repayment = $('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').val();
var installment_internal = $('#'+uid+' .debtor_detail_installment_calculator_internal').is(":checked");
if(enable_debtor_installment_weekly){
calculator_type = $('#'+ uid+' input:radio.debtor_detail_installment_repayment_calculator_type:checked').val();
switch(calculator_type){
case '1':
calculator_type = "manual";
break;
case '2':
calculator_type = "auto";
break;
case '3':
calculator_type = "repayment";
break;
default:
calculator_type = "manual";
break;
}
}
if($('#'+uid+' .debtor_detail_installment_calculator_installment_preview').is(':visible')){
if($('#'+uid+' .debtor_detail_installment_calculator_first_installment_date').val() == ""){
$('#'+uid+' .debtor_detail_installment_calculator_first_installment_date').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .debtor_detail_installment_calculator_first_installment_date').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_installment_calculator_installment_amount').maskMoney('unmasked')[0] == "" && $('#'+uid+' .debtor_detail_installment_calculator_installment_amount').maskMoney('unmasked')[0] <= 0){
$('#'+uid+' .debtor_detail_installment_calculator_installment_amount').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .debtor_detail_installment_calculator_installment_amount').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').maskMoney('unmasked')[0] == "" && $('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').maskMoney('unmasked')[0] <= 0){
$('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').removeClass('is-invalid');
}
if(calculator_type == "manual" || calculator_type == "repayment"){
$('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').val($('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').val().replace(/[^0-9]/g, ''));
$('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').val($('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').val().replace(/^0+/, ''));
if($('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').val() == ""){
$('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').removeClass('is-invalid');
}
}
}
if($('#'+uid+' .debtor_detail_installment_calculator_offer_date').val() == "" && !enable_debtor_installment_weekly){
$('#'+uid+' .debtor_detail_installment_calculator_offer_date').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .debtor_detail_installment_calculator_offer_date').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_installment_calculator_offer_refno').val() == "" && !enable_debtor_installment_weekly){
$('#'+uid+' .debtor_detail_installment_calculator_offer_refno').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .debtor_detail_installment_calculator_offer_refno').removeClass('is-invalid');
}
if(enable_debtor_installment_weekly){
if($('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').maskMoney('unmasked')[0] != ""){
var discount_processed = false;
var proposed_amount = $('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').maskMoney('unmasked')[0];
if(!$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').prop('disabled')){
if($('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').maskMoney('unmasked')[0] != '0'){
var discount_percentage = $('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').maskMoney('unmasked')[0];
var final_discount_amount = getDecimal(Decimal(getDecimal(proposed_amount)).times(Decimal(getDecimal(discount_percentage)).dividedBy(100)).toString());
var final_offer_amount = getDecimal(Decimal(getDecimal(proposed_amount)).minus(Decimal(getDecimal(final_discount_amount))).toString());
$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').maskMoney('mask',final_discount_amount);
$('#'+uid+' .debtor_detail_installment_calculator_offer_amount').maskMoney('mask',final_offer_amount);
$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').prop('disabled',true);
discount_processed = true;
}else{
if($('#'+uid+' .debtor_detail_installment_calculator_discount_amount').prop('disabled')){
$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').prop('disabled',false);
$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').maskMoney('mask',0.00);
$('#'+uid+' .debtor_detail_installment_calculator_offer_amount').maskMoney('mask',proposed_amount);
}
}
}
if(!discount_processed){
if(!$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').prop('disabled')){
if($('#'+uid+' .debtor_detail_installment_calculator_discount_amount').maskMoney('unmasked')[0] != '0'){
var discount_value = $('#'+uid+' .debtor_detail_installment_calculator_discount_amount').maskMoney('unmasked')[0];
var final_discount_percentage = getDecimal(Decimal(getDecimal(discount_value)).dividedBy(Decimal(getDecimal(proposed_amount))).times(100).toString());
var final_offer_amount = getDecimal(Decimal(getDecimal(proposed_amount)).minus(Decimal(getDecimal(discount_value))).toString());
$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').maskMoney('mask',final_discount_percentage);
$('#'+uid+' .debtor_detail_installment_calculator_offer_amount').maskMoney('mask',final_offer_amount);
$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').prop('disabled',true);
discount_processed = true;
}else{
if($('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').prop('disabled')){
$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').prop('disabled',false);
$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').maskMoney('mask',0.00);
}
}
}
}
if(!discount_processed){
$('#'+uid+' .debtor_detail_installment_calculator_offer_amount').maskMoney('mask',proposed_amount);
}else{
}
}else{
$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').prop('disabled',false);
$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').maskMoney('mask',0.00);
$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').prop('disabled',false);
$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').maskMoney('mask',0.00);
$('#'+uid+' .debtor_detail_installment_calculator_offer_amount').maskMoney('mask',0.00);
}
if($('#'+uid+' .debtor_detail_installment_calculator_repayment_date').val() == "" && calculator_type == "repayment"){
$('#'+uid+' .debtor_detail_installment_calculator_repayment_date').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .debtor_detail_installment_calculator_repayment_date').removeClass('is-invalid');
}
}
if(error){
if($('#'+uid+' .debtor_detail_installment_calculator_installment_preview').is(':visible')){
$("#"+uid+" .debtor_detail_installment_calculator_installment_preview").prop('disabled',true);
$("#"+uid+" .debtor_detail_installment_calculator_installment_request").prop('disabled',true);
}else{
$("#"+uid+" .debtor_detail_installment_calculator_approve").prop('disabled',true);
}
}else{
if($('#'+uid+' .debtor_detail_installment_calculator_installment_preview').is(':visible')){
$("#"+uid+" .debtor_detail_installment_calculator_installment_preview").prop('disabled',false);
$("#"+uid+" .debtor_detail_installment_calculator_installment_request").prop('disabled',false);
}else{
$("#"+uid+" .debtor_detail_installment_calculator_approve").prop('disabled',false);
}
}
}
function resetInstallmentCalculator(uid){
if(enable_debtor_installment_weekly){
$('#'+uid+" input:radio.debtor_detail_installment_repayment_calculator_type[value='1']").click();
$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').maskMoney('mask',0.00);
$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').maskMoney('mask',0.00);
$('#'+uid+' .debtor_detail_installment_calculator_recurring_period').val('0');
$('#'+uid+' .debtor_detail_installment_calculator_repayment_date').val('');
$('#'+uid +'_DebtorPage-content .debtor_detail_installment_calculator_cancel').addClass('hideMe');
}
$('#'+uid+' .debtor_detail_installment_calculator_type').bootstrapToggle('off');
$('#'+uid+' .debtor_detail_installment_calculator_internal').bootstrapToggle('off');
$('#'+uid+' .debtor_detail_installment_calculator_first_installment_date').val('');
$('#'+uid+' .debtor_detail_installment_calculator_installment_amount').val('');
$('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').val('');
$('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').val('');
$('#'+uid+' .debtor_detail_installment_calculator_offer_date').val('');
$('#'+uid+' .debtor_detail_installment_calculator_installment_note').val('');
$('#'+uid+' .debtor_detail_installment_calculator_offer_refno').val('');
$("#"+uid+" .debtor_detail_installment_calculator_installment_request").addClass('hideMe');
$("#"+uid+" .debtor_detail_installment_calculator_supervisor").addClass('hideMe');
$('#'+uid+' .debtor_detail_installment_calculator_installment_preview').removeClass('hideMe');
$('#'+uid+" .debtor_detail_installment_calculator_preview_tbody").html('');
$("#"+uid+" .debtor_detail_installment_calculator_installment_reset").attr('volare-flagextension','');
disableInstallmentCalculator(uid,"",false);
validateInstallmentCalculator(uid);
}
function disableInstallmentCalculator(uid,has_extension = "",disabled = true){
$('#'+uid+' .debtor_detail_installment_calculator_type').prop('disabled',disabled);
if(enable_debtor_installment_weekly){
$('#'+uid+' .debtor_detail_installment_repayment_calculator_type').prop('disabled',disabled);
if(!disabled){
$('#'+uid+" input:radio.debtor_detail_installment_repayment_calculator_type[value='1']").click();
}
$('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_discount_amount').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_recurring_period').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_repayment_date').prop('disabled',disabled);
}
$('#'+uid+' .debtor_detail_installment_calculator_internal').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_first_installment_date').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_installment_amount').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_installment_note').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_offer_date').prop('disabled',disabled);
$('#'+uid+' .debtor_detail_installment_calculator_offer_refno').prop('disabled',disabled);
if(has_extension == "2"){
$('#'+uid+' .debtor_detail_installment_calculator_offer_date').prop('disabled',false);
$('#'+uid+' .debtor_detail_installment_calculator_offer_refno').prop('disabled',false);
$('#'+uid+' .debtor_detail_installment_calculator_installment_note').prop('disabled',false);
$('#'+uid+' .debtor_detail_installment_calculator_installment_preview').addClass('hideMe');
// $('#'+uid+' .debtor_detail_installment_calculator_installment_request').prop('disabled',disabled);
}
}
function submitInstallmentCalculator(uid,debtor_id){
var calculator_type = $('#'+uid+' .debtor_detail_installment_calculator_type').is(":checked") ? "auto":"manual";
var installment_date = moment($('#'+uid+' .debtor_detail_installment_calculator_first_installment_date').val(),momentDateFormat).format(momentSqlDateFormat);
var installment_offer_date = moment($('#'+uid+' .debtor_detail_installment_calculator_offer_date').val(),momentDateFormat).format(momentSqlDateFormat);
var installment_offer_refno = $('#'+uid+' .debtor_detail_installment_calculator_offer_refno').val();
var installment_amount = $('#'+uid+' .debtor_detail_installment_calculator_installment_amount').maskMoney('unmasked')[0];
var installment_note = $('#'+uid+' .debtor_detail_installment_calculator_installment_note').val();
var installment_proposal_amount = $('#'+uid+' .debtor_detail_installment_calculator_proposal_amount').maskMoney('unmasked')[0];
var installment_no_of_repayment = $('#'+uid+' .debtor_detail_installment_calculator_installment_no_of_repayment').val();
var installment_internal = $('#'+uid+' .debtor_detail_installment_calculator_internal').is(":checked");
var installment_request_type = "2";
if(installment_internal)
installment_request_type = "8";
// var installment_json = JSON.stringify(generateInstallmentTable(uid,"jsononly"));
var installment_json = JSON.stringify(global.general.installment_json);
var installmentinfo = {
debtorId: debtor_id,
offerLetterDate: installment_offer_date,
offerLetterRefNo: installment_offer_refno,
flagptpOS: "1",
ptpOS: installment_proposal_amount,
ptpStatusIndex: installment_request_type,
notes: installment_note,
jsonPTP: installment_json
};
if(enable_debtor_installment_weekly){
installmentinfo['discount_percentage'] = $('#'+uid+' .debtor_detail_installment_calculator_discount_percentage').maskMoney('unmasked')[0];
installmentinfo['discount_amount'] = $('#'+uid+' .debtor_detail_installment_calculator_discount_amount').maskMoney('unmasked')[0];
installmentinfo['payment_plan_offer_amount'] = $('#'+uid+' .debtor_detail_installment_calculator_offer_amount').maskMoney('unmasked')[0];
}
volareApi("saveInstallmentPlan", {action: 'saveInstallmentPlan',debtor_id:debtor_id,installmentinfo:installmentinfo},{uid:uid});
}
function incomingCallModal(uid,incoming_number,searchresult = []){
// var uid = getUniqueStr();
// console.log(searchresult);
// console.log("ha?"+incoming_number);
var incoming_call_script = "";
var showIncomingCallScript = false;
if(global.callscript.incoming_callscript.script != null){
// incoming_call_script = fillDataInPlaceholderv2(""+global.callscript.incoming_callscript.script,global.callscript.callscriptvariable);
incoming_call_script = global.callscript.incoming_callscript.script.replace(/\n/g, ' ');
showIncomingCallScript = true;
}
var incoming_additional_call_script = "";
if(enable_incoming_additional_call_script && global.callscript.incoming_additional_callscript != null){
var rpc_followup_script = Handlebars.compile($('#template-rpc_followup_script').html());
var i = 0;
$.each(global.callscript.incoming_additional_callscript,function(index, el) {
var rpcscriptvar = {};
rpcscriptvar.followup_script_title = el['name'];
rpcscriptvar.followup_script_content = el['script'];
rpcscriptvar.followup_script_title_id = "CallScript-title"+i;
rpcscriptvar.followup_script_content_id = "CallScript-collapse"+i;
incoming_additional_call_script += rpc_followup_script(rpcscriptvar);
i++;
});
}
console.log(incoming_additional_call_script);
var incoming_call_modal = Handlebars.compile($('#template-incoming_call_modal').html());
var incoming_call_modal_var = {};
incoming_call_modal_var.uid = uid;
incoming_call_modal_var.lang = lang;
incoming_call_modal_var.incoming_number = incoming_number;
incoming_call_modal_var.showIncomingCallScript = showIncomingCallScript;
incoming_call_modal_var.incoming_call_script = incoming_call_script;
incoming_call_modal_var.incoming_additional_call_script = incoming_additional_call_script;
incoming_call_modal_var.title = lang.lang_incoming_call.replace('#number#',maskNumber(incoming_number));
$('#IncomingCallModalPlaceholder').html(incoming_call_modal(incoming_call_modal_var));
if(enable_inbound_call_vehicle_number_search){
$('#'+uid+' .incoming_call_search_vehicle_number').removeClass('hideMe');
}
// console.log("ha?"+incoming_number);
populateIncomingCallSearchResult(uid,searchresult,incoming_number,"presearch");
$('#'+uid).draggable({
handle: ".modal-dialog",
scroll: false,
});
$('#'+uid).modal({backdrop:false});
$('#'+uid+' .incoming_call_status_header').removeClass('blink');
validateIncomingCallSearch(uid);
}
function presearchIncomingCall(uid,incoming_number){
// volareApi("presearchDebtorForIncomingCall",{action: 'searchDebtorForIncomingCall',searchvalue:{phonenumber:incoming_number}},{uid:uid});
var searchvalue = {};
if(global.calldata[uid].header_volare_input != ""){
searchvalue.multisearch = global.calldata[uid].header_volare_input;
}else{
searchvalue.phonenumber = incoming_number;
}
volareApi("presearchDebtorForIncomingCall",{action: 'searchDebtorForIncomingCall',searchvalue:searchvalue,additional_param:getUndisposedDialerLogAdditionalParam("1",global.calldata[uid].destinationNumber,global.calldata[uid].sipcallid)},{uid:uid});
}
function validateIncomingCallSearch(uid){
var error = false;
if($('#'+uid+' .incoming_call_search_type_current').attr('volare-value') == ""){
$('#'+uid+' .incoming_call_search_type_current').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .incoming_call_search_type_current').removeClass('is-invalid');
}
if($('#'+uid+' .incoming_call_search_text').val() == ""){
$('#'+uid+' .incoming_call_search_text').addClass('is-invalid');
error = true;
}else{
$('#'+uid+' .incoming_call_search_text').removeClass('is-invalid');
}
if(error){
$("#"+uid+" .incoming_call_search_submit").prop('disabled',true);
}else{
$("#"+uid+" .incoming_call_search_submit").prop('disabled',false);
}
}
function validateCallbackCallSearch(){
var error = false;
if($('.callback_incoming_call_search_type_current').attr('volare-value') == ""){
$('.callback_incoming_call_search_type_current').addClass('is-invalid');
error = true;
}else{
$('.callback_incoming_call_search_type_current').removeClass('is-invalid');
}
if($('.callback_incoming_call_search_text').val() == ""){
$('.callback_incoming_call_search_text').addClass('is-invalid');
error = true;
}else{
$('.callback_incoming_call_search_text').removeClass('is-invalid');
}
if(error){
$(".callback_incoming_call_search_submit").prop('disabled',true);
}else{
$(".callback_incoming_call_search_submit").prop('disabled',false);
}
}
function populateIncomingCallSearchResult(uid,searchresult,incoming_number,additionalparam,searchvalue = ""){
incoming_number = $('#'+uid+'').attr('volare-incomingnumber');
if(searchresult.length > 0){
var tbody_data = "";
var incoming_call_search_result_tbody = Handlebars.compile($('#template-incoming_call_search_result_tbody').html());
for (var ii = 0; ii < searchresult.length; ii++) {
var row = searchresult[ii];
var incoming_call_search_result_tbody_var = {};
incoming_call_search_result_tbody_var.uid = uid;
incoming_call_search_result_tbody_var.lang = lang;
incoming_call_search_result_tbody_var.debtor_id = row.id;
incoming_call_search_result_tbody_var.name = row.DebtorName;
incoming_call_search_result_tbody_var.incoming_number = incoming_number;
incoming_call_search_result_tbody_var.ic = maskNumber(row.IC);
incoming_call_search_result_tbody_var.collectorname = row.CollectorName;
incoming_call_search_result_tbody_var.card_no_account = (row.card_no != '' && row.card_no != null) ?maskNumber(row.card_no):row.account;
incoming_call_search_result_tbody_var.differentcollector = row.differentcollector;
if(enable_incoming_call_search_result_batch_number){
incoming_call_search_result_tbody_var.card_no = row.card_no;
incoming_call_search_result_tbody_var.account = row.account;
incoming_call_search_result_tbody_var.batch_no = row.batch_no;
}
tbody_data += incoming_call_search_result_tbody(incoming_call_search_result_tbody_var);
}
if(searchvalue != "")
$("#"+uid+" .incoming_call_search_target_value").html(searchvalue);
$("#"+uid+" .incoming_call_search_result_tbody").html(tbody_data);
$("#"+uid+" .reception-step1").addClass('hideMe');
$("#"+uid+" .reception-step2").removeClass('hideMe');
$("#"+uid+" .incoming_call_back").removeClass('hideMe');
if(enable_incoming_call_search_result_batch_number){
// if(!$('.incoming_call_search_result_old_field_related').hasClass('hideMe'))
$('.incoming_call_search_result_old_field_related').addClass('hideMe');
// if($('.incoming_call_search_result_new_field_related').hasClass('hideMe'))
$('.incoming_call_search_result_new_field_related').removeClass('hideMe');
}else{
// if($('.incoming_call_search_result_old_field_related').hasClass('hideMe'))
$('.incoming_call_search_result_old_field_related').removeClass('hideMe');
// if(!$('.incoming_call_search_result_new_field_related').hasClass('hideMe'))
$('.incoming_call_search_result_new_field_related').addClass('hideMe');
}
}else{
if(additionalparam != "presearch"){
$("#"+uid+" .incoming_call_search_target_value").html(searchvalue);
$("#"+uid+" .reception-step1").addClass('hideMe');
$("#"+uid+" .reception-no-match").removeClass('hideMe');
$("#"+uid+" .incoming_call_back").removeClass('hideMe');
}
}
}
function populateCallbackIncomingCallSearchResult(searchresult,incoming_number,additionalparam,searchvalue = ""){
// console.log(searchvalue);
// incoming_number = $('#'+uid+'').attr('volare-incomingnumber');
if(searchresult.length > 0){
var tbody_data = "";
var incoming_call_search_result_tbody = Handlebars.compile($('#template-callback_incoming_call_search_result_tbody').html());
for (var ii = 0; ii < searchresult.length; ii++) {
var row = searchresult[ii];
// console.log(row);
var incoming_call_search_result_tbody_var = {};
// incoming_call_search_result_tbody_var.uid = uid;
incoming_call_search_result_tbody_var.lang = lang;
incoming_call_search_result_tbody_var.debtor_id = row.id;
incoming_call_search_result_tbody_var.name = row.DebtorName;
incoming_call_search_result_tbody_var.incoming_number = incoming_number;
incoming_call_search_result_tbody_var.ic = maskNumber(row.IC);
incoming_call_search_result_tbody_var.collectorname = row.CollectorName;
incoming_call_search_result_tbody_var.card_no_account = (row.card_no != '' && row.card_no != null) ?maskNumber(row.card_no):row.account;
incoming_call_search_result_tbody_var.differentcollector = row.differentcollector;
if(enable_incoming_call_search_result_batch_number){
incoming_call_search_result_tbody_var.card_no = row.card_no;
incoming_call_search_result_tbody_var.account = row.account;
incoming_call_search_result_tbody_var.batch_no = row.batch_no;
}
tbody_data += incoming_call_search_result_tbody(incoming_call_search_result_tbody_var);
}
// if(searchvalue != "")
// $(" .dialer_setting_ivr_request_callback_content_search_no_result_target").html(incoming_number);
$(".callback_incoming_call_search_result_tbody").html(tbody_data);
$('.dialer_setting_ivr_request_callback_content_search').addClass('hideMe');
$('.dialer_setting_ivr_request_callback_content_search_result').removeClass('hideMe');
$('.dialer_setting_ivr_request_callback_content_search_no_result').addClass('hideMe');
// $(".reception-step1").addClass('hideMe');
// $(".reception-step2").removeClass('hideMe');
// $(".incoming_call_back").removeClass('hideMe');
}else{
// console.log(searchresult,incoming_number,additionalparam,searchvalue);
// if(searchvalue != "")
$(".dialer_setting_ivr_request_callback_content_search_no_result_target").html(searchvalue);
// $(" .dialer_setting_ivr_request_callback_content_search_no_result_target").html(incoming_number);
$('.dialer_setting_ivr_request_callback_content_search').addClass('hideMe');
$('.dialer_setting_ivr_request_callback_content_search_result').addClass('hideMe');
$('.dialer_setting_ivr_request_callback_content_search_no_result').removeClass('hideMe');
// if(additionalparam != "presearch"){
// $("#"+uid+" .incoming_call_search_target_value").html(searchvalue);
// $("#"+uid+" .reception-step1").addClass('hideMe');
// $("#"+uid+" .reception-no-match").removeClass('hideMe');
// $("#"+uid+" .incoming_call_back").removeClass('hideMe');
// }
}
}
function showAccessTimeTimeoutAlert(){
var warningtext = words("lang_your_session_will_expire_in_seconds","seconds","30 ");
var notify = $.notify({
icon: 'fa fa-exclamation-triangle fa-2x mr-2',
title: lang.lang_session_timeout_warning+' '+' ',
message: ''+warningtext+'
'+lang.lang_log_out+' ',
target: '_blank'
},{
// settings
element: 'body',
position: null,
// To define style such as success, info, warming, danger
type: "warning",
allow_dismiss: false,
newest_on_top: false,
showProgressbar: false,
placement: {
from: "top",
align: "left"
},
offset: 20,
spacing: 10,
z_index: 1031,
delay: 0,
// Suppose to fade away only when user click on Answer. I dunno how to do that...
timer: 1000,
url_target: '_blank',
mouse_over: null,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
onShow: null,
onShown: null,
onClose: null,
onClosed: null,
icon_type: 'class',
template: '' +
'
' +
'
' +
'
{1} ' +
'
{2} ' +
'
' +
'
' +
'
'
});
// global.calldata[uid].notify = notify;
}
function showIncomingCallAlert(uid,incoming_number,search_result = []){
var debtor_indicator = "";
if(search_result != null && search_result.length > 0){
debtor_indicator = ' ';
}
var notify = $.notify({
icon: 'fa fa-phone-volume fa-2x mr-2',
title: lang.lang_incomingcall+' '+debtor_indicator+' '+maskNumber(incoming_number)+' ',
//I have included Answer button. If user is still typing follow up this button will be disabled till user submited the follow up.
// message: '
'+lang.lang_answer+' ',
message: ''+lang.lang_please_complete_your_current_task_before_answering+'
'+lang.lang_answer+' ',
target: '_blank'
},{
// settings
element: 'body',
position: null,
// To define style such as success, info, warming, danger
type: "warning",
allow_dismiss: true,
newest_on_top: false,
showProgressbar: false,
placement: {
from: "top",
align: "left"
},
offset: 20,
spacing: 10,
z_index: 1031,
delay: 0,
// Suppose to fade away only when user click on Answer. I dunno how to do that...
timer: 1000,
url_target: '_blank',
mouse_over: null,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
onShow: null,
onShown: null,
onClose: null,
onClosed: null,
icon_type: 'class',
template: '' +
'
' +
'
' +
'
{1} ' +
'
{2} ' +
'
' +
'
' +
'
'
});
global.calldata[uid].notify = notify;
}
function hideIncomingCallAlert(uid){
if(global.calldata[uid] != null){
global.calldata[uid].notify.close();
// delete global.general.incoming_call_notification[uid];
}
// $('#'+uid+' .notifyjs-wrapper').trigger('notify-hide');
}
function hideIntercomCallAlert(uid){
if(global.general.intercom_call[uid] != null){
global.general.intercom_call[uid].notify.close();
// delete global.general.incoming_call_notification[uid];
}
// $('#'+uid+' .notifyjs-wrapper').trigger('notify-hide');
}
function lodReprintConfirmation(debtor_id,template_id){
swal({
title: lang.lang_print_confirmation,
text: lang.lang_you_have_printed_from_this_template_before,
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: lang.lang_yes,
cancelButtonText: lang.lang_cancel
}).then((result) => {
if (result.value) {
// volareApi("getDebtorLOD", {action: 'getDebtorLOD',debtor_id:debtor_id,template_id:template_id,forceprint:"1"});
// if(typeof useVolareAdminApi !== 'undefined' && useVolareAdminApi == true){
// volareApi("getDebtorLODv2", {action: 'getDebtorLODv2',debtor_id:debtor_id,template_id:template_id,forceprint:"1"});
// }else{
// volareApi("getDebtorLOD", {action: 'getDebtorLOD',debtor_id:debtor_id,template_id:template_id,forceprint:"1"});
// }
volareApi("getDebtorLODv3", {action: 'getDebtorLODv3',debtor_id:debtor_id,template_id:template_id,forceprint:"1"});
}
});
}
function showMapDebtorConfirmation(uid,number,debtor_id,dialer_log_id){
var message = ''+lang.lang_this_missed_call_number_matches_this_account+'
'+lang.lang_map+' ';
var notify = $.notify({
icon: 'missed-call-big mr-2',
title: lang.lang_missed_call_customer_mapping+' '+number+' ',
message: message,
target: '_blank'
}, {
// settings
element: 'body',
position: null,
// To define style such as success, info, warming, danger
type: "warning",
allow_dismiss: true,
newest_on_top: false,
showProgressbar: false,
placement: {
from: "top",
align: "left"
},
offset: 20,
spacing: 10,
z_index: 1031,
delay: 0,
// Suppose to fade away only when user click on Answer. I dunno how to do that...
timer: 1000,
url_target: '_blank',
mouse_over: null,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
onShow: null,
onShown: null,
onClose: null,
onClosed: null,
icon_type: 'class',
template: '' +
'
x ' +
'
' +
'
{1} ' +
'
{2} ' +
'
' +
'
' +
'
'
});
global.general.map_debtor[uid] = {notify:notify};
}
function showIntercomAlert(uid,number,mode = "outgoing",session = "",headers={}){
var debtor_id = "";
var debtor_name = "";
var rpc_selection = "";
var which_party = "";
console.log(headers);
if(headers['X-volare-pretransfer-debtor_id'] != null)
debtor_id = headers['X-volare-pretransfer-debtor_id'];
if(headers['X-volare-pretransfer-debtor_name'] != null)
debtor_name = headers['X-volare-pretransfer-debtor_name'];
if(headers['X-volare-pretransfer-rpc_selection'] != null)
rpc_selection = headers['X-volare-pretransfer-rpc_selection'];
if(headers['X-volare-pretransfer-which_party'] != null)
which_party = headers['X-volare-pretransfer-which_party'];
global.general.uids[uid].pretransfer = {debtor_id:debtor_id,debtor_name:debtor_name,rpc_selection:rpc_selection,which_party:which_party,incoming_number:number};
// number = "Zaman";
var intercom_number_display = number;
if(global.general.collector_extension_list[number] != null)
intercom_number_display = number + " " + global.general.collector_extension_list[number];
var message = '
';
var title = lang.lang_intercom+' '+intercom_number_display+' ';
if(mode == "incoming"){
if(debtor_id != "" && debtor_name != ""){
if(rpc_selection != "" ){
message = ''+lang.lang_verified_customer+'
'+lang.lang_answer+' ';
title = lang.lang_transfered_incoming_call+' '+debtor_name+' ';
}else{
message = '
'+lang.lang_answer+' ';
title = lang.lang_transfered_incoming_call+' '+debtor_name+' ';
}
}else{
// message = '
'+lang.lang_answer+' ';
message = ''+lang.lang_please_complete_your_current_task_before_answering+'
'+lang.lang_answer+' ';
}
}
var notify = $.notify({
icon: 'fa fa-user-tie fa-2x mr-2',
title: title,
message: message,
target: '_blank'
}, {
// settings
element: 'body',
position: null,
// To define style such as success, info, warming, danger
type: "info",
allow_dismiss: true,
newest_on_top: false,
showProgressbar: false,
placement: {
from: "top",
align: "left"
},
offset: 20,
spacing: 10,
z_index: 1031,
delay: 0,
// Suppose to fade away only when user click on Answer. I dunno how to do that...
timer: 1000,
url_target: '_blank',
mouse_over: null,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
onShow: null,
onShown: null,
onClose: null,
onClosed: null,
icon_type: 'class',
template: '' +
'
' +
'
' +
'
{1} ' +
'
{2} ' +
'
' +
'
' +
'
'
});
global.general.intercom_call[uid] = {notify:notify,session:session};
global.calldata[uid].notify = notify;
}
function outgoingIntercom(number,name,forcecall = false,sip_headers = []){
if(busynow() && !forcecall){
swal(lang.lang_please_finish_your_call_followup_before_starting_a_new_task);
return;
}
var uid = getUniqueStr();
if(global.general.uids[uid] == null)
global.general.uids[uid] = {};
busynow("iambusy","intercom");
// var sip_headers = [];
// sip_headers.push({name: 'X-volare-pretransfer-debtor_id', value: '123', session: false});
// sip_headers.push({name: 'X-volare-pretransfer-debtor_name', value: '12321321', session: false});
// sip_headers.push({name: 'X-volare-pretransfer-rpc_selection', value: '312321312', session: false});
// sip_headers.push({name: 'X-volare-pretransfer-which_party', value: '12312312', session: false});
var oConfigCall = {
'eventHandlers' : global.intercomHandlers,
'mediaConstraints' : { 'audio': true, 'video': false },
'extraHeaders':[
"volareuid: "+uid,
"destinationNumber: "+number,
"volare-mode: intercom-outgoing",
],
};
$.each(sip_headers,function(index, el) {
// if(el.name != "" && el.value != ""){
// oConfigCall.extraHeaders.push(el.name+": "+el.value);
// }
oConfigCall.extraHeaders.push(el);
});
// var oConfigCall = {
// audio_remote: document.getElementById("intercom_audio_remote"),
// events_listener: { events: '*', listener: intercomListener },
// sip_caps: [
// { name: 'WebVolare' },
// { name: 'language', value: '\"en\"' },
// { name: 'destinationNumber',value:number},
// { name: 'volareuid',value:uid},
// { name: 'calltype',value:'outgoing'},
// ],
// sip_headers:sip_headers
// };
// var oConfigCall = {
// audio_remote: document.getElementById("intercom_audio_remote"),
// events_listener: { events: '*', listener: intercomListener },
// sip_caps: [
// { name: 'WebVolare' },
// { name: 'language', value: '\"en\"' },
// { name: 'destinationNumber',value:number},
// { name: 'volareuid',value:uid},
// { name: 'calltype',value:'outgoing'},
// ],
// sip_headers:[{name: 'X-volare-pretransfer-debtor_id', value: 'abababa', session: false}]
// };
// global.sipIntercomOutgoingSession = global.sipCoreSession.newSession('call-audio', oConfigCall);
var cleannumber = cleanNumber(number);
var finaltarget = cleannumber;
if(finaltarget.length > 6){
var prefix = "";
if($('select.general_dial_prefix').val() != ""){
prefix = $('select.general_dial_prefix').val();
}
finaltarget = prefix+cleannumber;
}
// if (global.sipOutgoingSession.call('100125924078') != 0) {
// global.sipIntercomOutgoingSession = global.sipCoreSession.call('sip:'+prefix+cleannumber,oConfigCall);
if (global.sipCoreSession.call('sip:'+finaltarget,oConfigCall) == null) {
// if (global.sipIntercomOutgoingSession.call(finaltarget) != 0) {
global.sipIntercomOutgoingSession = null;
swal(lang.lang_failed_to_start_call_process);
// btnCall.disabled = false;
// btnHangUp.disabled = true;
return;
}
if(!forcecall){
showIntercomAlert(uid,number,"outgoing",global.sipIntercomOutgoingSession);
}
}
function hangupTransferIntercom(){
if(global.sipIntercomOutgoingSession != null){
global.sipIntercomOutgoingSession.terminate();
// global.sipIntercomOutgoingSession.hangup();
}
}
function appendCallLog(debtor_id,contactno_id,number,calltype,calltime,duration){
// console.log(debtor_id,contactno_id,number,calltype,calltime,duration);
var dialer_setting_call_log_tr = Handlebars.compile($('#template-dialer_setting_call_log_tr').html());
var dialer_setting_call_log_tr_var = {};
dialer_setting_call_log_tr_var.lang = lang;
//PhoneNumber, CalloutTime, HangupTime, CallType
var row = {debtorid:debtor_id,contactnoid:contactno_id,PhoneNumber:number,CallType:calltype,CalloutTime:calltime,timespan:duration};
dialer_setting_call_log_tr_var.calltype_css = "";
dialer_setting_call_log_tr_var.calltype_lang = "";
switch(row.CallType){
case "1":
case 1:
dialer_setting_call_log_tr_var.calltype_css = 'incoming-call';
dialer_setting_call_log_tr_var.calltype_lang = lang.lang_incomingcall;
break;
case "2":
case 2:
dialer_setting_call_log_tr_var.calltype_css = 'extension-call';
dialer_setting_call_log_tr_var.calltype_lang = lang.lang_intercom;
break;
case "3":
case 3:
dialer_setting_call_log_tr_var.calltype_css = 'outgoing-call';
dialer_setting_call_log_tr_var.calltype_lang = lang.lang_outgoing_call_titleonly;
break;
case "4":
case 4:
dialer_setting_call_log_tr_var.calltype_css = 'missed-call';
dialer_setting_call_log_tr_var.calltype_lang = lang.lang_missed_call;
break;
default:break;
}
// console.log(dialer_setting_call_log_tr_var);
if(dialer_setting_call_log_tr_var.calltype_css == ""){
return;
}
dialer_setting_call_log_tr_var.debtorid = row.debtorid;
dialer_setting_call_log_tr_var.number = row.PhoneNumber;
dialer_setting_call_log_tr_var.datetime = row.CalloutTime;
dialer_setting_call_log_tr_var.duration = row.timespan;
dialer_setting_call_log_tr_var.isdebtor = false;
if(row.debtorid != null && row.debtorid != "" && row.debtorid > 0 ){
dialer_setting_call_log_tr_var.isdebtor = true;
}
$('.dialer_setting_call_log_tbody').prepend(dialer_setting_call_log_tr(dialer_setting_call_log_tr_var));
if(!$('.dialer_setting_call_log_nodata').hasClass('hideMe')){
$('.dialer_setting_call_log_nodata').addClass('hideMe');
}
if($('.dialer_setting_call_log_table').hasClass('hideMe')){
$('.dialer_setting_call_log_table').removeClass('hideMe');
}
}
function refreshManager(actionlist){
actionlist = actionlist.split(",");
var apilist = [];
for (var i = 0; i < actionlist.length; i++) {
switch(actionlist[i]){
case "internal_message":
if(!enable_internal_message || global.access.internal_messaging_collector <= 0)
break;
case "collection_to_date":
case "collector_dialerlog":
case "callbadge":
if(enable_bypass_call_badge_reload && actionlist[i] == "callbadge")
actionlist[i] = "ptp_nextcall";
case "ptp_nextcall":
case "ivr_return_call_count":
apilist.push(actionlist[i]);
break;
case "calllist":
refreshCallList();
break;
default:break;
}
}
if(apilist.length > 0){
volareApi("refreshManager",{action: 'getData',datatype:apilist});
}
// switch(mode){
// case "callbadge":
// break;
// default:break;
// }
}
function refreshCallList(){
if($("#gridContainer").is(":visible")){
$("#gridContainer").dxDataGrid("instance").refresh();
// $("#gridContainer").dxDataGrid("instance").refresh();
}else{
$('#CallList-tab').attr('volare-refresh','1');
}
// $("#gridContainer").dxDataGrid("instance").repaint();
}
function reloadCallLog(data){
var dialer_setting_call_log_tbody = "";
var dialer_setting_call_log_thead = Handlebars.compile($('#template-dialer_setting_call_log_title_tr').html());
var dialer_setting_call_log_tr = Handlebars.compile($('#template-dialer_setting_call_log_tr').html());
var dialer_setting_call_log_tr_var = {};
dialer_setting_call_log_tr_var.lang = lang;
if(data.length > 0){
// for (var ix = 0; ix < 200; ix++) {
for (var ix = 0; ix < data.length; ix++) {
//PhoneNumber, CalloutTime, HangupTime, CallType
// var row = data[0];
var row = data[ix];
dialer_setting_call_log_tr_var.calltype_css = "";
switch(row.CallType){
case "1":
case 1:
dialer_setting_call_log_tr_var.calltype_css = 'incoming-call';
dialer_setting_call_log_tr_var.calltype_lang = lang.lang_incomingcall;
break;
case "2":
case 2:
dialer_setting_call_log_tr_var.calltype_css = 'extension-call';
dialer_setting_call_log_tr_var.calltype_lang = lang.lang_intercom;
break;
case "3":
case 3:
dialer_setting_call_log_tr_var.calltype_css = 'outgoing-call';
dialer_setting_call_log_tr_var.calltype_lang = lang.lang_outgoing_call_titleonly;
break;
case "4":
case 4:
dialer_setting_call_log_tr_var.calltype_css = 'missed-call';
dialer_setting_call_log_tr_var.calltype_lang = lang.lang_missed_call;
break;
default:break;
}
if(dialer_setting_call_log_tr_var.calltype_css == ""){
continue;
}
dialer_setting_call_log_tr_var.dialer_log_id = row.id;
dialer_setting_call_log_tr_var.debtorid = row.debtorid;
dialer_setting_call_log_tr_var.number = row.PhoneNumber;
dialer_setting_call_log_tr_var.datetime = row.CalloutTime;
dialer_setting_call_log_tr_var.duration = row.timespan;
dialer_setting_call_log_tr_var.isdebtor = false;
dialer_setting_call_log_tr_var.have_hit_result = false;
dialer_setting_call_log_tr_var.hit_result = [];
if(row.debtorid != null && row.debtorid != "" && row.debtorid > 0 ){
dialer_setting_call_log_tr_var.isdebtor = true;
}
dialer_setting_call_log_tr_var.dialer_setting_call_log_matching_debtor = "";
if(row.hit_result != null && row.hit_result.length > 0){
dialer_setting_call_log_tr_var.have_hit_result = true;
var dialer_setting_call_log_matching_debtor = Handlebars.compile($('#template-dialer_setting_call_log_matching_debtor').html());
var dialer_setting_call_log_matching_debtor_var = {};
dialer_setting_call_log_matching_debtor_var.dialer_setting_call_log_matching_debtor_tr = "";
dialer_setting_call_log_matching_debtor_var.dialer_log_id = row.id;
var dialer_setting_call_log_matching_debtor_tr = Handlebars.compile($('#template-dialer_setting_call_log_matching_debtor_tr').html());
var dialer_setting_call_log_matching_debtor_tr_var = {};
// console.log(row.hit_result);
$.each(row.hit_result,function(index, el) {
dialer_setting_call_log_matching_debtor_tr_var.id = el.id;
dialer_setting_call_log_matching_debtor_tr_var.name = el.name;
dialer_setting_call_log_matching_debtor_tr_var.account = el.account;
dialer_setting_call_log_matching_debtor_tr_var.phone_number = row.PhoneNumber;
dialer_setting_call_log_matching_debtor_tr_var.dialer_log_id = row.id;
if((el.account == null || el.account == "" )&& el.card_no != "" && el.card_no != null){
dialer_setting_call_log_matching_debtor_tr_var.account = el.card_no;
}
dialer_setting_call_log_matching_debtor_var.dialer_setting_call_log_matching_debtor_tr += dialer_setting_call_log_matching_debtor_tr(dialer_setting_call_log_matching_debtor_tr_var);
});
dialer_setting_call_log_tr_var.dialer_setting_call_log_matching_debtor = dialer_setting_call_log_matching_debtor(dialer_setting_call_log_matching_debtor_var);
}
if(ix != 0 && ix % 10 === 0)
dialer_setting_call_log_tbody += dialer_setting_call_log_thead({});
dialer_setting_call_log_tbody += dialer_setting_call_log_tr(dialer_setting_call_log_tr_var);
}
$('.dialer_setting_call_log_thead').html(dialer_setting_call_log_thead({}));
$('.dialer_setting_call_log_tbody').html(dialer_setting_call_log_tbody);
$('.dialer_setting_call_log_table').removeClass('hideMe');
$('.dialer_setting_call_log_nodata').addClass('hideMe');
}else{
$('.dialer_setting_call_log_table').addClass('hideMe');
$('.dialer_setting_call_log_nodata').removeClass('hideMe');
}
}
function tabManager(uid,mode = "add"){
if(mode == "add"){
var searchindex = global.tablist.indexOf(uid);
var tabAlreadyExists = false;
if(searchindex > -1){
tabAlreadyExists = true;
}
if(tabAlreadyExists){
$('#main_tab a[href="#'+uid+'_DebtorPage-content"]').tab('show');
// $('#'+uid+"_DebtorPage-tab").remove();
// $('#'+uid+"_DebtorPage-content").remove();
// global.tablist.splice(searchindex,1);
}else{
global.tablist.push(uid);
}
if(global.tablist.length > tab_maximum_numbers){
$('#'+global.tablist[0]+"_DebtorPage-tab").remove();
$('#'+global.tablist[0]+"_DebtorPage-content").remove();
global.tablist.splice(0,1);
}
return tabAlreadyExists;
}else if(mode == "delete"){
var searchindex = global.tablist.indexOf(uid);
var tabAlreadyExists = false;
if(searchindex > -1){
if(enable_ivr_request_callback && global.access.is_request_call_back_enabled > 0){
process_temp_callback_view_limit($('#'+uid+"_DebtorPage-tab").attr('volare-debtorid'),"delete");
}
global.tablist.splice(searchindex,1);
tabAlreadyExists = true;
$('#'+uid+"_DebtorPage-tab").remove();
$('#'+uid+"_DebtorPage-content").remove();
if(global.tablist.length > 0){
$('#'+global.tablist[global.tablist.length - 1]+"_DebtorPage-tab").click();
}else{
$('#CallList-tab').click();
}
}
return tabAlreadyExists;
}else if(mode == "clear"){
$.each(global.tablist,function(index, el) {
if(enable_ivr_request_callback && global.access.is_request_call_back_enabled > 0){
process_temp_callback_view_limit($('#'+global.tablist[index]+"_DebtorPage-tab").attr('volare-debtorid'),"delete");
}
$('#'+global.tablist[index]+"_DebtorPage-tab").remove();
$('#'+global.tablist[index]+"_DebtorPage-content").remove();
global.tablist.splice(index,1);
});
}
}
function ifHolidayShowAlert(targetdate){
targetdate = moment(targetdate,momentDateFormat).format(momentSqlDateFormat);
if(global.general.holiday != null && global.general.holiday[targetdate] != null && global.general.last_alerted_holiday != targetdate){
swal(lang.lang_warning_selected_date_is_holiday,global.general.holiday[targetdate]);
global.general.last_alerted_holiday = targetdate;
}
}
function validateRPCNextCallDateTime(uid){
//kokoda
var rpc_followup_next_call_date = $('#'+uid+' .rpc_followup_next_call_date').val();
if(global.general.uids[uid].enforcement_setting != null && global.general.uids[uid].enforcement_setting.is_enforce_next_call_earlier_or_equal_ptp == "1"){
var rpc_followup_ptp_date = $('#'+uid+' .rpc_followup_ptp_date').val();
$('#'+uid+" .rpc_followup_next_call_date").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
format: datetimepickerDateFormat,
formatDate:datetimepickerDateFormat,
maxDate:moment(rpc_followup_ptp_date,momentDateFormat).format(momentDateFormat),
minDate:0,
step: 1,
timepicker:false,
});
if(moment($('#'+uid+' .rpc_followup_next_call_date').val(),momentDateFormat).isAfter(moment(rpc_followup_ptp_date,momentDateFormat))){
$('#'+uid+" .rpc_followup_next_call_date").val('');
}
}
if(moment($('#'+uid+' .rpc_followup_next_call_date').val(),momentDateFormat).isSame(new Date(), "day")){
$('#'+uid+" .rpc_followup_next_call_time").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
format: datetimepickerTimeFormat,
timepickerScrollbar: false,
timepicker:true,
datepicker:false,
step:1,
minTime:0,
});
if(moment($('#'+uid+' .rpc_followup_next_call_date').val() +' '+ $('#'+uid+' .rpc_followup_next_call_time').val(),momentDateTimeFormat).isBefore(new Date(), "minute")){
$('#'+uid+" .rpc_followup_next_call_time").val('');
}
if(enable_next_call_time_auto_fill && $('#'+uid+" .rpc_followup_next_call_time").val() == ''){
$('#'+uid+" .rpc_followup_next_call_time").val(moment().format(momentSqlTimeFormat));
$('#'+uid+" .rpc_followup_next_call_time").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
format: datetimepickerTimeFormat,
timepickerScrollbar: false,
timepicker:true,
datepicker:false,
step:1,
minTime:0,
});
}
}else{
if(enable_next_call_time_auto_fill && $('#'+uid+" .rpc_followup_next_call_time").val() == ''){
$('#'+uid+" .rpc_followup_next_call_time").val('00:00');
}
$('#'+uid+" .rpc_followup_next_call_time").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
format: datetimepickerTimeFormat,
timepickerScrollbar: false,
timepicker:true,
datepicker:false,
step:1,
minTime:false,
});
}
}
function preselectRPCByCauseCode(uid,causecode){
// console.log(causecode);
// console.log(uid);
// console.log($('#'+uid+" input:radio.rpc_whatparty:checked").val());
// $('#'+uid+" input:radio.rpc_whatparty[value='nis']").click();
if(typeof $('#'+uid+" input:radio.rpc_whatparty:checked").val() === 'undefined'){
// console.log(typeof $('#'+uid+" input:radio.rpc_whatparty:checked").val());
// 480 Temporarily Unavailable - Callee currently unavailable.
// 484 Address Incomplete - Request-URI incomplete.
// 486 Busy Here - Callee is busy.
// 487 Request Terminated - Request has terminated by bye or cancel.
// 488 Not Acceptable Here - Some aspect of the session description or the Request-URI is not acceptable, or Codec issue.
// 503 Service Unavailable - The server is undergoing maintenance or is temporarily overloaded and so cannot process the request. A "Retry-After" header field may specify when the client may reattempt its request.
if(causecode == "404"){
// $("input[name='rpc_whatparty'][value='nis']").prop('checked', true);
$('#'+uid+" input:radio.rpc_whatparty[value='nis']").click();
// $('#'+uid+" input:radio.rpc_whatparty[value='nis']").prop('checked',true);
}else if(causecode == "503"){
// $("input[name='rpc_whatparty'][value='nis']").prop('checked', true);
$('#'+uid+" input:radio.rpc_whatparty[value='rna']").click();
// $('#'+uid+" input:radio.rpc_whatparty[value='rna']").prop('checked',true);
}else if(causecode == "486"){
// $("input[name='rpc_whatparty'][value='nis']").prop('checked', true);
$('#'+uid+" input:radio.rpc_whatparty[value='busy']").click();
// $('#'+uid+" input:radio.rpc_whatparty[value='busy']").prop('checked',true);
}
}
}
function preselectRPCByCauseCodev2(uid,causecode){
// console.log(causecode);
// console.log(global.calldata[uid]);
if(global.calldata[uid].answered){
$('#'+uid+" .rpc_headerv2_dialpad").prop('disabled',false).removeClass('disabled');
$('#'+uid+" .rpc_headerv2_connected").prop('disabled',false).removeClass('disabled');
$('#'+uid+" .rpc_headerv2_wrongnumber").prop('disabled',false).removeClass('disabled');
$('#'+uid+" .rpc_headerv2_vm").prop('disabled',false).removeClass('disabled');
$('#'+uid+" .rpc_headerv2_refuse").prop('disabled',false).removeClass('disabled');
$('#'+uid+" .rpc_nextv2").prop('disabled',false);
$('#'+uid+" .rpc_headerv2_connected").click();
}else{
switch(causecode){
case "404":
case 404:
$('#'+uid+" .rpc_headerv2_nis").prop('disabled',false);
$('#'+uid+" .rpc_headerv2_nis").removeClass('disabled');
$('#'+uid+" .rpc_headerv2_nis").click();
// $('#'+uid+" input:radio.rpc_headerv2[value='4']").click();
break;
case "503":
case 503:
$('#'+uid+" .rpc_headerv2_rna").prop('disabled',false);
$('#'+uid+" .rpc_headerv2_rna").removeClass('disabled');
$('#'+uid+" .rpc_headerv2_rna").click();
// $('#'+uid+" input:radio.rpc_headerv2[value='5']").click();
break;
case "486":
case 486:
$('#'+uid+" .rpc_headerv2_busy").prop('disabled',false);
$('#'+uid+" .rpc_headerv2_busy").removeClass('disabled');
$('#'+uid+" .rpc_headerv2_busy").click();
// $('#'+uid+" input:radio.rpc_headerv2[value='6']").click();
break;
case "487":
default:
$('#'+uid+" .rpc_headerv2_rna").prop('disabled',false);
$('#'+uid+" .rpc_headerv2_rna").removeClass('disabled');
$('#'+uid+" .rpc_headerv2_rna").click();
break;
}
$('#'+uid+" .general_answered_call_related").addClass('hideMe');
ud("Strongest rule - Not answered call , PTP forcefully disabled. ")
}
}
function muteMicrophone(mode){
var session = null;
if(global.sipOutgoingSession != null){
session = global.sipOutgoingSession;
}else if(global.sipIncomingSession != null){
session = global.sipIncomingSession;
}else if(global.vicidial_i.sipIncomingSession != null){
session = global.vicidial_i.sipIncomingSession;
}
if( session != null ){
if(mode){
session.mute();
}else{
session.unmute();
}
}
// if( session != null && session.o_session != null && session.o_session.o_stream_local != null && session.o_session.o_stream_local.getAudioTracks().length > 0 ){
// for (var nTrack = 0; nTrack < session.o_session.o_stream_local.getAudioTracks().length ; nTrack++) {
// session.o_session.o_stream_local.getAudioTracks()[nTrack].enabled = !mode;
// }
// }
}
function toggleCallHold(mode){
var session = null;
if(global.general.busy.status == true && global.general.busy.reason == "manual"){
console.log('out');
session = global.sipOutgoingSession;
}else if(global.general.busy.status == true && global.general.busy.reason == "incoming"){
console.log('in');
session = global.sipIncomingSession;
}
var result = false;
if( session != null ){
if(mode == "hold")
result = session.hold();
else if(mode == "unhold")
result = session.unhold();
}
return result;
}
function toggleCallHold_old(mode){
var session = null;
if(global.sipOutgoingSession != null){
console.log('out');
session = global.sipOutgoingSession;
}else if(global.sipIncomingSession != null){
console.log('in');
session = global.sipIncomingSession;
}
if( session != null ){
if(mode == "hold")
session.hold();
else if(mode == "unhold")
console.log(session.unhold());
}
}
function reloadNextCall(todaynextcalllist){
// $('#promisetopay').text(formatCurrency(data.latestPTPToDate));
// console.log(data.allListCount);
if(todaynextcalllist.length > 0){
var next_call_now = false;
for (var i = 0; i < global.nextcallflasher_ids.length; i++) {
clearTimeout(global.nextcallflasher_ids[i]);
}
global.nextcallflasher_ids = [];
for (var i = 0; i < todaynextcalllist.length; i++) {
var row = todaynextcalllist[i];
var nowunixtime = $.now()/1000;
if(nowunixtime >= row.start && nowunixtime <= row.stop ){
next_call_now = true;
// $('#nextcallid').html(langword['lang_next_call']);
// $('#top_next_call_count').html(data['data']['todaynextcalllist'].length);
$('#nextcallid').removeClass("lang_no_next_call");
$('#nextcallid').removeClass("lang_next_call");
$('#nextcallid').html(moment(row['NEXTCALL']['NEXTCALL']).format('HH:mm'));
// $('#top_next_call_count').html(data['data']['todaynextcalllist'].length);
// $('#nextcallid').removeClass("lang_next_call_now");
// if(!$('#nextcallid').hasClass('lang_next_call')){
// $('#nextcallid').addClass("lang_next_call");
// }
if($('#nextcall_flasher').hasClass('next-call:disabled')){
$('#nextcall_flasher').removeClass("next-call:disabled");
$('#nextcall_flasher').addClass("next-call");
}
}else if(row.start>nowunixtime){
var howmanysecondslater = row.start - nowunixtime;
var timerid = setTimeout(function(){
// volareApi("reloadCallBadge",{action: 'getSubInfo',});
refreshManager("callbadge");
}
, howmanysecondslater*1000);
global.nextcallflasher_ids.push(timerid);
}
if(!next_call_now){
$('#nextcallid').html(lang.lang_next_call);
$('#nextcallid').removeClass("lang_no_next_call");
$('#nextcallid').addClass("lang_next_call");
$('#top_next_call_count').html(todaynextcalllist.length);
$('#nextcall_flasher').removeClass("next-call");
$('#nextcall_flasher').addClass("next-call:disabled");
}
// console.log($.now()/1000);
// alert(moment(row['NEXTCALL']).format("YYYY-MM-DD"));
}
}else{
$('#nextcallid').html(lang.lang_no_next_call);
$('#nextcallid').removeClass("lang_next_call");
$('#nextcallid').addClass("lang_no_next_call");
$('#top_next_call_count').html('');
$('#nextcall_flasher').removeClass("next-call");
$('#nextcall_flasher').addClass("next-call:disabled");
}
}
function setMainStatus(mainstatus,mode = "",substatus = ""){
var mainclass = "float-right";
var subclass = "hideMe";
if(mainstatus != ""){
if(mode == "error"){
mainclass = "float-right text-danger pr-2 flash";
}
$('#bottom_main_status').html(mainstatus);
$('#bottom_main_status').attr('class',mainclass);
}
if(substatus == "headset"){
subclass = "float-right text-danger pr-2 flash";
$('#bottom_sub_status_word').html(lang.lang_unable_to_detect_headset);
$('#bottom_sub_status').attr('class',subclass);
}
}
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href);
if(results != null)
return results[1] || 0;
else
return "";
}
function displayLoginErrorIfAny(){
var code = $.urlParam('c');
// console.log(code);
switch(code){
case "410":
$('#login_login_error').html(words('lang_you_have_been_logged_out_due_to_inactivity'));
$('#login_login_error').removeClass('hideMe');
break;
case "411":
$('#login_login_error').html(words('lang_you_has_been_logged_out_by_another_pc'));
$('#login_login_error').removeClass('hideMe');
break;
case "412":
var access_time_today_range = localStorage.getItem("access_time_today_range");
localStorage.removeItem("access_time_today_range");
displayAccessTimeError(access_time_today_range);
break;
default:
$('#login_login_error').html(code);
$('#login_login_error').removeClass('hideMe');
break;
}
}
function displayAccessTimeError(access_time_today_range){
if(access_time_today_range != "" && access_time_today_range != null){
$('#login_login_error').html(words('lang_you_are_only_allowed_to_login_from_time_range',"time_range",access_time_today_range));
}else{
$('#login_login_error').html(words('lang_you_are_not_allowed_to_login_today'));
}
$('#login_login_error').removeClass('hideMe');
}
function cleanPrefixFromNumber(number){
$.each(global.general.maskingnumberlist,function(index, row) {
if( number.length > 6 && (row.prefix+"0") == (number.substr(0,row.prefix.length+1))){
number = number.substr(row.prefix.length,number.length);
return;
}
});
return number;
}
function AccessTimeTimeoutReminder(){
if(!busynow() && !global.general.mainAccessTimeTimeoutReminderDisplayed){
swal({
title: lang.lang_reminder,
html: lang.lang_you_have_15_minutes_before_the_end_of_your_shift,
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: lang.lang_ok,
cancelButtonText: lang.lang_log_out
}).then((result) => {
if (result.value) {
//renewsession
// volareApi("keepalive", {action: 'keepalive'});
}else{
logoutProcess();
var logouturl = "./index.php?action=logout";
window.location.href = logouturl;
}
});
global.general.mainAccessTimeTimeoutReminderDisplayed = true;
}
}
function sessionTimeoutWarning(seconds){
var warningtext = words("lang_your_session_will_expire_in_seconds","seconds",""+seconds+" ");
swal({
title: lang.lang_session_timeout_warning,
html: warningtext,
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: lang.lang_stay,
cancelButtonText: lang.lang_cancel
}).then((result) => {
if (result.value) {
//renewsession
volareApi("keepalive", {action: 'keepalive'});
}else{
logoutProcess();
var logouturl = "./index.php?action=logout";
window.location.href = logouturl;
}
});
}
function resetAccessTimeTimeoutReminder(){
// console.log('kitaze');
if(global.general.mainAccessTimeTimeoutReminderDisplayed == false){
if(global.general.mainAccessTimeTimeoutHandler !== false){
clearTimeout(global.general.mainAccessTimeTimeoutHandler);
global.general.mainAccessTimeTimeoutHandler = false;
}
if(global.general.mainAccessTimeTimeoutHandler === false){
var access_time_session_expiretime_unix = sessionStorage.getItem("access_time_session_expiretime_unix");
// console.log(access_time_session_expiretime_unix);
if(access_time_session_expiretime_unix != null && access_time_session_expiretime_unix != ""){
var target_time = ((access_time_session_expiretime_unix-900) - ($.now()/1000));
if(target_time < 0 ){
target_time = 0;
}
global.general.mainAccessTimeTimeoutHandler = setTimeout(function () {
AccessTimeTimeoutReminder();
},target_time*1000);
// console.log("Triggered on "+moment.unix(target_time+($.now()/1000)).format("MMMM Do YYYY, h:mm:ss a"));
}
}
//access_time_session_expiretime_unix
}
if(global.general.mainAccessTimeTimeoutWarningDisplayed == false){
if(global.general.mainAccessTimeTimeoutWarningHandler !== false){
clearTimeout(global.general.mainAccessTimeTimeoutWarningHandler);
global.general.mainAccessTimeTimeoutWarningHandler = false;
}
if(global.general.mainAccessTimeTimeoutWarningHandler === false){
var access_time_session_expiretime_unix = sessionStorage.getItem("access_time_session_expiretime_unix");
// console.log(access_time_session_expiretime_unix);
if(access_time_session_expiretime_unix != null && access_time_session_expiretime_unix != ""){
var target_time = ((access_time_session_expiretime_unix-30) - ($.now()/1000));
if(target_time < 0 ){
target_time = 0;
}
global.general.mainAccessTimeTimeoutWarningHandler = setTimeout(function () {
var remainseconds = ((access_time_session_expiretime_unix) - ($.now()/1000));
if(remainseconds < 0 ){
remainseconds = 0;
}
remainseconds = Math.floor(remainseconds);
resetAccessTimeTimeoutCounter(remainseconds);
},target_time*1000);
// console.log("Triggered on "+moment.unix(target_time+($.now()/1000)).format("MMMM Do YYYY, h:mm:ss a"));
}
}
}
}
function startAccessTimeTimeoutDurationCounter(remainseconds){
global.mainAccessTimeTimeoutCounter = remainseconds;
global.mainAccessTimeTimeoutDurationCounter = setInterval(function () {
--global.mainAccessTimeTimeoutCounter;
console.log(global.mainAccessTimeTimeoutCounter);
$('.main_access_time_timeout_countdown').html(remainseconds);
if(global.general.mainSessionTimeoutWarningDisplayed == false){
global.general.mainSessionTimeoutWarningDisplayed = true;
showAccessTimeTimeoutAlert();
}
if(global.mainAccessTimeTimeoutCounter <= 0){
logoutProcess();
stopAccessTimeTimeoutDurationCounter();
window.location.href = "./index.php?action=logout&c=412";
}
}, 1000);
}
function startSessionTimeoutDurationCounter(remainseconds){
global.mainSessionTimeoutCounter = remainseconds;
global.mainSessionTimeoutDurationCounter = setInterval(function () {
--global.mainSessionTimeoutCounter;
// $('.SPCallDurationDMC').html(moment("1900-01-01 00:00:00").add(global.outgoingCallCounter, 'seconds').format("mm:ss"));
if(global.general.mainSessionTimeoutWarningSeconds !== false &&global.mainSessionTimeoutCounter <= global.general.mainSessionTimeoutWarningSeconds){
$('.main_session_timeout_countdown').html(global.mainSessionTimeoutCounter);
if(global.general.mainSessionTimeoutWarningDisplayed == false){
if(busynow()){
// if(global.sipOutgoingSession != null || global.sipIncomingSession != null || global.vicidial_i.sipCoreSession != null && global.sipIntercomOutgoingSession != null){
ud("Due to on call, auto session keep alive has been executed...");
volareApi("keepalive", {action: 'keepalive'});
}else{
global.general.mainSessionTimeoutWarningDisplayed = true;
sessionTimeoutWarning(global.general.mainSessionTimeoutWarningSeconds);
}
}
}
if(global.mainSessionTimeoutCounter <= 0){
if(busynow()){
// if(global.sipOutgoingSession != null || global.sipIncomingSession != null || global.vicidial_i.sipCoreSession != null && global.sipIntercomOutgoingSession != null){
ud("Due to on call, auto session keep alive has been executed...");
volareApi("keepalive", {action: 'keepalive'});
}else{
logoutProcess();
stopSessionTimeoutDurationCounter();
window.location.href = "./index.php?action=logout&c=410";
}
}
// console.log(global.incomingCallCounter[uid],$('#'+uid+' .rpc_call_counter').html());
}, 1000);
}
function stopAccessTimeTimeoutDurationCounter(){
clearInterval(global.mainAccessTimeTimeoutDurationCounter);
global.mainAccessTimeTimeoutCounter = null;
// return $('#'+uid+' .rpc_call_counter').html();
}
function stopSessionTimeoutDurationCounter(){
clearInterval(global.mainSessionTimeoutDurationCounter);
global.mainSessionTimeoutDurationCounter = null;
// return $('#'+uid+' .rpc_call_counter').html();
}
function resetAccessTimeTimeoutCounter(remainseconds){
if(remainseconds > 0){
if(global.general.mainAccessTimeTimeoutWarningDisplayed){
global.general.mainAccessTimeTimeoutWarningDisplayed = false;
}
if(global.mainAccessTimeTimeoutDurationCounter != null){
stopAccessTimeTimeoutDurationCounter();
}
startAccessTimeTimeoutDurationCounter(remainseconds);
}
}
function resetSessionTimeoutCounter(remainseconds){
// console.log(resetSessionTimeoutCounter);
if(enable_bypass_kagi_and_lockout_policy && global.access.is_bypass_lockout_policy_enabled == "1")
return;
if(remainseconds > 0){
if(global.general.mainSessionTimeoutWarningDisplayed){
global.general.mainSessionTimeoutWarningDisplayed = false;
}
if(global.mainSessionTimeoutDurationCounter != null){
stopSessionTimeoutDurationCounter();
}
startSessionTimeoutDurationCounter(remainseconds);
}
}
function showPasswordChangeForm(username , mode ="initial", data = "",policies = ""){
var finaldata = "";
var login_password_update = Handlebars.compile($('#template-login_password_update').html());
var login_password_update_var = {};
var message_requirements = [];
$.each(policies,function(index, el) {
if(el.rule == "alphanumeric"){
message_requirements.push(lang.lang_must_be_a_combination_of_upper_case_letter_lower_case_letter_special_characters);
}else if(el.rule == "length"){
message_requirements.push(words("lang_at_least_number_nonblank_characters_in_length","number",el.data));
}
});
login_password_update_var.message_requirements = message_requirements;
login_password_update_var.lang = lang;
login_password_update_var.mode = mode;
login_password_update_var.showUpdateOnly = false;
login_password_update_var.showUpdateAndCancel = false;
if(mode == "initial"){
login_password_update_var.message_title = lang.lang_first_time_login_password_change;
login_password_update_var.message_content = lang.lang_you_must_change_your_password_before_logging_on_the_first_time;
login_password_update_var.showUpdateOnly = true;
}else if(mode == "graceover"){
login_password_update_var.message_title = lang.lang_password_expired;
login_password_update_var.message_content = lang.lang_your_password_has_expired_please_change_your_password;
login_password_update_var.showUpdateOnly = true;
}else if(mode == "graceperiod"){
login_password_update_var.message_title = lang.lang_password_expired;
login_password_update_var.message_content = words('lang_your_password_has_expired_you_have_login_left_to_change','number',data);
login_password_update_var.showUpdateAndCancel = true;
}else if(mode == "reminderperiod"){
login_password_update_var.message_title = lang.lang_password_is_expiring;
login_password_update_var.message_content = words('lang_your_password_will_be_expired_in_number_days','number',data);
login_password_update_var.showUpdateAndCancel = true;
}
login_password_update_var.preenter_username = username;
console.log(login_password_update_var);
finaldata = login_password_update(login_password_update_var);
$('#login_base_placeholder').addClass('hideMe');
$('#change_password_placeholder').removeClass('hideMe');
$('#change_password_placeholder').html(finaldata);
// $('#login_base_placeholder').html(finaldata);
}
function showDisclaimerMessage(message){
setTimeout(function () {
swal({
title: lang.lang_disclaimer,
text: message,
confirmButtonText:lang.lang_ok,
animation: false
});
},100);
}
function b64toBlob(b64Data, contentType='', sliceSize=512) {
const byteCharacters = atob(b64Data);
const byteArrays = [];
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
const slice = byteCharacters.slice(offset, offset + sliceSize),
byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
const blob = new Blob(byteArrays, {type: contentType});
return blob;
}
function getUrlDataFromBase64(b64Data){
var blob = b64toBlob(b64Data, "application/pdf");
var blobUrl = URL.createObjectURL(blob);
return blobUrl;
}
function printBlobURL(blobUrl){
$('#letter_modal_reminder_letter_print_preview_pdf').attr('src','');
$('#letter_modal_reminder_letter_print_preview_pdf').attr('src',blobUrl);
// console.log($('#letter_modal_reminder_letter_print_preview_pdf').attr('src'));
// const iframeEle = document.getElementById("letter_modal_reminder_letter_print_preview_pdf");
setTimeout(function(){
const iframeEle = document.getElementById("letter_modal_reminder_letter_print_preview_pdf");
iframeEle.contentWindow.print();
},1000);
}
function rpcShowSteps(uid,step){
var steps = {
'rpc-step1':false,
'rpc-step2':false,
'rpc-step2a':false,
'rpc-step3':false,
'rpc-dialpad':false,
};
if(steps[step] != null){
steps[step] = true;
}
$.each(steps,function(index, el) {
if(el == true){
$('#'+uid+' .'+index+'').removeClass('hideMe');
}else{
$('#'+uid+' .'+index+'').addClass('hideMe');
}
});
}
function checkSociableTime(debtor_next_call = null){
var have_next_call = false;
var result = {result:false,message:''};
if(global.general.settings.outgoing_call_sociable_hour_start_time != "" && global.general.settings.outgoing_call_sociable_hour_end_time != ""){
var starttime = moment().format("YYYY-MM-DD")+" "+global.general.settings.outgoing_call_sociable_hour_start_time;
var stoptime = moment().format("YYYY-MM-DD")+" "+global.general.settings.outgoing_call_sociable_hour_end_time;
if((moment().isAfter(starttime) && moment().isBefore(stoptime)) || (debtor_next_call != null && debtor_next_call != "" && (moment().isSame(debtor_next_call) || moment().isAfter(debtor_next_call))) ){
result.result = true;
}else{
result.message = lang.lang_exceeded_sociable_hour+' ('+global.general.settings.outgoing_call_sociable_hour_start_time.substr(0,5)+' - '+global.general.settings.outgoing_call_sociable_hour_end_time.substr(0,5)+')';
}
}else{
result.result = true;
}
return result;
}
function checkSmsableTime(){
var result = {result:false,message:''};
if(global.general.settings.sms_delivery_start_time != "" && global.general.settings.sms_delivery_end_time != ""){
var starttime = moment().format("YYYY-MM-DD")+" "+global.general.settings.sms_delivery_start_time.substr(0,5)+":00";
var stoptime = moment().format("YYYY-MM-DD")+" "+global.general.settings.sms_delivery_end_time.substr(0,5)+":59";
if(moment().isAfter(starttime) && moment().isBefore(stoptime)){
result.result = true;
}else{
result.message = lang.lang_exceeded_sms_delivery_time+' ('+global.general.settings.sms_delivery_start_time.substr(0,5)+' - '+global.general.settings.sms_delivery_end_time.substr(0,5)+')';
}
}else{
result.result = true;
}
return result;
}
function checkFairDebtCondition(contact_number_id,relation_type_id,is_sms = false){
var result = false;
var called_quantity = 0;
var call_limit_rule = 0;
var proceed_to_call = true;
var which_month = "";
ud('Checking Fair Debt..');
if(is_sms){
if(global.general.fair_debt_details_sms[contact_number_id] != null && global.general.fair_debt_details_sms[contact_number_id][relation_type_id] != null){
var sms_limit = global.general.fair_debt_details_sms[contact_number_id][relation_type_id];
ud("daily "+sms_limit.sms_limit_daily+" "+sms_limit.today_called);
if((Number(sms_limit.sms_limit_daily) > -1 && Number(sms_limit.sms_limit_daily) <= Number(sms_limit.today_called))){
ud("daily exceeded "+sms_limit.sms_limit_daily+" "+sms_limit.today_called);
proceed_to_call = false;
}
ud("weekly "+sms_limit.sms_limit_weekly+" "+sms_limit.week_called.split(',')[moment().isoWeek()-1]);
if((Number(sms_limit.sms_limit_weekly) > -1 && Number(sms_limit.sms_limit_weekly) <= Number(sms_limit.week_called.split(',')[moment().isoWeek()-1]))){
ud("weekly exceeded "+sms_limit.sms_limit_weekly+" "+sms_limit.week_called.split(',')[moment().isoWeek()-1]);
proceed_to_call = false;
}
ud("monthly "+sms_limit.sms_limit_monthly+" "+sms_limit.month_called.split(',')[moment().month()]);
if((Number(sms_limit.sms_limit_monthly) > -1 && Number(sms_limit.sms_limit_monthly) <= Number(sms_limit.month_called.split(',')[moment().month()]))){
ud("monthly exceeded "+sms_limit.sms_limit_monthly+" "+sms_limit.month_called.split(',')[moment().month()]);
proceed_to_call = false;
}
result = {
called_quantity:called_quantity,
call_limit_rule:call_limit_rule,
proceed_to_call:proceed_to_call,
sms_limit_daily:sms_limit.sms_limit_daily,
sms_limit_weekly:sms_limit.sms_limit_weekly,
sms_limit_monthly:sms_limit.sms_limit_monthly,
called_limit_daily:sms_limit.today_called,
called_limit_weekly:sms_limit.week_called.split(',')[moment().isoWeek()-1],
called_limit_monthly:sms_limit.month_called.split(',')[moment().month()],
};
}else{
ud('No applicable Fair Debt.');
}
}else{
if(global.general.fair_debt_details[contact_number_id] != null && global.general.fair_debt_details[contact_number_id][relation_type_id] != null){
var call_limit = global.general.fair_debt_details[contact_number_id][relation_type_id];
ud("daily "+call_limit.call_limit_daily+" "+call_limit.today_called);
if((Number(call_limit.call_limit_daily) > -1 && Number(call_limit.call_limit_daily) <= Number(call_limit.today_called))){
ud("daily exceeded "+call_limit.call_limit_daily+" "+call_limit.today_called);
proceed_to_call = false;
}
ud("weekly "+call_limit.call_limit_weekly+" "+call_limit.week_called.split(',')[moment().isoWeek()-1]);
if((Number(call_limit.call_limit_weekly) > -1 && Number(call_limit.call_limit_weekly) <= Number(call_limit.week_called.split(',')[moment().isoWeek()-1]))){
ud("weekly exceeded "+call_limit.call_limit_weekly+" "+call_limit.week_called.split(',')[moment().isoWeek()-1]);
proceed_to_call = false;
}
ud("monthly "+call_limit.call_limit_monthly+" "+call_limit.month_called.split(',')[moment().month()]);
if((Number(call_limit.call_limit_monthly) > -1 && Number(call_limit.call_limit_monthly) <= Number(call_limit.month_called.split(',')[moment().month()]))){
ud("monthly exceeded "+call_limit.call_limit_monthly+" "+call_limit.month_called.split(',')[moment().month()]);
proceed_to_call = false;
}
// if(
// (call_limit.call_limit_daily > -1 && call_limit.call_limit_daily > call_limit.today_called) &&
// (call_limit.call_limit_weekly > -1 && call_limit.call_limit_weekly > call_limit.week_called.split(',')[moment().week()-1]) &&
// (call_limit.call_limit_monthly > -1 && call_limit.call_limit_monthly > call_limit.month_called.split(',')[moment().month()])
// ){
// proceed_to_call = true;
// }
result = {
called_quantity:called_quantity,
call_limit_rule:call_limit_rule,
proceed_to_call:proceed_to_call,
call_limit_daily:call_limit.call_limit_daily,
call_limit_weekly:call_limit.call_limit_weekly,
call_limit_monthly:call_limit.call_limit_monthly,
called_limit_daily:call_limit.today_called,
called_limit_weekly:call_limit.week_called.split(',')[moment().isoWeek()-1],
called_limit_monthly:call_limit.month_called.split(',')[moment().month()],
};
}else{
ud('No applicable Fair Debt.');
}
}
return result;
}
function getEnforcementSetting(uid,code){
var debtor = global.general.uids[uid].debtor;
// var filtered = $.grep(global.general.enforcement_setting,
// function(elem, index) {
// return (
// (elem.role == "all" || elem.role.split(",").indexOf("4") > -1) &&
// (elem.account_status == "all" || elem.account_status.split(",").indexOf("123") > -1) &&
// (elem.client == "all" || elem.client.split(",").indexOf("2") > -1) &&
// (elem.open_mia == "all" || elem.open_mia.split(",").indexOf(123) > -1) &&
// (elem.status == "all" || elem.status.split(",").indexOf("3") > -1)
// );
// }
// );
var filtered = cakeSearchv3(global.general.enforcement_setting,{
"status":code,
"client":debtor.client_id,
"opening_mia":debtor.opening_mia,
"account_status":{"host_id":debtor.account_status_id,"is_credit_card":debtor.is_credit_card},
"access_config":global.access.id
});
// var filtered = $.grep(global.general.enforcement_setting,
// function(elem, index) {
// return (
// (elem.role == "all" || elem.role.split(",").indexOf(global.access.id) > -1) &&
// (elem.account_status == "all" || elem.account_status.split(",").indexOf(debtor.account_status) > -1) &&
// (elem.client == "all" || elem.client.split(",").indexOf(debtor.client_id) > -1) &&
// (elem.open_mia == "all" || elem.open_mia.split(",").indexOf(debtor.opening_mia) > -1) &&
// (elem.status == "all" || elem.status.split(",").indexOf(debtor.status_id) > -1)
// );
// }
// );
if(filtered[0] != null)
global.general.uids[uid].enforcement_setting = filtered[0];
else
global.general.uids[uid].enforcement_setting = null;
// var filtered = $.grep(global.general.enforcement_setting,
// function(elem, index) {
// return (
// (elem.role == "all" || elem.role.split(",").indexOf(global.access.id) > 0) &&
// (elem.account_status == "all" || elem.account_status.split(",").indexOf(debtor.account_status) > 0) &&
// (elem.client == "all" || elem.client.split(",").indexOf(debtor.client_id) > 0) &&
// (elem.open_mia == "all" || elem.open_mia.split(",").indexOf(debtor.opening_mia) > 0) &&
// (elem.status == "all" || elem.status.split(",").indexOf(debtor.status_id) > 0)
// );
// }
// );
return filtered;
}
function centralizeWidth(target_classes){
if($.isArray(target_classes)){
$.each(target_classes,function(row_index, row) {
var max_width = 0;
$.each($(row),function(index,el){
// console.log($(this).html(),$(this).actual( 'width' ,{ display: 'inline-block' }),$(this).html() == "");
if($(this).html() != "" && max_width < $(this).actual( 'width' ,{ display: 'inline-block' }))
max_width = $(this).actual( 'width' ,{ display: 'inline-block' });
// console.log($(this).html());
// console.log($(this).actual( 'width' ));
});
if(max_width > 0){
$(row).width(max_width);
}
});
}
}
function storeClientPrefix(debtor){
global.client_prefix[debtor.id] = debtor.debtor_detail_template_filename;
if(global.client_prefix[debtor.id] != "" && global.client_prefix[debtor.id].search("_") == -1)
global.client_prefix[debtor.id] = global.client_prefix[debtor.id] + "_";
}
function recountNotifictaionCountForBadge(notification_type = "main"){
var result = 0;
if(notification_type == "main"){
if($('.main_notification .main_notification_data_item').length != null){
result = $('.main_notification .main_notification_data_item').length;
}
if(result > 0){
$('.main_notification_data_count').html(result);
}else{
$('.main_notification_data_count').html('');
}
}else if(notification_type == "wa"){
if($('.main_whatsapp_notification .main_notification_data_item').length != null){
result = $('.main_whatsapp_notification .main_notification_data_item').length;
}
if(result > 0){
$('.main_whatsapp_notification_data_count').html(result);
$('.main_whatsapp_notification_data_flash').addClass('flash');
}else{
$('.main_whatsapp_notification_data_count').html('');
$('.main_whatsapp_notification_data_flash').removeClass('flash');
}
}
}
function populateNotificationData(notification,notification_type = "main"){
var notification_data = "";
if(notification.length > 0){
var main_notification_data = "";
var main_notification_data_var = {};
if(notification_type == "main"){
main_notification_data = Handlebars.compile($('#template-main_notification_data').html());
}else if(notification_type == "wa"){
main_notification_data = Handlebars.compile($('#template-main_whatsapp_notification_data').html());
}
$.each(notification,function(index, el) {
var name = el.name;
if(name == "")
name = el.username;
var title = "";
if(el.module_state == "adhoc_internal_status")
title = lang.lang_adhoc_internal_status;
if(el.module_type_id == "2"){
if(el.remark_type_id == "1"){
title = lang.lang_collector_request+" : "+el.status_code;
}else if(el.remark_type_id == "2"){
title = lang.lang_supervisor_review+" : "+el.status_code;
}else if(el.remark_type_id == "3"){
title = lang.lang_admin_status+" : "+el.status_code;
}
}
// if(title == "")
// return true;aba
main_notification_data_var = el;
main_notification_data_var.title = title;
main_notification_data_var.datetime = el.created_at;
main_notification_data_var.content = el.description;
main_notification_data_var.debtor_id = el.debtor_id;
main_notification_data_var.user_notification_id = el.user_notification_id;
if(el.sender_name != null)
main_notification_data_var.content = lang.lang_by+" "+el.sender_name +" "+main_notification_data_var.content;
notification_data += main_notification_data(main_notification_data_var);
});
}else{
var main_notification_nodata = Handlebars.compile($('#template-main_notification_nodata').html());
notification_data = main_notification_nodata();
}
if(notification_type == "main"){
$('.main_notification').html(notification_data);
}else if(notification_type == "wa"){
$('.main_whatsapp_notification').html(notification_data);
}
recountNotifictaionCountForBadge(notification_type);
}
function prepareNotificationData(notification,notification_type = "main"){
var notification_data = "";
// console.log(notification);
if(notification != null){
var main_notification_data = "";
var main_notification_data_var = {};
if(notification_type == "main"){
main_notification_data = Handlebars.compile($('#template-main_notification_data').html());
}else if(notification_type == "wa"){
main_notification_data = Handlebars.compile($('#template-main_whatsapp_notification_data').html());
}
var el = notification;
var name = el.name;
if(name == "")
name = el.username;
var title = "";
if(el.module_state == "adhoc_internal_status")
title = lang.lang_adhoc_internal_status;
if(el.module_type_id == "2"){
if(el.remark_type_id == "1"){
title = lang.lang_collector_request+" : "+el.status_code;
}else if(el.remark_type_id == "2"){
title = lang.lang_supervisor_review+" : "+el.status_code;
}else if(el.remark_type_id == "3"){
title = lang.lang_admin_status+" : "+el.status_code;
}
}
// if(title == "")
// return true;aba
main_notification_data_var = el;
main_notification_data_var.title = title;
main_notification_data_var.datetime = el.created_at;
main_notification_data_var.content = el.description;
main_notification_data_var.debtor_id = el.debtor_id;
main_notification_data_var.user_notification_id = el.user_notification_id;
if(el.sender_name != null)
main_notification_data_var.content = lang.lang_by+" "+el.sender_name +" "+main_notification_data_var.content;
notification_data += main_notification_data(main_notification_data_var);
}
return notification_data;
}
function prepareWhatsappNotificationData(notification){
var notification_data = "";
// console.log(notification);
if(notification != null){
var main_notification_data = Handlebars.compile($('#template-main_notification_data').html());
var main_notification_data_var = {};
var el = notification;
var name = el.name;
if(name == "")
name = el.username;
var title = "";
if(el.module_state == "adhoc_internal_status")
title = lang.lang_adhoc_internal_status;
if(el.module_type_id == "2"){
if(el.remark_type_id == "1"){
title = lang.lang_collector_request+" : "+el.status_code;
}else if(el.remark_type_id == "2"){
title = lang.lang_supervisor_review+" : "+el.status_code;
}else if(el.remark_type_id == "3"){
title = lang.lang_admin_status+" : "+el.status_code;
}
}
// if(title == "")
// return true;aba
main_notification_data_var.title = title;
main_notification_data_var.datetime = el.created_at;
main_notification_data_var.content = el.description;
main_notification_data_var.debtor_id = el.debtor_id;
main_notification_data_var.user_notification_id = el.user_notification_id;
if(el.sender_name != null)
main_notification_data_var.content = lang.lang_by+" "+el.sender_name +" "+main_notification_data_var.content;
notification_data += main_notification_data(main_notification_data_var);
}
return notification_data;
}
function connectToNotificationServer(){
var socket = io('https://'+volare_echo_host+':'+echo_server_port+'/',{reconnection: false});
if(enable_notification_reload){
socket.emit("subscribe", {
channel: "NotificationChannel."+global.general.collector_user_id,
}).on('App\\Events\\NotificationEvent', function(e,data) {
if(debtor_detail_additional_logic != "courts"){
refreshManager("callbadge");
}else{
refreshManager("ptp_nextcall");
}
if(enable_whatsapp && global.access.is_whatsapp_enabled == "1")
$(".main_whatsapp_notification").dxDataGrid("instance").refresh();
// console.log(data.event);
// console.log(data.data);
});
}
socket.emit("subscribe", {
channel: "InternalMessaging.Alert."+global.general.collector_user_id,
}).on('App\\Events\\MessageAlertEvent', function(e,data) {
refreshManager("internal_message");
});
}
function checkTabID(force = false){
var result = false;
if(force || sessionStorage.getItem('tab_id') == localStorage.getItem('tab_id')){
if(force || (sessionStorage.getItem('tab_id') == null && localStorage.getItem('tab_id') == null)){
var session_tab_id = getUniqueStr();
sessionStorage.setItem("tab_id",session_tab_id);
localStorage.setItem("tab_id",session_tab_id);
}
result = true;
}
return result;
}
function clearTabID(only_if_main_window = false){
if(only_if_main_window){
if(sessionStorage.getItem('tab_id') != localStorage.getItem('tab_id'))
return;
}
sessionStorage.removeItem("tab_id");
localStorage.removeItem("tab_id");
}
function sessionOverrideConfirmation(){
swal({
title: lang.lang_duplicate_window,
text: lang.lang_we_have_detected_multiple_tab_window,
showCancelButton: true,
showConfirmButton: true,
allowOutsideClick: false,
confirmButtonText: lang.lang_yes,
cancelButtonText: lang.lang_cancel,
backdrop: `rgba(0,0,0,1)`
}).then((result) => {
if (result.value) {
checkTabID(true);
volareApi("main",{action:"main",currentlanguage:currentLanguage});
}else{
endBrowserSession();
}
})
}
function endBrowserSession(){
swal({
title: lang.lang_duplicate_window,
text: lang.lang_your_session_has_ended_due_to_other_tab_window,
showCancelButton: false,
showConfirmButton: false,
allowOutsideClick: false,
backdrop: `rgba(0.5,0.5,0.5,0.9)`
});
if(global.sipCoreSession != null){
global.sipCoreSession.stop();
}
if(global.vicidial_i.sipCoreSession != null){
global.vicidial_i.logout();
}
}
function cakeSearch(data_source,conditions){
// console.log(conditions);
var result = [];
if(data_source != null && conditions != null ){
$.each(data_source,function(data_source_index, data_source_row) {
var error = false;
$.each(conditions,function(conditions_index, conditions_row) {
if($.isArray(conditions_row)){
var suberror = true;
$.each(conditions_row,function(conditions_row_index, conditions_row_subrow) {
if(data_source_row[conditions_index] != null && data_source_row[conditions_index][conditions_row_subrow] != null){
suberror = false;
return false;
}
});
if(suberror){
error = true;
return false;
}
}else{
if(data_source_row[conditions_index] == null || (data_source_row[conditions_index] != "all" && data_source_row[conditions_index][conditions_row] == null )){
error = true;
return false;
}else{
return true;
}
}
});
if(!error)
result.push(data_source_row.data);
});
}
// console.log(conditions);
// console.log(data_source);
// console.log(result);
return result;
}
function cakeSearchv2(data_source,conditions){
// console.log(data_source,conditions);
var result = [];
if(data_source != null && conditions != null ){
$.each(data_source,function(data_source_index, data_source_row) {
var error = false;
$.each(conditions,function(conditions_index, conditions_row) {
if($.isArray(conditions_row)){
var suberror = true;
$.each(conditions_row,function(conditions_row_index, conditions_row_subrow) {
if(data_source_row[conditions_index] != null && data_source_row[conditions_index][conditions_row_subrow] != null){
suberror = false;
return false;
}
});
if(suberror){
error = true;
return false;
}
}else{
if(data_source_row[conditions_index].indexOf(conditions_row) == -1 && data_source_row[conditions_index] != "all"){
error = true;
return false;
}else{
return true;
}
}
});
if(!error)
result.push(data_source_row.data);
});
}
// console.log(conditions);
// console.log(data_source);
// console.log(result);
return result;
}
function cakeSearchv3(data_source,conditions){
// console.log(data_source,conditions);
var result = [];
if(data_source != null && conditions != null ){
$.each(data_source,function(data_source_index, data_source_row) {
var error = false;
$.each(conditions,function(conditions_index, conditions_row) {
if(data_source_row[conditions_index] == "all" || ( template_criteria_mode == "dca" && ( conditions_index == "npl_status" || conditions_index == "account_status" || conditions_index == "opening_mia" || conditions_index == "islamic" ) )){
return true;
}else if($.isArray(conditions_row)){
var suberror = true;
$.each(conditions_row,function(conditions_row_index, conditions_row_subrow) {
// console.log(conditions_row_subrow);
if(data_source_row[conditions_index].indexOf(conditions_row_subrow) > -1){
suberror = false;
return false;
}
});
if(suberror){
error = true;
return false;
}
}else{
// if(data_source_row[conditions_index] != "all"){
if(conditions_index == "npl_status" || conditions_index == "account_status"){
if($.isArray(data_source_row[conditions_index])){
var suberror = true;
$.each(data_source_row[conditions_index],function(data_source_row_index, data_source_row_subrow) {
if((conditions_row['host_id'] != null && data_source_row_subrow['host_id'] == conditions_row['host_id'])&&(conditions_row['is_credit_card'] != null && data_source_row_subrow['is_credit_card'] == conditions_row['is_credit_card'])){
suberror = false;
return false;
}
});
if(suberror){
error = true;
return false;
}
}
// if(data_source_row[conditions_index]['host_id'].indexOf(conditions_row.host_id) == -1 || data_source_row[conditions_index]['is_credit_card'].indexOf(conditions_row.is_credit_card) == -1){
// }
}else{
if(conditions_index == "opening_mia"){
if(conditions_row != null && Number(conditions_row) > 12)
conditions_row = ">12";
}
// console.log(conditions_index);
if(data_source_row[conditions_index].indexOf(conditions_row) == -1){
error = true;
return false;
}
}
// }
}
});
if(!error)
result.push(data_source_row.data);
});
}
// console.log(conditions);
// console.log(data_source);
// console.log(result);
return result;
}
function initDragging(component) {
var $tagBoxElement = component.element();
// console.log('t',$tagBoxElement.find('.dx-tag'));
// console.log('tc',$tagBoxElement.find('.dx-tag-container'));
$tagBoxElement.find('.dx-tag').draggable({
helper: 'clone',
start: function (event, ui) {
var $originalTag = $(this),
$clonedTag = ui.helper;
}
});
$tagBoxElement.find('.dx-tag-container').droppable({
greedy: true,
drop: function (event, ui) {
var draggingTagIndex = ui.draggable.index();
var values = component.option('value');
var targetTagIndex = values.length - 1;
var tempValue = values[draggingTagIndex];
// if(tempValue != null){
values.splice(draggingTagIndex, 1);
values.splice(targetTagIndex, 0, tempValue);
var ttt = [];
// var ds = $('.debtor_sidebar_customer_tagging_tagbox').dxTagBox("getDataSource");
$.each(values,function(index, el) {
if(el != null)
ttt.push(el);
});
// values = ttt;
// console.log(values);
$('.debtor_sidebar_customer_tagging_tagbox').dxTagBox("instance").option("value",ttt);
var debtor_id = $('.debtor_sidebar_customer_tagging_tagbox').attr('volare-debtor_id');
if(debtor_id != null && debtor_id != "")
volareApi("updateDebtorCustomerTaggingv2",{action:"updateDebtorCustomerTaggingv2",debtor_id:debtor_id,customer_tagging:ttt});
// console.log(ds);
ui.draggable.appendTo($(this));
// }
console.log($('.debtor_sidebar_customer_tagging_tagbox').dxTagBox("instance").option("value"));
}
});
$tagBoxElement.find('.dx-tag').droppable({
greedy: true,
drop: function (event, ui) {
var draggingTagIndex = ui.draggable.index();
var targetTagIndex = $(this).index();
var values = component.option('value');
// console.log("After : ", values);
var tempValue = values[draggingTagIndex];
if(draggingTagIndex < targetTagIndex && targetTagIndex > 0) {
targetTagIndex--;
}
event.stopImmediatePropagation();
values.splice(draggingTagIndex, 1);
values.splice(targetTagIndex, 0, tempValue);
var ttt = [];
$.each(values,function(index, el) {
if(el != null)
ttt.push(el);
});
$('.debtor_sidebar_customer_tagging_tagbox').dxTagBox("instance").option("value",ttt);
var debtor_id = $('.debtor_sidebar_customer_tagging_tagbox').attr('volare-debtor_id');
if(debtor_id != null && debtor_id != "")
volareApi("updateDebtorCustomerTaggingv2",{action:"updateDebtorCustomerTaggingv2",debtor_id:debtor_id,customer_tagging:ttt});
// values = ttt;
// console.log(values);
ui.draggable.insertBefore($(this));
console.log($('.debtor_sidebar_customer_tagging_tagbox').dxTagBox("instance").option("value"));
}
});
}
function isNotEmpty(value) {
return value !== undefined && value !== null && value !== "";
}
function prepareFollowupCards(row,type,debtor){
// console.log(global.access);
// global.access.is_recording_player_enabled = 0;
var basevar = {};
basevar.debtor_allcards = "";
if(type == "fu"){
global.general.followups[row.id] = row;
var card = Handlebars.compile($('#template-debtorsidebar_card_followup').html());
var cardvar = {};
cardvar.flagPtp = row.flagPtp == "1";
cardvar.lang = lang;
cardvar.flagClaimPaid = row.flagClaimPaid == "1";
cardvar.has_next_call = row.has_next_call == "1";
cardvar.id = row.id;
switch (row.MappedImageName)
{
case "Wrong Party Contact":
row.MappedImageName = "not-related-party";
break;
case "Right Party Contact":
row.MappedImageName = "debtor";
break;
case "Related Party Contact":
row.MappedImageName = "related-party";
break;
case "Unknown Party Contact":
row.MappedImageName = "unknown-party";
break;
}
switch (row.RelationLabel)
{
case "Wrong Party Contact":
row.RelationLabel = "Wrong Number";
break;
case "Right Party Contact":
case "Debtor":
row.RelationLabel = "Debtor";
if(showDebtorAsCustomer){
row.RelationLabel = "Customer";
}
break;
case "Related Party Contact":
row.RelationLabel = "Related Party";
break;
case "Unknown Party Contact":
row.RelationLabel = "Unknown";
break;
}
// if(row.flagpredictive == "1"){
// cardvar.calltype = "predictive";
// cardvar.calltypeword = lang.lang_predictive_call;
// }
// if(row.flagpredictive == "1"){
// cardvar.calltype = "predictive";
// cardvar.calltypeword = lang.lang_predictive_call;
// }
cardvar.allow_make_call = true;
if(global.debtordata[debtor.id].contactnumbers[row.CONTACTNOID] == null || global.debtordata[debtor.id].contactnumbers[row.CONTACTNOID].FlagContactable == "2"){
cardvar.allow_make_call = false;
}
cardvar.MappedImageName = row.MappedImageName;
cardvar.RelationLabel = row.RelationLabel;
cardvar.Telno = cleanNumber(row.Telno);
cardvar.PtpAmount = formatCurrency(row.PtpAmount);
cardvar.PtpDate = getLanguageDate(row.PtpDate);
cardvar.ClaimPaidAmnt = formatCurrency(row.ClaimPaidAmnt);
cardvar.ClaimPaidDt = getLanguageDate(row.ClaimPaidDt);
cardvar.Status = row.Status;
cardvar.next_call = row.next_call;
cardvar.FollowupDate = row.FollowupDate;
cardvar.RemarkByCollectorName = row.RemarkByCollectorName;
cardvar.remark = row.remark;
cardvar.CONTACTNOID = row.CONTACTNOID;
cardvar.debtor_id = debtor.id;
cardvar.calltype = "";
if(global.general.module_datas[row.id] != null){
switch (global.general.module_datas[row.id]['fu'].calltype)
{
case "1":
cardvar.calltype = "incoming";
cardvar.calltypeword = lang.lang_incomingcall;
break;
case "3":
cardvar.calltype = "outgoing";
cardvar.calltypeword = lang.lang_outgoing_call_titleonly;
break;
case "5":
cardvar.calltype = "predictive";
cardvar.calltypeword = lang.lang_predictive_call;
break;
case "11":
cardvar.calltype = "ivr_return_call";
cardvar.calltypeword = lang.lang_ivr_return_call;
break;
}
cardvar.prefix_word = "";
if(enable_dialer_log_prefix){
if(global.general.module_datas[row.id]['fu'].prefix && global.general.module_datas[row.id]['fu'].prefix != '' && global.general.masking_number_list[global.general.module_datas[row.id]['fu'].prefix] != null && global.general.masking_number_list[global.general.module_datas[row.id]['fu'].prefix] != ''){
cardvar.prefix_word = global.general.masking_number_list[global.general.module_datas[row.id]['fu'].prefix].maskingtext;
}
}
cardvar.sip_call_id = global.general.module_datas[row.id]['fu'].sip_call_id != null ? global.general.module_datas[row.id]['fu'].sip_call_id : null;
cardvar.recording_file_name = global.general.module_datas[row.id]['fu'].recording_file_name != null ? global.general.module_datas[row.id]['fu'].recording_file_name : null;
cardvar.call_duration = "";
if(enable_multiple_predictive_server){
cardvar.predictive_dialer_server_id = global.general.module_datas[row.id]['fu'].predictive_dialer_server_id != null ? global.general.module_datas[row.id]['fu'].predictive_dialer_server_id : null;
}
// console.log(global.general.module_datas[row.id]['fu'].call_duration);
if(enable_debtor_sidebar_followup_card_call_duration){
cardvar.call_duration = Number(global.general.module_datas[row.id]['fu'].call_duration);
cardvar.call_duration = " ("+moment("1900-01-01 00:00:00").add(cardvar.call_duration, 'seconds').format("mm:ss")+")";
}
// console.log(global.general.module_datas[row.id]['fu']);
cardvar.dialer_log_id = global.general.module_datas[row.id]['fu'].id;
}
cardvar.has_recording = (cardvar.sip_call_id != null && cardvar.sip_call_id != "" && cardvar.recording_file_name != null && cardvar.recording_file_name != "" && global.access.is_recording_player_enabled == "1");
if(enable_mahen_pasarmalam_workfromhome_intergration){
cardvar.remark = maskManualNumber(cardvar.remark);
}
cardvar.id = row.id;
// console.log(global.general.module_datas[row.id]);
basevar.debtor_allcards += card(cardvar);
// if(row['FlagVisit'] == "1"){
// newentry.find('.followup_fieldvisitdate').html( getLanguageDate(row['visitDate']));
// newentry.find('.followup_fieldvisitofficername').html(row['FVOfficer']);
// newentry.find('.fu_fvblock_span').show();
// }
}else if(type == "ir"){
var card = Handlebars.compile($('#template-debtorsidebar_card_internalremark').html());
var cardvar = {};
cardvar.status_wording = "";
if(row.AdminStatus == "" || row.AdminStatus == null ){
row.AdminStatus = lang.lang_none_selected;
}
if(row.SupervisionStatus == "" || row.SupervisionStatus == null){
row.SupervisionStatus = lang.lang_none_selected;
}
if(row.CollectorStatus == "" || row.CollectorStatus == null){
row.CollectorStatus = lang.lang_none_selected;
}
if(row.remark_type_id == "1"){
cardvar.CollectorStatus = row.CollectorStatus;
cardvar.status_wording = lang.lang_collector_request+" : "+row.CollectorStatus;
}else if(row.remark_type_id == "2"){
cardvar.SupervisionStatus = row.SupervisionStatus;
cardvar.status_wording = lang.lang_supervisor_review+" : "+row.SupervisionStatus;
}else if(row.remark_type_id == "3"){
cardvar.AdminStatus = row.AdminStatus;
cardvar.status_wording = lang.lang_admin_status+" : "+row.AdminStatus;
}
cardvar.Remark = row.Remark;
cardvar.FollowupDate = row.FollowupDate;
if(row.action_type_id != null){
if(row.action_type_id == "1"){
cardvar.action_type = lang.lang_approved_by;
}else if(row.action_type_id == "2"){
cardvar.action_type = lang.lang_rejected_by;
}
cardvar.action_by_name = row.action_by_name;
cardvar.action_datetime = row.action_datetime;
}
cardvar.RemarkDate = getLanguageDateTime(row.RemarkDate);
cardvar.RemarkByCollectorName = row.RemarkByCollectorName;
if(enable_internal_escalation){
cardvar.escalation_ticket_id = row.escalation_ticket_id;
cardvar.escalation_ticket_detail_id = row.escalation_ticket_detail_id;
}
cardvar.lang = {};
cardvar.lang.lang_reply = lang.lang_reply;
basevar.debtor_allcards += card(cardvar);
}else if(type == "pymt"){
var card = Handlebars.compile($('#template-debtorsidebar_card_payment01').html());
var cardvar = {};
// cardvar.CreatedDt = getLanguageDateTime(row.followuptime);
cardvar.CreatedDt = row.followuptime;
cardvar.bank = row.bank;
if(global.general.module_datas[row.Id] != null){
cardvar.PAYMENTDATE = getLanguageDate(global.general.module_datas[row.Id]['pymt'].PAYMENTDATE);
cardvar.PAYMENT = formatCurrency(global.general.module_datas[row.Id]['pymt'].PAYMENT);
cardvar.assigned_collector_name = global.general.module_datas[row.Id]['pymt'].assigned_collector_name;
}
cardvar.RemarkDate = getLanguageDateTime(row.RemarkDate);
cardvar.COLLECTORNAME = row.RemarkByCollectorName;
cardvar.reference = "";
if(row.receiptNo != null)
cardvar.reference += row.receiptNo;
if(row.reference_number != null)
cardvar.reference += " "+row.reference_number;
cardvar.REMARKS = row.Remark;
if(cardvar.assigned_collector_name != null && cardvar.assigned_collector_name != "")
cardvar.REMARKS = cardvar.assigned_collector_name + " - " + cardvar.REMARKS;
cardvar.Status = row.Status;
cardvar.lang = lang;
basevar.debtor_allcards += card(cardvar);
}else if(type == "sms"){
var card = Handlebars.compile($('#template-debtorsidebar_card_sms').html());
var cardvar = {};
cardvar = row;
cardvar.SMSSTATUS = row.SMSSTATUS;
cardvar.SMSTIMESTAMP = getLanguageDate(row.SMSTIMESTAMP);
cardvar.SMSCOLLECTORID = row.SMSCOLLECTORID;
cardvar.SMSHPNO = row.SMSHPNO;
cardvar.SMSMESSAGE = row.SMSMESSAGE;
cardvar.SMSDEBTORID = row.SMSDEBTORID;
// cardvar.CONTACTNOID = row.CONTACTNOID; // don't have
cardvar.SMSHPNO = row.SMSHPNO;
cardvar.RemarkDate = getLanguageDateTime(row.RemarkDate);
cardvar.REMARKS = row.REMARKS;
basevar.debtor_allcards += card(cardvar);
}else if(type == "fv"){
if(enable_field_visit){
var card = Handlebars.compile($('#template-debtorsidebar_card_fieldvisit').html());
var cardvar = {};
// console.log(row);
// console.log(global.general.module_datas[row.Id]);
cardvar = row;
cardvar.lang = lang;
cardvar.fv_status_word = '';
cardvar.field_visit_name = '';
cardvar.field_visit_text = '';
cardvar.fv_status = '';
// console.log(row.Id);
if(global.general.module_datas[row.Id] != null && global.general.module_datas[row.Id]['fv'] != null){
cardvar.fv = global.general.module_datas[row.Id]['fv'];
cardvar.fv_status = global.general.module_datas[row.Id]['fv'].fv_status;
switch (global.general.module_datas[row.Id]['fv'].fv_status)
{
case "0":
cardvar.fv_status_word = lang.lang_field_visit_request;
cardvar.fv_status_class_word = 'lang_field_visit_request';
cardvar.field_visit_name = global.general.module_datas[row.Id]['fv'].requested_by;
cardvar.field_visit_text = lang.lang_reason + ':' + cardvar.reason;
break;
case "1":
cardvar.fv_status_word = lang.lang_field_visit_approved;
cardvar.fv_status_class_word = 'lang_field_visit_approved';
cardvar.field_visit_name = global.general.module_datas[row.Id]['fv'].approved_by;
cardvar.field_visit_text = lang.lang_reason + ':' + cardvar.reason;
break;
case "2":
cardvar.fv_status_word = lang.lang_field_visit_assigned;
cardvar.fv_status_class_word = 'lang_field_visit_assigned';
cardvar.field_visit_name = global.general.module_datas[row.Id]['fv'].assigned_by;
break;
case "3":
cardvar.fv_status_word = lang.lang_field_visit_aborted;
cardvar.fv_status_class_word = 'lang_field_visit_aborted';
break;
case "4":
cardvar.fv_status_word = lang.lang_field_visit_rejected;
cardvar.fv_status_class_word = 'lang_field_visit_rejected';
cardvar.field_visit_name = global.general.module_datas[row.Id]['fv'].rejected_by;
break;
case "5":
cardvar.fv_status_word = lang.lang_field_visit_completed;
cardvar.fv_status_class_word = 'lang_field_visit_completed';
cardvar.field_visit_name = global.general.module_datas[row.Id]['fv'].field_visit_officer;
break;
default:break;
}
cardvar.address = global.general.module_datas[row.Id]['fv'].address;
if(enable_field_visit_followup_address_label)
cardvar.address = global.general.module_datas[row.Id]['fv'].label;
cardvar.reason = global.general.module_datas[row.Id]['fv'].reason;
cardvar.mission_start_datetime = global.general.module_datas[row.Id]['fv'].mission_start_datetime;
cardvar.fv.field_visit_photo_detail_info = JSON.stringify({
mission_start_datetime:global.general.module_datas[row.Id]['fv'].mission_start_datetime,
field_visit_officer:global.general.module_datas[row.Id]['fv'].field_visit_officer,
address: enable_field_visit_followup_address_label ? global.general.module_datas[row.Id]['fv'].label :global.general.module_datas[row.Id]['fv'].address,
});
}
basevar.debtor_allcards += card(cardvar);
}
}else if(type == "legal"){
if(enable_legal_followup){
var card = Handlebars.compile($('#template-debtorsidebar_card_legal').html());
if(enable_legal_followup_claim_paid){
card = Handlebars.compile($('#template-debtorsidebar_card_legal_claimpaid').html());
}
var cardvar = {};
cardvar = row;
cardvar.lang = lang;
if(global.general.module_datas[row.Id] != null && global.general.module_datas[row.Id]['legal'] != null){
cardvar.legal = global.general.module_datas[row.Id]['legal'];
}
basevar.debtor_allcards += card(cardvar);
}
}else if(type == "le"){
var card = Handlebars.compile($('#template-debtorsidebar_card_letteremail').html());
var cardvar = {};
cardvar = row;
cardvar.debtor_id = debtor.id;
cardvar.lang = lang;
// cardvar.remark = lang.lang_printed_document_with_the_following_template.replace("#name#","");
basevar.debtor_allcards += card(cardvar);
}else if(type =="wc"){
var card = Handlebars.compile($('#template-debtorsidebar_card_workcollection').html());
var cardvar = {};
cardvar = row;
cardvar.debtor_id = debtor.id;
cardvar.lang = lang;
// cardvar.remark = lang.lang_printed_document_with_the_following_template.replace("#name#","");
basevar.debtor_allcards += card(cardvar);
}else if(type =="pm"){
var card = Handlebars.compile($('#template-debtorsidebar_card_permanentmessage').html());
var cardvar = {};
cardvar = row;
cardvar.debtor_id = debtor.id;
cardvar.lang = lang;
// cardvar.remark = lang.lang_printed_document_with_the_following_template.replace("#name#","");
basevar.debtor_allcards += card(cardvar);
}else if(type =="elec"){
var card = Handlebars.compile($('#template-debtorsidebar_card_electronicdiary').html());
var cardvar = {};
cardvar = row;
cardvar.debtor_id = debtor.id;
cardvar.lang = lang;
// cardvar.remark = lang.lang_printed_document_with_the_following_template.replace("#name#","");
basevar.debtor_allcards += card(cardvar);
}else if(type =="ec"){
var card = Handlebars.compile($('#template-debtorsidebar_card_escalation').html());
var cardvar = {};
cardvar = row;
cardvar.has_request = false;
cardvar.has_recording = false;
cardvar.has_reply = false;
cardvar.has_view = false;
cardvar.debtor_id = debtor.id;
cardvar.lang = lang;
// cardvar.remark = lang.lang_printed_document_with_the_following_template.replace("#name#","");
// console.log(row);
// console.log(global.general.module_datas[row.id]);
if(global.general.module_datas[row.id] != null){
var data = global.general.module_datas[row.id].ec.data;
global.general.module_datas[row.id].ec.base = row;
cardvar.sip_call_id = global.general.module_datas[row.id].ec.sip_call_id;
cardvar.recording_file_name = global.general.module_datas[row.id].ec.recording_file_name;
cardvar.calltype = global.general.module_datas[row.id].ec.calltype;
cardvar.attachment_file_name = global.general.module_datas[row.id].ec.file_name;
if(cardvar.sip_call_id != null && cardvar.sip_call_id != '')
cardvar.has_recording = true;
// console.log(global.general.module_datas[row.id]);
switch(row.RemarkTypeId){
case "1":
if(row.escalation_state == "0"){
cardvar.escalation_title = lang.lang_new_contact_number_request;
cardvar.remark = lang.lang_added_new_contact_contact.replace("#contact_number#",data.contact_number);
global.general.module_datas[row.id].ec.escalation_title = lang.lang_new_contact_number_request;
if(row.escalation_target_ids.indexOf(global.general.collector_user_id+"") > -1){
cardvar.has_request = true;
}
}else if(row.escalation_state == "1"){
cardvar.escalation_title = lang.lang_new_contact_number_request_approved;
cardvar.has_reply = true;
cardvar.reply_by = row.updated_by;
cardvar.reply_remark = row.remark;
cardvar.remark = lang.lang_added_new_contact_contact.replace("#contact_number#",data.contact_number);
}else if(row.escalation_state == "2"){
cardvar.escalation_title = lang.lang_new_contact_number_request_rejected;
cardvar.has_reply = true;
cardvar.reply_by = row.updated_by;
cardvar.reply_remark = row.remark;
cardvar.remark = lang.lang_added_new_contact_contact.replace("#contact_number#",data.contact_number);
}
break;
case "2":
if(row.escalation_state == "0"){
cardvar.escalation_title = lang.lang_contact_number_tag_as_do_not_call_request;
cardvar.remark = lang.lang_contact_number_tag_as_do_not_call.replace("#contact_number#",data.contact_number);
global.general.module_datas[row.id].ec.escalation_title = lang.lang_contact_number_tag_as_do_not_call_request;
if(row.escalation_target_ids.indexOf(global.general.collector_user_id+"") > -1){
cardvar.has_request = true;
}
}else if(row.escalation_state == "1"){
cardvar.escalation_title = lang.lang_contact_number_tag_as_do_not_call_request_approved;
cardvar.has_reply = true;
cardvar.reply_by = row.updated_by;
cardvar.reply_remark = row.remark;
cardvar.remark = lang.lang_contact_number_tag_as_do_not_call.replace("#contact_number#",data.contact_number);
}else if(row.escalation_state == "2"){
cardvar.escalation_title = lang.lang_contact_number_tag_as_do_not_call_request_rejected;
cardvar.has_reply = true;
cardvar.reply_by = row.updated_by;
cardvar.reply_remark = row.remark;
cardvar.remark = lang.lang_contact_number_tag_as_do_not_call.replace("#contact_number#",data.contact_number);
}
break;
case "3":
if(row.escalation_state == "0"){
cardvar.escalation_title = lang.lang_contact_number_tag_as_do_not_sms_request;
cardvar.remark = lang.lang_contact_number_tag_as_do_not_sms.replace("#contact_number#",data.contact_number);
global.general.module_datas[row.id].ec.escalation_title = lang.lang_contact_number_tag_as_do_not_sms_request;
if(row.escalation_target_ids.indexOf(global.general.collector_user_id+"") > -1){
cardvar.has_request = true;
}
}else if(row.escalation_state == "1"){
cardvar.escalation_title = lang.lang_contact_number_tag_as_do_not_sms_request_approved;
cardvar.has_reply = true;
cardvar.reply_by = row.updated_by;
cardvar.reply_remark = row.remark;
cardvar.remark = lang.lang_contact_number_tag_as_do_not_sms.replace("#contact_number#",data.contact_number);
}else if(row.escalation_state == "2"){
cardvar.escalation_title = lang.lang_contact_number_tag_as_do_not_sms_request_rejected;
cardvar.has_reply = true;
cardvar.reply_by = row.updated_by;
cardvar.reply_remark = row.remark;
cardvar.remark = lang.lang_contact_number_tag_as_do_not_sms.replace("#contact_number#",data.contact_number);
}
break;
case "4":
if(row.escalation_state == "0"){
cardvar.escalation_title = lang.lang_schedule_next_call_after_sociable_hour_request;
cardvar.remark = lang.lang_schedule_next_call_after_sociable_hour_request;
global.general.module_datas[row.id].ec.escalation_title = lang.lang_schedule_next_call_after_sociable_hour_request;
if(row.escalation_target_ids.indexOf(global.general.collector_user_id+"") > -1){
cardvar.has_request = true;
}
}else if(row.escalation_state == "1"){
cardvar.escalation_title = lang.lang_schedule_next_call_after_sociable_hour_request_approved;
cardvar.has_reply = true;
cardvar.reply_by = row.updated_by;
cardvar.reply_remark = row.remark;
cardvar.remark = lang.lang_schedule_next_call_after_sociable_hour_request;
}else if(row.escalation_state == "2"){
cardvar.escalation_title = lang.lang_schedule_next_call_after_sociable_hour_request_rejected;
cardvar.has_reply = true;
cardvar.reply_by = row.updated_by;
cardvar.reply_remark = row.remark;
cardvar.remark = lang.lang_schedule_next_call_after_sociable_hour_request;
}
break;
case "5":
if(enable_atp){
if(global.general.module_datas[row.id].ec.atp_status == "0"){
cardvar.escalation_title = lang.lang_atp_request_pending;
cardvar.remark = lang.lang_atp_submitted_pending_review;
cardvar.has_view = true;
}else if(global.general.module_datas[row.id].ec.atp_status == "1"){
cardvar.escalation_title = lang.lang_atp_request_approved;
cardvar.remark = lang.lang_atp_submitted_approved;
cardvar.has_view = true;
}else if(global.general.module_datas[row.id].ec.atp_status == "2"){
cardvar.escalation_title = lang.lang_atp_request_rejected;
cardvar.remark = lang.lang_atp_submitted_rejected;
cardvar.has_view = true;
}else if(global.general.module_datas[row.id].ec.atp_status == "3"){
cardvar.escalation_title = lang.lang_atp_request_void;
cardvar.remark = lang.lang_atp_submitted_void;
cardvar.has_view = true;
}
}
break;
default:break;
}
// console.log(global.general.module_datas[row.id]);
}
basevar.debtor_allcards += card(cardvar);
}else if(type == "voicebot"){
global.general.followups[row.id] = row;
var card = Handlebars.compile($('#template-debtorsidebar_card_voicebot').html());
var cardvar = {};
cardvar.flagPtp = row.flagPtp == "1";
cardvar.lang = lang;
cardvar.flagClaimPaid = row.flagClaimPaid == "1";
cardvar.has_next_call = row.has_next_call == "1";
cardvar.id = row.id;
switch (row.MappedImageName)
{
case "Wrong Party Contact":
row.MappedImageName = "not-related-party";
break;
case "Right Party Contact":
row.MappedImageName = "debtor";
break;
case "Related Party Contact":
row.MappedImageName = "related-party";
break;
case "Unknown Party Contact":
row.MappedImageName = "unknown-party";
break;
}
switch (row.RelationLabel)
{
case "Wrong Party Contact":
row.RelationLabel = "Wrong Number";
break;
case "Right Party Contact":
case "Debtor":
row.RelationLabel = "Debtor";
if(showDebtorAsCustomer){
row.RelationLabel = "Customer";
}
break;
case "Related Party Contact":
row.RelationLabel = "Related Party";
break;
case "Unknown Party Contact":
row.RelationLabel = "Unknown";
break;
}
// if(row.flagpredictive == "1"){
// cardvar.calltype = "predictive";
// cardvar.calltypeword = lang.lang_predictive_call;
// }
// if(row.flagpredictive == "1"){
// cardvar.calltype = "predictive";
// cardvar.calltypeword = lang.lang_predictive_call;
// }
cardvar.allow_make_call = true;
if(global.debtordata[debtor.id].contactnumbers[row.CONTACTNOID] == null || global.debtordata[debtor.id].contactnumbers[row.CONTACTNOID].FlagContactable == "2"){
cardvar.allow_make_call = false;
}
cardvar.MappedImageName = row.MappedImageName;
cardvar.RelationLabel = row.RelationLabel;
cardvar.Telno = cleanNumber(row.Telno);
cardvar.PtpAmount = formatCurrency(row.PtpAmount);
cardvar.PtpDate = getLanguageDate(row.PtpDate);
cardvar.ClaimPaidAmnt = formatCurrency(row.ClaimPaidAmnt);
cardvar.ClaimPaidDt = getLanguageDate(row.ClaimPaidDt);
cardvar.Status = row.Status;
cardvar.next_call = row.next_call;
cardvar.FollowupDate = row.FollowupDate;
cardvar.RemarkByCollectorName = row.RemarkByCollectorName;
cardvar.remark = row.remark;
cardvar.CONTACTNOID = row.CONTACTNOID;
cardvar.debtor_id = debtor.id;
cardvar.calltype = "";
cardvar.predictive_campaign_id = row.predictive_campaign_id;
if(global.general.module_datas[row.id] != null){
switch (global.general.module_datas[row.id]['voicebot'].calltype)
{
case "1":
cardvar.calltype = "incoming";
cardvar.calltypeword = lang.lang_incomingcall;
break;
case "3":
cardvar.calltype = "outgoing";
cardvar.calltypeword = lang.lang_outgoing_call_titleonly;
break;
case "5":
cardvar.calltype = "predictive";
cardvar.calltypeword = lang.lang_predictive_call;
break;
case "12":
cardvar.calltype = "voicebot";
cardvar.calltypeword = lang.lang_voicebot;
break;
}
cardvar.prefix_word = "";
if(enable_dialer_log_prefix){
if(global.general.module_datas[row.id]['voicebot'].prefix && global.general.module_datas[row.id]['voicebot'].prefix != '' && global.general.masking_number_list[global.general.module_datas[row.id]['voicebot'].prefix] != null && global.general.masking_number_list[global.general.module_datas[row.id]['voicebot'].prefix] != ''){
cardvar.prefix_word = global.general.masking_number_list[global.general.module_datas[row.id]['voicebot'].prefix].maskingtext;
}
}
cardvar.sip_call_id = global.general.module_datas[row.id]['voicebot'].sip_call_id != null ? global.general.module_datas[row.id]['voicebot'].sip_call_id : null;
cardvar.recording_file_name = global.general.module_datas[row.id]['voicebot'].recording_file_name != null ? global.general.module_datas[row.id]['voicebot'].recording_file_name : null;
cardvar.call_duration = "";
if(enable_multiple_predictive_server){
cardvar.predictive_dialer_server_id = global.general.module_datas[row.id]['voicebot'].predictive_dialer_server_id != null ? global.general.module_datas[row.id]['voicebot'].predictive_dialer_server_id : null;
}
// console.log(global.general.module_datas[row.id]['fu'].call_duration);
if(enable_debtor_sidebar_followup_card_call_duration){
cardvar.call_duration = Number(global.general.module_datas[row.id]['voicebot'].call_duration);
cardvar.call_duration = " ("+moment("1900-01-01 00:00:00").add(cardvar.call_duration, 'seconds').format("mm:ss")+")";
}
// console.log(global.general.module_datas[row.id]['fu']);
cardvar.dialer_log_id = global.general.module_datas[row.id]['voicebot'].id;
}
cardvar.has_recording = (cardvar.sip_call_id != null && cardvar.sip_call_id != "" && cardvar.recording_file_name != null && cardvar.recording_file_name != "" && global.access.is_recording_player_enabled == "1");
if(enable_mahen_pasarmalam_workfromhome_intergration){
cardvar.remark = maskManualNumber(cardvar.remark);
}
cardvar.enable_voicebot_final_tag = enable_voicebot_final_tag;
if(enable_voicebot_final_tag){
cardvar.voicebot_final_tag = global.general.module_datas[row.id]['voicebot'].voicebot_final_tag != null ? global.general.module_datas[row.id]['voicebot'].voicebot_final_tag : null;
cardvar.volare_call_status = global.general.module_datas[row.id]['voicebot'].volare_call_status != null ? global.general.module_datas[row.id]['voicebot'].volare_call_status : null;
cardvar.hangup_by = global.general.module_datas[row.id]['voicebot'].hangup_by != null ? global.general.module_datas[row.id]['voicebot'].hangup_by : null;
}
cardvar.id = row.id;
// console.log(global.general.module_datas[row.id]);
basevar.debtor_allcards += card(cardvar);
// if(row['FlagVisit'] == "1"){
// newentry.find('.followup_fieldvisitdate').html( getLanguageDate(row['visitDate']));
// newentry.find('.followup_fieldvisitofficername').html(row['FVOfficer']);
// newentry.find('.fu_fvblock_span').show();
// }
}
return basevar.debtor_allcards;
}
function ud(...values){
$.each(values,function(index, content) {
if(typeof content == "object" || typeof content == "array"){
content = JSON.stringify(content,null, 2);
}
// if(var_dump)
// content = JSON.stringify(content);
global.debug.log.push(content);
});
}
function vd(...values){
$.each(values,function(index, content) {
if(typeof content == "object" || typeof content == "array"){
content = JSON.stringify(content,null, 2);
}
// if(var_dump)
// content = JSON.stringify(content);
global.debug.voice.push({datetime:moment().format(momentSqlDateTimeSecondFormat),data:content});
});
}
function logoutProcess(){
if(global.sipCoreSession != null){
global.sipCoreSession.stop();
}
if(global.vicidial_i.sipCoreSession != null){
global.vicidial_i.logout();
}
}
function escapeHTML(text){
var result = "";
if(text != null)
result = text.replace('<','<').replace('>','>');
return result;
}
function getReadStatus(status_code){
var result = lang.lang_unread;
if(status_code == "1")
result = lang.lang_read;
return result;
}
dxDataGridDoubleClick = function(e, callback){
var component = e.component;
if(e['rowType'] == "data"){
function initialClick() {
component.clickCount = 1;
component.clickKey = e.key;
component.clickDate = new Date();
}
function doubleClick(callback) {
if(callback !== undefined){
callback(e);
}
component.clickCount = 0;
component.clickKey = 0;
component.clickDate = null;
}
if ((!component.clickCount) || (component.clickCount != 1) || (component.clickKey != e.key) ) {
initialClick();
}
else if (component.clickKey == e.key) {
if (((new Date()) - component.clickDate) <= 800)
doubleClick(callback);
else
initialClick();
}
}
}
function updateInternalMessage(operation){
$('#internal_message_grid_view').dxDataGrid("instance").getSelectedRowKeys().done(function(ids){
if(ids.length>0){
volareApi("updateInternalMessage", {action: 'updateInternalMessage',internal_message_id:ids,direction:global.general.internal_message_mode,mode:operation});
}
});
}
function validateInternalMessageCompose(){
var error = false;
if($("select.main_internal_message_compose_collector_list_select").val() == ""){
$(".main_internal_message_compose_collector_list_select").addClass('is-invalid');
error = true;
}else{
$(".main_internal_message_compose_collector_list_select").removeClass('is-invalid');
}
if($(".main_internal_message_compose_input_subject").val() == ""){
$(".main_internal_message_compose_input_subject").addClass('is-invalid');
error = true;
}else{
$(".main_internal_message_compose_input_subject").removeClass('is-invalid');
}
if($(".main_internal_message_compose_input_content").val() == ""){
$(".main_internal_message_compose_input_content").addClass('is-invalid');
error = true;
}else{
$(".main_internal_message_compose_input_content").removeClass('is-invalid');
}
if(error){
$(".main_internal_message_compose_input_send").prop('disabled',true);
}else{
$(".main_internal_message_compose_input_send").prop('disabled',false);
}
}
function validateAddPayment(){
var error = false;
if($(".main_add_payment_payment_date").val() == ""){
$(".main_add_payment_payment_date").addClass('is-invalid');
error = true;
}else{
$(".main_add_payment_payment_date").removeClass('is-invalid');
}
if($(".main_add_payment_payment_amount").val() == ""){
$(".main_add_payment_payment_amount").addClass('is-invalid');
error = true;
}else{
$(".main_add_payment_payment_amount").removeClass('is-invalid');
}
if(error){
$(".main_add_payment_submit").prop('disabled',true);
}else{
$(".main_add_payment_submit").prop('disabled',false);
}
}
function displayNetworkError(uid){
var notify = $.notify({
icon: 'fas fa-info-circle fa-lg mr-2',
title: lang.lang_alert,
message: ' '+lang.lang_network_error_message+' '+lang.lang_report+' ',
target: '_blank'
},{
element: 'body',
position: null,
type: "warning",
allow_dismiss: true,
newest_on_top: false,
showProgressbar: false,
placement: {
from: "bottom",
align: "left"
},
offset: {x:20,y:50},
spacing: 10,
z_index: 1031,
delay: 0,
timer: 1000,
url_target: '_blank',
mouse_over: null,
animate: {
enter: 'animated fadeInLeft',
exit: 'animated fadeOutLeft'
},
onShow: null,
onShown: null,
onClose: null,
onClosed: null,
icon_type: 'class',
template: '' +
'
× ' +
'
' +
'
{1} ' +
'
{2} ' +
'
' +
'
' +
'
'
});
global.calldata[uid].notify_network = notify;
}
function initCallList(){
$("#gridContainer").dxDataGrid({
dataSource: {
store: DevExpress.data.AspNet.createStore({
key: "id",
loadUrl: "./volare_calllist.php",
// insertUrl: url,
// updateUrl: url,
// deleteUrl: url
onBeforeSend: function(method, options) {
options.data.color = global.filtercolor;
// console.log("aaa",options);
}
})
},
height: "100%",
columns: grid_call_list,
// [
// {caption: '#',dataType: "number",allowReordering:false,sortIndex: 0,alignment:"right",
// cellTemplate: function(cellElement, cellInfo) {
// cellElement.text(cellElement.parent().attr('aria-rowIndex')-cellElement.parent().prevAll('.dx-group-row').length);
// }
// },
// {dataField: "id",dataType: "string",visible:false,allowFiltering:false,showInColumnChooser:false},
// {dataField: "name",dataType: "string",caption:lang.lang_name},
// {dataField: "account",dataType: "string",caption:lang.lang_account},
// {dataField: "status_code",dataType: "string",caption:lang.lang_statuscode,alignment:"center"},
// {dataField: "collector_user_name",dataType: "string",caption:lang.lang_collector},
// {dataField: "client_outstanding_balance",caption:lang.lang_total_amount,dataType:"decimal",allowFiltering:false,alignment:"right",
// customizeText: function(row) {
// return formatCurrency(row.valueText);
// },
// },
// {dataField: "balance",caption:lang.lang_balance,dataType:"decimal",allowFiltering:false,alignment:"right",
// customizeText: function(row) {
// return formatCurrency(row.valueText);
// },
// },
// {dataField: "client_name",dataType: "string",caption:lang.lang_client},
// {dataField: "batch_no",dataType: "string",caption:lang.lang_batchno},
// {dataField: "new_ic",dataType: "string",caption:lang.lang_newic},
// {dataField: "old_ic",dataType: "string",caption:lang.lang_oldic},
// {dataField: "card_no",dataType: "string",caption:lang.lang_cardno},
// {dataField: "service_number",dataType: "string",caption:lang.lang_serviceno},
// {dataField: "next_call",caption:lang.lang_next_call,dataType:"datetime",allowFiltering:false},
// {dataField: "ptp_date",caption:lang.lang_ptp_date,dataType:"datetime",allowFiltering:false},
// {dataField: "ptp_amount",caption:lang.lang_ptpamount,dataType:"decimal",allowFiltering:false,alignment:"right",
// customizeText: function(row) {
// return formatCurrency(row.valueText);
// },
// },
// {dataField: "latest_paid_date",dataType: "date",caption:lang.lang_latestpaiddate,allowFiltering:false,
// customizeText: function(row) {
// return getLanguageDate(row.valueText);
// },
// },
// {dataField: "latest_paid_amount",caption:lang.lang_latestpaidamount,dataType:"decimal",allowFiltering:false,alignment:"right",
// customizeText: function(row) {
// return formatCurrency(row.valueText);
// },
// },
// {dataField: "latest_followup_date",dataType: "date",caption:lang.lang_latest_remark_date,allowFiltering:false,
// customizeText: function(row) {
// return getLanguageDate(row.valueText);
// },
// },
// {dataField: "latest_followup_remark",dataType: "string",caption:lang.lang_latest_remark,allowFiltering:false,width:200},
// {dataField: "latest_expiry",dataType: "string",caption:lang.lang_latest_expiry,allowFiltering:false,
// customizeText: function(row) {
// return getLanguageDate(row.valueText);
// },
// },
// {dataField: "days_past_due",dataType: "string",caption:lang.lang_dpd,allowFiltering:false},
// ,
// {dataField: "has_next_call",dataType: "string",visible:false,allowFiltering:false,showInColumnChooser:false},
// {dataField: "has_ptp",dataType: "boolean",visible:false,allowFiltering:false,showInColumnChooser:false},
// {dataField: "placement",caption:lang.lang_block,dataType: "string",allowFiltering:false},
// {dataField: "account_type",caption:lang.lang_accounttype,dataType: "string",allowFiltering:false},
// {dataField: "product_description",caption:lang.lang_productdescription,dataType: "string",allowFiltering:false},
// {dataField: "card_no",dataType: "string",caption:lang.lang_cardno},
// {dataField: "account",dataType: "string",caption:lang.lang_account},
// {dataField: "gender",dataType: "string",caption:lang.lang_gender},
// {dataField: "name",dataType: "string",caption:lang.lang_customer_name},
// {dataField: "cif_number",dataType: "string",caption:lang.lang_cif_number},
// {dataField: "client_name",dataType: "string",caption:lang.lang_product_group},
// {dataField: "product_type",dataType: "string",caption:lang.lang_product_type},
// {dataField: "is_islamic",dataType: "boolean",caption:lang.lang_conv_islm},
// {dataField: "total_debt",dataType: "double",caption:lang.lang_current_nlb,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "arrears_month",dataType: "string",caption:lang.lang_current_mia},
// {dataField: "days_past_due",dataType: "string",caption:lang.lang_current_dia},
// {dataField: "last_payment_date",dataType:"date",caption:lang.lang_last_payment_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "last_pay_amount",dataType: "double",caption:lang.lang_last_amount_paid,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "balance",dataType: "double",caption:lang.lang_current_os_balance,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "client_outstanding_balance",dataType: "double",caption:lang.lang_available_balance,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "balance",dataType: "double",caption:lang.lang_ledger_balance,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "deposit_date",dataType: "date",caption:lang.lang_last_deposit_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "deposit",dataType: "double",caption:lang.lang_last_deposit_rm,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}}, {dataField: "last_payment_date",dataType: "date",caption:lang.lang_npsf,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "balance",dataType: "double",caption:lang.lang_account_os_balance,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "current_days",dataType: "string",caption:lang.lang_current_overdue},
// {dataField: "x_days",dataType: "string",caption:lang.lang_past_due},
// {dataField: "baclient_outstanding_balancelance",dataType: "double",caption:lang.lang_os_epp,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "block_code",dataType: "string",caption:lang.lang_xpac_code_a},
// {dataField: "all_card_block_code",dataType: "string",caption:lang.lang_xpac_code_c},
// {dataField: "has_cheque_float",dataType: "boolean",caption:lang.lang_cheque_float},
// {dataField: "batch_no",dataType: "string",caption:lang.lang_worklist_name},
// {dataField: "standing_instruction",dataType: "string",caption:lang.lang_si_status},
// {dataField: "standing_instruction_date",dataType: "date",caption:lang.lang_si_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "pdc_date",dataType: "date",caption:lang.lang_pdc_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "fd_lien_code",dataType: "string",caption:lang.lang_fd_code},
// {dataField: "ptp_date",dataType: "date",caption:lang.lang_ptp_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "ptp_amount",dataType: "double",caption:lang.lang_ptpamount,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "broken_promise_date",dataType: "date",caption:lang.lang_ptp_broken_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "status_code",dataType: "string",caption:lang.lang_call_status},
// {dataField: "latest_followup_datetime",dataType: "datetime",caption:lang.lang_call_status_date,customizeText: function(row) {return getLanguageDateTime(row.valueText);}},
// {dataField: "popup_notes",dataType: "string",caption:lang.lang_latest_note},
// {dataField: "latest_pop_up_note_date",dataType: "date",caption:lang.lang_latest_note_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "latest_dialed_number",dataType: "string",caption:lang.lang_latest_dialled_no},
// {dataField: "last_collection_action_date",dataType: "date",caption:lang.lang_last_collection_action_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "latest_internal_status_supervisor_datetime",dataType: "date",caption:lang.lang_last_supervisor_review_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "next_call",dataType: "datetime",caption:lang.lang_next_call,customizeText: function(row) {return getLanguageDateTime(row.valueText);}},
// {dataField: "next_due_date",dataType: "datetime",caption:lang.lang_next_payment_due_date,customizeText: function(row) {return getLanguageDateTime(row.valueText);}},
// {dataField: "due_date",dataType: "datetime",caption:lang.lang_current_due_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "next_interest_due_date",dataType: "datetime",caption:lang.lang_next_interest_due_date,customizeText: function(row) {return getLanguageDateTime(row.valueText);}},
// {dataField: "excess_date",dataType: "date",caption:lang.lang_date_of_excess,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "short_paid_amount",dataType: "date",caption:lang.lang_short_pay_amount,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "monthly_instalment",dataType: "double",caption:lang.lang_monthly_instalment,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "partial_paid_amount",dataType: "double",caption:lang.lang_amt_partially_pd,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "arrear_amount",dataType: "double",caption:lang.lang_sum_of_inst_in_arrears,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "late_charges",dataType: "double",caption:lang.lang_late_charges,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "total_due",dataType: "double",caption:lang.lang_total_due_amt,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "memo_late_charge",dataType: "double",caption:lang.lang_memo_late_charges_amt,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "other_cost",dataType: "string",caption:lang.lang_other_chg_amt},
// {dataField: "account_status",dataType: "string",caption:lang.lang_account_status},
// {dataField: "branch",dataType: "string",caption:lang.lang_branch},
// {dataField: "new_ic",dataType: "string",caption:lang.lang_primary_nric},
// {dataField: "old_ic",dataType: "string",caption:lang.lang_secondary_ic_number},
// {dataField: "collector_user_name",dataType: "string",caption:lang.lang_caller_name_id},
// {dataField: "race",dataType: "string",caption:lang.lang_race},
// {dataField: "opening_total_debt",dataType: "double",caption:lang.lang_opening_nlb,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "opening_mia",dataType: "string",caption:lang.lang_opening_mia},
// {dataField: "loan_amount",dataType: "double",caption:lang.lang_loan_amount,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "interest_rate",dataType: "string",caption:lang.lang_interestrate},
// {dataField: "term",dataType: "string",caption:lang.lang_loan_team_tenure},
// {dataField: "has_charge_off",dataType: "boolean",caption:lang.lang_npl_status},
// {dataField: "charge_off_date",dataType: "date",caption:lang.lang_npl_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "mature_date",dataType: "date",caption:lang.lang_maturity_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "customer_tagging",dataType: "string",caption:lang.lang_special_status},
// {dataField: "total_payment",dataType: "double",caption:lang.lang_total_payment_to_date,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// {dataField: "statement_date",dataType: "date",caption:lang.lang_statement_date,customizeText: function(row) {return getLanguageDate(row.valueText);}},
// {dataField: "ptp_amount",dataType: "double",caption:lang.lang_total_ptp_amount,alignment:"right",customizeText: function(row) {return formatCurrency(row.valueText);}},
// ],
onCellPrepared: function (e) {
e.cellElement.addClass('pt-1 pb-1');
},
onSelectionChanged: function (selectedItems) {
var data = selectedItems.selectedRowsData[0];
if(data) {
var id = data.id;
var name = data.name;
global.lastplace['lastSideBarDebtorId'] = id;
global.lastplace['lastSideBarDebtorName'] = name;
global.lastplace['lastSelectedRow'] = id;
showDebtorSideBar(id);
}
},
onKeyDown: function(e){
var event = e.jQueryEvent;
if(event.shiftKey && event.which === 13){
var data = $("#gridContainer").dxDataGrid("instance").getSelectedRowsData()[0];
var id = data.id;
var name = data.name;
global.lastplace['lastDebtorDetailId'] = id;
global.lastplace['lastDebtorDetailName'] = name;
showDebtorDetail(id,name);
}
},
onRowClick: function (e) {
e.preventDefault
var component = e.component;
var id = e.data.id;
var name = e.data.name;
global.lastplace['lastDebtorDetailId'] = id;
global.lastplace['lastDebtorDetailName'] = name;
if(e['rowType'] == "data"){
if(global.general.tabcontrol.id != id){
global.general.tabcontrol.id = id;
}else{
showDebtorDetail(id,name);
}
}
},
onRowPrepared: function (e) {
if(e['rowType'] == "data"){
var color = "#bdc3c7";
var row = e['data'];
if(row['has_next_call'] == "1"){
if(row['next_call'] != "" && row['next_call'] != null){
if(moment(row['next_call']).isSame(new Date(), "day")){
if(moment(row['next_call']).isSame(new Date(), "hour")){
color = "#fde0c2";//orange next call now
}else{
color = "#ffffce";//"yellow"; today
}
}else if(moment(row['next_call']).isAfter(new Date(), "day")){
if(row['has_ptp'] == "1"){
color = "#e1ffd8";//"green"; future with ptp
}else{
color = "#d9ecfe";//"blue"; future without ptp
}
}else if(moment(row['next_call']).isBefore(new Date(), "day")){
color = "#bdc3c7";//"grey"; pass call
}
}
}else{
color = "#ffd8d8";//"red"; no next call
}
e['rowElement'].css('background',color);
}
},
onInitialized: function(e) {
e.component.__ready = false;
},
onContentReady: function(e) {
if ($("#createButton").length == 0) {
var $customButton = $(" ")
.text(lang.lang_reset_state)
.addClass("btn btn-light" )
.on('dxclick', function() {
var grid = $("#gridContainer").dxDataGrid("instance");
grid.state({}) ;
grid.refresh();
grid.repaint();
// store.remove(vm.gridOptions.stateStoring.storageKey);
});
var toolbar = e.element
.find('.dx-toolbar-after');
$(toolbar.get(0))
.prepend($customButton);
}
if (!e.component.__ready) {
e.component.__ready = true;
var state = e.component.state();
// console.log(e.component.state() );
// if(data.preloaddebtor == ""){
if(state.selectedRowKeys == null || state.selectedRowKeys.length == 0){
e.component.selectRowsByIndexes([0]);
}
// }else{
// var state = e.component.state();
// if(state.selectedRowKeys.length > 0){
// delete state.selectedRowKeys;
// e.component.state(state);
// $('#CallList-tab').attr('volare-refresh','1');
// // e.component.refresh();
// // e.component.repaint();
// }
// displayManager(data.preloaddebtor,"sidebar","notvisible",[data.pre_module_type_id]);
// displayManager(data.preloaddebtor,"detail","notvisible");
// e.component.deselectRows(e.component.getSelectedRowKeys());
// }
}
},
showScrollbar:'always',
allowColumnReordering:true,
showColumnLines:false,
stateStoring: {
enabled: true,
},
selection: { mode: 'single' },
columnAutoWidth:true,
groupPanel: {
visible: true
},
sorting: {
mode: "multiple"
},
searchPanel: {
visible: enable_call_list_search_box
},
scrolling: {
mode: "virtual",
useNative:enable_devextreme_call_list_use_native,
},
filterRow: {
visible: true
},
grouping: {
autoExpandAll: false
},
columnChooser: {
enabled: true
},
pager: {
showPageSizeSelector: true,
showInfo: true
},
summary: {
totalItems: [
{
name: "totalrecordcount",
displayFormat: "{0}",
showInColumn: "#",
summaryType: "count",
// customizeText: function (data) {
// return $("#gridContainer").dxDataGrid("instance").totalCount();
// }
},
// {
// column:"client_outstanding_balance",
// // column:lang.lang_total_amount,
// summaryType: "sum",
// customizeText: function (data) {
// return formatCurrency(data.value);
// }
// },
// {
// column:"total_amount",
// // column:lang.lang_total_amount,
// summaryType: "sum",
// customizeText: function (data) {
// return formatCurrency(data.value);
// }
// },
// {
// column:"balance",
// summaryType: "sum",
// customizeText: function (data) {
// return formatCurrency(data.value);
// }
// },
// {
// column:"balance_to_collect",
// summaryType: "sum",
// customizeText: function (data) {
// return formatCurrency(data.value);
// }
// },
// {
// column:"ptp_amount",
// summaryType: "sum",
// customizeText: function (data) {
// return formatCurrency(data.value);
// }
// // },{
// // column:"latest_paid_amount",
// // summaryType: "sum",
// // customizeText: function (data) {
// // return formatCurrency(data.value);
// // }
// },
],
// totalItems: [{
// column:"BATCHNO",
// summaryType: "count"
// }],
groupItems: [{
summaryType: "count"
},
{
column:"client_outstanding_balance",
summaryType: "sum",
customizeText: function (data) {
return lang.lang_total_amount+": "+formatCurrency(data.value);
}
},
// {
// column:"total_amount",
// summaryType: "sum",
// customizeText: function (data) {
// return lang.lang_total_amount+": "+formatCurrency(data.value);
// }
// },
{
column:"balance",
summaryType: "sum",
customizeText: function (data) {
return lang.lang_balance+": "+formatCurrency(data.value);
}
},
// {
// column:"balance_to_collect",
// summaryType: "sum",
// customizeText: function (data) {
// return lang.lang_balance+": "+formatCurrency(data.value);
// }
// },
{
column:"ptp_amount",
summaryType: "sum",
customizeText: function (data) {
return lang.lang_ptpamount+": "+formatCurrency(data.value);
}
},
// {
// column:"latest_paid_amount",
// summaryType: "sum",
// customizeText: function (data) {
// return lang.lang_latestpaidamount+": "+formatCurrency(data.value);
// }
// },
]
},
remoteOperations: {
filtering: true,
grouping: true,
groupPaging: true,
paging: true,
sorting: true,
summary: true
},
headerFilter: {
visible: true
}
});
UpdateHeight();
refreshManager("callbadge,internal_message,collection_to_date");
}
function populateInternalStatuses(internal_statuses,raw_list = false){
var internalstatuses = {internalstatus:[],adminstatus:[],supervisionstatus:[]};
if(raw_list){
$.each(internal_statuses,function(index, el) {
var targetword = "";
if(el['type'] == "collector_request"){
targetword = "internalstatus";
}else if(el['type'] == "admin_status"){
targetword = "adminstatus";
}else if(el['type'] == "supervisor_status"){
targetword = "supervisionstatus";
}
internalstatuses[targetword].push(el);
});
}else{
internalstatuses = internal_statuses;
}
internalstatuses.internalstatus = Object.values(internalstatuses.internalstatus).sort((a, b) => a.code.localeCompare(b.code));
internalstatuses.adminstatus = Object.values(internalstatuses.adminstatus).sort((a, b) => a.code.localeCompare(b.code));
internalstatuses.supervisionstatus = Object.values(internalstatuses.supervisionstatus).sort((a, b) => a.code.localeCompare(b.code));
$('.main_internalremark_list').empty();
if(global.access.internal_status != null && ((global.access.internal_status & 2) == 2)){
var main_internalremark_collector_request = Handlebars.compile($('#template-main_internalremark_collector_request').html());
var main_internalremark_collector_request_var = {};
var main_internalremark_collector_request_item = Handlebars.compile($('#template-main_internalremark_collector_request_item').html());
var main_internalremark_collector_request_item_var = {};
main_internalremark_collector_request_var.main_internalremark_collector_request_item = "";
for (var ii = 0; ii < internalstatuses.internalstatus.length; ii++) {
main_internalremark_collector_request_item_var.name = internalstatuses.internalstatus[ii].code;
main_internalremark_collector_request_item_var.value = internalstatuses.internalstatus[ii].id;
if(enable_internal_escalation){
main_internalremark_collector_request_item_var.escalate_to_team = internalstatuses.internalstatus[ii].escalate_to_team;
main_internalremark_collector_request_item_var.escalate_to_individual = internalstatuses.internalstatus[ii].escalate_to_individual;
}
main_internalremark_collector_request_var.main_internalremark_collector_request_item += main_internalremark_collector_request_item(main_internalremark_collector_request_item_var);
}
$('.main_internalremark_list').append(main_internalremark_collector_request(main_internalremark_collector_request_var));
$('.main_internalremark_collector_list').selectpicker({
liveSearch: true
});
}
if(global.access.internal_status != null && ((global.access.internal_status & 4) == 4)){
var main_internalremark_admin_status = Handlebars.compile($('#template-main_internalremark_admin_status').html());
var main_internalremark_admin_status_var = {};
var main_internalremark_admin_status_item = Handlebars.compile($('#template-main_internalremark_admin_status_item').html());
var main_internalremark_admin_status_item_var = {};
main_internalremark_admin_status_var.main_internalremark_admin_status_item = "";
for (var ii = 0; ii < internalstatuses.adminstatus.length; ii++) {
main_internalremark_admin_status_item_var.name = internalstatuses.adminstatus[ii].code;
main_internalremark_admin_status_item_var.value = internalstatuses.adminstatus[ii].id;
main_internalremark_admin_status_var.main_internalremark_admin_status_item += main_internalremark_admin_status_item(main_internalremark_admin_status_item_var);
}
$('.main_internalremark_list').append(main_internalremark_admin_status(main_internalremark_admin_status_var));
$('.main_internalremark_admin_list').selectpicker({
liveSearch: true
});
}
if(global.access.internal_status != null && ((global.access.internal_status & 8) == 8)){
var main_internalremark_supervision_status = Handlebars.compile($('#template-main_internalremark_supervision_status').html());
var main_internalremark_supervision_status_var = {};
var main_internalremark_supervision_status_item = Handlebars.compile($('#template-main_internalremark_supervision_status_item').html());
var main_internalremark_supervision_status_item_var = {};
main_internalremark_supervision_status_var.main_internalremark_supervision_status_item = "";
for (var ii = 0; ii < internalstatuses.supervisionstatus.length; ii++) {
main_internalremark_supervision_status_item_var.name = internalstatuses.supervisionstatus[ii].code;
main_internalremark_supervision_status_item_var.value = internalstatuses.supervisionstatus[ii].id;
main_internalremark_supervision_status_var.main_internalremark_supervision_status_item += main_internalremark_supervision_status_item(main_internalremark_supervision_status_item_var);
}
$('.main_internalremark_list').append(main_internalremark_supervision_status(main_internalremark_supervision_status_var));
$('.main_internalremark_supervision_list').selectpicker({
liveSearch: true
});
}
}
function realtimeValidateInternalStatuses(){
var invalid = 0;
if($('select.main_internalremark_remark_customer').is(':visible')){
if($('select.main_internalremark_remark_customer').val() == ""){
$('.main_internalremark_remark_customer').addClass('is-invalid');
invalid++;
}else{
$('.main_internalremark_remark_customer').removeClass('is-invalid');
}
}
if($('select.main_internalremark_remark_approved_by').is(':visible')){
if($('select.main_internalremark_remark_approved_by').val() == "" ){
$('.main_internalremark_remark_approved_by').addClass('is-invalid');
invalid++;
}else{
$('.main_internalremark_remark_approved_by').removeClass('is-invalid');
}
if($('.main_internalremark_remark_approved_date').val() == ""){
$('.main_internalremark_remark_approved_date').addClass('is-invalid');
invalid++;
}else{
$('.main_internalremark_remark_approved_date').removeClass('is-invalid');
}
}else if($('select.main_internalremark_remark_rejected_by').is(':visible')){
if($('select.main_internalremark_remark_rejected_by').val() == "" ){
$('.main_internalremark_remark_rejected_by').addClass('is-invalid');
invalid++;
}else{
$('.main_internalremark_remark_rejected_by').removeClass('is-invalid');
}
if($('.main_internalremark_remark_rejected_date').val() == ""){
$('.main_internalremark_remark_rejected_date').addClass('is-invalid');
invalid++;
}else{
$('.main_internalremark_remark_rejected_date').removeClass('is-invalid');
}
}
// if($('#'+uid+' .is-invalid:visible').length > 0){
if(invalid > 0){
$('.main_internalremark_submit').prop('disabled',true);
}else{
$('.main_internalremark_submit').prop('disabled',false);
}
}
function realtimeValidateFieldVisitRequest(uid){
var invalid = 0;
if(enable_field_visit_reason_select){
if($('#'+uid+' select.debtor_detail_field_visit_reason_select').val() == ""){
$('#'+uid+' .debtor_detail_field_visit_reason_select').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_field_visit_reason_select').removeClass('is-invalid');
}
}else{
if($('#'+uid+' .debtor_detail_field_visit_reason').val() == ""){
$('#'+uid+' .debtor_detail_field_visit_reason').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_field_visit_reason').removeClass('is-invalid');
}
}
// if($('#'+uid+' .is-invalid:visible').length > 0){
if(invalid > 0){
$('#'+uid+' .debtor_detail_field_visit_request').prop('disabled',true);
}else{
$('#'+uid+' .debtor_detail_field_visit_request').prop('disabled',false);
}
}
function maskNumber(number){
var original_number = number;
var mask_number_display_value = Number(mask_number_display);
if(mask_number_display_value>0 && number != null && number != "" && number.length >= mask_number_display_value){
if(mask_number_display_reverse_direction){
number = "*".repeat(number.length-mask_number_display_value)+number.substr(number.length-mask_number_display_value);
}else{
number = number.substr(0,number.length - mask_number_display_value)+"*".repeat(mask_number_display_value);
}
}
if(debtor_detail_additional_logic == "collectius" && mask_number_read_from_access_config && global.access.is_sensitive_data_masking_enabled > "0"){
number = original_number;
if(number != null && number != "" ){
var final_number = '';
if(number.search(/@/g) > -1){
var temp_number = number.split('@');
// console.log(temp_number);
// number = number.substr(0,3)+'****'+number.substr(7);
number = "*".repeat(temp_number[0].length)+'@'+temp_number[1];
}else if(number != null && number != '' && number.length > 0){
if(number.substr(0,1) != "0"){
final_number = number.substr(0,3)+'***'+number.substr(6);
}else{
final_number = number.substr(0,1)+'***'+number.substr(4);
}
number = final_number;
}
}
}
return number;
}
function maskNumberAdditional(number){
if(enable_additional_mask){
// var mask_number_display_value = Number(mask_number_display);
// if(mask_number_display_value>0 && number != null && number != "" && number.length >= mask_number_display_value){
// if(mask_number_display_reverse_direction){
// number = "*".repeat(number.length-mask_number_display_value)+number.substr(number.length-mask_number_display_value);
// }else{
// number = number.substr(0,number.length - mask_number_display_value)+"*".repeat(mask_number_display_value);
// }
// }
number = maskNumber(number);
}
return number;
}
function maskManualNumber(data){
data = data.replace(/\b\d{6,20}\b/g, function(match) {
return maskNumber(match);
});
return data;
}
// class hb {
// constructor(template_name){
// this.var = {};
// this.var.template_name = template_name;
// this.var.lang = lang;
// }
// hb(){
// // return Handlebars.compile($('#template-debtorsidebar_card_letteremail').html())(this.var);
// }
// }
function uploadAttachmentForAddContact(uid,debtor_id){
var deferred = new $.Deferred();
var rpc_followup_addcontact_attachment = $('#'+uid+' select.rpc_followup_addcontact_attachment').val();
var rpc_followup_addcontact_attachment_filetype = $('#'+uid+' select.rpc_followup_addcontact_attachment_filetype option:selected').val();
if($('#'+uid+' .rpc_followup_addcontact_attachment') != null && $('#'+uid+' .rpc_followup_addcontact_attachment').prop("files").length > 0){
var fd = new FormData();
fd.append( "attachmentfile", $('#'+uid+' .rpc_followup_addcontact_attachment').prop("files")[0] );
fd.append( "debtor_id", debtor_id );
fd.append( "filetype", rpc_followup_addcontact_attachment_filetype );
fd.append( "action", 'uploadDebtorDetailAttachment' );
volareApi("uploadDebtorDetailAttachment",fd,{uid:uid,fileupload:'',debtor_id:debtor_id,deferred:deferred});
}else{
deferred.resolve(null);
}
return deferred;
}
function realtimeValidateComplaintManagement(uid){
var invalid = 0;
if($('#'+uid+' .debtor_detail_complaint_customer_request').is(":visible")){
if($('#'+uid+' .debtor_detail_complaint_customer_request_supervisor').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_supervisor').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_supervisor').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_customer_request_type_of_issue').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_type_of_issue').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_type_of_issue').removeClass('is-invalid');
switch($('#'+uid+' select.debtor_detail_complaint_customer_request_type_of_issue').val()){
case "Complaint":
case "First Level Resolution":
$('#'+uid+' .debtor_detail_complaint_complaint_details').removeClass('hideMe');
$('#'+uid+' .debtor_detail_complaint_findings_resolution').removeClass('hideMe');
break;
default:
$('#'+uid+' .debtor_detail_complaint_complaint_details').addClass('hideMe');
$('#'+uid+' .debtor_detail_complaint_findings_resolution').addClass('hideMe');
break;
}
}
if($('#'+uid+' select.debtor_detail_complaint_customer_request_case_acknowledged_via').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_via').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_via').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_customer_request_case_received_date').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_case_received_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_case_received_date').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_customer_request_case_received_time').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_case_received_time').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_case_received_time').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_date').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_date').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_time').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_time').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_time').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_customer_request_request_source').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_request_source').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_request_source').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_customer_request_status').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_status').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_status').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_customer_request_case_details').val() == ""){
$('#'+uid+' .debtor_detail_complaint_customer_request_case_details').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_customer_request_case_details').removeClass('is-invalid');
}
}
if($('#'+uid+' .debtor_detail_complaint_complaint_details').is(":visible")){
// if($('#'+uid+' .debtor_detail_complaint_complaint_details_due_date').val() == ""){
// $('#'+uid+' .debtor_detail_complaint_complaint_details_due_date').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .debtor_detail_complaint_complaint_details_due_date').removeClass('is-invalid');
// }
if($('#'+uid+' .debtor_detail_complaint_complaint_details_case_ref_no').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_case_ref_no').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_case_ref_no').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_complaint_details_complaint_channel').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_complaint_channel').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_complaint_channel').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_name').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_name').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_name').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_issue_summary').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_issue_summary').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_issue_summary').removeClass('is-invalid');
}
if(!enable_complaint_management_minor_exclude_verification){
if($('#'+uid+' .debtor_detail_complaint_complaint_details_detail_of_complaint_issue').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_detail_of_complaint_issue').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_detail_of_complaint_issue').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_date').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_date').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_by').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_by').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_by').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_complaint_details_resolved_via').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_via').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_via').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_complaint_details_resolution_details').val() == ""){
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolution_details').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolution_details').removeClass('is-invalid');
}
}
}
if($('#'+uid+' .debtor_detail_complaint_findings_resolution').is(":visible")){
if(!enable_complaint_management_minor_exclude_verification){
if($('#'+uid+' select.debtor_detail_complaint_findings_resolution_complaint_staff').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_complaint_staff').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_complaint_staff').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_findings_resolution_root_cause').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_root_cause').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_root_cause').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_findings_resolution_reason').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_reason').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_reason').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_findings_resolution_valid').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_valid').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_valid').removeClass('is-invalid');
}
if($('#'+uid+' select.debtor_detail_complaint_findings_resolution_unit').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_unit').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_unit').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_findings_resolution_action_plan_remarks').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_action_plan_remarks').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_action_plan_remarks').removeClass('is-invalid');
}
}
// if($('#'+uid+' .debtor_detail_complaint_findings_resolution_aging').val() == ""){
// $('#'+uid+' .debtor_detail_complaint_findings_resolution_aging').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .debtor_detail_complaint_findings_resolution_aging').removeClass('is-invalid');
// }
if($('#'+uid+' select.debtor_detail_complaint_findings_resolution_valid').val() == "1"){
if($('#'+uid+' .debtor_detail_complaint_findings_resolution_staff_id').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_staff_id').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_staff_id').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_findings_resolution_supervisor_id').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_supervisor_id').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_supervisor_id').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_name').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_name').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_name').removeClass('is-invalid');
}
if($('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_staff').val() == ""){
$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_staff').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_staff').removeClass('is-invalid');
}
}else{
$('#'+uid+' .debtor_detail_complaint_findings_resolution_staff_id').removeClass('is-invalid');
$('#'+uid+' .debtor_detail_complaint_findings_resolution_supervisor_id').removeClass('is-invalid');
$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_name').removeClass('is-invalid');
$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_staff').removeClass('is-invalid');
}
}
if(invalid > 0){
$('#'+uid+' .debtor_detail_complaint_submit').prop('disabled',true);
}else{
$('#'+uid+' .debtor_detail_complaint_submit').prop('disabled',false);
}
}
function realtimeValidateATPRebateCalculator(uid){
var invalid = 0;
if($('#'+uid+' .atp_rebate_calculator_loan_amount').val() == ""){
$('#'+uid+' .atp_rebate_calculator_loan_amount').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_rebate_calculator_loan_amount').removeClass('is-invalid');
}
if($('#'+uid+' .atp_rebate_calculator_interest_rate').val() == ""){
$('#'+uid+' .atp_rebate_calculator_interest_rate').addClass('is-invalid');
invalid++;
}else{
if($('#'+uid+' .atp_rebate_calculator_interest_rate').val() < 0){
$('#'+uid+' .atp_rebate_calculator_interest_rate').val(0);
}else if($('#'+uid+' .atp_rebate_calculator_interest_rate').val() > 100){
$('#'+uid+' .atp_rebate_calculator_interest_rate').val(100);
}
$('#'+uid+' .atp_rebate_calculator_interest_rate').removeClass('is-invalid');
}
if($('#'+uid+' .atp_rebate_calculator_agreement_date').val() == ""){
$('#'+uid+' .atp_rebate_calculator_agreement_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_rebate_calculator_agreement_date').removeClass('is-invalid');
}
if($('#'+uid+' .atp_rebate_calculator_settlement_date').val() == ""){
$('#'+uid+' .atp_rebate_calculator_settlement_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_rebate_calculator_settlement_date').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .atp_rebate_calculator_calculate_rebate').prop('disabled',true);
}else{
$('#'+uid+' .atp_rebate_calculator_calculate_rebate').prop('disabled',false);
}
}
function reconstructMOATier(uid){
$('#'+uid+' .moa_template_payment_term_table_tbody').html('');
var moa_template_payment_term_table_tr = Handlebars.compile($('#template-bicbs_moa_template_payment_term_table_tr').html());
var moa_template_payment_term_table_tr_var = {};
var moa_template_payment_term_table_tbody = "";
var total_index = 0;
var total_tier = 0;
for (var i = 0; i < global.general.moa_tier[uid].length; i++) {
total_tier += Number(global.general.moa_tier[uid][i].tenure);
}
var outstanding_principal = global.general.moa_tier[uid][i].principal;
for (var i = 0; i < global.general.moa_tier[uid].length; i++) {
var row = global.general.moa_tier[uid][i];
for (var ii = Number(total_index); ii < (Number(row.tenure) + Number(total_index) + 1); ii++) {
// console.log(ii,row.tenure + total_index);
var remaining_tenure = (total_tier-ii);
var proposed_installment = "";
var profit_overdue = "";
var cumulative_profit_overdue = "";
if(ii == 0){
profit_overdue = global.debtordata[global.general.moa_debtor_id[uid]].debtor.profit_overdue;
cumulative_profit_overdue = "-";
}else{
if(remaining_tenure > 0 ){
proposed_installment = row.installment_payment_amount;
}else{
proposed_installment = 'shiruka';
}
profit_overdue = '-';
cumulative_profit_overdue = "-";
}
moa_template_payment_term_table_tr_var.month = ii;
moa_template_payment_term_table_tr_var.remaining_tenure = remaining_tenure;
moa_template_payment_term_table_tr_var.proposed_installment = proposed_installment;
moa_template_payment_term_table_tr_var.monthly_profit_due = '';
moa_template_payment_term_table_tr_var.profit_return = '';
moa_template_payment_term_table_tr_var.principal_return = '';
moa_template_payment_term_table_tr_var.profit_overdue = profit_overdue;
moa_template_payment_term_table_tr_var.cumulative_profit_overdue = cumulative_profit_overdue;
moa_template_payment_term_table_tr_var.monthly_ibra = '';
moa_template_payment_term_table_tr_var.outstanding_unearned_income = '';
moa_template_payment_term_table_tr_var.outstanding_principal = '';
moa_template_payment_term_table_tr_var.year = '';
moa_template_payment_term_table_tbody += moa_template_payment_term_table_tr(moa_template_payment_term_table_tr_var);
}
total_index = ii;
}
$('#'+uid+' .moa_template_payment_term_table_tbody').html(moa_template_payment_term_table_tbody);
}
function realtimeValidateATPBTier(uid){
var invalid = 0;
if($('#'+uid+' select.atpb_template_payment_term_tier').val() == ""){
$('#'+uid+' .atpb_template_payment_term_tier').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atpb_template_payment_term_tier').removeClass('is-invalid');
}
if($('#'+uid+' .atpb_template_payment_term_first_payment_date').val() == ""){
$('#'+uid+' .atpb_template_payment_term_first_payment_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atpb_template_payment_term_first_payment_date').removeClass('is-invalid');
}
if($('#'+uid+' .atpb_template_payment_term_tenure').val() == "" || Number($('#'+uid+' .atpb_template_payment_term_tenure').val()) == '0' || Object.is(Number($('#'+uid+' .atpb_template_payment_term_tenure').val()),NaN)){
$('#'+uid+' .atpb_template_payment_term_tenure').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atpb_template_payment_term_tenure').removeClass('is-invalid');
}
if($('#'+uid+' .atpb_template_payment_term_installment_payment_amount').val() == ""){
$('#'+uid+' .atpb_template_payment_term_installment_payment_amount').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atpb_template_payment_term_installment_payment_amount').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .atpb_template_payment_term_add_tier').prop('disabled',true);
}else{
$('#'+uid+' .atpb_template_payment_term_add_tier').prop('disabled',false);
}
}
function realtimeValidateMOATier(uid){
var invalid = 0;
if($('#'+uid+' select.moa_template_payment_term_tier').val() == ""){
$('#'+uid+' .moa_template_payment_term_tier').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_payment_term_tier').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_payment_term_first_payment_date').val() == ""){
$('#'+uid+' .moa_template_payment_term_first_payment_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_payment_term_first_payment_date').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_payment_term_tenure').val() == "" || Number($('#'+uid+' .moa_template_payment_term_tenure').val()) == '0' || Object.is(Number($('#'+uid+' .moa_template_payment_term_tenure').val()),NaN)){
$('#'+uid+' .moa_template_payment_term_tenure').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_payment_term_tenure').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_payment_term_installment_payment_amount').val() == ""){
$('#'+uid+' .moa_template_payment_term_installment_payment_amount').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_payment_term_installment_payment_amount').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .moa_template_payment_term_add_tier').prop('disabled',true);
}else{
$('#'+uid+' .moa_template_payment_term_add_tier').prop('disabled',false);
}
}
function realtimeValidateATPTier(uid){
var invalid = 0;
if($('#'+uid+' select.atp_unsecured_atp_template_payment_term_tier').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_payment_term_tier').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_payment_term_tier').removeClass('is-invalid');
}
if($('#'+uid+' .atp_unsecured_atp_template_payment_term_first_payment_date').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_payment_term_first_payment_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_payment_term_first_payment_date').removeClass('is-invalid');
}
if($('#'+uid+' .atp_unsecured_atp_template_payment_term_tenure').val() == "" || Number($('#'+uid+' .atp_unsecured_atp_template_payment_term_tenure').val()) == '0' || Object.is(Number($('#'+uid+' .atp_unsecured_atp_template_payment_term_tenure').val()),NaN)){
$('#'+uid+' .atp_unsecured_atp_template_payment_term_tenure').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_payment_term_tenure').removeClass('is-invalid');
}
if($('#'+uid+' .atp_unsecured_atp_template_payment_term_instalment_amount').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_payment_term_instalment_amount').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_payment_term_instalment_amount').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .atp_unsecured_atp_template_payment_term_add_tier').prop('disabled',true);
}else{
$('#'+uid+' .atp_unsecured_atp_template_payment_term_add_tier').prop('disabled',false);
}
}
function realtimeValidateMOADecisionMaker(uid){
var invalid = 0;
if($('#'+uid+' select.moa_template_decision_activity').val() == ""){
$('#'+uid+' .moa_template_decision_activity').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_decision_activity').removeClass('is-invalid');
}
if($('#'+uid+' select.moa_template_decision_decision_by').val() == ""){
$('#'+uid+' .moa_template_decision_decision_by').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_decision_decision_by').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .moa_template_decision_by_add').prop('disabled',true);
}else{
$('#'+uid+' .moa_template_decision_by_add').prop('disabled',false);
}
}
function realtimeValidateATPBDecisionMaker(uid){
var invalid = 0;
if($('#'+uid+' select.atpb_template_decision_activity').val() == ""){
$('#'+uid+' .atpb_template_decision_activity').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atpb_template_decision_activity').removeClass('is-invalid');
}
if($('#'+uid+' select.atpb_template_decision_decision_by').val() == ""){
$('#'+uid+' .atpb_template_decision_decision_by').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atpb_template_decision_decision_by').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .atpb_template_decision_by_add').prop('disabled',true);
}else{
$('#'+uid+' .atpb_template_decision_by_add').prop('disabled',false);
}
}
function realtimeValidateATPDecisionMaker(uid){
var invalid = 0;
if($('#'+uid+' select.atp_unsecured_atp_template_decision_activity').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_decision_activity').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_decision_activity').removeClass('is-invalid');
}
if($('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_decision_decision_by').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_decision_decision_by').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .atp_unsecured_atp_template_decision_by_add').prop('disabled',true);
}else{
$('#'+uid+' .atp_unsecured_atp_template_decision_by_add').prop('disabled',false);
}
}
function realtimeValidateMOAOverall(uid){
var invalid = 0;
if($('#'+uid+' .moa_template_general_application_date').val() == ""){
$('#'+uid+' .moa_template_general_application_date').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_general_application_date').removeClass('is-invalid');
}
if($('#'+uid+' select.moa_template_general_approval_authority').val() == ""){
$('#'+uid+' .moa_template_general_approval_authority').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_general_approval_authority').removeClass('is-invalid');
}
if($('#'+uid+' select.moa_template_general_type_of_reschedule').val() == ""){
$('#'+uid+' .moa_template_general_type_of_reschedule').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_general_type_of_reschedule').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_general_application').val() == ""){
$('#'+uid+' .moa_template_general_application').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_general_application').removeClass('is-invalid');
}
$('#'+uid+' .moa_template_customer_information_relationship').each(function(index, el) {
if($(this).val() == ""){
$(this).addClass('is-invalid');
invalid++;
}else{
$(this).removeClass('is-invalid');
}
});
$('#'+uid+' .moa_template_customer_information_occupation').each(function(index, el) {
if($(this).val() == ""){
$(this).addClass('is-invalid');
invalid++;
}else{
$(this).removeClass('is-invalid');
}
});
$('#'+uid+' .moa_template_customer_information_employer').each(function(index, el) {
if($(this).val() == ""){
$(this).addClass('is-invalid');
invalid++;
}else{
$(this).removeClass('is-invalid');
}
});
$('#'+uid+' .moa_template_customer_information_year_of_service').each(function(index, el) {
if($(this).val() == ""){
$(this).addClass('is-invalid');
invalid++;
}else{
$(this).removeClass('is-invalid');
}
});
$('#'+uid+' .moa_template_customer_information_no_of_dependants').each(function(index, el) {
if($(this).val() == ""){
$(this).addClass('is-invalid');
invalid++;
}else{
$(this).removeClass('is-invalid');
}
});
// $('#'+uid+' .moa_template_customer_information_monthly_income').each(function(index, el) {
// if($(this).val() == ""){
// $(this).addClass('is-invalid');
// invalid++;
// }else{
// $(this).removeClass('is-invalid');
// }
// });
$('#'+uid+' .moa_template_customer_information_basic_salary').each(function(index, el) {
if($(this).val() == ""){
$(this).addClass('is-invalid');
invalid++;
}else{
$(this).removeClass('is-invalid');
}
});
$('#'+uid+' .moa_template_customer_information_total_incomes').each(function(index, el) {
var special_index = $(this).attr('volare-special_index');
// console.log( getDecimal(
// Decimal(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_basic_salary_'+special_index).maskMoney('unmasked')[0]
// )
// ).plus(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_allowance_'+special_index).maskMoney('unmasked')[0]
// )
// ).toString()
// ));
// console.log( getDecimal(
// Decimal(
// $('#'+uid+' .moa_template_customer_information_basic_salary_'+special_index).maskMoney('unmasked')[0]
// ).plus(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_allowance_'+special_index).maskMoney('unmasked')[0]
// )
// ).plus(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_overtime_'+special_index).maskMoney('unmasked')[0]
// )
// ).plus(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_others_'+special_index).maskMoney('unmasked')[0]
// )
// )
// ).toString());
// console.log($('#'+uid+' .moa_template_customer_information_basic_salary_'+special_index).maskMoney('unmasked')[0],$('#'+uid+' .moa_template_customer_information_allowance_'+special_index).maskMoney('unmasked')[0],$('#'+uid+' .moa_template_customer_information_overtime_'+special_index).maskMoney('unmasked')[0],$('#'+uid+' .moa_template_customer_information_others_'+special_index).maskMoney('unmasked')[0]);
$('#'+uid+' .moa_template_customer_information_total_incomes_'+special_index).maskMoney('mask',
getDecimal(
Decimal(
getDecimal(
$('#'+uid+' .moa_template_customer_information_basic_salary_'+special_index).maskMoney('unmasked')[0]
)
).plus(
getDecimal(
$('#'+uid+' .moa_template_customer_information_allowance_'+special_index).maskMoney('unmasked')[0]
)
).plus(
getDecimal(
$('#'+uid+' .moa_template_customer_information_overtime_'+special_index).maskMoney('unmasked')[0]
)
).plus(
getDecimal(
$('#'+uid+' .moa_template_customer_information_others_'+special_index).maskMoney('unmasked')[0]
)
).toString()
)
);
});
$('#'+uid+' .moa_template_customer_information_statutory_deduction').each(function(index, el) {
if($(this).val() == ""){
$(this).addClass('is-invalid');
invalid++;
}else{
$(this).removeClass('is-invalid');
}
});
if($('#'+uid+' .moa_template_financing_commitment_reschedule_installment').val() == ""){
$('#'+uid+' .moa_template_financing_commitment_reschedule_installment').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_financing_commitment_reschedule_installment').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_change_of_profit_rate_type_of_existing_profit_rate').val() == ""){
$('#'+uid+' .moa_template_change_of_profit_rate_type_of_existing_profit_rate').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_change_of_profit_rate_type_of_existing_profit_rate').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_change_of_profit_rate_existing_interest_rate').val() == ""){
$('#'+uid+' .moa_template_change_of_profit_rate_existing_interest_rate').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_change_of_profit_rate_existing_interest_rate').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_change_of_profit_rate_revision_interest_rate').val() == ""){
$('#'+uid+' .moa_template_change_of_profit_rate_revision_interest_rate').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_change_of_profit_rate_revision_interest_rate').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_comments_application_info').val() == ""){
$('#'+uid+' .moa_template_comments_application_info').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_comments_application_info').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_comments_income_document').val() == ""){
$('#'+uid+' .moa_template_comments_income_document').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_comments_income_document').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_comments_ramci').val() == ""){
$('#'+uid+' .moa_template_comments_ramci').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_comments_ramci').removeClass('is-invalid');
}
if($('#'+uid+' .moa_template_payment_term_tier_row').length <= 0){
invalid++;
}
if($('#'+uid+' .moa_template_decision_by_row').length <= 0){
invalid++;
}else{
var have_approval_ind = false;
if(global.general.moa_decision[uid] != null){
$.each(global.general.moa_decision[uid],function(index, el) {
if(global.general.atp_activity[el.activity].approval_ind == "1"){
have_approval_ind = true;
return false;
}
});
if(!have_approval_ind)
invalid++;
}
}
if($('#'+uid+' select.moa_template_review_decision_by').val() == ""){
$('#'+uid+' .moa_template_review_decision_by').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .moa_template_review_decision_by').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .moa_template_submit').prop('disabled',true);
}else{
$('#'+uid+' .moa_template_submit').prop('disabled',false);
}
}
function realtimeValidateATPBOverall(uid){
var invalid = 0;
if($('#'+uid+' .atpb_template_composition_waiver_subrogation_proposed_sum').val() == ""){
$('#'+uid+' .atpb_template_composition_waiver_subrogation_proposed_sum').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atpb_template_composition_waiver_subrogation_proposed_sum').removeClass('is-invalid');
}
// if($('#'+uid+' select.moa_template_general_approval_authority').val() == ""){
// $('#'+uid+' .moa_template_general_approval_authority').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_general_approval_authority').removeClass('is-invalid');
// }
// if($('#'+uid+' select.moa_template_general_type_of_reschedule').val() == ""){
// $('#'+uid+' .moa_template_general_type_of_reschedule').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_general_type_of_reschedule').removeClass('is-invalid');
// }
// if($('#'+uid+' .moa_template_general_application').val() == ""){
// $('#'+uid+' .moa_template_general_application').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_general_application').removeClass('is-invalid');
// }
// $('#'+uid+' .moa_template_customer_information_relationship').each(function(index, el) {
// if($(this).val() == ""){
// $(this).addClass('is-invalid');
// invalid++;
// }else{
// $(this).removeClass('is-invalid');
// }
// });
// $('#'+uid+' .moa_template_customer_information_occupation').each(function(index, el) {
// if($(this).val() == ""){
// $(this).addClass('is-invalid');
// invalid++;
// }else{
// $(this).removeClass('is-invalid');
// }
// });
// $('#'+uid+' .moa_template_customer_information_employer').each(function(index, el) {
// if($(this).val() == ""){
// $(this).addClass('is-invalid');
// invalid++;
// }else{
// $(this).removeClass('is-invalid');
// }
// });
// $('#'+uid+' .moa_template_customer_information_year_of_service').each(function(index, el) {
// if($(this).val() == ""){
// $(this).addClass('is-invalid');
// invalid++;
// }else{
// $(this).removeClass('is-invalid');
// }
// });
// $('#'+uid+' .moa_template_customer_information_no_of_dependants').each(function(index, el) {
// if($(this).val() == ""){
// $(this).addClass('is-invalid');
// invalid++;
// }else{
// $(this).removeClass('is-invalid');
// }
// });
// $('#'+uid+' .moa_template_customer_information_basic_salary').each(function(index, el) {
// if($(this).val() == ""){
// $(this).addClass('is-invalid');
// invalid++;
// }else{
// $(this).removeClass('is-invalid');
// }
// });
// $('#'+uid+' .moa_template_customer_information_total_incomes').each(function(index, el) {
// var special_index = $(this).attr('volare-special_index');
// $('#'+uid+' .moa_template_customer_information_total_incomes_'+special_index).maskMoney('mask',
// getDecimal(
// Decimal(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_basic_salary_'+special_index).maskMoney('unmasked')[0]
// )
// ).plus(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_allowance_'+special_index).maskMoney('unmasked')[0]
// )
// ).plus(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_overtime_'+special_index).maskMoney('unmasked')[0]
// )
// ).plus(
// getDecimal(
// $('#'+uid+' .moa_template_customer_information_others_'+special_index).maskMoney('unmasked')[0]
// )
// ).toString()
// )
// );
// });
// $('#'+uid+' .moa_template_customer_information_statutory_deduction').each(function(index, el) {
// if($(this).val() == ""){
// $(this).addClass('is-invalid');
// invalid++;
// }else{
// $(this).removeClass('is-invalid');
// }
// });
// if($('#'+uid+' .moa_template_financing_commitment_reschedule_installment').val() == ""){
// $('#'+uid+' .moa_template_financing_commitment_reschedule_installment').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_financing_commitment_reschedule_installment').removeClass('is-invalid');
// }
// if($('#'+uid+' .moa_template_change_of_profit_rate_type_of_existing_profit_rate').val() == ""){
// $('#'+uid+' .moa_template_change_of_profit_rate_type_of_existing_profit_rate').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_change_of_profit_rate_type_of_existing_profit_rate').removeClass('is-invalid');
// }
// if($('#'+uid+' .moa_template_change_of_profit_rate_existing_interest_rate').val() == ""){
// $('#'+uid+' .moa_template_change_of_profit_rate_existing_interest_rate').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_change_of_profit_rate_existing_interest_rate').removeClass('is-invalid');
// }
// if($('#'+uid+' .moa_template_change_of_profit_rate_revision_interest_rate').val() == ""){
// $('#'+uid+' .moa_template_change_of_profit_rate_revision_interest_rate').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_change_of_profit_rate_revision_interest_rate').removeClass('is-invalid');
// }
// if($('#'+uid+' .moa_template_comments_application_info').val() == ""){
// $('#'+uid+' .moa_template_comments_application_info').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_comments_application_info').removeClass('is-invalid');
// }
// if($('#'+uid+' .moa_template_comments_income_document').val() == ""){
// $('#'+uid+' .moa_template_comments_income_document').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_comments_income_document').removeClass('is-invalid');
// }
// if($('#'+uid+' .moa_template_comments_ramci').val() == ""){
// $('#'+uid+' .moa_template_comments_ramci').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .moa_template_comments_ramci').removeClass('is-invalid');
// }
// if($('#'+uid+' .moa_template_payment_term_tier_row').length <= 0){
// invalid++;
// }
if($('#'+uid+' .atpb_template_decision_by_row').length <= 0){
invalid++;
}else{
var have_approval_ind = false;
if(global.general.atpb_decision[uid] != null){
$.each(global.general.atpb_decision[uid],function(index, el) {
if(global.general.atp_activity[el.activity].approval_ind == "1"){
have_approval_ind = true;
return false;
}
});
if(!have_approval_ind)
invalid++;
}
}
if($('#'+uid+' select.atpb_template_review_decision_by').val() == ""){
$('#'+uid+' .atpb_template_review_decision_by').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atpb_template_review_decision_by').removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+' .atpb_template_submit').prop('disabled',true);
}else{
$('#'+uid+' .atpb_template_submit').prop('disabled',false);
}
}
function realtimeValidateATPOverall(uid){
var invalid = 0;
if($('#'+uid+' select.atp_unsecured_atp_template_type_of_request').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_type_of_request').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_type_of_request').removeClass('is-invalid');
if($('#'+uid+' select.atp_unsecured_atp_template_type_of_request option:selected').text() == "Waiver"){
$('#'+uid+' .atp_unsecured_atp_letter_offer_contact_number').prop('disabled',true);
}else{
$('#'+uid+' .atp_unsecured_atp_letter_offer_contact_number').prop('disabled',false);
}
}
if($('#'+uid+' select.atp_unsecured_atp_template_reason_for_settlement').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_reason_for_settlement').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_reason_for_settlement').removeClass('is-invalid');
}
if($('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum').removeClass('is-invalid');
}
// if(global.general.atp_uid[uid] == 'secured'){
// if($('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').val() == ""){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').removeClass('is-invalid');
// }
// }
var total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance = 0;
if(global.general.atp_uid[uid] == 'secured'){
if($('#'+uid+' select.atp_unsecured_atp_template_type_of_package_1').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_type_of_package_1').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_type_of_package_1').removeClass('is-invalid');
}
$('#'+uid+' .atp_unsecured_atp_template_existing_acount_row').each(function(index, el) {
var instalment_in_arrears = parseFloat($(el).find('.atp_unsecured_atp_template_existing_acount_instalment_in_arrears').maskMoney('unmasked')[0]);
var lpi = parseFloat($(el).find('.atp_unsecured_atp_template_existing_acount_lpi').maskMoney('unmasked')[0]);
var others_misc_charges = parseFloat($(el).find('.atp_unsecured_atp_template_existing_acount_others_misc_charges').maskMoney('unmasked')[0]);
if(!isNaN(instalment_in_arrears) && !isNaN(lpi) && !isNaN(others_misc_charges)){
$(el).find('.atp_unsecured_atp_template_existing_acount_total_outstanding_balance').maskMoney('mask',(getDecimal(Decimal(getDecimal(instalment_in_arrears)).plus(getDecimal(lpi)).plus(getDecimal(others_misc_charges)).toString())));
total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance = (getDecimal(Decimal(getDecimal(instalment_in_arrears)).plus(getDecimal(lpi)).plus(getDecimal(others_misc_charges)).plus(getDecimal(total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance)).toString()));
}
});
}else{
var total_unbill_legal = 0;
var total_late_payment_charge = 0;
var total_finance_profit_charges = 0;
var total_others_misc_charges = 0;
$('#'+uid+' .atp_unsecured_atp_template_existing_acount_row').each(function(index, el) {
var unbill_legal = parseFloat($(el).find('.atp_unsecured_atp_template_existing_acount_unbill_legal').maskMoney('unmasked')[0]);
var debtor_balance = parseFloat($(el).find('.atp_unsecured_atp_template_existing_acount_total_outstanding_balance').attr('volare-debtor_balance'));
var late_payment_charge = formatDecimal($(el).find('.atp_unsecured_atp_template_existing_acount_late_payment_charge').maskMoney('unmasked')[0]);
var finance_profit_charges = formatDecimal($(el).find('.atp_unsecured_atp_template_existing_acount_finance_profit_charges').maskMoney('unmasked')[0]);
var others_misc_charges = formatDecimal($(el).find('.atp_unsecured_atp_template_existing_acount_others_misc_charges').maskMoney('unmasked')[0]);
if(!isNaN(unbill_legal) && !isNaN(debtor_balance)){
// console.log(unbill_legal,debtor_balance);
var unbill_legal_balance = getDecimal(Decimal(getDecimal(unbill_legal)).plus(getDecimal(debtor_balance)).toString());
$(el).find('.atp_unsecured_atp_template_existing_acount_total_outstanding_balance').maskMoney('mask',unbill_legal_balance);
total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance = (getDecimal(Decimal(getDecimal(unbill_legal_balance)).plus(getDecimal(total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance)).toString()));
}
if(!isNaN(unbill_legal)){
total_unbill_legal += formatDecimal(unbill_legal);
}
if(!isNaN(late_payment_charge)){
total_late_payment_charge += formatDecimal(late_payment_charge);
}
if(!isNaN(finance_profit_charges)){
total_finance_profit_charges += formatDecimal(finance_profit_charges);
}
if(!isNaN(others_misc_charges)){
total_others_misc_charges += formatDecimal(others_misc_charges);
}
});
$('#'+uid+' .atp_unsecured_atp_template_civil_action_unbilled_legal_fees').maskMoney('mask',formatDecimal(total_unbill_legal));
var atp_unsecured_atp_template_account_info_charge_off_amount = formatDecimal($('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_amount').maskMoney('unmasked')[0]);
var atp_unsecured_atp_template_civil_action_unbilled_legal_fees = formatDecimal($('#'+uid+' .atp_unsecured_atp_template_civil_action_unbilled_legal_fees').maskMoney('unmasked')[0]);
var atp_unsecured_atp_template_account_info_transaction_debited_after_charge_off = formatDecimal($('#'+uid+' .atp_unsecured_atp_template_account_info_transaction_debited_after_charge_off').maskMoney('unmasked')[0]);
var atp_unsecured_atp_template_account_info_total_payment_after_charge_off = formatDecimal($('#'+uid+' .atp_unsecured_atp_template_account_info_total_payment_after_charge_off').maskMoney('unmasked')[0]);
var net_charge_off_amount = formatDecimal((atp_unsecured_atp_template_account_info_charge_off_amount + atp_unsecured_atp_template_civil_action_unbilled_legal_fees + atp_unsecured_atp_template_account_info_transaction_debited_after_charge_off) - atp_unsecured_atp_template_account_info_total_payment_after_charge_off);
// console.log(atp_unsecured_atp_template_account_info_charge_off_amount,atp_unsecured_atp_template_civil_action_unbilled_legal_fees,atp_unsecured_atp_template_account_info_transaction_debited_after_charge_off,atp_unsecured_atp_template_account_info_total_payment_after_charge_off);
// console.log(formatDecimal((atp_unsecured_atp_template_account_info_charge_off_amount + atp_unsecured_atp_template_civil_action_unbilled_legal_fees + atp_unsecured_atp_template_account_info_transaction_debited_after_charge_off) - atp_unsecured_atp_template_account_info_total_payment_after_charge_off));
$('#'+uid+' .atp_unsecured_atp_template_account_info_net_charge_off_amount').maskMoney('mask',net_charge_off_amount);
if(global.debtordata[global.general.atp_debtor_id[uid]].debtor.client_screen == 'CC')
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('mask',net_charge_off_amount);
var atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os = 0;
var atp_unsecured_atp_template_composition_of_waiver_interest_total_os = 0;
if(global.debtordata[global.general.atp_debtor_id[uid]].debtor.client_screen == 'CC'){
// var late_factor = 1;
// if(global.debtordata[global.general.atp_debtor_id[uid]].debtor.has_charge_off == '5'){
// late_factor = 3;
// }
// if(total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance <= 1000){
// atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os = 10*late_factor;
// }else if(total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance > 1000 && total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance <= 10000){
// atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os = formatDecimal((total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance*0.01)*late_factor);
// }else if(total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance > 10000){
// atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os = 100*late_factor;
// }
// atp_unsecured_atp_template_composition_of_waiver_interest_total_os = total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance * 0.18 * 31 / 365 * late_factor;
var late_factor = 0;
if(global.debtordata[global.general.atp_debtor_id[uid]].debtor.has_charge_off == '5'){
late_factor = 6;
}
var atp_unsecured_atp_template_payment_term_total_tenure = getDecimal($('#'+uid+' .atp_unsecured_atp_template_payment_term_total_tenure').val());
// console.log(atp_unsecured_atp_template_payment_term_total_tenure);
// atp_unsecured_atp_template_composition_of_waiver_interest_total_os = total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance * 0.18 * 31 / 365 * (late_factor + atp_unsecured_atp_template_payment_term_total_tenure);
atp_unsecured_atp_template_composition_of_waiver_interest_total_os =
Decimal(total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance).minus(net_charge_off_amount).plus(Decimal(total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance).times(0.18).times(31).dividedBy(365).times(late_factor+atp_unsecured_atp_template_payment_term_total_tenure));
// atp_unsecured_atp_template_composition_of_waiver_interest_total_os = Decimal(getDecimal($('#'+uid+' .atp_unsecured_atp_template_existing_acount_system_total').maskMoney('unmasked')[0])).minus(atp_unsecured_atp_template_civil_action_unbilled_legal_fees).minus(getDecimal($('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('unmasked')[0]));
}else if(global.debtordata[global.general.atp_debtor_id[uid]].debtor.client_screen == 'PL'){
atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os = total_late_payment_charge;
atp_unsecured_atp_template_composition_of_waiver_interest_total_os = total_finance_profit_charges;
}
// console.log(atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os,atp_unsecured_atp_template_composition_of_waiver_interest_total_os,total_unbill_legal,total_others_misc_charges);
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').maskMoney('mask',formatDecimal(atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('mask',formatDecimal(atp_unsecured_atp_template_composition_of_waiver_interest_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os').maskMoney('mask',formatDecimal(total_unbill_legal));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').maskMoney('mask',formatDecimal(total_others_misc_charges));
}
$('#'+uid+' .atp_unsecured_atp_template_existing_acount_system_total').maskMoney('mask',formatDecimal(total_atp_unsecured_atp_template_existing_acount_total_outstanding_balance));
if($('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').removeClass('is-invalid');
}
if($('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum').removeClass('is-invalid');
}
if($('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum').removeClass('is-invalid');
}
if($('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum').removeClass('is-invalid');
}
// if($('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').val() == ""){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').removeClass('is-invalid');
// }
if($('#'+uid+' .atp_unsecured_atp_template_basis_comments').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_basis_comments').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_basis_comments').removeClass('is-invalid');
}
if($('#'+uid+' .atp_unsecured_atp_template_payment_term_total_instalment_payment_tier_row').length <= 0){
invalid++;
}
if($('#'+uid+' .atp_unsecured_atp_template_decision_by_row').length <= 0){
invalid++;
}else{
var have_approval_ind = false;
if(global.general.atp_decision[uid] != null){
$.each(global.general.atp_decision[uid],function(index, el) {
if(global.general.atp_activity[el.activity].approval_ind == "1"){
have_approval_ind = true;
return false;
}
});
if(!have_approval_ind)
invalid++;
}
}
if($('#'+uid+' .atp_rebate_calculator_rebate').val() == ""){
$('#'+uid+' .atp_rebate_calculator_calculate_rebate').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_rebate_calculator_calculate_rebate').removeClass('is-invalid');
}
if($('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').val() == ""){
$('#'+uid+' .atp_unsecured_atp_template_review_decision_by').addClass('is-invalid');
invalid++;
}else{
$('#'+uid+' .atp_unsecured_atp_template_review_decision_by').removeClass('is-invalid');
}
if(invalid > 0){
// $('#'+uid+' .atp_unsecured_atp_template_save_draft').prop('disabled',true);
$('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',true);
}else{
// $('#'+uid+' .atp_unsecured_atp_template_save_draft').prop('disabled',false);
$('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',false);
}
}
function realtimeValidateATPOfferLetterRemark(){
var invalid = 0;
if($('.atp_unsecured_atp_template_offer_letter_send_remark').val() == ""){
$('.atp_unsecured_atp_template_offer_letter_send_remark').addClass('is-invalid');
invalid++;
}else{
$('.atp_unsecured_atp_template_offer_letter_send_remark').removeClass('is-invalid');
}
if(invalid > 0){
$('.atp_unsecured_atp_template_offer_letter_send_confirm').prop('disabled',true);
}else{
$('.atp_unsecured_atp_template_offer_letter_send_confirm').prop('disabled',false);
}
}
function realtimeValidateATPBOfferLetterRemark(){
var invalid = 0;
if($('.atpb_template_offer_letter_send_remark').val() == ""){
$('.atpb_template_offer_letter_send_remark').addClass('is-invalid');
invalid++;
}else{
$('.atpb_template_offer_letter_send_remark').removeClass('is-invalid');
}
if(invalid > 0){
$('.atpb_template_offer_letter_send_confirm').prop('disabled',true);
}else{
$('.atpb_template_offer_letter_send_confirm').prop('disabled',false);
}
}
function realtimeCalculateSecured(uid){
// console.log('moshiya');
var atp_secured_atp_template_judgment_computation_judgement_total_os = $('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_total_os').maskMoney('unmasked')[0];
var atp_secured_atp_template_judgment_computation_interest_total_os = $('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_total_os').maskMoney('unmasked')[0];
var atp_secured_atp_template_judgment_computation_cost_awarded_total_os = $('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_total_os').maskMoney('unmasked')[0];
var atp_secured_atp_template_judgment_computation_payment_compensation_total_os = $('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_total_os').maskMoney('unmasked')[0];
var atp_secured_atp_template_judgment_computation_judgement_proposed_sum = $('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_proposed_sum').maskMoney('unmasked')[0];
var atp_secured_atp_template_judgment_computation_interest_proposed_sum = $('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_proposed_sum').maskMoney('unmasked')[0];
var atp_secured_atp_template_judgment_computation_cost_awarded_proposed_sum = $('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_proposed_sum').maskMoney('unmasked')[0];
var atp_secured_atp_template_judgment_computation_payment_compensation_proposed_sum = $('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_proposed_sum').maskMoney('unmasked')[0];
//all total
$('#'+uid+' .atp_secured_atp_template_judgment_computation_os_balance_total_os').maskMoney('mask',formatDecimal(atp_secured_atp_template_judgment_computation_judgement_total_os+atp_secured_atp_template_judgment_computation_interest_total_os+atp_secured_atp_template_judgment_computation_cost_awarded_total_os+atp_secured_atp_template_judgment_computation_payment_compensation_total_os));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_os_balance_proposed_sum').maskMoney('mask',formatDecimal(atp_secured_atp_template_judgment_computation_judgement_proposed_sum+atp_secured_atp_template_judgment_computation_interest_proposed_sum+atp_secured_atp_template_judgment_computation_cost_awarded_proposed_sum+atp_secured_atp_template_judgment_computation_payment_compensation_proposed_sum));
}
function realtimeCalculateATPB(uid){
var atpb_template_composition_waiver_principal_loan_total_os = $('#'+uid+' .atpb_template_composition_waiver_principal_loan_total_os').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_subrogation_total_os = $('#'+uid+' .atpb_template_composition_waiver_subrogation_total_os').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_subrogation_proposed_sum = $('#'+uid+' .atpb_template_composition_waiver_subrogation_proposed_sum').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_subrogation_discount_value = formatDecimal(Decimal(atpb_template_composition_waiver_subrogation_total_os).minus(atpb_template_composition_waiver_subrogation_proposed_sum));
$('#'+uid+' .atpb_template_composition_waiver_subrogation_discount_value').maskMoney('mask',atpb_template_composition_waiver_subrogation_discount_value);
var atpb_template_composition_waiver_subrogation_discount_rate = formatDecimal(Decimal(atpb_template_composition_waiver_subrogation_discount_value).dividedBy(atpb_template_composition_waiver_subrogation_total_os).times(100));
$('#'+uid+' .atpb_template_composition_waiver_subrogation_discount_rate').maskMoney('mask',atpb_template_composition_waiver_subrogation_discount_rate);
//=============
var atpb_template_composition_waiver_margin_os_total_os = $('#'+uid+' .atpb_template_composition_waiver_margin_os_total_os').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_margin_os_proposed_sum = $('#'+uid+' .atpb_template_composition_waiver_margin_os_proposed_sum').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_margin_os_discount_value = formatDecimal(Decimal(atpb_template_composition_waiver_margin_os_total_os).minus(atpb_template_composition_waiver_margin_os_proposed_sum));
$('#'+uid+' .atpb_template_composition_waiver_margin_os_discount_value').maskMoney('mask',atpb_template_composition_waiver_margin_os_discount_value);
var atpb_template_composition_waiver_margin_os_discount_rate = formatDecimal(Decimal(atpb_template_composition_waiver_margin_os_discount_value).dividedBy(atpb_template_composition_waiver_margin_os_total_os).times(100));
$('#'+uid+' .atpb_template_composition_waiver_margin_os_discount_rate').maskMoney('mask',atpb_template_composition_waiver_margin_os_discount_rate);
//=============
var atpb_template_composition_waiver_arrears_profit_sharing_total_os = $('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_total_os').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_arrears_profit_sharing_proposed_sum = $('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_proposed_sum').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_arrears_profit_sharing_discount_value = formatDecimal(Decimal(atpb_template_composition_waiver_arrears_profit_sharing_total_os).minus(atpb_template_composition_waiver_arrears_profit_sharing_proposed_sum));
$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_discount_value').maskMoney('mask',atpb_template_composition_waiver_arrears_profit_sharing_discount_value);
var atpb_template_composition_waiver_arrears_profit_sharing_discount_rate = formatDecimal(Decimal(atpb_template_composition_waiver_arrears_profit_sharing_discount_value).dividedBy(atpb_template_composition_waiver_arrears_profit_sharing_total_os).times(100));
$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_discount_rate').maskMoney('mask',atpb_template_composition_waiver_arrears_profit_sharing_discount_rate);
//=============
var atpb_template_composition_waiver_penalty_arrears_total_os = $('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_total_os').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_penalty_arrears_proposed_sum = $('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_proposed_sum').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_penalty_arrears_discount_value = formatDecimal(Decimal(atpb_template_composition_waiver_penalty_arrears_total_os).minus(atpb_template_composition_waiver_penalty_arrears_proposed_sum));
$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_discount_value').maskMoney('mask',atpb_template_composition_waiver_penalty_arrears_discount_value);
var atpb_template_composition_waiver_penalty_arrears_discount_rate = formatDecimal(Decimal(atpb_template_composition_waiver_penalty_arrears_discount_value).dividedBy(atpb_template_composition_waiver_penalty_arrears_total_os).times(100));
$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_discount_rate').maskMoney('mask',atpb_template_composition_waiver_penalty_arrears_discount_rate);
//=============
var atpb_template_composition_waiver_other_charges_total_os = $('#'+uid+' .atpb_template_composition_waiver_other_charges_total_os').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_other_charges_proposed_sum = $('#'+uid+' .atpb_template_composition_waiver_other_charges_proposed_sum').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_other_charges_discount_value = formatDecimal(Decimal(atpb_template_composition_waiver_other_charges_total_os).minus(atpb_template_composition_waiver_other_charges_proposed_sum));
$('#'+uid+' .atpb_template_composition_waiver_other_charges_discount_value').maskMoney('mask',atpb_template_composition_waiver_other_charges_discount_value);
var atpb_template_composition_waiver_other_charges_discount_rate = formatDecimal(Decimal(atpb_template_composition_waiver_other_charges_discount_value).dividedBy(atpb_template_composition_waiver_other_charges_total_os).times(100));
$('#'+uid+' .atpb_template_composition_waiver_other_charges_discount_rate').maskMoney('mask',atpb_template_composition_waiver_other_charges_discount_rate);
//=============
var atpb_template_composition_waiver_unbill_legal_fees_total_os = $('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_total_os').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_unbill_legal_fees_proposed_sum = $('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_proposed_sum').maskMoney('unmasked')[0];
var atpb_template_composition_waiver_unbill_legal_fees_discount_value = formatDecimal(Decimal(atpb_template_composition_waiver_unbill_legal_fees_total_os).minus(atpb_template_composition_waiver_unbill_legal_fees_proposed_sum));
$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_discount_value').maskMoney('mask',atpb_template_composition_waiver_unbill_legal_fees_discount_value);
var atpb_template_composition_waiver_unbill_legal_fees_discount_rate = formatDecimal(Decimal(atpb_template_composition_waiver_unbill_legal_fees_discount_value).dividedBy(atpb_template_composition_waiver_unbill_legal_fees_total_os).times(100));
$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_discount_rate').maskMoney('mask',atpb_template_composition_waiver_unbill_legal_fees_discount_rate);
var atpb_template_composition_waiver_total_projected_outstanding_total_os = formatDecimal(Decimal(atpb_template_composition_waiver_principal_loan_total_os).plus(atpb_template_composition_waiver_subrogation_total_os).plus(atpb_template_composition_waiver_margin_os_total_os).plus(atpb_template_composition_waiver_arrears_profit_sharing_total_os).plus(atpb_template_composition_waiver_penalty_arrears_total_os).plus(atpb_template_composition_waiver_other_charges_total_os).plus(atpb_template_composition_waiver_unbill_legal_fees_total_os));
$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_total_os').maskMoney('mask',atpb_template_composition_waiver_total_projected_outstanding_total_os);
$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_proposed_sum').maskMoney('mask',formatDecimal(Decimal(0)
.plus(atpb_template_composition_waiver_subrogation_proposed_sum)
.plus(atpb_template_composition_waiver_margin_os_proposed_sum)
.plus(atpb_template_composition_waiver_arrears_profit_sharing_proposed_sum)
.plus(atpb_template_composition_waiver_penalty_arrears_proposed_sum)
.plus(atpb_template_composition_waiver_other_charges_proposed_sum)
.plus(atpb_template_composition_waiver_unbill_legal_fees_proposed_sum)));
var atpb_template_composition_waiver_total_projected_outstanding_discount_value = formatDecimal(Decimal(0)
.plus(atpb_template_composition_waiver_subrogation_discount_value)
.plus(atpb_template_composition_waiver_margin_os_discount_value)
.plus(atpb_template_composition_waiver_arrears_profit_sharing_discount_value)
.plus(atpb_template_composition_waiver_penalty_arrears_discount_value)
.plus(atpb_template_composition_waiver_other_charges_discount_value)
.plus(atpb_template_composition_waiver_unbill_legal_fees_discount_value))
$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_discount_value').maskMoney('mask',atpb_template_composition_waiver_total_projected_outstanding_discount_value);
// $('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_discount_rate').maskMoney('mask',formatDecimal(Decimal(0)
// .plus(atpb_template_composition_waiver_subrogation_discount_rate)
// .plus(atpb_template_composition_waiver_margin_os_discount_rate)
// .plus(atpb_template_composition_waiver_arrears_profit_sharing_discount_rate)
// .plus(atpb_template_composition_waiver_penalty_arrears_discount_rate)
// .plus(atpb_template_composition_waiver_other_charges_discount_rate)
// .plus(atpb_template_composition_waiver_unbill_legal_fees_discount_rate)));
var atpb_template_composition_waiver_total_projected_outstanding_discount_rate = formatDecimal(Decimal(atpb_template_composition_waiver_total_projected_outstanding_discount_value).dividedBy(atpb_template_composition_waiver_total_projected_outstanding_total_os).times(100));
$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_discount_rate').maskMoney('mask',atpb_template_composition_waiver_total_projected_outstanding_discount_rate);
$('#'+uid+' .atpb_template_existing_section_system_total').maskMoney('mask',atpb_template_composition_waiver_total_projected_outstanding_total_os);
// //interest
// var atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').maskMoney('unmasked')[0];
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_interest_total_os).minus(atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum)));
// var atp_unsecured_atp_template_composition_of_waiver_interest_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('unmasked')[0];
// if(atp_unsecured_atp_template_composition_of_waiver_interest_total_os > 0){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_interest_waiver/atp_unsecured_atp_template_composition_of_waiver_interest_total_os)*100));
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('mask',0.00);
// }
// //misc
// var atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum').maskMoney('unmasked')[0];
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_misc_total_os).minus(atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum)));
// var atp_unsecured_atp_template_composition_of_waiver_misc_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver').maskMoney('unmasked')[0];
// if(atp_unsecured_atp_template_composition_of_waiver_misc_total_os > 0){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_misc_waiver/atp_unsecured_atp_template_composition_of_waiver_misc_total_os)*100));
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver_percent').maskMoney('mask',0.00);
// }
// // late payment
// var atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum').maskMoney('unmasked')[0];
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os).minus(atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum)));
// var atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver').maskMoney('unmasked')[0];
// if(atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os > 0){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver/atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os)*100));
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver_percent').maskMoney('mask',0.00);
// }
// //unbill
// var atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum').maskMoney('unmasked')[0];
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os).minus(formatDecimal(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum))));
// var atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver').maskMoney('unmasked')[0];
// if(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os > 0){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver_percent').maskMoney('mask',formatDecimal((formatDecimal(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver)/formatDecimal(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os))*100));
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver_percent').maskMoney('mask',0.00);
// }
// //all total
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_total_os').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_principal_total_os).plus(atp_unsecured_atp_template_composition_of_waiver_interest_total_os).plus(atp_unsecured_atp_template_composition_of_waiver_misc_total_os).plus(atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os).plus(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os)));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum).plus(atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum).plus(atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum).plus(atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum).plus(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum)));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_principal_waiver).plus(atp_unsecured_atp_template_composition_of_waiver_interest_waiver).plus(atp_unsecured_atp_template_composition_of_waiver_misc_waiver).plus(atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver).plus(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver)));
// var atp_unsecured_atp_template_composition_of_waiver_total_total_os = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_total_os').maskMoney('unmasked')[0];
// var atp_unsecured_atp_template_composition_of_waiver_total_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('unmasked')[0];
// if(atp_unsecured_atp_template_composition_of_waiver_total_total_os > 0){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_total_waiver/atp_unsecured_atp_template_composition_of_waiver_total_total_os)*100));
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver_percent').maskMoney('mask',0.00);
// }
// var atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').maskMoney('unmasked')[0];
// $('#'+uid+' .atp_unsecured_atp_template_agreed_settlement_sum').maskMoney('mask',atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum);
// var atp_unsecured_atp_template_composition_of_waiver_total_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('unmasked')[0];
// $('#'+uid+' .atp_unsecured_atp_template_projected_waiver_amount').maskMoney('mask',atp_unsecured_atp_template_composition_of_waiver_total_waiver);
}
function realtimeCalculateUnsecured(uid){
// console.log('moshiya');
var atp_unsecured_atp_template_composition_of_waiver_principal_total_os = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('unmasked')[0];
var atp_unsecured_atp_template_composition_of_waiver_interest_total_os = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('unmasked')[0];
var atp_unsecured_atp_template_composition_of_waiver_misc_total_os = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').maskMoney('unmasked')[0];
var atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').maskMoney('unmasked')[0];
var atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os').maskMoney('unmasked')[0];
//principal
var atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum').maskMoney('unmasked')[0];
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_principal_total_os).minus(atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum)));
var atp_unsecured_atp_template_composition_of_waiver_principal_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver').maskMoney('unmasked')[0];
if(atp_unsecured_atp_template_composition_of_waiver_principal_total_os > 0){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_principal_waiver/atp_unsecured_atp_template_composition_of_waiver_principal_total_os)*100));
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver_percent').maskMoney('mask',0.00);
}
//interest
var atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').maskMoney('unmasked')[0];
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_interest_total_os).minus(atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum)));
var atp_unsecured_atp_template_composition_of_waiver_interest_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('unmasked')[0];
if(atp_unsecured_atp_template_composition_of_waiver_interest_total_os > 0){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_interest_waiver/atp_unsecured_atp_template_composition_of_waiver_interest_total_os)*100));
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('mask',0.00);
}
//misc
var atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum').maskMoney('unmasked')[0];
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_misc_total_os).minus(atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum)));
var atp_unsecured_atp_template_composition_of_waiver_misc_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver').maskMoney('unmasked')[0];
if(atp_unsecured_atp_template_composition_of_waiver_misc_total_os > 0){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_misc_waiver/atp_unsecured_atp_template_composition_of_waiver_misc_total_os)*100));
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver_percent').maskMoney('mask',0.00);
}
// late payment
var atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum').maskMoney('unmasked')[0];
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os).minus(atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum)));
var atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver').maskMoney('unmasked')[0];
if(atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os > 0){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver/atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os)*100));
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver_percent').maskMoney('mask',0.00);
}
//unbill
var atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum').maskMoney('unmasked')[0];
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os).minus(formatDecimal(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum))));
var atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver').maskMoney('unmasked')[0];
if(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os > 0){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver_percent').maskMoney('mask',formatDecimal((formatDecimal(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver)/formatDecimal(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os))*100));
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver_percent').maskMoney('mask',0.00);
}
//all total
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_total_os').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_principal_total_os).plus(atp_unsecured_atp_template_composition_of_waiver_interest_total_os).plus(atp_unsecured_atp_template_composition_of_waiver_misc_total_os).plus(atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os).plus(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os)));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum).plus(atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum).plus(atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum).plus(atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum).plus(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum)));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('mask',formatDecimal(Decimal(atp_unsecured_atp_template_composition_of_waiver_principal_waiver).plus(atp_unsecured_atp_template_composition_of_waiver_interest_waiver).plus(atp_unsecured_atp_template_composition_of_waiver_misc_waiver).plus(atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver).plus(atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver)));
var atp_unsecured_atp_template_composition_of_waiver_total_total_os = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_total_os').maskMoney('unmasked')[0];
var atp_unsecured_atp_template_composition_of_waiver_total_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('unmasked')[0];
if(atp_unsecured_atp_template_composition_of_waiver_total_total_os > 0){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver_percent').maskMoney('mask',formatDecimal((atp_unsecured_atp_template_composition_of_waiver_total_waiver/atp_unsecured_atp_template_composition_of_waiver_total_total_os)*100));
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver_percent').maskMoney('mask',0.00);
}
var atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').maskMoney('unmasked')[0];
$('#'+uid+' .atp_unsecured_atp_template_agreed_settlement_sum').maskMoney('mask',atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum);
var atp_unsecured_atp_template_composition_of_waiver_total_waiver = $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('unmasked')[0];
$('#'+uid+' .atp_unsecured_atp_template_projected_waiver_amount').maskMoney('mask',atp_unsecured_atp_template_composition_of_waiver_total_waiver);
}
function getDecimal(data,decimal_point = 2){
if($.isNumeric(data) === false)
data = 0;
return formatDecimal(data,decimal_point);
}
function formatDecimal(data,decimal_point = 2){
data = Number.parseFloat(data);
return Number.parseFloat(data.toFixedFloor(decimal_point));
}
function populateMOATemplateModal(uid,debtor_id,moa = false){
// var atp_calculator_modal_cc = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'atp_calculator_modal_cc').html());
var moa_calculator_modal = Handlebars.compile($('#template-bicbs_moa_calculator_modal').html());
var moa_calculator_modal_var = {};
var debtor = global.debtordata[debtor_id].debtor;
global.general.moa_debtor_id[uid] = debtor_id;
moa_calculator_modal_var.collector_name = global.general.collector_name;
moa_calculator_modal_var.collector_user_id = global.general.collector_user_id;
moa_calculator_modal_var.debtor = global.debtordata[debtor_id].debtor;
moa_calculator_modal_var.moa_dropdown = global.general.atp_dropdown;
moa_calculator_modal_var.moa_activity = global.general.atp_activity;
moa_calculator_modal_var.collector_list = global.general.collector_list;
moa_calculator_modal_var.collector_full_list = global.general.collector_full_list;
moa_calculator_modal_var.uid = uid;
moa_calculator_modal_var.approval_authority = "";
moa_calculator_modal_var.type_of_reschedule = "";
// atp_calculator_modal_cc_var.smsnumbers = global.debtordata[debtor_id].smsnumbers;
// global.general.atp_tier[uid] = [];
// global.general.atp_decision[uid] = [];
var atp_status = "";
if(moa != false){
var tier_type = [];
$.each(global.general.atp_dropdown.tier_type,function(index, el) {
tier_type[el.id] = el.name;
});
$.each(moa.moa_tiering_info_section,function(index, el) {
moa.moa_tiering_info_section[index].tier_name = tier_type[el.tier] != null ? tier_type[el.tier]:'';
});
moa_calculator_modal_var.moa_account_list_section = moa.moa_account_list_section;
moa_calculator_modal_var.moa_tiering_info_section = moa.moa_tiering_info_section;
moa_calculator_modal_var.moa_relationship_section = moa.moa_relationship_section;
global.general.moa_tier[uid] = moa.moa_tiering_info_section;
moa_calculator_modal_var.moa_existing_account_section = moa.moa_existing_account_section;
moa_calculator_modal_var.moa_approval_decision = moa.moa_approval_decision;
global.general.moa_decision[uid] = moa.moa_approval_decision;
moa_calculator_modal_var.moa_financing_commitment_section = moa.moa_financing_commitment_section;
global.general.moa_financing_commitment[uid] = moa.moa_financing_commitment_section;
}
$('#'+uid+' .moa_calculator_modal').html(moa_calculator_modal(moa_calculator_modal_var));
$('#'+uid+" .moa_template_existing_account_outstanding_balance_details_as_at").val(moment().format(momentDateFormat));
// // $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by .inactive_user").addClass('hideMe');
// // $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by .deleted_user").addClass('hideMe');
// $('#'+uid+" .atp_unsecured_atp_template_review_decision_by").selectpicker('destroy');
// $('#'+uid+' .atp_unsecured_atp_template_review_decision_by').selectpicker({
// hideDisabled: true,
// liveSearch: true
// });
// // var initial_atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor = '';
// // if(debtor.client_screen == 'PL'){
// // initial_atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor = debtor.client_outstanding_balance - debtor.write_off_iis;
// // }else if(debtor.client_screen == 'CC'){
// // if(debtor.has_charge_off != '5'){
// // }else if(debtor.has_charge_off == '5'){
// // initial_atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor = debtor.charge_off_amount;
// // }
// // // IF debtor.is_credit_card='1' AND debtor.has_charge_off!=5 then refer to
// // // Sum of Unsecured Section C [Total Outstanding Balance / Debt (v)] minus [Late Payment Charges (i)] minus [Finance / Profit Charges (ii)] minus [Others / Misc Charges (iii)] minus [Unbill Legal /COC / FPP / EPP (iv)]
// // // IF debtor.is_credit_card='1' AND debtor.has_charge_off=5 then refer to
// // // Sum of Unsecured Section D [h) Net Charge Off Amount]
// // }
// // $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor').val(formatDecimal(initial_atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor));
// if(global.debtordata[debtor_id].debtor.client_screen == 'CC'){
// // $('#'+uid+' .atp_unsecured_atp_template_existing_acount_unbill_legal').maskMoney('mask',formatDecimal(global.debtordata[debtor_id].debtor.all_card_unbilled_installment_amount_exclude_standalone_limit));
// // console.log(debtor);
// // atp_unsecured_atp_template_account_info_account_opened
// var earliest_card_issued_date = '';
// var latest_last_payment_date = '';
// var earliest_charge_off_date = '';
// var total_charge_off_amount = 0;
// var total_payment_after_charge_off = 0;
// for (var i = 0; i < debtor.debtor_othercards.length; i++) {
// if(debtor.debtor_othercards[i].client_screen == 'CC'){
// if(
// (moment(debtor.debtor_othercards[i].card_issued_date,momentSqlDateFormat).format(momentSqlDateFormat) != 'Invalid date') &&
// ( earliest_card_issued_date == '' || moment(debtor.debtor_othercards[i].card_issued_date,momentSqlDateFormat).isBefore(earliest_card_issued_date) )
// ){
// earliest_card_issued_date = debtor.debtor_othercards[i].card_issued_date;
// }
// if(
// (moment(debtor.debtor_othercards[i].charge_off_date,momentSqlDateTimeFormat).format(momentSqlDateFormat) != 'Invalid date') &&
// ( earliest_charge_off_date == '' || moment(debtor.debtor_othercards[i].charge_off_date,momentSqlDateFormat).isBefore(earliest_charge_off_date) )
// ){
// earliest_charge_off_date = debtor.debtor_othercards[i].charge_off_date;
// }
// if(
// (moment(debtor.debtor_othercards[i].last_payment_date,momentSqlDateTimeFormat).format(momentSqlDateFormat) != 'Invalid date') &&
// ( latest_last_payment_date == '' || moment(debtor.debtor_othercards[i].last_payment_date,momentSqlDateFormat).isAfter(latest_last_payment_date) )
// ){
// latest_last_payment_date = debtor.debtor_othercards[i].last_payment_date;
// }
// if($.isNumeric(debtor.debtor_othercards[i].charge_off_amount)){
// total_charge_off_amount += Number(debtor.debtor_othercards[i].charge_off_amount);
// }
// if($.isNumeric(debtor.debtor_othercards[i].payment_after_charge_off)){
// total_payment_after_charge_off += Number(debtor.debtor_othercards[i].payment_after_charge_off);
// }
// }
// }
// if(earliest_card_issued_date != '' && earliest_card_issued_date != null)
// earliest_card_issued_date= moment(earliest_card_issued_date,momentSqlDateFormat).format(momentDateFormat);
// $('#'+uid+' .atp_unsecured_atp_template_account_info_account_opened').val(earliest_card_issued_date);
// if(latest_last_payment_date != '' && latest_last_payment_date != null)
// latest_last_payment_date= moment(latest_last_payment_date,momentSqlDateFormat).format(momentDateFormat);
// $('#'+uid+' .atp_unsecured_atp_template_account_info_last_payment_date').val(latest_last_payment_date);
// if(earliest_charge_off_date != '' && earliest_charge_off_date != null)
// earliest_charge_off_date= moment(earliest_charge_off_date,momentSqlDateFormat).format(momentDateFormat);
// // $('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_date').val(earliest_charge_off_date);
// $('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_amount').maskMoney('mask',formatDecimal(total_charge_off_amount));
// $('#'+uid+' .atp_unsecured_atp_template_account_info_total_payment_after_charge_off').maskMoney('mask',formatDecimal(total_payment_after_charge_off));
// }
// if(global.debtordata[debtor_id].debtor.client_screen == 'CC' || global.debtordata[debtor_id].debtor.client_screen == 'PL' ){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').prop('disabled',true);
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').prop('disabled',true);
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').prop('disabled',true);
// if(global.debtordata[debtor_id].debtor.client_screen == 'HP'){
// // $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').prop('disabled',false);
// }
// }
// var principal_total_os = 0;
// switch(global.debtordata[debtor_id].debtor.client_screen){
// case 'MG':
// if(global.debtordata[debtor_id].debtor.is_islamic == '0'){
// principal_total_os = global.debtordata[debtor_id].debtor.client_outstanding_balance;
// }else{
// principal_total_os = global.debtordata[debtor_id].debtor.os_cost;
// }
// break;
// case 'OD':
// principal_total_os = global.debtordata[debtor_id].debtor.balance;
// break;
// case 'HP':
// if(global.debtordata[debtor_id].debtor.account_status_id == '8'){
// if(global.debtordata[debtor_id].debtor.product_code == 'HLBB'){
// principal_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.client_outstanding_balance) - formatDecimal(global.debtordata[debtor_id].debtor.write_off_iis));
// }else if(global.debtordata[debtor_id].debtor.product_code == 'Ex-EBB'){
// if(!(global.debtordata[debtor_id].debtor.ebb_write_off_os_iis != null))
// global.debtordata[debtor_id].debtor.ebb_write_off_os_iis = 0;
// principal_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.client_outstanding_balance) - formatDecimal(global.debtordata[debtor_id].debtor.ebb_write_off_os_iis));
// }
// }else{
// principal_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.client_outstanding_balance) - formatDecimal(global.debtordata[debtor_id].debtor.installment_in_suspend));
// }
// break;
// case 'PL':
// principal_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.client_outstanding_balance) - formatDecimal(global.debtordata[debtor_id].debtor.write_off_iis));
// break;
// default:break;
// }
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('mask',formatDecimal(principal_total_os));
// var interest_total_os = 0;
// switch(global.debtordata[debtor_id].debtor.client_screen){
// case 'MG':
// if(global.debtordata[debtor_id].debtor.is_islamic == '0'){
// interest_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.billed_interest) + formatDecimal(global.debtordata[debtor_id].debtor.new_interest));
// }else{
// interest_total_os = global.debtordata[debtor_id].debtor.interest_rebate;
// }
// break;
// case 'OD':
// interest_total_os = global.debtordata[debtor_id].debtor.new_interest;
// break;
// case 'HP':
// if(global.debtordata[debtor_id].debtor.account_status_id == '8'){
// if(global.debtordata[debtor_id].debtor.product_code == 'HLBB'){
// interest_total_os = global.debtordata[debtor_id].debtor.write_off_iis;
// }else if(global.debtordata[debtor_id].debtor.product_code == 'Ex-EBB'){
// interest_total_os = global.debtordata[debtor_id].debtor.ebb_write_off_os_iis;
// }
// }else{
// interest_total_os = global.debtordata[debtor_id].debtor.installment_in_suspend;
// }
// break;
// default:break;
// }
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('mask',formatDecimal(principal_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('mask',formatDecimal(interest_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').maskMoney('mask',formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.other_cost) + formatDecimal(global.debtordata[debtor_id].debtor.miscellaneous_charges)));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').maskMoney('mask',formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.late_charges) + formatDecimal(global.debtordata[debtor_id].debtor.memo_late_charge)));
if(moa != false){
if(moa.moa_history != null){
moa_calculator_modal_var.approval_authority = moa.moa_history.approval_authority;
moa_calculator_modal_var.type_of_reschedule = moa.moa_history.type_of_request;
$('#'+uid+' .moa_template_general_application_date').val(moment(moa.moa_history.created_at,momentSqlDateTimeFormat).format(momentDateFormat));
$('#'+uid+' .moa_template_general_application').val(moa.moa_history.application_note);
// $('#'+uid+' .atp_rebate_calculator_interest_rate').val(atp.atp_history.interest_profit_rate);
// $('#'+uid+' .atp_rebate_calculator_loan_term').val(atp.atp_history.term);
// $('#'+uid+' .atp_rebate_calculator_term_charges').val(atp.atp_history.term_charges);
// $('#'+uid+' .atp_rebate_calculator_agreement_date').val(getLanguageDate(atp.atp_history.agreement_date));
// $('#'+uid+' .atp_rebate_calculator_settlement_date').val(getLanguageDate(atp.atp_history.settlement_date));
// $('#'+uid+' .atp_rebate_calculator_factor').val(atp.atp_history.factor);
// $('#'+uid+' .atp_rebate_calculator_remaining_months').val(atp.atp_history.remaining_months);
// $('#'+uid+' .atp_rebate_calculator_rebate').val(atp.atp_history.rebate);
// $('#'+uid+' select.atp_unsecured_atp_template_entity').val(atp.atp_history.is_islamic);
// // is_secured:0,
// $('#'+uid+' .atp_unsecured_atp_template_date').val(getLanguageDate(atp.atp_history.created_at));
// $('#'+uid+' .atp_unsecured_atp_template_collection_centre').val(atp.atp_history.collection_center);
// $('#'+uid+' .atp_unsecured_atp_template_product').val(atp.atp_history.client_name);
// $('#'+uid+' .atp_unsecured_atp_template_dca_name').attr('volare-user_id',atp.atp_history.user_id);
// $('#'+uid+' .atp_unsecured_atp_template_dca_name').val(atp.atp_history.user_name);
// $('#'+uid+' .atp_unsecured_atp_template_customer_id').val(maskNumber(atp.atp_history.new_ic));
// $('#'+uid+' .atp_unsecured_atp_template_customer_id').attr('volare-new_ic',atp.atp_history.new_ic);
// $('#'+uid+' .atp_unsecured_atp_template_customer_name').val(atp.atp_history.debtor_name);
// $('#'+uid+' .atp_unsecured_atp_template_connected_party').prop("checked",atp.atp_history.is_connected_party == "1" ? 1 : 0);
// $('#'+uid+' .atp_unsecured_atp_template_email').val(atp.atp_history.email_address);
// $('#'+uid+' .atp_unsecured_atp_template_type_of_request').val(atp.atp_history.type_of_request);
// $('#'+uid+' .atp_unsecured_atp_template_type_of_package_1').val(atp.atp_history.type_of_package);
// $('#'+uid+' .atp_unsecured_atp_template_type_of_package_2').val(atp.atp_history.type_of_package_02);
// $('#'+uid+' .atp_unsecured_atp_template_type_of_package_3').val(atp.atp_history.type_of_package_03);
// $('#'+uid+' .atp_unsecured_atp_template_type_of_package_1').change();
// $('#'+uid+' .atp_unsecured_atp_template_reason_for_settlement').val(atp.atp_history.reason_for_settlement);
// $('#'+uid+' .atp_unsecured_atp_template_agreed_settlement_sum').maskMoney('mask',formatDecimal(atp.atp_history.agreed_settlement_sum));
// $('#'+uid+' .atp_unsecured_atp_template_projected_waiver_amount').maskMoney('mask',formatDecimal(atp.atp_history.projected_waiver_amount));
// // debtor_id:debtor_id,
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_currency_amount').val(atp.atp_history.epf_withdrawal_payment);
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_date').val(getLanguageDate(atp.atp_history.epf_withdrawal_calendar));
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_total_tenure').val(atp.atp_history.total_tenure);
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_total_instalment_payment_amount').val(atp.atp_history.total_installment);
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_email_when_instalment').prop("checked",atp.atp_history.installment_email == "1");
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_waive_accured_interest').prop("checked",atp.atp_history.bankrupt_status == "1");
// $('#'+uid+' .atp_unsecured_atp_template_existing_acount_position_as_at').val(getLanguageDate(atp.atp_history.position_as_at));
// //don't populate system total to prevent over count
// $('#'+uid+' .atp_unsecured_atp_template_existing_acount_system_total').maskMoney('mask',formatDecimal(atp.atp_history.system_total));
// $('#'+uid+' .atp_unsecured_atp_template_existing_acount_user_input_total').maskMoney('mask',formatDecimal(atp.atp_history.user_input_total));
// $('#'+uid+' .atp_unsecured_atp_template_account_info_account_opened').val(getLanguageDate(atp.atp_history.account_open));
// $('#'+uid+' .atp_unsecured_atp_template_account_info_credit_limit').val(atp.atp_history.credit_limit);
// $('#'+uid+' .atp_unsecured_atp_template_account_info_last_payment_date').val(getLanguageDate(atp.atp_history.last_payment_date));
// $('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_date').val(getLanguageDate(atp.atp_history.charge_off_date));
// $('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_amount').val(atp.atp_history.charge_off_amount);
// $('#'+uid+' .atp_unsecured_atp_template_account_info_transaction_debited_after_charge_off').val(atp.atp_history.transaction_debited_after_charge_off);
// $('#'+uid+' .atp_unsecured_atp_template_account_info_total_payment_after_charge_off').val(atp.atp_history.total_payment_after_charge_off);
// $('#'+uid+' .atp_unsecured_atp_template_account_info_net_charge_off_amount').val(atp.atp_history.net_charge_off_amount);
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_unbilled_legal_fees').val(atp.atp_history.unbilled_legal_fees);
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_legal_status').val(atp.atp_history.legal_status);
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_legal_status_date').val(getLanguageDate(atp.atp_history.legal_status_date));
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_creditor_petition_filed').val(getLanguageDate(atp.atp_history.creditor_petition_filed_date));
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_aoro_date').val(getLanguageDate(atp.atp_history.adj_receive_order_date));
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_pod_date').val(getLanguageDate(atp.atp_history.proof_of_debt_date));
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_aoro_by_3rd_party').val(getLanguageDate(atp.atp_history.aoro_date));
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_law_firm_name').val(atp.atp_history.law_firm_name);
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_lawyer_reference_number').val(atp.atp_history.lawyer_reference_no);
// $('#'+uid+' .atp_unsecured_atp_template_civil_action_summon_number').val(atp.atp_history.summon_no);
// $('#'+uid+' .atp_unsecured_atp_template_bureau_check_ctos').val(atp.atp_history.ctos);
// $('#'+uid+' .atp_unsecured_atp_template_bureau_check_ramci').val(atp.atp_history.ramci);
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('mask',formatDecimal(atp.atp_history.principal_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.principal_proposed_sum));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver').maskMoney('mask',formatDecimal(atp.atp_history.principal_waiver));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.principal_waiver_percentage));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').maskMoney('mask',formatDecimal(atp.atp_history.misc_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.misc_proposed_sum));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver').maskMoney('mask',formatDecimal(atp.atp_history.misc_waiver));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.misc_waiver_percentage));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').maskMoney('mask',formatDecimal(atp.atp_history.compensation_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.compensation_proposed_sum));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver').maskMoney('mask',formatDecimal(atp.atp_history.compensation_waiver));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.compensation_waiver_percentage));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os').maskMoney('mask',formatDecimal(atp.atp_history.unbill_legal_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.unbill_legal_proposed_sum));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver').maskMoney('mask',formatDecimal(atp.atp_history.unbill_legal_waiver));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.unbill_legal_waiver_percentage));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_total_os').maskMoney('mask',formatDecimal(atp.atp_history.total_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.total_proposed_sum));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('mask',formatDecimal(atp.atp_history.total_waiver));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.total_waiver_percentage));
// $('#'+uid+' .atp_unsecured_atp_template_basis_comments').val(atp.atp_history.comments);
// $('#'+uid+' .atp_unsecured_atp_template_created_by').val(atp.atp_history.created_by);
// $('#'+uid+' .atp_unsecured_atp_template_created_by').attr('volare-collector_user_id',atp.atp_history.created_by_id);
// // $('#'+uid+' .atp_unsecured_atp_template_created_by').val(atp.atp_history.created_by_name);
// // reviewed_by:$('#'+uid+' .atp_unsecured_atp_template_review_decision_by option:selected').text(),
// $('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').val(atp.atp_history.reviewed_by_id);
// $('#'+uid+' .atp_unsecured_atp_template_review_decision').val(atp.atp_history.reviewed_by_decision);
// $('#'+uid+' .atp_unsecured_atp_template_review_decision_date').val(atp.atp_history.reviewed_by_decision_date);
// $('#'+uid+' .atp_unsecured_atp_template_review_remarks').val(atp.atp_history.reviewed_by_remark);
// $('#'+uid+' .atp_unsecured_atp_template_basis_comments').val(atp.atp_history.comments);
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('mask',formatDecimal(atp.atp_history.interest_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.interest_proposed_sum));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('mask',formatDecimal(atp.atp_history.interest_waiver));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.interest_waiver_percentage));
// $('#'+uid+' .atp_unsecured_atp_template_profit_charges_1').maskMoney('mask',formatDecimal(atp.atp_history.profit_charges_1));
// $('#'+uid+' .atp_unsecured_atp_template_profit_charges_2').maskMoney('mask',formatDecimal(atp.atp_history.profit_charges_2));
// $('#'+uid+' .atp_unsecured_atp_template_projected_late_payment_1').maskMoney('mask',formatDecimal(atp.atp_history.projected_late_payment_1));
// $('#'+uid+' .atp_unsecured_atp_template_projected_late_payment_2').maskMoney('mask',formatDecimal(atp.atp_history.projected_late_payment_2));
// $('#'+uid+' .atp_unsecured_atp_template_agency_fee_rate_1').maskMoney('mask',formatDecimal(atp.atp_history.agency_fee_rate_1));
// $('#'+uid+' .atp_unsecured_atp_template_agency_fee_rate_2').maskMoney('mask',formatDecimal(atp.atp_history.agency_fee_rate_2));
// $('#'+uid+' .atp_unsecured_atp_template_net_charge_off_amount_1').maskMoney('mask',formatDecimal(atp.atp_history.net_charge_off_amount_1));
// $('#'+uid+' .atp_unsecured_atp_template_settlement_proposal').maskMoney('mask',formatDecimal(atp.atp_history.settlement_proposal));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_total_os').maskMoney('mask',formatDecimal(atp.atp_history.judgement_total_os));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.judgement_proposed_sum));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_waiver').maskMoney('mask',formatDecimal(atp.atp_history.judgement_waiver));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_total_os').maskMoney('mask',formatDecimal(atp.atp_history.h_interest_total_os));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.h_interest_proposed_sum));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_waiver').maskMoney('mask',formatDecimal(atp.atp_history.h_interest_waiver));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_total_os').maskMoney('mask',formatDecimal(atp.atp_history.cost_awarded_total_os));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.cost_awarded_proposed_sum));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_waiver').maskMoney('mask',formatDecimal(atp.atp_history.cost_awarded_waiver));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_total_os').maskMoney('mask',formatDecimal(atp.atp_history.payment_compensation_total_os));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.payment_compensation_proposed_sum));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_waiver').maskMoney('mask',formatDecimal(atp.atp_history.payment_compensation_waiver));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_os_balance_total_os').maskMoney('mask',formatDecimal(atp.atp_history.os_balance_total_os));
// $('#'+uid+' .atp_secured_atp_template_judgment_computation_os_balance_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.os_balance_proposed_sum));
// $('#'+uid+' .atp_secured_atp_template_basis_is_partial_write_off').prop("checked",atp.atp_history.is_partial_write_off == "1");
// $('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_sales_order_date').val(atp.atp_history.sales_order_date);
// $('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auction_date').val(atp.atp_history.auction_date);
// $('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_reserved_price').maskMoney('mask',formatDecimal(atp.atp_history.reserved_price));
// $('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_no_of_past_auction').val(atp.atp_history.no_of_past_auction);
// // $('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auction_off_date').val(atp.atp_history.auction_off_date);
// $('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auction_off_date').val(moment(atp.atp_history.auction_off_date,momentSqlDateFormat).format(momentDateFormat));
// $('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auctioned_selling_price').maskMoney('mask',formatDecimal(atp.atp_history.auctioned_selling_price));
// $('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_summon_filling_date').val(atp.atp_history.summon_filling_date);
// $('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_judgement_date').val(atp.atp_history.judgement_date);
// $('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_execution_mode').val(atp.atp_history.execution_mode);
// // $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('mask',formatDecimal(atp.atp_history.interest_total_os));
// // $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.interest_proposed_sum));
// // $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('mask',formatDecimal(atp.atp_history.interest_waiver));
// // $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.interest_waiver_percentage));
// $('#'+uid+' .atp_secured_atp_template_recomputation_existing_interest_rate').val(atp.atp_history.existing_interest_rate);
// $('#'+uid+' .atp_secured_atp_template_recomputation_existing_blr01').val(atp.atp_history.existing_blr_1);
// $('#'+uid+' .atp_secured_atp_template_recomputation_existing_blr02').val(atp.atp_history.existing_blr_2);
// $('#'+uid+' .atp_secured_atp_template_recomputation_existing_interest').val(atp.atp_history.existing_interest);
// $('#'+uid+' .atp_secured_atp_template_recomputation_revision_interest_rate').val(atp.atp_history.revision_interest_rate);
// $('#'+uid+' .atp_secured_atp_template_recomputation_revision_blr').val(atp.atp_history.revision_blr);
// $('#'+uid+' .atp_secured_atp_template_recomputation_revision_interest').val(atp.atp_history.revision_interest);
// $('#'+uid+' .atp_secured_atp_template_bureau_check_code_4028').maskMoney('mask',formatDecimal(atp.atp_history.code_4028));
// $('#'+uid+' .atp_secured_atp_template_bureau_check_provision_misc').maskMoney('mask',formatDecimal(atp.atp_history.provision_misc));
// $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_model').val(atp.atp_history.model);
// // $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_market_value').val(atp.atp_history.vehicle_market_value);
// $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_market_value').maskMoney('mask', formatDecimal(atp.atp_history.vehicle_market_value));
// if(enable_atp_dca_name){
// $('#'+uid+' .atp_unsecured_atp_template_dca_name').val(atp.atp_history.is_amsx_atp == "1"?atp.atp_history.created_by :'');
// }
// if(enable_atp_letter_offer){
// $('#'+uid+' .atp_unsecured_atp_letter_offer_contact_number').val(atp.atp_history.contact_number_id);
// }
// if(enable_irl_inquiry_atp){
// $('#'+uid+' .atp_unsecured_atp_template_irl_inquiry_remark').val(atp.atp_history.irl_inquiry_remark);
// }
// // if(atp_calculator_modal_cc_var.properties_vehicle_model != ''){
// // $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_model').val(atp_calculator_modal_cc_var.properties_vehicle_model);
// // }
// // if(atp_calculator_modal_cc_var.properties_vehicle_market_value != ''){
// // $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_market_value').val(atp_calculator_modal_cc_var.properties_vehicle_model);
// // }
// // atp.atp_account_list_section
// // $.each(atp.atp_account_list_section,function(index, el) {
// // });
// // $.each(atp.atp_tiering_info_section,function(index, el) {
// // });
// // $.each(atp.atp_existing_account_section,function(index, el) {
// // });
// // $.each(atp.atp_approval_decision,function(index, el) {
// // });
// // $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by .inactive_user").removeClass('hideMe');
// // $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by .deleted_user").removeClass('hideMe');
// $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by").selectpicker('destroy');
// $('#'+uid+' .atp_unsecured_atp_template_review_decision_by').selectpicker({
// hideDisabled: false,
// liveSearch: true
// });
// $('#'+uid+' .atp_unsecured_atp_template_save_draft').attr('volare-atp_history_id',atp.atp_history.id);
// $('#'+uid+' .atp_unsecured_atp_template_submit').attr('volare-atp_history_id',atp.atp_history.id);
// atp_status = atp.atp_history.atp_status;
// // 0 = Pending 1 = Approved 2 = Rejected 3 = Void 4 = Draft
// switch(atp.atp_history.atp_status){
// case '0':
// case '1':
// case '2':
// case '3':
// $('#'+uid+' .atp_unsecured_atp_template_save_draft').prop('disabled',true);
// $('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc input').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc textarea').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc select').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc .atp_rebate_calculator_calculate_rebate').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_payment_term_total_instalment_payment_tier_delete').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_decision_by_delete').prop('disabled',true);
// break;
// default:break;
// }
}
}
$('#'+uid+' .volare_date').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
// $('#'+uid+' .atp_rebate_calculator_agreement_date').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
// $('#'+uid+' .atp_rebate_calculator_settlement_date').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_first_payment_date').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_date').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
// $('#'+uid+' .atp_unsecured_atp_template_existing_acount_position_as_at').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
$('#'+uid+' input[data-toggle="toggle"]').bootstrapToggle({on: 'Yes',off: 'No'});
// $('#'+uid+' .atp_secured_atp_template_date').val(moment().format(momentDateFormat));
// $('#'+uid+' .atp_unsecured_atp_template_date').val(moment().format(momentDateFormat));
$('#'+uid+' .volare_currency').maskMoney({thousands:currencyThousands, decimal:currencyDecimal,allowNegative:true});
$('#'+uid+' .volare_currency').each(function(index, el) {
// console.log($(el).val());
$(el).val(formatDecimal($(el).val()));
$(el).maskMoney('mask');
});
// $('#'+uid+' .volare_currency').maskMoney('mask');
// if(debtor.client_screen == 'CC' || debtor.client_screen == 'PL'){
// $('#'+uid+' .atp_secured_related').addClass('hideMe');
// $('#'+uid+' .atp_unsecured_related').removeClass('hideMe');
// global.general.atp_uid[uid] = 'unsecured';
// }else{
// $('#'+uid+' .atp_secured_related').removeClass('hideMe');
// $('#'+uid+' .atp_unsecured_related').addClass('hideMe');
// global.general.atp_uid[uid] = 'secured';
// }
// // if(enable_atp_letter_offer){
// // $('#'+uid+' .atp_letter_offer_related').removeClass('hideMe');
// // }
// if(enable_atp_letter_offer){
// $('#'+uid+' .atp_letter_offer_general_related').removeClass('hideMe');
// }
if(atp_status == "" || atp_status == "4"){
realtimeValidateMOATier(uid);
// realtimeValidateATPRebateCalculator(uid);
// realtimeValidateATPDecisionMaker(uid);
realtimeValidateMOAOverall(uid);
// realtimeCalculateUnsecured(uid);
}else if(atp_status == "0"){
// $('#'+uid+' .atp_unsecured_atp_template_review_decision').removeClass('hideMe');
// var decision_section_changeable = false;
// if(atp.atp_history.reviewed_by_decision == "0"){
// if(global.general.collector_user_id == atp.atp_history.reviewed_by_id){
// $('#'+uid+' .atp_unsecured_atp_template_review_decision').prop('disabled',false);
// $('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_review_remarks').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_review_decision').attr('original_id',atp.atp_history.reviewed_by_decision);
// $('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').attr('original_id',atp.atp_history.reviewed_by_id);
// // $('#'+uid+' .atp_unsecured_atp_template_submit').attr('mode','review_by');
// decision_section_changeable = true;
// }else if(global.general.collector_user_id == atp.atp_history.created_by_id){
// $('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').prop('disabled',false);
// decision_section_changeable = true;
// }
// if(decision_section_changeable){
// $('#'+uid+' .atp_unsecured_atp_template_decision_activity').prop('disabled',false);
// $('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by').prop('disabled',false);
// $('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_decision_by_delete').prop('disabled',false);
// realtimeValidateATPDecisionMaker(uid);
// realtimeValidateATPOverall(uid);
// }
// }else{
// $('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_decision_by_add').prop('disabled',true);
// var pending_decision_index = '';
// $.each(atp.atp_approval_decision,function(index, el) {
// if(el.decision == "0"){
// pending_decision_index = index;
// return false;
// }
// });
// if(pending_decision_index !== ''){
// if(global.general.collector_user_id == atp.atp_approval_decision[pending_decision_index].decision_by_id){
// $('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_decision_decision_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_decision_remark_'+pending_decision_index+'').prop('disabled',false);
// // $('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_decision').attr('original_id',atp.atp_approval_decision[pending_decision_index].decision);
// $('#'+uid+' .atp_unsecured_atp_template_decision_decision_'+pending_decision_index).attr('original_id',atp.atp_approval_decision[pending_decision_index].decision);
// // $('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_by').attr('original_id',atp.atp_approval_decision[pending_decision_index].decision_by_id);
// $('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by_'+pending_decision_index).attr('original_id',atp.atp_approval_decision[pending_decision_index].decision_by_id);
// // $('#'+uid+' .atp_unsecured_atp_template_submit').attr('mode','decision_by');
// $('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',false);
// }else if(global.general.collector_user_id == atp.atp_history.reviewed_by_id){
// $('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by_'+pending_decision_index+'').prop('disabled',false);
// // $('#'+uid+' .atp_unsecured_atp_template_decision_decision_'+pending_decision_index+'').prop('disabled',false);
// // $('#'+uid+' .atp_unsecured_atp_template_decision_remark_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_submit').attr('mode','review_change_decision_by_bulk');
// $('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',false);
// }
// }
// }
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_review_decision').removeClass('hideMe');
// $('#'+uid+' .atp_unsecured_atp_template_review_decision').prop('disabled',true);
// if((atp_status == "1" || atp_status == "5") && enable_atp_letter_offer){
// $('#'+uid+' .atp_letter_offer_related').removeClass('hideMe');
// $('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_esignatory').prop('disabled',false);
// if(global.access.is_atp_preview_letter_offer_enabled == "1")
// $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_preview').removeClass('hideMe');
// var atp_offer_letter_template = "";
// if(debtor.is_credit_card == '1'){
// atp_offer_letter_template = "unsecured_cc";
// }else if(debtor.is_credit_card == '0' && debtor.is_islamic == '0' && debtor.client_screen == 'PL'){
// atp_offer_letter_template = "unsecured_pl_conventional";
// }else if(debtor.is_credit_card == '0' && debtor.is_islamic == '1' && debtor.client_screen == 'PL'){
// atp_offer_letter_template = "unsecured_pl_islamic";
// }else if(debtor.is_credit_card == '0' && debtor.is_islamic == '0' && (debtor.client_screen == 'HP' || debtor.client_screen == 'MG' || debtor.client_screen == 'OD') ){
// atp_offer_letter_template = "secured_conventional";
// }else if(debtor.is_credit_card == '0' && debtor.is_islamic == '1' && (debtor.client_screen == 'HP' || debtor.client_screen == 'MG' || debtor.client_screen == 'OD')){
// atp_offer_letter_template = "secured_islamic";
// }
// // console.log(debtor.is_credit_card,debtor.is_islamic,debtor.client_screen);
// $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template').append(''+lang['lang_'+atp_offer_letter_template]+' ');
// $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_preview').attr('volare-atp_history_id',atp.atp_history.id);
// $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_generate').attr('volare-atp_history_id',atp.atp_history.id);
// $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_cancel').attr('volare-atp_history_id',atp.atp_history.id);
// // $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_option').attr('value',atp_offer_letter_template);
// $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template').selectpicker();
// }
}
// $('#'+uid+' .atp_unsecured_atp_template_review_decision_by').selectpicker({
// liveSearch: "true"
// });
// $('#'+uid+' .atp_unsecured_atp_template_decision_decision_by').selectpicker({
// liveSearch: "true"
// });
// $('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_by').selectpicker({
// liveSearch: "true"
// });
// if(enable_atp_letter_offer){
// populateATPOfferLetterHistory(uid,atp.atp_letter_offer_history);
// }
// if(enable_irl_inquiry_atp){
// if(atp == false || atp == null || (atp.atp_history.atp_status != null && atp.atp_history.atp_status == "4") ){
// $('#'+uid+" .debtor_detail_as400_online_message_110436_atp_tbody").attr('volare-irl_inquiry_refresh','1');
// processATPIrlTbodyUpdate(uid,debtor.id);
// }else{
// $('#'+uid+" .debtor_detail_as400_online_message_110436_atp_tbody").attr('volare-irl_inquiry_refresh','0');
// $('#'+uid+" .atp_unsecured_atp_template_connected_party").prop('disabled',true);
// $('#'+uid+" .atp_secured_atp_template_customer_list_connected_party").prop('disabled',true);
// }
// $('#'+uid+" .debtor_detail_as400_online_message_110436_atp_related").removeClass('hideMe');
// $('#'+uid+" .atp_secured_atp_template_customer_and_account_information_relationship").addClass('hideMe');
// }
// if(Number(global.access.ATP_calculator) >= 2){
// $('#'+uid+' .atp_unsecured_atp_template_footer').removeClass('hideMe');
// }else{
// $('#'+uid+' .atp_unsecured_atp_template_footer').addClass('hideMe');
// }
$('#'+uid+' .moa_calculator_modal').modal('show');
}
function populateATPBTemplateModal(uid,debtor_id,atpb = false){
// var atp_calculator_modal_cc = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'atp_calculator_modal_cc').html());
var atpb_calculator_modal = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'atpb_calculator_modal').html());
var atpb_calculator_modal_var = {};
var debtor = global.debtordata[debtor_id].debtor;
global.general.atpb_debtor_id[uid] = debtor_id;
atpb_calculator_modal_var.collector_name = global.general.collector_name;
atpb_calculator_modal_var.collector_user_id = global.general.collector_user_id;
atpb_calculator_modal_var.debtor = global.debtordata[debtor_id].debtor;
atpb_calculator_modal_var.atp_dropdown = global.general.atp_dropdown;
atpb_calculator_modal_var.atp_activity = global.general.atp_activity;
atpb_calculator_modal_var.collector_list = global.general.collector_list;
atpb_calculator_modal_var.collector_full_list = global.general.collector_full_list;
atpb_calculator_modal_var.uid = uid;
atpb_calculator_modal_var.atp_calculator_list = global.general.atp_calculator_list;
var collateral_total_coverage = {};
// collateral_total_coverage.total_collateral_binding_value = debtor.collateral_atpb_sum.security_document_value_sum / debtor.gross_arrears;
collateral_total_coverage.total_collateral_binding_value = debtor.collateral_atpb_sum.security_document_value_sum / debtor.loan_amount;
// collateral_total_coverage.total_collateral_market_value = debtor.collateral_atpb_sum.market_value_sum / debtor.gross_arrears;
collateral_total_coverage.total_collateral_market_value = debtor.collateral_atpb_sum.market_value_sum / debtor.loan_amount;
// collateral_total_coverage.total_collateral_liquidity_value = debtor.collateral_atpb_sum.valuation_value_sum / debtor.gross_arrears;
collateral_total_coverage.total_collateral_liquidity_value = debtor.collateral_atpb_sum.valuation_value_sum / debtor.loan_amount;
atpb_calculator_modal_var.collateral_total_coverage = collateral_total_coverage;
atpb_calculator_modal_var.approval_authority = "";
atpb_calculator_modal_var.type_of_reschedule = "";
// atp_calculator_modal_cc_var.smsnumbers = global.debtordata[debtor_id].smsnumbers;
global.general.atpb_tier[uid] = [];
global.general.atpb_decision[uid] = [];
var atp_status = "";
if(atpb != false){
var tier_type = [];
$.each(global.general.atp_dropdown.tier_type,function(index, el) {
tier_type[el.id] = el.name;
});
$.each(atpb.atpb_tiering_info_section,function(index, el) {
atpb.atpb_tiering_info_section[index].tier_name = tier_type[el.tier] != null ? tier_type[el.tier]:'';
});
// console.log(atpb.atpb_collateral_list_section);
atpb_calculator_modal_var.atpb_collateral_list_section = atpb.atpb_collateral_list_section;
// atpb_calculator_modal_var.atpb_account_list_section = atpb.atpb_account_list_section;
atpb_calculator_modal_var.atpb_tiering_info_section = atpb.atpb_tiering_info_section;
atpb_calculator_modal_var.has_atpb_tiering_info_section = true;
// atpb_calculator_modal_var.has_existing_atpb_collateral_list_section = true;
atpb_calculator_modal_var.has_existing_atpb_collateral_list_section = atpb.atpb_history.atp_status == "0" || atpb.atpb_history.atp_status == "4"?false:true;
global.general.atpb_tier[uid] = atpb.atpb_tiering_info_section;
// atpb_calculator_modal_var.atpb_existing_account_section = atpb.atpb_existing_account_section;
atpb_calculator_modal_var.atpb_approval_decision = atpb.atpb_approval_decision;
global.general.atpb_decision[uid] = atpb.atpb_approval_decision;
// atpb_calculator_modal_var.atpb_financing_commitment_section = atpb.atpb_financing_commitment_section;
// global.general.atpb_financing_commitment[uid] = atpb.atpb_financing_commitment_section;
}
$('#'+uid+' .atpb_calculator_modal').html(atpb_calculator_modal(atpb_calculator_modal_var));
$('#'+uid+" .atpb_template_existing_account_outstanding_balance_details_as_at").val(moment().format(momentDateFormat));
$('#'+uid+" .atpb_template_review_decision_by").selectpicker('destroy');
$('#'+uid+' .atpb_template_review_decision_by').selectpicker({
hideDisabled: true,
liveSearch: true
});
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('mask',formatDecimal(principal_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('mask',formatDecimal(interest_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').maskMoney('mask',formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.other_cost) + formatDecimal(global.debtordata[debtor_id].debtor.miscellaneous_charges)));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').maskMoney('mask',formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.late_charges) + formatDecimal(global.debtordata[debtor_id].debtor.memo_late_charge)));
if(atpb != false){
if(atpb.atpb_history != null){
// atpb_calculator_modal_var.approval_authority = atpb.atpb_history.approval_authority;
// atpb_calculator_modal_var.type_of_reschedule = atpb.atpb_history.type_of_request;
$('#'+uid+' .atpb_template_general_application_date').val(moment(atpb.atpb_history.created_at,momentSqlDateTimeFormat).format(momentDateFormat));
$('#'+uid+' .atpb_template_general_application').val(atpb.atpb_history.application_note);
$('#'+uid+' .atpb_template_general_information_customer_business_group').val(atpb.atpb_history.customer_business_group);
$('#'+uid+' .atpb_template_general_information_business_or_occupation').val(atpb.atpb_history.business_or_occupation);
$('#'+uid+' .atpb_template_general_information_key_person').val(atpb.atpb_history.key_person);
$('#'+uid+' .atpb_template_general_information_business_operating_since').val(atpb.atpb_history.business_operating_since != null ?moment(atpb.atpb_history.business_operating_since,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_general_information_relationship_with_bsi_since').val(atpb.atpb_history.relationship_with_bsi_since != null ?moment(atpb.atpb_history.relationship_with_bsi_since,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_general_information_company_structure').val(atpb.atpb_history.company_structure);
$('#'+uid+' .atpb_template_general_information_customer_application').val(atpb.atpb_history.customer_application);
$('#'+uid+' .atpb_template_general_information_financing_position_in_other_banks').val(atpb.atpb_history.financing_position_in_other_banks);
$('#'+uid+' .atpb_template_customer_account_account_status').val(atpb.atpb_history.account_status);
$('#'+uid+' .atpb_template_customer_account_loan_kol').val(atpb.atpb_history.loan_kol);
$('#'+uid+' .atpb_template_customer_account_cif_kol').val(atpb.atpb_history.cif_kol);
$('#'+uid+' .atpb_template_customer_account_days_past_due').val(atpb.atpb_history.days_past_due);
$('#'+uid+' .atpb_template_customer_account_liquidity_date').val(atpb.atpb_history.liquidity_date != null ?moment(atpb.atpb_history.liquidity_date,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_customer_account_due_date').val(atpb.atpb_history.due_date != null ?moment(atpb.atpb_history.due_date,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_customer_account_min_repayment').val(atpb.atpb_history.min_repayment);
$('#'+uid+' .atpb_template_customer_account_credit_limit').val(atpb.atpb_history.credit_limit);
$('#'+uid+' .atpb_template_existing_section_account_status').val(atpb.atpb_history.account_status);
$('#'+uid+' .atpb_template_existing_section_placement').val(atpb.atpb_history.placement);
$('#'+uid+' .atpb_template_existing_section_cif_kol').val(atpb.atpb_history.cif_kol);
$('#'+uid+' .atpb_template_existing_section_days_past_due').val(atpb.atpb_history.days_past_due);
$('#'+uid+' .atpb_template_existing_section_liquidity_date').val(atpb.atpb_history.liquidity_date != null ?moment(atpb.atpb_history.liquidity_date,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_existing_section_due_date').val(atpb.atpb_history.due_date != null ?moment(atpb.atpb_history.due_date,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_existing_section_margin_os').val(atpb.atpb_history.margin_os);
$('#'+uid+' .atpb_template_existing_section_gross_arrears').val(atpb.atpb_history.gross_arrears);
$('#'+uid+' .atpb_template_existing_section_principal_arrears').val(atpb.atpb_history.principal_arrears);
$('#'+uid+' .atpb_template_existing_section_margin_arrears').val(atpb.atpb_history.margin_arrears);
$('#'+uid+' .atpb_template_existing_section_penalty').val(atpb.atpb_history.penalty);
$('#'+uid+' .atpb_template_existing_section_rate').val(atpb.atpb_history.rate);
$('#'+uid+' .atpb_template_existing_section_min_repayment').val(atpb.atpb_history.min_repayment);
$('#'+uid+' .atpb_template_existing_section_credit_limit').val(atpb.atpb_history.credit_limit);
$('#'+uid+' .atpb_template_background_problems').val(atpb.atpb_history.background_problems);
$('#'+uid+' .atpb_template_financial_analysis').val(atpb.atpb_history.financial_analysis);
$('#'+uid+' .atpb_template_legal_type_of_legality').val(atpb.atpb_history.type_of_legality);
$('#'+uid+' .atpb_template_legal_document_no_and_date').val(atpb.atpb_history.document_no_and_date);
$('#'+uid+' .atpb_template_legal_legal_explanation').val(atpb.atpb_history.legal_explanation);
$('#'+uid+' .atpb_template_existing_section_user_input_total').val(atpb.atpb_history.user_input_total);
//section g
// $('#'+uid+' .atpb_template_collateral_section_collateral_description').val(atpb.atpb_history.collateral_description);
// $('#'+uid+' .atpb_template_collateral_section_collateral_id').val(atpb.atpb_history.collateral_id);
// $('#'+uid+' .atpb_template_collateral_section_lot_location').val(atpb.atpb_history.lot_location);
// $('#'+uid+' .atpb_template_collateral_section_collateral_type').val(atpb.atpb_history.collateral_type);
// $('#'+uid+' .atpb_template_collateral_section_valuation_date').val(moment(atpb.atpb_history.valuation_date,momentSqlDateFormat).format(momentDateFormat));
// $('#'+uid+' .atpb_template_collateral_section_expiry_date').val(moment(atpb.atpb_history.expiry_date,momentSqlDateFormat).format(momentDateFormat));
// $('#'+uid+' .atpb_template_collateral_section_security_document_value').val(atpb.atpb_history.security_document_value);
// $('#'+uid+' .atpb_template_collateral_section_market_value').val(atpb.atpb_history.market_value);
// $('#'+uid+' .atpb_template_collateral_section_valuation_value').val(atpb.atpb_history.valuation_value);
// $('#'+uid+' .atpb_template_collateral_section_total_security_document_value').val(atpb.atpb_history.total_security_document_value);
// $('#'+uid+' .atpb_template_collateral_section_total_market_value').val(atpb.atpb_history.total_market_value);
// $('#'+uid+' .atpb_template_collateral_section_total_liquidity_value').val(atpb.atpb_history.total_liquidity_value);
// $('#'+uid+' .atpb_template_collateral_section_security_document_type').val(atpb.atpb_history.security_document_type);
// $('#'+uid+' .atpb_template_collateral_section_insurance_premium').val(atpb.atpb_history.insurance_premium);
// $('#'+uid+' .atpb_template_collateral_section_loan_amount').val(atpb.atpb_history.loan_amount);
// $('#'+uid+' .atpb_template_collateral_section_total_collateral_binding_value').val(atpb.atpb_history.total_collateral_binding_value);
// $('#'+uid+' .atpb_template_collateral_section_total_collateral_liquidity_value').val(atpb.atpb_history.collateral_liquidity_value);
$('#'+uid+' .atpb_template_collateral_section_collateral_explanation').val(atpb.atpb_history.collateral_explanation);
//section h
$('#'+uid+' .atpb_template_analysis_study').val(atpb.atpb_history.analysis_study);
//section i
$('#'+uid+' .atpb_template_existing_settlement_data_date').val(atpb.atpb_history.data_date != null ?moment(atpb.atpb_history.data_date,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_existing_settlement_margin_os').val(atpb.atpb_history.margin_os);
$('#'+uid+' .atpb_template_existing_settlement_gross_arrears').val(atpb.atpb_history.gross_arrears);
$('#'+uid+' .atpb_template_existing_settlement_principal_arrears').val(atpb.atpb_history.principal_arrears);
$('#'+uid+' .atpb_template_existing_settlement_existing_restructuring_fee').val(atpb.atpb_history.existing_restructuring_fee);
$('#'+uid+' .atpb_template_existing_settlement_penalty').val(atpb.atpb_history.penalty);
$('#'+uid+' .atpb_template_existing_settlement_rate').val(atpb.atpb_history.rate);
$('#'+uid+' .atpb_template_existing_settlement_remaining_tenure').val(atpb.atpb_history.remaining_tenure);
$('#'+uid+' .atpb_template_existing_settlement_total_installment').val(atpb.atpb_history.total_installment);
$('#'+uid+' .atpb_template_existing_settlement_due_date').val(atpb.atpb_history.due_date != null ?moment(atpb.atpb_history.due_date,momentSqlDateFormat).format(momentDateFormat):'');
//section j
$('#'+uid+' .atpb_template_proposal_settlement_restructure_frequency').val(atpb.atpb_history.restructure_frequency);
$('#'+uid+' .atpb_template_proposal_settlement_request_type').val(atpb.atpb_history.request_type);
$('#'+uid+' .atpb_template_proposal_settlement_repayment_capacity').val(atpb.atpb_history.repayment_capacity);
$('#'+uid+' .atpb_template_proposal_settlement_payment_source').val(atpb.atpb_history.payment_source);
$('#'+uid+' .atpb_template_proposal_settlement_restructure_to').val(atpb.atpb_history.restructure_to);
$('#'+uid+' .atpb_template_proposal_settlement_new_financing_type').val(atpb.atpb_history.new_financing_type);
$('#'+uid+' .atpb_template_proposal_settlement_principle_outstanding_proposal').val(atpb.atpb_history.principle_outstanding_proposal);
$('#'+uid+' .atpb_template_proposal_settlement_margin_outstanding_proposal').val(atpb.atpb_history.margin_outstanding_proposal);
$('#'+uid+' .atpb_template_proposal_settlement_err_percentage').val(atpb.atpb_history.err_percentage);
$('#'+uid+' .atpb_template_proposal_settlement_bank_profit_sharing_ratio').val(atpb.atpb_history.bank_profit_sharing_ratio);
$('#'+uid+' .atpb_template_proposal_settlement_customer_profit_sharing_ratio').val(atpb.atpb_history.customer_profit_sharing_ratio);
$('#'+uid+' .atpb_template_proposal_settlement_proposal_restructuring_fee').val(atpb.atpb_history.proposal_restructuring_fee);
$('#'+uid+' .atpb_template_proposal_settlement_administrative_fee').val(atpb.atpb_history.administrative_fee);
$('#'+uid+' .atpb_template_proposal_settlement_restructuring_period').val(atpb.atpb_history.restructuring_period);
$('#'+uid+' .atpb_template_proposal_settlement_new_due_date').val(atpb.atpb_history.new_due_date != null ?moment(atpb.atpb_history.new_due_date,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_proposal_settlement_payment_method').val(atpb.atpb_history.payment_method);
$('#'+uid+' .atpb_template_proposal_settlement_payment_effective_date').val(atpb.atpb_history.payment_effective_date != null ?moment(atpb.atpb_history.payment_effective_date,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_template_proposal_settlement_installment_scheme').val(atpb.atpb_history.installment_scheme);
$('#'+uid+' .atpb_template_proposal_settlement_post_restructuring_strategic_steps').val(atpb.atpb_history.post_restructuring_strategic_steps);
$('#'+uid+' .atpb_template_proposal_settlement_requirements_signing_financing_agreement').val(atpb.atpb_history.requirements_signing_financing_agreement);
$('#'+uid+' .atpb_template_proposal_settlement_effective_conditions').val(atpb.atpb_history.effective_conditions);
$('#'+uid+' .atpb_template_proposal_settlement_other_conditions').val(atpb.atpb_history.other_conditions);
$('#'+uid+' .atpb_template_payment_term_total_tenure').val(atpb.atpb_history.total_tenure);
$('#'+uid+' .atpb_template_payment_term_total_installment').val(atpb.atpb_history.total_installment);
//section k
$('#'+uid+' .atpb_template_recommendation_card_blocking_proposal').val(atpb.atpb_history.card_blocking_proposal);
$('#'+uid+' .atpb_template_recommendation_initial_bucket').val(atpb.atpb_history.initial_bucket);
$('#'+uid+' .atpb_template_recommendation_reaging').val(atpb.atpb_history.reaging);
//section M
$('#'+uid+' .atpb_template_basis_recommendation_comments').val(atpb.atpb_history.basis_recommendation_comments);
// $('#'+uid+' select.atpb_template_review_decision_by').val(atpb.atpb_history.reviewed_by_id);
$('#'+uid+' select.atpb_template_review_decision_by').val(atpb.atpb_history.reviewed_by_id);
$('#'+uid+' .atpb_template_review_decision').val(atpb.atpb_history.reviewed_by_decision);
$('#'+uid+' .atpb_template_review_decision_date').val(atpb.atpb_history.reviewed_by_decision_date);
$('#'+uid+' .atpb_template_review_remarks').val(atpb.atpb_history.reviewed_by_remark);
$('#'+uid+' .atpb_template_financing_committee_status').val(atpb.atpb_history.financing_committee_status);
$('#'+uid+' .atpb_template_authority_decision_committee').val(atpb.atpb_history.authority_decision_committee);
$('#'+uid+' .atpb_template_authority_to_decide').val(atpb.atpb_history.authority_to_decide);
$('#'+uid+' .atpb_template_composition_waiver_principal_loan_total_os').val(atpb.atpb_history.principle_os_total_os);
$('#'+uid+' .atpb_template_composition_waiver_principal_loan_proposed_sum').val(atpb.atpb_history.principle_os_proposed_sum);
$('#'+uid+' .atpb_template_composition_waiver_principal_loan_discount_value').val(atpb.atpb_history.principle_os_discount);
$('#'+uid+' .atpb_template_composition_waiver_principal_loan_discount_rate').val(atpb.atpb_history.principle_os_percentage);
$('#'+uid+' .atpb_template_composition_waiver_subrogation_total_os').val(atpb.atpb_history.subrogation_total_os);
$('#'+uid+' .atpb_template_composition_waiver_subrogation_proposed_sum').val(atpb.atpb_history.subrogation_proposed_sum);
$('#'+uid+' .atpb_template_composition_waiver_subrogation_discount_value').val(atpb.atpb_history.subrogation_discount);
$('#'+uid+' .atpb_template_composition_waiver_subrogation_discount_rate').val(atpb.atpb_history.subrogation_percentage);
$('#'+uid+' .atpb_template_composition_waiver_margin_os_total_os').val(atpb.atpb_history.margin_os_total_os);
$('#'+uid+' .atpb_template_composition_waiver_margin_os_proposed_sum').val(atpb.atpb_history.margin_os_proposed_sum);
$('#'+uid+' .atpb_template_composition_waiver_margin_os_discount_value').val(atpb.atpb_history.margin_os_discount);
$('#'+uid+' .atpb_template_composition_waiver_margin_os_discount_rate').val(atpb.atpb_history.margin_os_percentage);
$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_total_os').val(atpb.atpb_history.arrears_profit_sharing_total_os);
$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_proposed_sum').val(atpb.atpb_history.arrears_profit_sharing_proposed_sum);
$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_discount_value').val(atpb.atpb_history.arrears_profit_sharing_discount);
$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_discount_rate').val(atpb.atpb_history.arrears_profit_sharing_percentage);
$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_total_os').val(atpb.atpb_history.penalty_arrears_total_os);
$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_proposed_sum').val(atpb.atpb_history.penalty_arrears_proposed_sum);
$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_discount_value').val(atpb.atpb_history.penalty_arrears_discount);
$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_discount_rate').val(atpb.atpb_history.penalty_arrears_percentage);
$('#'+uid+' .atpb_template_composition_waiver_other_charges_total_os').val(atpb.atpb_history.other_charges_total_os);
$('#'+uid+' .atpb_template_composition_waiver_other_charges_proposed_sum').val(atpb.atpb_history.other_charges_proposed_sum);
$('#'+uid+' .atpb_template_composition_waiver_other_charges_discount_value').val(atpb.atpb_history.other_charges_discount);
$('#'+uid+' .atpb_template_composition_waiver_other_charges_discount_rate').val(atpb.atpb_history.other_charges_percentage);
$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_total_os').val(atpb.atpb_history.unbill_legal_fee_total_os);
$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_proposed_sum').val(atpb.atpb_history.unbill_legal_fee_proposed_sum);
$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_discount_value').val(atpb.atpb_history.unbill_legal_fee_discount);
$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_discount_rate').val(atpb.atpb_history.unbill_legal_fee_percentage);
$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_total_os').val(atpb.atpb_history.total_projected_os_total_os);
$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_proposed_sum').val(atpb.atpb_history.total_projected_os_proposed_sum);
$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_discount_value').val(atpb.atpb_history.total_projected_os_discount);
$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_discount_rate').val(atpb.atpb_history.total_projected_os_percentage);
$('#'+uid+' .atpb_letter_offer_reference_no').val(atpb.atpb_history.reference_no);
$('#'+uid+' .atpb_letter_offer_letter_date').val(atpb.atpb_history.letter_date);
$('#'+uid+' .atpb_letter_offer_settlement_account_no').val(atpb.atpb_history.settlement_account_no);
$('#'+uid+' .atpb_letter_offer_settlement_account_holder_name').val(atpb.atpb_history.settlement_account_holder_name);
$('#'+uid+' .atpb_letter_offer_collateral_retrieval_desc').val(atpb.atpb_history.collateral_retrieval_desc);
// $('#'+uid+' .atpb_letter_offer_letter_date').val(atpb.atpb_history.letter_date != null ?moment(atpb.atpb_history.letter_date,momentSqlDateFormat).format(momentDateFormat):'');
$('#'+uid+' .atpb_letter_offer_letter_date').val(moment().format(momentDateFormat));
// atpb_status: mode == "draft" ? '4' : '0' ,
$('#'+uid+" select.atpb_template_review_decision_by").selectpicker('destroy');
$('#'+uid+' .atpb_template_review_decision_by').selectpicker({
hideDisabled: false,
liveSearch: true
});
$('#'+uid+' .atpb_template_save_draft').attr('volare-atp_history_id',atpb.atpb_history.id);
$('#'+uid+' .atpb_template_submit').attr('volare-atp_history_id',atpb.atpb_history.id);
atp_status = atpb.atpb_history.atp_status;
// console.log(atp_status);
// 0 = Pending 1 = Approved 2 = Rejected 3 = Void 4 = Draft
switch(atpb.atpb_history.atp_status){
case '0':
case '1':
case '2':
case '3':
$('#'+uid+' .atpb_template_save_draft').prop('disabled',true);
$('#'+uid+' .atpb_template_submit').prop('disabled',true);
$('#'+uid+' .atpb_calculator_modal input').prop('disabled',true);
$('#'+uid+' .atpb_calculator_modal textarea').prop('disabled',true);
$('#'+uid+' .atpb_calculator_modal select').prop('disabled',true);
// $('#'+uid+' .atpb_calculator_modal .atpb_rebate_calculator_calculate_rebate').prop('disabled',true);
$('#'+uid+' .atpb_calculator_modal .atpb_template_payment_term_tier_row_delete').prop('disabled',true);
$('#'+uid+' .atpb_calculator_modal .atpb_template_decision_by_delete').prop('disabled',true);
break;
default:break;
}
}
}
$('#'+uid+' .volare_date').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
// $('#'+uid+' .atp_rebate_calculator_agreement_date').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
// $('#'+uid+' .atp_rebate_calculator_settlement_date').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_first_payment_date').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_date').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
// $('#'+uid+' .atp_unsecured_atp_template_existing_acount_position_as_at').datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
$('#'+uid+' input[data-toggle="toggle"]').bootstrapToggle({on: 'Yes',off: 'No'});
// $('#'+uid+' .atp_secured_atp_template_date').val(moment().format(momentDateFormat));
// $('#'+uid+' .atp_unsecured_atp_template_date').val(moment().format(momentDateFormat));
$('#'+uid+' .volare_currency').maskMoney({thousands:currencyThousands, decimal:currencyDecimal,allowNegative:true});
$('#'+uid+' .volare_currency').each(function(index, el) {
// console.log($(el).val());
$(el).val(formatDecimal($(el).val()));
$(el).maskMoney('mask');
});
// $('#'+uid+' .volare_currency').maskMoney('mask');
// // if(enable_atp_letter_offer){
// // $('#'+uid+' .atp_letter_offer_related').removeClass('hideMe');
// // }
// if(enable_atp_letter_offer){
$('#'+uid+' .atpb_letter_offer_general_related').removeClass('hideMe');
// }
if(atp_status == "" || atp_status == "4"){
realtimeValidateATPBTier(uid);
// realtimeValidateATPRebateCalculator(uid);
realtimeValidateATPBDecisionMaker(uid);
realtimeValidateATPBOverall(uid);
realtimeCalculateATPB(uid);
// realtimeCalculateUnsecured(uid);
}else if(atp_status == "0"){
$('#'+uid+' .atpb_template_review_decision').removeClass('hideMe');
var decision_section_changeable = false;
if(atpb.atpb_history.reviewed_by_decision == "0"){
if(global.general.collector_user_id == atpb.atpb_history.reviewed_by_id){
$('#'+uid+' .atpb_template_review_decision').prop('disabled',false);
$('#'+uid+' select.atpb_template_review_decision_by').prop('disabled',false);
$('#'+uid+' .atpb_template_review_remarks').prop('disabled',false);
$('#'+uid+' .atpb_template_review_decision').attr('original_id',atpb.atpb_history.reviewed_by_decision);
$('#'+uid+' select.atpb_template_review_decision_by').attr('original_id',atpb.atpb_history.reviewed_by_id);
// $('#'+uid+' .atp_unsecured_atp_template_submit').attr('mode','review_by');
decision_section_changeable = true;
}else if(global.general.collector_user_id == atpb.atpb_history.created_by_id){
$('#'+uid+' select.atpb_template_review_decision_by').prop('disabled',false);
decision_section_changeable = true;
}
if(decision_section_changeable){
$('#'+uid+' .atpb_template_decision_activity').prop('disabled',false);
$('#'+uid+' select.atpb_template_decision_decision_by').prop('disabled',false);
$('#'+uid+' .atpb_calculator_modal .atpb_template_decision_by_delete').prop('disabled',false);
realtimeValidateATPBDecisionMaker(uid);
realtimeValidateATPBOverall(uid);
}
}else{
$('#'+uid+' .atpb_calculator_modal .atpb_template_decision_by_add').prop('disabled',true);
var pending_decision_index = '';
$.each(atpb.atpb_approval_decision,function(index, el) {
if(el.decision == "0"){
pending_decision_index = index;
return false;
}
});
if(pending_decision_index !== ''){
if(global.general.collector_user_id == atpb.atpb_approval_decision[pending_decision_index].decision_by_id){
$('#'+uid+' select.atpb_template_decision_decision_by_'+pending_decision_index+'').prop('disabled',false);
$('#'+uid+' .atpb_template_decision_decision_'+pending_decision_index+'').prop('disabled',false);
$('#'+uid+' .atpb_template_decision_remark_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_decision').attr('original_id',atp.atp_approval_decision[pending_decision_index].decision);
$('#'+uid+' .atpb_template_decision_decision_'+pending_decision_index).attr('original_id',atpb.atpb_approval_decision[pending_decision_index].decision);
// $('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_by').attr('original_id',atp.atp_approval_decision[pending_decision_index].decision_by_id);
$('#'+uid+' select.atpb_template_decision_decision_by_'+pending_decision_index).attr('original_id',atpb.atpb_approval_decision[pending_decision_index].decision_by_id);
// $('#'+uid+' .atp_unsecured_atp_template_submit').attr('mode','decision_by');
$('#'+uid+' .atpb_template_submit').prop('disabled',false);
}else if(global.general.collector_user_id == atpb.atpb_history.reviewed_by_id){
$('#'+uid+' select.atpb_template_decision_decision_by_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_decision_decision_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_decision_remark_'+pending_decision_index+'').prop('disabled',false);
$('#'+uid+' .atpb_template_submit').attr('mode','review_change_decision_by_bulk');
$('#'+uid+' .atpb_template_submit').prop('disabled',false);
}
}
}
}else{
$('#'+uid+' .atpb_template_review_decision').removeClass('hideMe');
$('#'+uid+' .atpb_template_review_decision').prop('disabled',true);
if((atp_status == "1" || atp_status == "5")){
$('#'+uid+' .atpb_calculator_modal .atpb_template_decision_by_add').prop('disabled',true);
$('#'+uid+' .atpb_letter_offer_related').removeClass('hideMe');
$('#'+uid+' .atpb_template_decision_by_row_decision_esignatory').prop('disabled',false);
if(global.access.is_atp_preview_letter_offer_enabled == "1")
$('#'+uid+' .atpb_template_offer_letter_generation_template_preview').removeClass('hideMe');
var atp_offer_letter_template = [];
// Surat Persetujuan Diskon Non HC = non_hc_ld_approval_letter
// Surat Pelunasan Diskon Non HC = non_hc_ld_settlement_letter
// Surat Keputusan Diskon Hasanah Card = hasanah_card_hc_decision_letter
// Surat Keputusan Diskon Hasanah Card Skema Cicilan = hasanah_card_hc_installment_scheme_letter
// SPRP Murabahah = sprp_ld_murabahah_mapping_letter
// SPRP Mudharabah = sprp_ld_mudharabah_mapping_letter
// SPRP Hasanah Card = sprp_hc_hasanah_card_mapping_letter
if(debtor.client_name == 'BSI_LD'){
switch(global.general.atp_dropdown.request_type[atpb.atpb_history.request_type].name){
case "Pelunasan Diskon Margin":
case "Pelunasan Bertahap":
atp_offer_letter_template.push("non_hc_ld_approval_letter");
atp_offer_letter_template.push("non_hc_ld_settlement_letter");
break;
case "Restru Reguler":
atp_offer_letter_template.push("sprp_ld_murabahah_mapping_letter");
atp_offer_letter_template.push("sprp_ld_mudharabah_mapping_letter");
break;
break;
case "Restru Program":
break;
default:break;
}
}else if(debtor.client_name == 'BSI_HC'){
switch(global.general.atp_dropdown.request_type[atpb.atpb_history.request_type].name){
case "Pelunasan Diskon Margin":
case "Pelunasan Bertahap":
atp_offer_letter_template.push("hasanah_card_hc_decision_letter");
atp_offer_letter_template.push("hasanah_card_hc_installment_scheme_letter");
break;
case "Restru Reguler":
atp_offer_letter_template.push("sprp_hc_hasanah_card_mapping_letter");
break;
break;
case "Restru Program":
break;
default:break;
}
}
var final_letter_generation_template = "";
for (var iii = 0; iii < atp_offer_letter_template.length; iii++) {
final_letter_generation_template += ''+lang['lang_'+atp_offer_letter_template[iii]]+' \n';
}
// console.log(debtor.is_credit_card,debtor.is_islamic,debtor.client_screen);
$('#'+uid+' .atpb_template_offer_letter_generation_template').append(final_letter_generation_template);
$('#'+uid+' .atpb_template_offer_letter_generation_template_preview').attr('volare-atp_history_id',atpb.atpb_history.id);
$('#'+uid+' .atpb_template_offer_letter_generation_template_generate').attr('volare-atp_history_id',atpb.atpb_history.id);
$('#'+uid+' .atpb_template_offer_letter_generation_template_cancel').attr('volare-atp_history_id',atpb.atpb_history.id);
// $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_option').attr('value',atp_offer_letter_template);
$('#'+uid+' .atpb_template_offer_letter_generation_template').prop('disabled',false);
$('#'+uid+' .atpb_template_offer_letter_generation_template').selectpicker();
$('#'+uid+' .atpb_letter_offer_reference_no').prop('disabled',false);
$('#'+uid+' .atpb_letter_offer_letter_date').prop('disabled',false);
$('#'+uid+' .atpb_letter_offer_settlement_account_no').prop('disabled',false);
$('#'+uid+' .atpb_letter_offer_settlement_account_holder_name').prop('disabled',false);
$('#'+uid+' .atpb_letter_offer_collateral_retrieval_desc').prop('disabled',false);
}
}
$('#'+uid+' .atpb_template_review_decision_by').selectpicker({
liveSearch: "true"
});
$('#'+uid+' .atpb_template_decision_decision_by').selectpicker({
liveSearch: "true"
});
$('#'+uid+' .atpb_template_decision_by_row_decision_by').selectpicker({
liveSearch: "true"
});
// if(enable_atp_letter_offer){
populateATPBOfferLetterHistory(uid,atpb.atpb_letter_offer_history);
// }
if(Number(global.access.ATP_calculator) >= 2){
$('#'+uid+' .atpb_template_footer').removeClass('hideMe');
}else{
$('#'+uid+' .atpb_template_footer').addClass('hideMe');
}
$('#'+uid+' .atpb_calculator_modal').modal('show');
}
function populateATPTemplateModal(uid,debtor_id,atp = false){
// var atp_calculator_modal_cc = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'atp_calculator_modal_cc').html());
var atp_calculator_modal_cc = Handlebars.compile($('#template-cc_atp_calculator_modal_cc').html());
var atp_calculator_modal_cc_var = {};
var debtor = global.debtordata[debtor_id].debtor;
global.general.atp_debtor_id[uid] = debtor_id;
atp_calculator_modal_cc_var.collector_name = global.general.collector_name;
atp_calculator_modal_cc_var.collector_user_id = global.general.collector_user_id;
atp_calculator_modal_cc_var.debtor = global.debtordata[debtor_id].debtor;
atp_calculator_modal_cc_var.atp_dropdown = global.general.atp_dropdown;
atp_calculator_modal_cc_var.atp_activity = global.general.atp_activity;
atp_calculator_modal_cc_var.collector_list = global.general.collector_list;
atp_calculator_modal_cc_var.collector_full_list = global.general.collector_full_list;
atp_calculator_modal_cc_var.uid = uid;
atp_calculator_modal_cc_var.smsnumbers = global.debtordata[debtor_id].smsnumbers;
global.general.atp_tier[uid] = [];
global.general.atp_decision[uid] = [];
var atp_status = "";
if(atp != false){
var tier_type = [];
$.each(global.general.atp_dropdown.tier_type,function(index, el) {
tier_type[el.id] = el.name;
});
$.each(atp.atp_tiering_info_section,function(index, el) {
atp.atp_tiering_info_section[index].tier_name = tier_type[el.tier] != null ? tier_type[el.tier]:'';
});
atp_calculator_modal_cc_var.atp_account_list_section = atp.atp_account_list_section;
atp_calculator_modal_cc_var.atp_tiering_info_section = atp.atp_tiering_info_section;
atp_calculator_modal_cc_var.atp_relationship_section = atp.atp_relationship_section;
atp_calculator_modal_cc_var.atp_properties_section = atp.atp_properties_section;
if(enable_irl_inquiry_atp){
atp_calculator_modal_cc_var.atp_irl_inquiry = atp.atp_irl_inquiry;
}
// atp_calculator_modal_cc_var.model = '';
// atp_calculator_modal_cc_var.vehicle_market_value = '';
// $.each(atp.atp_properties_section,function(index, el) {
// if(el.model != ''){
// atp_calculator_modal_cc_var.properties_vehicle_model = el.model;
// atp_calculator_modal_cc_var.properties_vehicle_market_value = el.vehicle_market_value;
// return false;
// }
// });
global.general.atp_tier[uid] = atp.atp_tiering_info_section;
atp_calculator_modal_cc_var.atp_existing_account_section = atp.atp_existing_account_section;
atp_calculator_modal_cc_var.atp_approval_decision = atp.atp_approval_decision;
global.general.atp_decision[uid] = atp.atp_approval_decision;
}
$('#'+uid+' .atp_calculator_modal_cc').html(atp_calculator_modal_cc(atp_calculator_modal_cc_var));
// $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by .inactive_user").addClass('hideMe');
// $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by .deleted_user").addClass('hideMe');
$('#'+uid+" .atp_unsecured_atp_template_review_decision_by").selectpicker('destroy');
$('#'+uid+' .atp_unsecured_atp_template_review_decision_by').selectpicker({
hideDisabled: true,
liveSearch: true
});
// var initial_atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor = '';
// if(debtor.client_screen == 'PL'){
// initial_atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor = debtor.client_outstanding_balance - debtor.write_off_iis;
// }else if(debtor.client_screen == 'CC'){
// if(debtor.has_charge_off != '5'){
// }else if(debtor.has_charge_off == '5'){
// initial_atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor = debtor.charge_off_amount;
// }
// // IF debtor.is_credit_card='1' AND debtor.has_charge_off!=5 then refer to
// // Sum of Unsecured Section C [Total Outstanding Balance / Debt (v)] minus [Late Payment Charges (i)] minus [Finance / Profit Charges (ii)] minus [Others / Misc Charges (iii)] minus [Unbill Legal /COC / FPP / EPP (iv)]
// // IF debtor.is_credit_card='1' AND debtor.has_charge_off=5 then refer to
// // Sum of Unsecured Section D [h) Net Charge Off Amount]
// }
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor').val(formatDecimal(initial_atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sumdebtor));
if(global.debtordata[debtor_id].debtor.client_screen == 'CC'){
// $('#'+uid+' .atp_unsecured_atp_template_existing_acount_unbill_legal').maskMoney('mask',formatDecimal(global.debtordata[debtor_id].debtor.all_card_unbilled_installment_amount_exclude_standalone_limit));
// console.log(debtor);
// atp_unsecured_atp_template_account_info_account_opened
var earliest_card_issued_date = '';
var latest_last_payment_date = '';
var earliest_charge_off_date = '';
var total_charge_off_amount = 0;
var total_payment_after_charge_off = 0;
for (var i = 0; i < debtor.debtor_othercards.length; i++) {
if(debtor.debtor_othercards[i].client_screen == 'CC'){
if(
(moment(debtor.debtor_othercards[i].card_issued_date,momentSqlDateFormat).format(momentSqlDateFormat) != 'Invalid date') &&
( earliest_card_issued_date == '' || moment(debtor.debtor_othercards[i].card_issued_date,momentSqlDateFormat).isBefore(earliest_card_issued_date) )
){
earliest_card_issued_date = debtor.debtor_othercards[i].card_issued_date;
}
if(
(moment(debtor.debtor_othercards[i].charge_off_date,momentSqlDateTimeFormat).format(momentSqlDateFormat) != 'Invalid date') &&
( earliest_charge_off_date == '' || moment(debtor.debtor_othercards[i].charge_off_date,momentSqlDateFormat).isBefore(earliest_charge_off_date) )
){
earliest_charge_off_date = debtor.debtor_othercards[i].charge_off_date;
}
if(
(moment(debtor.debtor_othercards[i].last_payment_date,momentSqlDateTimeFormat).format(momentSqlDateFormat) != 'Invalid date') &&
( latest_last_payment_date == '' || moment(debtor.debtor_othercards[i].last_payment_date,momentSqlDateFormat).isAfter(latest_last_payment_date) )
){
latest_last_payment_date = debtor.debtor_othercards[i].last_payment_date;
}
if($.isNumeric(debtor.debtor_othercards[i].charge_off_amount)){
total_charge_off_amount += Number(debtor.debtor_othercards[i].charge_off_amount);
}
if($.isNumeric(debtor.debtor_othercards[i].payment_after_charge_off)){
total_payment_after_charge_off += Number(debtor.debtor_othercards[i].payment_after_charge_off);
}
}
}
if(earliest_card_issued_date != '' && earliest_card_issued_date != null)
earliest_card_issued_date= moment(earliest_card_issued_date,momentSqlDateFormat).format(momentDateFormat);
$('#'+uid+' .atp_unsecured_atp_template_account_info_account_opened').val(earliest_card_issued_date);
if(latest_last_payment_date != '' && latest_last_payment_date != null)
latest_last_payment_date= moment(latest_last_payment_date,momentSqlDateFormat).format(momentDateFormat);
$('#'+uid+' .atp_unsecured_atp_template_account_info_last_payment_date').val(latest_last_payment_date);
if(earliest_charge_off_date != '' && earliest_charge_off_date != null)
earliest_charge_off_date= moment(earliest_charge_off_date,momentSqlDateFormat).format(momentDateFormat);
// $('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_date').val(earliest_charge_off_date);
$('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_amount').maskMoney('mask',formatDecimal(total_charge_off_amount));
$('#'+uid+' .atp_unsecured_atp_template_account_info_total_payment_after_charge_off').maskMoney('mask',formatDecimal(total_payment_after_charge_off));
}
if(global.debtordata[debtor_id].debtor.client_screen == 'CC' || global.debtordata[debtor_id].debtor.client_screen == 'PL' ){
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').prop('disabled',true);
}else{
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').prop('disabled',true);
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os').prop('disabled',false);
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').prop('disabled',true);
if(global.debtordata[debtor_id].debtor.client_screen == 'HP'){
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').prop('disabled',false);
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').prop('disabled',false);
}
}
var principal_total_os = 0;
switch(global.debtordata[debtor_id].debtor.client_screen){
case 'MG':
if(global.debtordata[debtor_id].debtor.is_islamic == '0'){
principal_total_os = global.debtordata[debtor_id].debtor.client_outstanding_balance;
}else{
principal_total_os = global.debtordata[debtor_id].debtor.os_cost;
}
break;
case 'OD':
principal_total_os = global.debtordata[debtor_id].debtor.balance;
break;
case 'HP':
if(global.debtordata[debtor_id].debtor.account_status_id == '8'){
if(global.debtordata[debtor_id].debtor.product_code == 'HLBB'){
principal_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.client_outstanding_balance) - formatDecimal(global.debtordata[debtor_id].debtor.write_off_iis));
}else if(global.debtordata[debtor_id].debtor.product_code == 'Ex-EBB'){
if(!(global.debtordata[debtor_id].debtor.ebb_write_off_os_iis != null))
global.debtordata[debtor_id].debtor.ebb_write_off_os_iis = 0;
principal_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.client_outstanding_balance) - formatDecimal(global.debtordata[debtor_id].debtor.ebb_write_off_os_iis));
}
}else{
principal_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.client_outstanding_balance) - formatDecimal(global.debtordata[debtor_id].debtor.installment_in_suspend));
}
break;
case 'PL':
principal_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.client_outstanding_balance) - formatDecimal(global.debtordata[debtor_id].debtor.write_off_iis));
break;
default:break;
}
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('mask',formatDecimal(principal_total_os));
var interest_total_os = 0;
switch(global.debtordata[debtor_id].debtor.client_screen){
case 'MG':
if(global.debtordata[debtor_id].debtor.is_islamic == '0'){
interest_total_os = formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.billed_interest) + formatDecimal(global.debtordata[debtor_id].debtor.new_interest));
}else{
interest_total_os = global.debtordata[debtor_id].debtor.interest_rebate;
}
break;
case 'OD':
interest_total_os = global.debtordata[debtor_id].debtor.new_interest;
break;
case 'HP':
if(global.debtordata[debtor_id].debtor.account_status_id == '8'){
if(global.debtordata[debtor_id].debtor.product_code == 'HLBB'){
interest_total_os = global.debtordata[debtor_id].debtor.write_off_iis;
}else if(global.debtordata[debtor_id].debtor.product_code == 'Ex-EBB'){
interest_total_os = global.debtordata[debtor_id].debtor.ebb_write_off_os_iis;
}
}else{
interest_total_os = global.debtordata[debtor_id].debtor.installment_in_suspend;
}
break;
default:break;
}
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('mask',formatDecimal(principal_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('mask',formatDecimal(interest_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').maskMoney('mask',formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.other_cost) + formatDecimal(global.debtordata[debtor_id].debtor.miscellaneous_charges)));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').maskMoney('mask',formatDecimal(formatDecimal(global.debtordata[debtor_id].debtor.late_charges) + formatDecimal(global.debtordata[debtor_id].debtor.memo_late_charge)));
if(atp != false){
if(atp.atp_history != null){
$('#'+uid+' .atp_rebate_calculator_loan_amount').val(atp.atp_history.loan_financing_amount);
$('#'+uid+' .atp_rebate_calculator_interest_rate').val(atp.atp_history.interest_profit_rate);
$('#'+uid+' .atp_rebate_calculator_loan_term').val(atp.atp_history.term);
$('#'+uid+' .atp_rebate_calculator_term_charges').val(atp.atp_history.term_charges);
$('#'+uid+' .atp_rebate_calculator_agreement_date').val(getLanguageDate(atp.atp_history.agreement_date));
$('#'+uid+' .atp_rebate_calculator_settlement_date').val(getLanguageDate(atp.atp_history.settlement_date));
$('#'+uid+' .atp_rebate_calculator_factor').val(atp.atp_history.factor);
$('#'+uid+' .atp_rebate_calculator_remaining_months').val(atp.atp_history.remaining_months);
$('#'+uid+' .atp_rebate_calculator_rebate').val(atp.atp_history.rebate);
$('#'+uid+' select.atp_unsecured_atp_template_entity').val(atp.atp_history.is_islamic);
// is_secured:0,
$('#'+uid+' .atp_unsecured_atp_template_date').val(getLanguageDate(atp.atp_history.created_at));
$('#'+uid+' .atp_unsecured_atp_template_collection_centre').val(atp.atp_history.collection_center);
$('#'+uid+' .atp_unsecured_atp_template_product').val(atp.atp_history.client_name);
$('#'+uid+' .atp_unsecured_atp_template_dca_name').attr('volare-user_id',atp.atp_history.user_id);
$('#'+uid+' .atp_unsecured_atp_template_dca_name').val(atp.atp_history.user_name);
$('#'+uid+' .atp_unsecured_atp_template_customer_id').val(maskNumber(atp.atp_history.new_ic));
$('#'+uid+' .atp_unsecured_atp_template_customer_id').attr('volare-new_ic',atp.atp_history.new_ic);
$('#'+uid+' .atp_unsecured_atp_template_customer_name').val(atp.atp_history.debtor_name);
$('#'+uid+' .atp_unsecured_atp_template_connected_party').prop("checked",atp.atp_history.is_connected_party == "1" ? 1 : 0);
$('#'+uid+' .atp_unsecured_atp_template_email').val(atp.atp_history.email_address);
$('#'+uid+' .atp_unsecured_atp_template_type_of_request').val(atp.atp_history.type_of_request);
$('#'+uid+' .atp_unsecured_atp_template_type_of_package_1').val(atp.atp_history.type_of_package);
$('#'+uid+' .atp_unsecured_atp_template_type_of_package_2').val(atp.atp_history.type_of_package_02);
$('#'+uid+' .atp_unsecured_atp_template_type_of_package_3').val(atp.atp_history.type_of_package_03);
$('#'+uid+' .atp_unsecured_atp_template_type_of_package_1').change();
$('#'+uid+' .atp_unsecured_atp_template_reason_for_settlement').val(atp.atp_history.reason_for_settlement);
$('#'+uid+' .atp_unsecured_atp_template_agreed_settlement_sum').maskMoney('mask',formatDecimal(atp.atp_history.agreed_settlement_sum));
$('#'+uid+' .atp_unsecured_atp_template_projected_waiver_amount').maskMoney('mask',formatDecimal(atp.atp_history.projected_waiver_amount));
// debtor_id:debtor_id,
$('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_currency_amount').val(atp.atp_history.epf_withdrawal_payment);
$('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_date').val(getLanguageDate(atp.atp_history.epf_withdrawal_calendar));
$('#'+uid+' .atp_unsecured_atp_template_payment_term_total_tenure').val(atp.atp_history.total_tenure);
$('#'+uid+' .atp_unsecured_atp_template_payment_term_total_instalment_payment_amount').val(atp.atp_history.total_installment);
$('#'+uid+' .atp_unsecured_atp_template_payment_term_email_when_instalment').prop("checked",atp.atp_history.installment_email == "1");
$('#'+uid+' .atp_unsecured_atp_template_payment_term_waive_accured_interest').prop("checked",atp.atp_history.bankrupt_status == "1");
$('#'+uid+' .atp_unsecured_atp_template_existing_acount_position_as_at').val(getLanguageDate(atp.atp_history.position_as_at));
//don't populate system total to prevent over count
$('#'+uid+' .atp_unsecured_atp_template_existing_acount_system_total').maskMoney('mask',formatDecimal(atp.atp_history.system_total));
$('#'+uid+' .atp_unsecured_atp_template_existing_acount_user_input_total').maskMoney('mask',formatDecimal(atp.atp_history.user_input_total));
$('#'+uid+' .atp_unsecured_atp_template_account_info_account_opened').val(getLanguageDate(atp.atp_history.account_open));
$('#'+uid+' .atp_unsecured_atp_template_account_info_credit_limit').val(atp.atp_history.credit_limit);
$('#'+uid+' .atp_unsecured_atp_template_account_info_last_payment_date').val(getLanguageDate(atp.atp_history.last_payment_date));
$('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_date').val(getLanguageDate(atp.atp_history.charge_off_date));
$('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_amount').val(atp.atp_history.charge_off_amount);
$('#'+uid+' .atp_unsecured_atp_template_account_info_transaction_debited_after_charge_off').val(atp.atp_history.transaction_debited_after_charge_off);
$('#'+uid+' .atp_unsecured_atp_template_account_info_total_payment_after_charge_off').val(atp.atp_history.total_payment_after_charge_off);
$('#'+uid+' .atp_unsecured_atp_template_account_info_net_charge_off_amount').val(atp.atp_history.net_charge_off_amount);
$('#'+uid+' .atp_unsecured_atp_template_civil_action_unbilled_legal_fees').val(atp.atp_history.unbilled_legal_fees);
$('#'+uid+' .atp_unsecured_atp_template_civil_action_legal_status').val(atp.atp_history.legal_status);
$('#'+uid+' .atp_unsecured_atp_template_civil_action_legal_status_date').val(getLanguageDate(atp.atp_history.legal_status_date));
$('#'+uid+' .atp_unsecured_atp_template_civil_action_creditor_petition_filed').val(getLanguageDate(atp.atp_history.creditor_petition_filed_date));
$('#'+uid+' .atp_unsecured_atp_template_civil_action_aoro_date').val(getLanguageDate(atp.atp_history.adj_receive_order_date));
$('#'+uid+' .atp_unsecured_atp_template_civil_action_pod_date').val(getLanguageDate(atp.atp_history.proof_of_debt_date));
$('#'+uid+' .atp_unsecured_atp_template_civil_action_aoro_by_3rd_party').val(getLanguageDate(atp.atp_history.aoro_date));
$('#'+uid+' .atp_unsecured_atp_template_civil_action_law_firm_name').val(atp.atp_history.law_firm_name);
$('#'+uid+' .atp_unsecured_atp_template_civil_action_lawyer_reference_number').val(atp.atp_history.lawyer_reference_no);
$('#'+uid+' .atp_unsecured_atp_template_civil_action_summon_number').val(atp.atp_history.summon_no);
$('#'+uid+' .atp_unsecured_atp_template_bureau_check_ctos').val(atp.atp_history.ctos);
$('#'+uid+' .atp_unsecured_atp_template_bureau_check_ramci').val(atp.atp_history.ramci);
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('mask',formatDecimal(atp.atp_history.principal_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.principal_proposed_sum));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver').maskMoney('mask',formatDecimal(atp.atp_history.principal_waiver));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.principal_waiver_percentage));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').maskMoney('mask',formatDecimal(atp.atp_history.misc_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.misc_proposed_sum));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver').maskMoney('mask',formatDecimal(atp.atp_history.misc_waiver));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.misc_waiver_percentage));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').maskMoney('mask',formatDecimal(atp.atp_history.compensation_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.compensation_proposed_sum));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver').maskMoney('mask',formatDecimal(atp.atp_history.compensation_waiver));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.compensation_waiver_percentage));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os').maskMoney('mask',formatDecimal(atp.atp_history.unbill_legal_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.unbill_legal_proposed_sum));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver').maskMoney('mask',formatDecimal(atp.atp_history.unbill_legal_waiver));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.unbill_legal_waiver_percentage));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_total_os').maskMoney('mask',formatDecimal(atp.atp_history.total_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.total_proposed_sum));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('mask',formatDecimal(atp.atp_history.total_waiver));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.total_waiver_percentage));
$('#'+uid+' .atp_unsecured_atp_template_basis_comments').val(atp.atp_history.comments);
$('#'+uid+' .atp_unsecured_atp_template_created_by').val(atp.atp_history.created_by);
$('#'+uid+' .atp_unsecured_atp_template_created_by').attr('volare-collector_user_id',atp.atp_history.created_by_id);
// $('#'+uid+' .atp_unsecured_atp_template_created_by').val(atp.atp_history.created_by_name);
// reviewed_by:$('#'+uid+' .atp_unsecured_atp_template_review_decision_by option:selected').text(),
$('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').val(atp.atp_history.reviewed_by_id);
$('#'+uid+' .atp_unsecured_atp_template_review_decision').val(atp.atp_history.reviewed_by_decision);
$('#'+uid+' .atp_unsecured_atp_template_review_decision_date').val(atp.atp_history.reviewed_by_decision_date);
$('#'+uid+' .atp_unsecured_atp_template_review_remarks').val(atp.atp_history.reviewed_by_remark);
$('#'+uid+' .atp_unsecured_atp_template_basis_comments').val(atp.atp_history.comments);
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('mask',formatDecimal(atp.atp_history.interest_total_os));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.interest_proposed_sum));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('mask',formatDecimal(atp.atp_history.interest_waiver));
$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.interest_waiver_percentage));
$('#'+uid+' .atp_unsecured_atp_template_profit_charges_1').maskMoney('mask',formatDecimal(atp.atp_history.profit_charges_1));
$('#'+uid+' .atp_unsecured_atp_template_profit_charges_2').maskMoney('mask',formatDecimal(atp.atp_history.profit_charges_2));
$('#'+uid+' .atp_unsecured_atp_template_projected_late_payment_1').maskMoney('mask',formatDecimal(atp.atp_history.projected_late_payment_1));
$('#'+uid+' .atp_unsecured_atp_template_projected_late_payment_2').maskMoney('mask',formatDecimal(atp.atp_history.projected_late_payment_2));
$('#'+uid+' .atp_unsecured_atp_template_agency_fee_rate_1').maskMoney('mask',formatDecimal(atp.atp_history.agency_fee_rate_1));
$('#'+uid+' .atp_unsecured_atp_template_agency_fee_rate_2').maskMoney('mask',formatDecimal(atp.atp_history.agency_fee_rate_2));
$('#'+uid+' .atp_unsecured_atp_template_net_charge_off_amount_1').maskMoney('mask',formatDecimal(atp.atp_history.net_charge_off_amount_1));
$('#'+uid+' .atp_unsecured_atp_template_settlement_proposal').maskMoney('mask',formatDecimal(atp.atp_history.settlement_proposal));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_total_os').maskMoney('mask',formatDecimal(atp.atp_history.judgement_total_os));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.judgement_proposed_sum));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_waiver').maskMoney('mask',formatDecimal(atp.atp_history.judgement_waiver));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_total_os').maskMoney('mask',formatDecimal(atp.atp_history.h_interest_total_os));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.h_interest_proposed_sum));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_waiver').maskMoney('mask',formatDecimal(atp.atp_history.h_interest_waiver));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_total_os').maskMoney('mask',formatDecimal(atp.atp_history.cost_awarded_total_os));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.cost_awarded_proposed_sum));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_waiver').maskMoney('mask',formatDecimal(atp.atp_history.cost_awarded_waiver));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_total_os').maskMoney('mask',formatDecimal(atp.atp_history.payment_compensation_total_os));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.payment_compensation_proposed_sum));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_waiver').maskMoney('mask',formatDecimal(atp.atp_history.payment_compensation_waiver));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_os_balance_total_os').maskMoney('mask',formatDecimal(atp.atp_history.os_balance_total_os));
$('#'+uid+' .atp_secured_atp_template_judgment_computation_os_balance_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.os_balance_proposed_sum));
$('#'+uid+' .atp_secured_atp_template_basis_is_partial_write_off').prop("checked",atp.atp_history.is_partial_write_off == "1");
$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_sales_order_date').val(atp.atp_history.sales_order_date);
$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auction_date').val(atp.atp_history.auction_date);
$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_reserved_price').maskMoney('mask',formatDecimal(atp.atp_history.reserved_price));
$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_no_of_past_auction').val(atp.atp_history.no_of_past_auction);
// $('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auction_off_date').val(atp.atp_history.auction_off_date);
$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auction_off_date').val(moment(atp.atp_history.auction_off_date,momentSqlDateFormat).format(momentDateFormat));
$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auctioned_selling_price').maskMoney('mask',formatDecimal(atp.atp_history.auctioned_selling_price));
$('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_summon_filling_date').val(atp.atp_history.summon_filling_date);
$('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_judgement_date').val(atp.atp_history.judgement_date);
$('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_execution_mode').val(atp.atp_history.execution_mode);
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('mask',formatDecimal(atp.atp_history.interest_total_os));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').maskMoney('mask',formatDecimal(atp.atp_history.interest_proposed_sum));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('mask',formatDecimal(atp.atp_history.interest_waiver));
// $('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('mask',formatDecimal(atp.atp_history.interest_waiver_percentage));
$('#'+uid+' .atp_secured_atp_template_recomputation_existing_interest_rate').val(atp.atp_history.existing_interest_rate);
$('#'+uid+' .atp_secured_atp_template_recomputation_existing_blr01').val(atp.atp_history.existing_blr_1);
$('#'+uid+' .atp_secured_atp_template_recomputation_existing_blr02').val(atp.atp_history.existing_blr_2);
$('#'+uid+' .atp_secured_atp_template_recomputation_existing_interest').val(atp.atp_history.existing_interest);
$('#'+uid+' .atp_secured_atp_template_recomputation_revision_interest_rate').val(atp.atp_history.revision_interest_rate);
$('#'+uid+' .atp_secured_atp_template_recomputation_revision_blr').val(atp.atp_history.revision_blr);
$('#'+uid+' .atp_secured_atp_template_recomputation_revision_interest').val(atp.atp_history.revision_interest);
$('#'+uid+' .atp_secured_atp_template_bureau_check_code_4028').maskMoney('mask',formatDecimal(atp.atp_history.code_4028));
$('#'+uid+' .atp_secured_atp_template_bureau_check_provision_misc').maskMoney('mask',formatDecimal(atp.atp_history.provision_misc));
$('#'+uid+' .atp_secured_atp_template_collateral_vehicle_model').val(atp.atp_history.model);
// $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_market_value').val(atp.atp_history.vehicle_market_value);
$('#'+uid+' .atp_secured_atp_template_collateral_vehicle_market_value').maskMoney('mask', formatDecimal(atp.atp_history.vehicle_market_value));
if(enable_atp_dca_name){
$('#'+uid+' .atp_unsecured_atp_template_dca_name').val(atp.atp_history.is_amsx_atp == "1"?atp.atp_history.created_by :'');
}
if(enable_atp_letter_offer){
$('#'+uid+' .atp_unsecured_atp_letter_offer_contact_number').val(atp.atp_history.contact_number_id);
}
if(enable_irl_inquiry_atp){
$('#'+uid+' .atp_unsecured_atp_template_irl_inquiry_remark').val(atp.atp_history.irl_inquiry_remark);
}
if(enable_ge_enhancement){
$('#'+uid+' .atp_unsecured_atp_template_email_validity_email_validity').html(atp.atp_history.email_validity == "1" ? lang.lang_yes : lang.lang_no );
$('#'+uid+' .atp_unsecured_atp_template_email_validity_email_validity_failed_reason').html(atp.atp_history.email_validity_failed_reason);
$('#'+uid+' .atp_unsecured_atp_template_email_validity_email_validity_sent_datetime').html(atp.atp_history.email_validity_send_date);
$('#'+uid+' .atp_unsecured_atp_template_email_validity_email_validity_result_datetime').html(atp.atp_history.email_validity_result_date);
}
// if(atp_calculator_modal_cc_var.properties_vehicle_model != ''){
// $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_model').val(atp_calculator_modal_cc_var.properties_vehicle_model);
// }
// if(atp_calculator_modal_cc_var.properties_vehicle_market_value != ''){
// $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_market_value').val(atp_calculator_modal_cc_var.properties_vehicle_model);
// }
// atp.atp_account_list_section
// $.each(atp.atp_account_list_section,function(index, el) {
// });
// $.each(atp.atp_tiering_info_section,function(index, el) {
// });
// $.each(atp.atp_existing_account_section,function(index, el) {
// });
// $.each(atp.atp_approval_decision,function(index, el) {
// });
// $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by .inactive_user").removeClass('hideMe');
// $('#'+uid+" select.atp_unsecured_atp_template_review_decision_by .deleted_user").removeClass('hideMe');
$('#'+uid+" select.atp_unsecured_atp_template_review_decision_by").selectpicker('destroy');
$('#'+uid+' .atp_unsecured_atp_template_review_decision_by').selectpicker({
hideDisabled: false,
liveSearch: true
});
$('#'+uid+' .atp_unsecured_atp_template_save_draft').attr('volare-atp_history_id',atp.atp_history.id);
$('#'+uid+' .atp_unsecured_atp_template_submit').attr('volare-atp_history_id',atp.atp_history.id);
atp_status = atp.atp_history.atp_status;
// 0 = Pending 1 = Approved 2 = Rejected 3 = Void 4 = Draft
switch(atp.atp_history.atp_status){
case '0':
case '1':
case '2':
case '3':
$('#'+uid+' .atp_unsecured_atp_template_save_draft').prop('disabled',true);
$('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',true);
$('#'+uid+' .atp_calculator_modal_cc input').prop('disabled',true);
$('#'+uid+' .atp_calculator_modal_cc textarea').prop('disabled',true);
$('#'+uid+' .atp_calculator_modal_cc select').prop('disabled',true);
$('#'+uid+' .atp_calculator_modal_cc .atp_rebate_calculator_calculate_rebate').prop('disabled',true);
$('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_payment_term_total_instalment_payment_tier_delete').prop('disabled',true);
$('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_decision_by_delete').prop('disabled',true);
break;
default:break;
}
}
}
$('#'+uid+' .volare_date').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+' .atp_rebate_calculator_agreement_date').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+' .atp_rebate_calculator_settlement_date').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+' .atp_unsecured_atp_template_payment_term_first_payment_date').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_date').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+' .atp_unsecured_atp_template_existing_acount_position_as_at').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+' input[data-toggle="toggle"]').bootstrapToggle({on: 'Yes',off: 'No'});
$('#'+uid+' .atp_secured_atp_template_date').val(moment().format(momentDateFormat));
$('#'+uid+' .atp_unsecured_atp_template_date').val(moment().format(momentDateFormat));
$('#'+uid+' .volare_currency').maskMoney({thousands:currencyThousands, decimal:currencyDecimal,allowNegative:true});
$('#'+uid+' .volare_currency').each(function(index, el) {
// console.log($(el).val());
$(el).val(formatDecimal($(el).val()));
$(el).maskMoney('mask');
});
// $('#'+uid+' .volare_currency').maskMoney('mask');
if(debtor.client_screen == 'CC' || debtor.client_screen == 'PL'){
$('#'+uid+' .atp_secured_related').addClass('hideMe');
$('#'+uid+' .atp_unsecured_related').removeClass('hideMe');
global.general.atp_uid[uid] = 'unsecured';
}else{
$('#'+uid+' .atp_secured_related').removeClass('hideMe');
$('#'+uid+' .atp_unsecured_related').addClass('hideMe');
global.general.atp_uid[uid] = 'secured';
}
// if(enable_atp_letter_offer){
// $('#'+uid+' .atp_letter_offer_related').removeClass('hideMe');
// }
if(enable_atp_letter_offer){
$('#'+uid+' .atp_letter_offer_general_related').removeClass('hideMe');
}
if(enable_ge_enhancement){
$('#'+uid+' .atp_unsecured_atp_template_email_validity').removeClass('hideMe');
}
if(atp_status == "" || atp_status == "4"){
realtimeValidateATPTier(uid);
realtimeValidateATPRebateCalculator(uid);
realtimeValidateATPDecisionMaker(uid);
realtimeValidateATPOverall(uid);
realtimeCalculateUnsecured(uid);
}else if(atp_status == "0"){
$('#'+uid+' .atp_unsecured_atp_template_review_decision').removeClass('hideMe');
var decision_section_changeable = false;
if(atp.atp_history.reviewed_by_decision == "0"){
if(global.general.collector_user_id == atp.atp_history.reviewed_by_id){
$('#'+uid+' .atp_unsecured_atp_template_review_decision').prop('disabled',false);
$('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').prop('disabled',false);
$('#'+uid+' .atp_unsecured_atp_template_review_remarks').prop('disabled',false);
$('#'+uid+' .atp_unsecured_atp_template_review_decision').attr('original_id',atp.atp_history.reviewed_by_decision);
$('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').attr('original_id',atp.atp_history.reviewed_by_id);
// $('#'+uid+' .atp_unsecured_atp_template_submit').attr('mode','review_by');
decision_section_changeable = true;
}else if(global.general.collector_user_id == atp.atp_history.created_by_id){
$('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').prop('disabled',false);
decision_section_changeable = true;
}
if(decision_section_changeable){
$('#'+uid+' .atp_unsecured_atp_template_decision_activity').prop('disabled',false);
$('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by').prop('disabled',false);
$('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_decision_by_delete').prop('disabled',false);
realtimeValidateATPDecisionMaker(uid);
realtimeValidateATPOverall(uid);
}
}else{
$('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_decision_by_add').prop('disabled',true);
var pending_decision_index = '';
$.each(atp.atp_approval_decision,function(index, el) {
if(el.decision == "0"){
pending_decision_index = index;
return false;
}
});
if(pending_decision_index !== ''){
if(global.general.collector_user_id == atp.atp_approval_decision[pending_decision_index].decision_by_id){
$('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by_'+pending_decision_index+'').prop('disabled',false);
$('#'+uid+' .atp_unsecured_atp_template_decision_decision_'+pending_decision_index+'').prop('disabled',false);
$('#'+uid+' .atp_unsecured_atp_template_decision_remark_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_decision').attr('original_id',atp.atp_approval_decision[pending_decision_index].decision);
$('#'+uid+' .atp_unsecured_atp_template_decision_decision_'+pending_decision_index).attr('original_id',atp.atp_approval_decision[pending_decision_index].decision);
// $('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_by').attr('original_id',atp.atp_approval_decision[pending_decision_index].decision_by_id);
$('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by_'+pending_decision_index).attr('original_id',atp.atp_approval_decision[pending_decision_index].decision_by_id);
// $('#'+uid+' .atp_unsecured_atp_template_submit').attr('mode','decision_by');
$('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',false);
}else if(global.general.collector_user_id == atp.atp_history.reviewed_by_id){
$('#'+uid+' select.atp_unsecured_atp_template_decision_decision_by_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_decision_decision_'+pending_decision_index+'').prop('disabled',false);
// $('#'+uid+' .atp_unsecured_atp_template_decision_remark_'+pending_decision_index+'').prop('disabled',false);
$('#'+uid+' .atp_unsecured_atp_template_submit').attr('mode','review_change_decision_by_bulk');
$('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',false);
}
}
}
}else{
$('#'+uid+' .atp_unsecured_atp_template_review_decision').removeClass('hideMe');
$('#'+uid+' .atp_unsecured_atp_template_review_decision').prop('disabled',true);
if((atp_status == "1" || atp_status == "5") && enable_atp_letter_offer){
$('#'+uid+' .atp_letter_offer_related').removeClass('hideMe');
$('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_esignatory').prop('disabled',false);
if(global.access.is_atp_preview_letter_offer_enabled == "1")
$('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_preview').removeClass('hideMe');
var atp_offer_letter_template = "";
if(debtor.is_credit_card == '1'){
atp_offer_letter_template = "unsecured_cc";
}else if(debtor.is_credit_card == '0' && debtor.is_islamic == '0' && debtor.client_screen == 'PL'){
atp_offer_letter_template = "unsecured_pl_conventional";
}else if(debtor.is_credit_card == '0' && debtor.is_islamic == '1' && debtor.client_screen == 'PL'){
atp_offer_letter_template = "unsecured_pl_islamic";
}else if(debtor.is_credit_card == '0' && debtor.is_islamic == '0' && (debtor.client_screen == 'HP' || debtor.client_screen == 'MG' || debtor.client_screen == 'OD') ){
atp_offer_letter_template = "secured_conventional";
}else if(debtor.is_credit_card == '0' && debtor.is_islamic == '1' && (debtor.client_screen == 'HP' || debtor.client_screen == 'MG' || debtor.client_screen == 'OD')){
atp_offer_letter_template = "secured_islamic";
}
// console.log(debtor.is_credit_card,debtor.is_islamic,debtor.client_screen);
$('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template').append(''+lang['lang_'+atp_offer_letter_template]+' ');
$('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_preview').attr('volare-atp_history_id',atp.atp_history.id);
$('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_generate').attr('volare-atp_history_id',atp.atp_history.id);
$('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_cancel').attr('volare-atp_history_id',atp.atp_history.id);
// $('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template_option').attr('value',atp_offer_letter_template);
$('#'+uid+' .atp_unsecured_atp_template_offer_letter_generation_template').selectpicker();
}
}
$('#'+uid+' .atp_unsecured_atp_template_review_decision_by').selectpicker({
liveSearch: "true"
});
$('#'+uid+' .atp_unsecured_atp_template_decision_decision_by').selectpicker({
liveSearch: "true"
});
$('#'+uid+' .atp_unsecured_atp_template_decision_by_row_decision_by').selectpicker({
liveSearch: "true"
});
if(enable_atp_letter_offer){
populateATPOfferLetterHistory(uid,atp.atp_letter_offer_history);
}
if(enable_irl_inquiry_atp){
if(atp == false || atp == null || (atp.atp_history.atp_status != null && atp.atp_history.atp_status == "4") ){
$('#'+uid+" .debtor_detail_as400_online_message_110436_atp_tbody").attr('volare-irl_inquiry_refresh','1');
processATPIrlTbodyUpdate(uid,debtor.id);
}else{
$('#'+uid+" .debtor_detail_as400_online_message_110436_atp_tbody").attr('volare-irl_inquiry_refresh','0');
$('#'+uid+" .atp_unsecured_atp_template_connected_party").prop('disabled',true);
$('#'+uid+" .atp_secured_atp_template_customer_list_connected_party").prop('disabled',true);
}
$('#'+uid+" .debtor_detail_as400_online_message_110436_atp_related").removeClass('hideMe');
$('#'+uid+" .atp_secured_atp_template_customer_and_account_information_relationship").addClass('hideMe');
}
if(Number(global.access.ATP_calculator) >= 2){
$('#'+uid+' .atp_unsecured_atp_template_footer').removeClass('hideMe');
}else{
$('#'+uid+' .atp_unsecured_atp_template_footer').addClass('hideMe');
}
$('#'+uid+' .atp_calculator_modal_cc').modal('show');
}
function populateATPBOfferLetterHistory(uid,data){
if(!(global.access.is_atp_preview_letter_offer_history_table_enabled == "1"))
return;
var atpb_template_offer_letter_history_tbody = "";
var atpb_template_offer_letter_history_tr = Handlebars.compile($('#template-bsi_atpb_template_offer_letter_history_tr').html());
var atpb_template_offer_letter_history_tr_var = {};
$.each(data,function(index, row) {
// console.log(row);
atpb_template_offer_letter_history_tr_var = row;
atpb_template_offer_letter_history_tr_var.index = index+1;
atpb_template_offer_letter_history_tr_var.uid = uid;
atpb_template_offer_letter_history_tbody += atpb_template_offer_letter_history_tr(atpb_template_offer_letter_history_tr_var);
});
$('#'+uid+' .atpb_template_offer_letter_history_tbody').html(atpb_template_offer_letter_history_tbody);
}
function populateATPOfferLetterHistory(uid,data){
if(!(global.access.is_atp_preview_letter_offer_history_table_enabled == "1"))
return;
var atp_unsecured_atp_template_offer_letter_history_tbody = "";
var atp_unsecured_atp_template_offer_letter_history_tr = Handlebars.compile($('#template-cc_atp_unsecured_atp_template_offer_letter_history_tr').html());
var atp_unsecured_atp_template_offer_letter_history_tr_var = {};
$.each(data,function(index, row) {
// console.log(row);
atp_unsecured_atp_template_offer_letter_history_tr_var = row;
atp_unsecured_atp_template_offer_letter_history_tr_var.index = index+1;
atp_unsecured_atp_template_offer_letter_history_tr_var.uid = uid;
atp_unsecured_atp_template_offer_letter_history_tbody += atp_unsecured_atp_template_offer_letter_history_tr(atp_unsecured_atp_template_offer_letter_history_tr_var);
});
$('#'+uid+' .atp_unsecured_atp_template_offer_letter_history_tbody').html(atp_unsecured_atp_template_offer_letter_history_tbody);
}
function upsertMOA(uid,debtor_id,mode = 'draft' ,moa_history_id = false){
var moa_history = {
//calculator part
created_at:moment($('#'+uid+' .moa_template_general_application_date').val(),momentDateFormat).format(momentSqlDateFormat),
approval_authority:$('#'+uid+' .moa_template_general_approval_authority').val(),
type_of_request:$('#'+uid+' .moa_template_general_type_of_reschedule').val(),
application_note:$('#'+uid+' .moa_template_general_application').val(),
position_as_at:moment($('#'+uid+' .moa_template_existing_account_outstanding_balance_details_as_at').val(),momentDateFormat).format(momentSqlDateFormat),
total_income:$('#'+uid+' .moa_template_financing_commitment_total_income').val(),
total_expenses:$('#'+uid+' .moa_template_financing_commitment_total_expenses').val(),
net_income:$('#'+uid+' .moa_template_financing_commitment_net_income').val(),
reschedule_installment:$('#'+uid+' .moa_template_financing_commitment_reschedule_installment').val(),
net_income_after_r_n_r:$('#'+uid+' .moa_template_financing_commitment_net_income_after_r_n_r').val(),
debtor_id:debtor_id,
loan_financing_amount:$('#'+uid+' .moa_template_proposal_settlement_financing_amount').val(),
principal_total_os:$('#'+uid+' .moa_template_proposal_settlement_principal_total_os').val(),
compensation_total_os:$('#'+uid+' .moa_template_proposal_settlement_compensation_total_os').val(),
interest_total_os:$('#'+uid+' .moa_template_proposal_settlement_interest_total_os').val(),
interest_profit_rate:$('#'+uid+' .moa_template_proposal_settlement_interest_profit_rate').val(),
ceiling_profit_rate:$('#'+uid+' .moa_template_proposal_settlement_ceiling_profit_rate').val(),
total_installment:$('#'+uid+' .moa_template_payment_term_total_installment').val(),
total_tenure:$('#'+uid+' .moa_template_payment_term_total_tenure').val(),
is_extension_period:$('#'+uid+' input:radio.moa_template_payment_term_is_extension_period:checked').val(),
type_of_existing_profit_rate:$('#'+uid+' .moa_template_change_of_profit_rate_type_of_existing_profit_rate').val(),
existing_interest_rate:$('#'+uid+' .moa_template_change_of_profit_rate_existing_interest_rate').val(),
revision_interest_rate:$('#'+uid+' .moa_template_change_of_profit_rate_revision_interest_rate').val(),
application_info:$('#'+uid+' .moa_template_comments_application_info').val(),
income_document:$('#'+uid+' .moa_template_comments_income_document').val(),
ramci:$('#'+uid+' .moa_template_comments_ramci').val(),
last_reschedule_date:$('#'+uid+' .moa_template_comments_rnr_last_reschedule_date').val(),
number_of_reschedule:$('#'+uid+' .moa_template_comments_rnr_number_of_reschedule').val(),
comments:$('#'+uid+' .moa_template_comments_comments').val(),
special_conditions:$('#'+uid+' .moa_template_comments_special_conditions').val(),
moa_status: mode == "draft" ? '4' : '0' ,
};
var moa_relationship_section = [];
$('#'+uid+' .moa_template_customer_list').each(function(index, el) {
moa_relationship_section.push({
relation_name:$(el).find('.moa_template_customer_information_relation_name').val(),
cif_number:$(el).find('.moa_template_customer_information_cif_number').val(),
nric:$(el).find('.moa_template_customer_information_nric').val(),
age:$(el).find('.moa_template_customer_information_age').val(),
relationship:$(el).find('.moa_template_customer_information_relationship').val(),
occupation:$(el).find('.moa_template_customer_information_occupation').val(),
employer:$(el).find('.moa_template_customer_information_employer').val(),
year_of_service:$(el).find('.moa_template_customer_information_year_of_service').val(),
no_of_dependants:$(el).find('.moa_template_customer_information_no_of_dependants').val(),
is_connected_party:$(el).find('.moa_template_customer_information_is_connected_party').prop("checked") ? 1:0,
// monthly_income:$(el).find('.moa_template_customer_information_monthly_income').val(),
basic_salary:$(el).find('.moa_template_customer_information_basic_salary').val(),
allowance:$(el).find('.moa_template_customer_information_allowance').val(),
overtime:$(el).find('.moa_template_customer_information_overtime').val(),
others:$(el).find('.moa_template_customer_information_others').val(),
total_incomes:$(el).find('.moa_template_customer_information_total_incomes').val(),
statutory_deduction:$(el).find('.moa_template_customer_information_statutory_deduction').val(),
household_expenses:$(el).find('.moa_template_customer_information_household_expenses').val(),
child_care:$(el).find('.moa_template_customer_information_child_card').val(),
utilities:$(el).find('.moa_template_customer_information_utilities').val(),
transport:$(el).find('.moa_template_customer_information_transport').val(),
});
});
var moa_existing_account_section = [];
$('#'+uid+' .moa_template_existing_account_row').each(function(index, el) {
moa_existing_account_section.push({
debtor_id:$(el).attr('volare-debtor_id'),
client_screen:$(el).attr('volare-client_screen'),
facility_type:$(el).find('.moa_template_existing_account_row_facility_type').val(),
approved_loan_date:moment($(el).find('.moa_template_existing_account_row_approved_loan_date').val(),momentDateFormat).format(momentSqlDateFormat),
limit_amount:$(el).find('.moa_template_existing_account_row_limit_amount').maskMoney('unmasked')[0],
profit_rate:$(el).find('.moa_template_existing_account_row_profit_rate').maskMoney('unmasked')[0],
ceiling_rate:$(el).find('.moa_template_existing_account_row_ceiling_rate').maskMoney('unmasked')[0],
tenure:$(el).find('.moa_template_existing_account_row_tenure').maskMoney('unmasked')[0],
maturity_date:moment($(el).find('.moa_template_existing_account_row_maturity_date').val(),momentDateFormat).format(momentSqlDateFormat),
monthly_installment:$(el).find('.moa_template_existing_account_row_monthly_installment').maskMoney('unmasked')[0],
collateral_security:$(el).find('.moa_template_existing_account_row_collateral_security').val(),
market_value:$(el).find('.moa_template_existing_account_row_market_value').maskMoney('unmasked')[0],
force_sale_value:$(el).find('.moa_template_existing_account_row_force_sale_value').maskMoney('unmasked')[0],
legal_action_status:$(el).find('.moa_template_existing_account_row_legal_action_status').val(),
arrears_month:$(el).find('.moa_template_existing_account_row_arrears_month').val(),
total_arrears:$(el).find('.moa_template_existing_account_row_total_arrears').maskMoney('unmasked')[0],
total_due:$(el).find('.moa_template_existing_account_row_total_due').maskMoney('unmasked')[0],
overdue_term:$(el).find('.moa_template_existing_account_row_total_due').maskMoney('unmasked')[0],
profit_charges:$(el).find('.moa_template_existing_account_row_profit_charges').maskMoney('unmasked')[0],
misc_charges:$(el).find('.moa_template_existing_account_row_misc_charges').maskMoney('unmasked')[0],
other_charges:$(el).find('.moa_template_existing_account_row_other_charges').maskMoney('unmasked')[0],
total_outstanding_balance:$(el).find('.moa_template_existing_account_row_total_outstanding_balance').maskMoney('unmasked')[0],
ta_width:$(el).find('.moa_template_existing_account_row_ta_width').maskMoney('unmasked')[0],
balance:$(el).find('.moa_template_existing_account_row_ta_balance').maskMoney('unmasked')[0],
outstanding_balance:$(el).find('.moa_template_existing_account_row_ta_outstanding_balance').maskMoney('unmasked')[0],
// total_due:$(el).find('.atp_unsecured_atp_template_existing_acount_total_arrears').val(),
});
});
var moa_financing_commitment_section = global.general.moa_financing_commitment[uid];
// var atp_account_list_section = [];
// $('#'+uid+' .atp_unsecured_atp_template_short_fall').each(function(index, el) {
// atp_account_list_section.push({
// debtor_id:$(el).attr('volare-debtor_id'),
// account:$(el).attr('volare-account'),
// card_no:$(el).attr('volare-card_no'),
// account_status:$(el).attr('volare-account_status'),
// since:$(el).attr('volare-charge_off_date'),
// short_non_clean:$(el).val(),
// });
// });
var moa_tiering_info_section = global.general.moa_tier[uid];
var moa_approval_decision = [];
$.each(global.general.moa_decision[uid],function(index, el) {
moa_approval_decision.push({
// activity:el.activity_id,
activity:el.activity,
decision_by:el.decision_by,
decision_by_id:el.decision_by_id,
decision:el.decision,
decision_date:'null',
remark:el.remark,
});
});
// console.log(atp_approval_decision,atp_existing_account_section,atp_tiering_info_section,atp_account_list_section,atp_history);
var moa = {
moa_history:moa_history,
moa_relationship_section:moa_relationship_section,
// atp_properties_section:atp_properties_section,
// atp_account_list_section:atp_account_list_section,
moa_tiering_info_section:moa_tiering_info_section,
moa_existing_account_section:moa_existing_account_section,
moa_financing_commitment_section:moa_financing_commitment_section,
moa_approval_decision:moa_approval_decision,
};
if(moa_history_id != false){
moa.moa_history_id = moa_history_id;
}
console.log(moa);
volareApi("createMOA",{action: 'createMOA',debtor_id:debtor_id,moa:moa,},{uid:uid});
}
function upsertATPB(uid,debtor_id,mode = 'draft' ,atpb_history_id = false){
var atpb_history = {
//section a
customer_business_group:$('#'+uid+' .atpb_template_general_information_customer_business_group').val(),
business_or_occupation:$('#'+uid+' .atpb_template_general_information_business_or_occupation').val(),
key_person:$('#'+uid+' .atpb_template_general_information_key_person').val(),
business_operating_since:moment($('#'+uid+' .atpb_template_general_information_business_operating_since').val(),momentDateFormat).format(momentSqlDateFormat),
relationship_with_bsi_since:moment($('#'+uid+' .atpb_template_general_information_relationship_with_bsi_since').val(),momentDateFormat).format(momentSqlDateFormat),
company_structure:$('#'+uid+' .atpb_template_general_information_company_structure').val(),
customer_application:$('#'+uid+' .atpb_template_general_information_customer_application').val(),
financing_position_in_other_banks:$('#'+uid+' .atpb_template_general_information_financing_position_in_other_banks').val(),
//section b
account_status:$('#'+uid+' .atpb_template_customer_account_account_status').val(),
loan_kol:$('#'+uid+' .atpb_template_customer_account_loan_kol').val(),
cif_kol:$('#'+uid+' .atpb_template_customer_account_cif_kol').val(),
days_past_due:$('#'+uid+' .atpb_template_customer_account_days_past_due').val(),
liquidity_date:moment($('#'+uid+' .atpb_template_customer_account_liquidity_date').val(),momentDateFormat).format(momentSqlDateFormat),
due_date:moment($('#'+uid+' .atpb_template_customer_account_due_date').val(),momentDateFormat).format(momentSqlDateFormat),
min_repayment:$('#'+uid+' .atpb_template_customer_account_min_repayment').val(),
credit_limit:$('#'+uid+' .atpb_template_customer_account_credit_limit').val(),
//section c
user_input_total:$('#'+uid+' .atpb_template_existing_section_user_input_total').maskMoney('unmasked')[0],
// account_status:$('#'+uid+' .atpb_template_existing_section_account_status').val(),
placement:$('#'+uid+' .atpb_template_existing_section_placement').val(),
// cif_kol:$('#'+uid+' .atpb_template_existing_section_cif_kol').val(),
// days_past_due:$('#'+uid+' .atpb_template_existing_section_days_past_due').val(),
// liquidity_date:$('#'+uid+' .atpb_template_existing_section_liquidity_date').val(),
// due_date:$('#'+uid+' .atpb_template_existing_section_due_date').val(),
margin_os:$('#'+uid+' .atpb_template_existing_section_margin_os').val(),
gross_arrears:$('#'+uid+' .atpb_template_existing_section_gross_arrears').val(),
principal_arrears:$('#'+uid+' .atpb_template_existing_section_principal_arrears').val(),
margin_arrears:$('#'+uid+' .atpb_template_existing_section_margin_arrears').val(),
penalty:$('#'+uid+' .atpb_template_existing_section_penalty').val(),
rate:$('#'+uid+' .atpb_template_existing_section_rate').val(),
// min_repayment:$('#'+uid+' .atpb_template_existing_section_min_repayment').val(),
// credit_limit:$('#'+uid+' .atpb_template_existing_section_credit_limit').val(),
//section d
background_problems:$('#'+uid+' .atpb_template_background_problems').val(),
//section e
financial_analysis:$('#'+uid+' .atpb_template_financial_analysis').val(),
//section f
type_of_legality:$('#'+uid+' .atpb_template_legal_type_of_legality').val(),
document_no_and_date:$('#'+uid+' .atpb_template_legal_document_no_and_date').val(),
legal_explanation:$('#'+uid+' .atpb_template_legal_legal_explanation').val(),
//section g
// collateral_description:$('#'+uid+' .atpb_template_collateral_section_collateral_description').val(),
// collateral_id:$('#'+uid+' .atpb_template_collateral_section_collateral_id').val(),
// lot_location:$('#'+uid+' .atpb_template_collateral_section_lot_location').val(),
// collateral_type:$('#'+uid+' .atpb_template_collateral_section_collateral_type').val(),
// proof_of_ownership:$('#'+uid+' .atpb_template_collateral_section_proof_of_ownership').val(),
// valuation_date:moment($('#'+uid+' .atpb_template_collateral_section_valuation_date').val(),momentDateFormat).format(momentSqlDateFormat),
// expiry_date:moment($('#'+uid+' .atpb_template_collateral_section_expiry_date').val(),momentDateFormat).format(momentSqlDateFormat),
// security_document_value:$('#'+uid+' .atpb_template_collateral_section_security_document_value').val(),
// market_value:$('#'+uid+' .atpb_template_collateral_section_market_value').val(),
// valuation_value:$('#'+uid+' .atpb_template_collateral_section_valuation_value').val(),
// total_security_document_value:$('#'+uid+' .atpb_template_collateral_section_total_security_document_value').val(),
// total_market_value:$('#'+uid+' .atpb_template_collateral_section_total_market_value').val(),
// total_liquidity_value:$('#'+uid+' .atpb_template_collateral_section_total_liquidity_value').val(),
// security_document_type:$('#'+uid+' .atpb_template_collateral_section_security_document_type').val(),
// insurance_premium:$('#'+uid+' .atpb_template_collateral_section_insurance_premium').val(),
// loan_amount:$('#'+uid+' .atpb_template_collateral_section_loan_amount').val(),
// total_collateral_binding_value:$('#'+uid+' .atpb_template_collateral_section_total_collateral_binding_value').val(),
// collateral_liquidity_value:$('#'+uid+' .atpb_template_collateral_section_total_collateral_liquidity_value').val(),
collateral_explanation:$('#'+uid+' .atpb_template_collateral_section_collateral_explanation').val(),
//section h
analysis_study:$('#'+uid+' .atpb_template_analysis_study').val(),
//section i
data_date:moment($('#'+uid+' .atpb_template_existing_settlement_data_date').val(),momentDateFormat).format(momentSqlDateFormat),
margin_os:$('#'+uid+' .atpb_template_existing_settlement_margin_os').val(),
gross_arrears:$('#'+uid+' .atpb_template_existing_settlement_gross_arrears').val(),
principal_arrears:$('#'+uid+' .atpb_template_existing_settlement_principal_arrears').val(),
existing_restructuring_fee:$('#'+uid+' .atpb_template_existing_settlement_existing_restructuring_fee').val(),
penalty:$('#'+uid+' .atpb_template_existing_settlement_penalty').val(),
rate:$('#'+uid+' .atpb_template_existing_settlement_rate').val(),
remaining_tenure:$('#'+uid+' .atpb_template_existing_settlement_remaining_tenure').val(),
total_installment:$('#'+uid+' .atpb_template_existing_settlement_total_installment').val(),
due_date:moment($('#'+uid+' .atpb_template_existing_settlement_due_date').val(),momentDateFormat).format(momentSqlDateFormat),
//section j
restructure_frequency:$('#'+uid+' .atpb_template_proposal_settlement_restructure_frequency').val(),
request_type:$('#'+uid+' .atpb_template_proposal_settlement_request_type').val(),
repayment_capacity:$('#'+uid+' .atpb_template_proposal_settlement_repayment_capacity').maskMoney('unmasked')[0],
payment_source:$('#'+uid+' .atpb_template_proposal_settlement_payment_source').val(),
restructure_to:$('#'+uid+' .atpb_template_proposal_settlement_restructure_to').maskMoney('unmasked')[0],
new_financing_type:$('#'+uid+' .atpb_template_proposal_settlement_new_financing_type').val(),
principle_outstanding_proposal:$('#'+uid+' .atpb_template_proposal_settlement_principle_outstanding_proposal').maskMoney('unmasked')[0],
margin_outstanding_proposal:$('#'+uid+' .atpb_template_proposal_settlement_margin_outstanding_proposal').maskMoney('unmasked')[0],
err_percentage:$('#'+uid+' .atpb_template_proposal_settlement_err_percentage').maskMoney('unmasked')[0],
bank_profit_sharing_ratio:$('#'+uid+' .atpb_template_proposal_settlement_bank_profit_sharing_ratio').maskMoney('unmasked')[0],
customer_profit_sharing_ratio:$('#'+uid+' .atpb_template_proposal_settlement_customer_profit_sharing_ratio').maskMoney('unmasked')[0],
proposal_restructuring_fee:$('#'+uid+' .atpb_template_proposal_settlement_proposal_restructuring_fee').maskMoney('unmasked')[0],
administrative_fee:$('#'+uid+' .atpb_template_proposal_settlement_administrative_fee').maskMoney('unmasked')[0],
restructuring_period:$('#'+uid+' .atpb_template_proposal_settlement_restructuring_period').maskMoney('unmasked')[0],
new_due_date:moment($('#'+uid+' .atpb_template_proposal_settlement_new_due_date').val(),momentDateFormat).format(momentSqlDateFormat),
payment_method:$('#'+uid+' .atpb_template_proposal_settlement_payment_method').val(),
payment_effective_date:moment($('#'+uid+' .atpb_template_proposal_settlement_payment_effective_date').val(),momentDateFormat).format(momentSqlDateFormat),
installment_scheme:$('#'+uid+' .atpb_template_proposal_settlement_installment_scheme').maskMoney('unmasked')[0],
post_restructuring_strategic_steps:$('#'+uid+' .atpb_template_proposal_settlement_post_restructuring_strategic_steps').val(),
requirements_signing_financing_agreement:$('#'+uid+' .atpb_template_proposal_settlement_requirements_signing_financing_agreement').val(),
effective_conditions:$('#'+uid+' .atpb_template_proposal_settlement_effective_conditions').val(),
other_conditions:$('#'+uid+' .atpb_template_proposal_settlement_other_conditions').val(),
total_tenure:$('#'+uid+' .atpb_template_payment_term_total_tenure').val(),
total_installment:$('#'+uid+' .atpb_template_payment_term_total_installment').val(),
//section k
recommendation_comments:$('#'+uid+' .atpb_template_recommendation_recommendation_comments').val(),
card_blocking_proposal:$('#'+uid+' .atpb_template_recommendation_card_blocking_proposal').val(),
initial_bucket:$('#'+uid+' .atpb_template_recommendation_initial_bucket').val(),
reaging:$('#'+uid+' .atpb_template_recommendation_reaging').val(),
//section L
principle_os_total_os:$('#'+uid+' .atpb_template_composition_waiver_principal_loan_total_os').maskMoney('unmasked')[0],
principle_os_proposed_sum:$('#'+uid+' .atpb_template_composition_waiver_principal_loan_proposed_sum').maskMoney('unmasked')[0],
principle_os_discount:$('#'+uid+' .atpb_template_composition_waiver_principal_loan_discount_value').maskMoney('unmasked')[0],
principle_os_percentage:$('#'+uid+' .atpb_template_composition_waiver_principal_loan_discount_rate').maskMoney('unmasked')[0],
subrogation_total_os:$('#'+uid+' .atpb_template_composition_waiver_subrogation_total_os').maskMoney('unmasked')[0],
subrogation_proposed_sum:$('#'+uid+' .atpb_template_composition_waiver_subrogation_proposed_sum').maskMoney('unmasked')[0],
subrogation_discount:$('#'+uid+' .atpb_template_composition_waiver_subrogation_discount_value').maskMoney('unmasked')[0],
subrogation_percentage:$('#'+uid+' .atpb_template_composition_waiver_subrogation_discount_rate').maskMoney('unmasked')[0],
margin_os_total_os:$('#'+uid+' .atpb_template_composition_waiver_margin_os_total_os').maskMoney('unmasked')[0],
margin_os_proposed_sum:$('#'+uid+' .atpb_template_composition_waiver_margin_os_proposed_sum').maskMoney('unmasked')[0],
margin_os_discount:$('#'+uid+' .atpb_template_composition_waiver_margin_os_discount_value').maskMoney('unmasked')[0],
margin_os_percentage:$('#'+uid+' .atpb_template_composition_waiver_margin_os_discount_rate').maskMoney('unmasked')[0],
arrears_profit_sharing_total_os:$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_total_os').maskMoney('unmasked')[0],
arrears_profit_sharing_proposed_sum:$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_proposed_sum').maskMoney('unmasked')[0],
arrears_profit_sharing_discount:$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_discount_value').maskMoney('unmasked')[0],
arrears_profit_sharing_percentage:$('#'+uid+' .atpb_template_composition_waiver_arrears_profit_sharing_discount_rate').maskMoney('unmasked')[0],
penalty_arrears_total_os:$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_total_os').maskMoney('unmasked')[0],
penalty_arrears_proposed_sum:$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_proposed_sum').maskMoney('unmasked')[0],
penalty_arrears_discount:$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_discount_value').maskMoney('unmasked')[0],
penalty_arrears_percentage:$('#'+uid+' .atpb_template_composition_waiver_penalty_arrears_discount_rate').maskMoney('unmasked')[0],
other_charges_total_os:$('#'+uid+' .atpb_template_composition_waiver_other_charges_total_os').maskMoney('unmasked')[0],
other_charges_proposed_sum:$('#'+uid+' .atpb_template_composition_waiver_other_charges_proposed_sum').maskMoney('unmasked')[0],
other_charges_discount:$('#'+uid+' .atpb_template_composition_waiver_other_charges_discount_value').maskMoney('unmasked')[0],
other_charges_percentage:$('#'+uid+' .atpb_template_composition_waiver_other_charges_discount_rate').maskMoney('unmasked')[0],
unbill_legal_fee_total_os:$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_total_os').maskMoney('unmasked')[0],
unbill_legal_fee_proposed_sum:$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_proposed_sum').maskMoney('unmasked')[0],
unbill_legal_fee_discount:$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_discount_value').maskMoney('unmasked')[0],
unbill_legal_fee_percentage:$('#'+uid+' .atpb_template_composition_waiver_unbill_legal_fees_discount_rate').maskMoney('unmasked')[0],
total_projected_os_total_os:$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_total_os').maskMoney('unmasked')[0],
total_projected_os_proposed_sum:$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_proposed_sum').maskMoney('unmasked')[0],
total_projected_os_discount:$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_discount_value').maskMoney('unmasked')[0],
total_projected_os_percentage:$('#'+uid+' .atpb_template_composition_waiver_total_projected_outstanding_discount_rate').maskMoney('unmasked')[0],
//section M
basis_recommendation_comments:$('#'+uid+' .atpb_template_basis_recommendation_comments').val(),
// reviewed_by_id:$('#'+uid+' select.atpb_template_review_decision_by').val(),
//Approval Section
created_by:$('#'+uid+' .atpb_template_created_by').val(),
created_by_id:$('#'+uid+' .atpb_template_created_by').attr('volare-collector_user_id'),
// created_by_name:$('#'+uid+' .atp_unsecured_atp_template_created_by').val(),
reviewed_by:$('#'+uid+' select.atpb_template_review_decision_by option:selected').text(),
reviewed_by_id:$('#'+uid+' select.atpb_template_review_decision_by').val(),
// reviewed_by_name:$('#'+uid+' .atp_unsecured_atp_template_review_decision_by option:selected').text(),
reviewed_by_decision:$('#'+uid+' .atpb_template_review_decision').val(),
// reviewed_by_decision_date:$('#'+uid+' .atp_unsecured_atp_template_review_decision_date').val(),
reviewed_by_decision_date:'null',
reviewed_by_remark:$('#'+uid+' .atpb_template_review_remarks').val(),
financing_committee_status:$('#'+uid+' .atpb_template_financing_committee_status').val(),
authority_decision_committee:$('#'+uid+' .atpb_template_authority_decision_committee').val(),
authority_to_decide:$('#'+uid+' .atpb_template_authority_to_decide').val(),
atpb_status: mode == "draft" ? '4' : '0' ,
};
// console.log(atpb_history);
var atpb_collateral_list_section = [];
$('#'+uid+' .atpb_template_collateral_section_collateral_row').each(function(index, el) {
atpb_collateral_list_section.push({
collateral_description:$(el).find('.atpb_template_collateral_section_collateral_description').val(),
collateral_id:$(el).find('.atpb_template_collateral_section_collateral_id').val(),
lot_location:$(el).find('.atpb_template_collateral_section_lot_location').val(),
collateral_type:$(el).find('.atpb_template_collateral_section_collateral_type').val(),
proof_of_ownership:$(el).find('.atpb_template_collateral_section_proof_of_ownership').val(),
valuation_date:moment($(el).find('.atpb_template_collateral_section_valuation_date').val(),momentDateFormat).format(momentSqlDateFormat),
expiry_date:moment($(el).find('.atpb_template_collateral_section_expiry_date').val(),momentDateFormat).format(momentSqlDateFormat),
security_document_value:$(el).find('.atpb_template_collateral_section_security_document_value').maskMoney('unmasked')[0],
market_value:$(el).find('.atpb_template_collateral_section_market_value').maskMoney('unmasked')[0],
valuation_value:$(el).find('.atpb_template_collateral_section_valuation_value').maskMoney('unmasked')[0],
total_security_document_value:$(el).find('.atpb_template_collateral_section_total_security_document_value').maskMoney('unmasked')[0],
total_market_value:$(el).find('.atpb_template_collateral_section_total_market_value').maskMoney('unmasked')[0],
total_liquidity_value:$(el).find('.atpb_template_collateral_section_total_liquidity_value').maskMoney('unmasked')[0],
security_document_type:$(el).find('.atpb_template_collateral_section_security_document_type').val(),
insurance_premium:$(el).find('.atpb_template_collateral_section_insurance_premium').maskMoney('unmasked')[0],
loan_amount:$(el).find('.atpb_template_collateral_section_loan_amount').maskMoney('unmasked')[0],
total_collateral_binding_value:$(el).find('.atpb_template_collateral_section_total_collateral_binding_value').maskMoney('unmasked')[0],
total_collateral_market_value:$(el).find('.atpb_template_collateral_section_total_collateral_market_value').maskMoney('unmasked')[0],
total_collateral_liquidity_value:$(el).find('.atpb_template_collateral_section_total_collateral_liquidity_value').maskMoney('unmasked')[0],
});
});
// var moa_existing_account_section = [];
// $('#'+uid+' .moa_template_existing_account_row').each(function(index, el) {
// moa_existing_account_section.push({
// debtor_id:$(el).attr('volare-debtor_id'),
// client_screen:$(el).attr('volare-client_screen'),
// facility_type:$(el).find('.moa_template_existing_account_row_facility_type').val(),
// approved_loan_date:moment($(el).find('.moa_template_existing_account_row_approved_loan_date').val(),momentDateFormat).format(momentSqlDateFormat),
// limit_amount:$(el).find('.moa_template_existing_account_row_limit_amount').maskMoney('unmasked')[0],
// profit_rate:$(el).find('.moa_template_existing_account_row_profit_rate').maskMoney('unmasked')[0],
// ceiling_rate:$(el).find('.moa_template_existing_account_row_ceiling_rate').maskMoney('unmasked')[0],
// tenure:$(el).find('.moa_template_existing_account_row_tenure').maskMoney('unmasked')[0],
// maturity_date:moment($(el).find('.moa_template_existing_account_row_maturity_date').val(),momentDateFormat).format(momentSqlDateFormat),
// monthly_installment:$(el).find('.moa_template_existing_account_row_monthly_installment').maskMoney('unmasked')[0],
// collateral_security:$(el).find('.moa_template_existing_account_row_collateral_security').val(),
// market_value:$(el).find('.moa_template_existing_account_row_market_value').maskMoney('unmasked')[0],
// force_sale_value:$(el).find('.moa_template_existing_account_row_force_sale_value').maskMoney('unmasked')[0],
// legal_action_status:$(el).find('.moa_template_existing_account_row_legal_action_status').val(),
// arrears_month:$(el).find('.moa_template_existing_account_row_arrears_month').val(),
// total_arrears:$(el).find('.moa_template_existing_account_row_total_arrears').maskMoney('unmasked')[0],
// total_due:$(el).find('.moa_template_existing_account_row_total_due').maskMoney('unmasked')[0],
// overdue_term:$(el).find('.moa_template_existing_account_row_total_due').maskMoney('unmasked')[0],
// profit_charges:$(el).find('.moa_template_existing_account_row_profit_charges').maskMoney('unmasked')[0],
// misc_charges:$(el).find('.moa_template_existing_account_row_misc_charges').maskMoney('unmasked')[0],
// other_charges:$(el).find('.moa_template_existing_account_row_other_charges').maskMoney('unmasked')[0],
// total_outstanding_balance:$(el).find('.moa_template_existing_account_row_total_outstanding_balance').maskMoney('unmasked')[0],
// ta_width:$(el).find('.moa_template_existing_account_row_ta_width').maskMoney('unmasked')[0],
// balance:$(el).find('.moa_template_existing_account_row_ta_balance').maskMoney('unmasked')[0],
// outstanding_balance:$(el).find('.moa_template_existing_account_row_ta_outstanding_balance').maskMoney('unmasked')[0],
// // total_due:$(el).find('.atp_unsecured_atp_template_existing_acount_total_arrears').val(),
// });
// });
// var moa_financing_commitment_section = global.general.moa_financing_commitment[uid];
var atpb_tiering_info_section = global.general.atpb_tier[uid];
var atpb_approval_decision = [];
$.each(global.general.atpb_decision[uid],function(index, el) {
atpb_approval_decision.push({
// activity:el.activity_id,
activity:el.activity,
decision_by:el.decision_by,
decision_by_id:el.decision_by_id,
decision:el.decision,
decision_date:'null',
remark:el.remark,
});
});
// console.log(atp_approval_decision,atp_existing_account_section,atp_tiering_info_section,atp_account_list_section,atp_history);
var atpb = {
atpb_history:atpb_history,
atpb_collateral_list_section:atpb_collateral_list_section,
// atpb_relationship_section:atpb_relationship_section,
// atp_properties_section:atp_properties_section,
// atp_account_list_section:atp_account_list_section,
atpb_tiering_info_section:atpb_tiering_info_section,
// moa_existing_account_section:moa_existing_account_section,
// moa_financing_commitment_section:moa_financing_commitment_section,
atpb_approval_decision:atpb_approval_decision,
};
if(atpb_history_id != false){
atpb.atpb_history_id = atpb_history_id;
}
// console.log(atpb);
// return;
volareApi("createATPB",{action: 'createATPB',debtor_id:debtor_id,atpb:atpb,},{uid:uid});
}
function upsertATP(uid,debtor_id,mode = 'draft' ,atp_history_id = false){
var atp_history = {
//calculator part
loan_financing_amount:$('#'+uid+' .atp_rebate_calculator_loan_amount').maskMoney('unmasked')[0],
interest_profit_rate:$('#'+uid+' .atp_rebate_calculator_interest_rate').val(),
term:$('#'+uid+' .atp_rebate_calculator_loan_term').val(),
term_charges:$('#'+uid+' .atp_rebate_calculator_term_charges').maskMoney('unmasked')[0],
agreement_date:moment($('#'+uid+' .atp_rebate_calculator_agreement_date').val(),momentDateFormat).format(momentSqlDateFormat),
settlement_date:moment($('#'+uid+' .atp_rebate_calculator_settlement_date').val(),momentDateFormat).format(momentSqlDateFormat),
factor:$('#'+uid+' .atp_rebate_calculator_factor').val(),
remaining_months:$('#'+uid+' .atp_rebate_calculator_remaining_months').val(),
rebate:$('#'+uid+' .atp_rebate_calculator_rebate').maskMoney('unmasked')[0],
//Entity
is_islamic:$('#'+uid+' select.atp_unsecured_atp_template_entity').val(),
//Section A
is_secured:global.general.atp_uid[uid] == 'secured' ? 1:0,
created_at:moment($('#'+uid+' .atp_unsecured_atp_template_date').val(),momentDateFormat).format(momentSqlDateFormat),
collection_center:$('#'+uid+' .atp_unsecured_atp_template_collection_centre').val(),
client_name:$('#'+uid+' .atp_unsecured_atp_template_product').val(),
user_id:$('#'+uid+' .atp_unsecured_atp_template_dca_name').attr('volare-user_id'),
user_name:$('#'+uid+' .atp_unsecured_atp_template_dca_name').val(),
new_ic:$('#'+uid+' .atp_unsecured_atp_template_customer_id').attr('volare-new_ic'),
debtor_name:$('#'+uid+' .atp_unsecured_atp_template_customer_name').val(),
is_connected_party:$('#'+uid+' .atp_unsecured_atp_template_connected_party').prop("checked") ? 1:0,
email_address:$('#'+uid+' .atp_unsecured_atp_template_email').val(),
//Section B
type_of_request:$('#'+uid+' .atp_unsecured_atp_template_type_of_request').val(),
type_of_package:$('#'+uid+' .atp_unsecured_atp_template_type_of_package_1').val(),
type_of_package_02:$('#'+uid+' .atp_unsecured_atp_template_type_of_package_2').val(),
type_of_package_03:$('#'+uid+' .atp_unsecured_atp_template_type_of_package_3').val(),
reason_for_settlement:$('#'+uid+' .atp_unsecured_atp_template_reason_for_settlement').val(),
agreed_settlement_sum:$('#'+uid+' .atp_unsecured_atp_template_agreed_settlement_sum').maskMoney('unmasked')[0],
projected_waiver_amount:$('#'+uid+' .atp_unsecured_atp_template_projected_waiver_amount').maskMoney('unmasked')[0],
debtor_id:debtor_id,
epf_withdrawal_payment:$('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_currency_amount').maskMoney('unmasked')[0],
epf_withdrawal_calendar:moment($('#'+uid+' .atp_unsecured_atp_template_payment_term_epf_date').val(),momentDateFormat).format(momentSqlDateFormat),
total_tenure:$('#'+uid+' .atp_unsecured_atp_template_payment_term_total_tenure').val(),
total_installment:$('#'+uid+' .atp_unsecured_atp_template_payment_term_total_instalment_payment_amount').maskMoney('unmasked')[0],
installment_email:$('#'+uid+' .atp_unsecured_atp_template_payment_term_email_when_instalment').prop("checked") ? 1:0,
bankrupt_status:$('#'+uid+' .atp_unsecured_atp_template_payment_term_waive_accured_interest').prop("checked") ? 1:0,
existing_interest_rate:$('#'+uid+' .atp_secured_atp_template_recomputation_existing_interest_rate').val()?$('#'+uid+' .atp_secured_atp_template_recomputation_existing_interest_rate').val():0,
existing_blr_1:$('#'+uid+' .atp_secured_atp_template_recomputation_existing_blr01').val()?$('#'+uid+' .atp_secured_atp_template_recomputation_existing_blr01').val():0,
existing_blr_2:$('#'+uid+' .atp_secured_atp_template_recomputation_existing_blr02').val()?$('#'+uid+' .atp_secured_atp_template_recomputation_existing_blr02').val():0,
existing_interest:$('#'+uid+' .atp_secured_atp_template_recomputation_existing_interest').val()?$('#'+uid+' .atp_secured_atp_template_recomputation_existing_interest').val():0,
revision_interest_rate:$('#'+uid+' .atp_secured_atp_template_recomputation_revision_interest_rate').val()?$('#'+uid+' .atp_secured_atp_template_recomputation_revision_interest_rate').val():0,
revision_blr:$('#'+uid+' .atp_secured_atp_template_recomputation_revision_blr').val()?$('#'+uid+' .atp_secured_atp_template_recomputation_revision_blr').val():0,
revision_interest:$('#'+uid+' .atp_secured_atp_template_recomputation_revision_interest').val()?$('#'+uid+' .atp_secured_atp_template_recomputation_revision_interest').val():0,
//Section C
position_as_at:moment($('#'+uid+' .atp_unsecured_atp_template_existing_acount_position_as_at').val(),momentDateFormat).format(momentSqlDateFormat),
system_total:$('#'+uid+' .atp_unsecured_atp_template_existing_acount_system_total').maskMoney('unmasked')[0],
user_input_total:$('#'+uid+' .atp_unsecured_atp_template_existing_acount_user_input_total').maskMoney('unmasked')[0],
//Section D
account_open:moment($('#'+uid+' .atp_unsecured_atp_template_account_info_account_opened').val(),momentDateFormat).format(momentSqlDateFormat),
credit_limit:$('#'+uid+' .atp_unsecured_atp_template_account_info_credit_limit').maskMoney('unmasked')[0],
last_payment_date:moment($('#'+uid+' .atp_unsecured_atp_template_account_info_last_payment_date').val(),momentDateFormat).format(momentSqlDateFormat),
charge_off_date:moment($('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_date').val(),momentDateFormat).format(momentSqlDateFormat),
// charge_off_date:$('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_date').val(),
charge_off_amount:$('#'+uid+' .atp_unsecured_atp_template_account_info_charge_off_amount').maskMoney('unmasked')[0],
transaction_debited_after_charge_off:$('#'+uid+' .atp_unsecured_atp_template_account_info_transaction_debited_after_charge_off').maskMoney('unmasked')[0],
total_payment_after_charge_off:$('#'+uid+' .atp_unsecured_atp_template_account_info_total_payment_after_charge_off').maskMoney('unmasked')[0],
net_charge_off_amount:$('#'+uid+' .atp_unsecured_atp_template_account_info_net_charge_off_amount').maskMoney('unmasked')[0],
unbilled_legal_fees:$('#'+uid+' .atp_unsecured_atp_template_civil_action_unbilled_legal_fees').maskMoney('unmasked')[0],
legal_status:$('#'+uid+' .atp_unsecured_atp_template_civil_action_legal_status').val(),
legal_status_date:moment($('#'+uid+' .atp_unsecured_atp_template_civil_action_legal_status_date').val(),momentDateFormat).format(momentSqlDateFormat),
creditor_petition_filed_date:moment($('#'+uid+' .atp_unsecured_atp_template_civil_action_creditor_petition_filed').val(),momentDateFormat).format(momentSqlDateFormat),
adj_receive_order_date:moment($('#'+uid+' .atp_unsecured_atp_template_civil_action_aoro_date').val(),momentDateFormat).format(momentSqlDateFormat),
proof_of_debt_date:moment($('#'+uid+' .atp_unsecured_atp_template_civil_action_pod_date').val(),momentDateFormat).format(momentSqlDateFormat),
aoro_date:moment($('#'+uid+' .atp_unsecured_atp_template_civil_action_aoro_by_3rd_party').val(),momentDateFormat).format(momentSqlDateFormat),
law_firm_name:$('#'+uid+' .atp_unsecured_atp_template_civil_action_law_firm_name').val(),
lawyer_reference_no:$('#'+uid+' .atp_unsecured_atp_template_civil_action_lawyer_reference_number').val(),
summon_no:$('#'+uid+' .atp_unsecured_atp_template_civil_action_summon_number').val(),
//Section E
ctos:$('#'+uid+' .atp_unsecured_atp_template_bureau_check_ctos').val(),
ramci:$('#'+uid+' .atp_unsecured_atp_template_bureau_check_ramci').val(),
code_4028:$('#'+uid+' .atp_secured_atp_template_bureau_check_code_4028').maskMoney('unmasked')[0],
provision_misc:$('#'+uid+' .atp_secured_atp_template_bureau_check_provision_misc').maskMoney('unmasked')[0],
sales_order_date:$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_sales_order_date').val(),
auction_date:$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auction_date').val(),
reserved_price:$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_reserved_price').maskMoney('unmasked')[0],
no_of_past_auction:$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_no_of_past_auction').val(),
auction_off_date:moment($('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auction_off_date').val(),momentDateFormat).format(momentSqlDateFormat),
auctioned_selling_price:$('#'+uid+' .atp_secured_atp_template_legal_status_foreclosure_auctioned_selling_price').maskMoney('unmasked')[0],
summon_filling_date:$('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_summon_filling_date').val(),
judgement_date:$('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_judgement_date').val(),
execution_mode:$('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_execution_mode').val(),
model:$('#'+uid+' .atp_secured_atp_template_collateral_vehicle_model').val(),
vehicle_market_value:$('#'+uid+' .atp_secured_atp_template_collateral_vehicle_market_value').maskMoney('unmasked')[0],
//Section F
principal_total_os:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_total_os').maskMoney('unmasked')[0],
principal_proposed_sum:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_proposed_sum').maskMoney('unmasked')[0],
principal_waiver:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver').maskMoney('unmasked')[0],
principal_waiver_percentage:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_principal_waiver_percent').maskMoney('unmasked')[0],
interest_total_os:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_total_os').maskMoney('unmasked')[0],
interest_proposed_sum:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum').maskMoney('unmasked')[0],
interest_waiver:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver').maskMoney('unmasked')[0],
interest_waiver_percentage:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent').maskMoney('unmasked')[0],
misc_total_os:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_total_os').maskMoney('unmasked')[0],
misc_proposed_sum:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_proposed_sum').maskMoney('unmasked')[0],
misc_waiver:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver').maskMoney('unmasked')[0],
misc_waiver_percentage:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_misc_waiver_percent').maskMoney('unmasked')[0],
compensation_total_os:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_total_os').maskMoney('unmasked')[0],
compensation_proposed_sum:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_proposed_sum').maskMoney('unmasked')[0],
compensation_waiver:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver').maskMoney('unmasked')[0],
compensation_waiver_percentage:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_late_payment_waiver_percent').maskMoney('unmasked')[0],
unbill_legal_total_os:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_total_os').maskMoney('unmasked')[0],
unbill_legal_proposed_sum:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_proposed_sum').maskMoney('unmasked')[0],
unbill_legal_waiver:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver').maskMoney('unmasked')[0],
unbill_legal_waiver_percentage:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_unbill_legal_waiver_percent').maskMoney('unmasked')[0],
total_total_os:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_total_os').maskMoney('unmasked')[0],
total_proposed_sum:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_proposed_sum').maskMoney('unmasked')[0],
total_waiver:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver').maskMoney('unmasked')[0],
total_waiver_percentage:$('#'+uid+' .atp_unsecured_atp_template_composition_of_waiver_total_waiver_percent').maskMoney('unmasked')[0],
profit_charges_1:$('#'+uid+' .atp_unsecured_atp_template_profit_charges_1').maskMoney('unmasked')[0],
profit_charges_2:$('#'+uid+' .atp_unsecured_atp_template_profit_charges_2').maskMoney('unmasked')[0],
projected_late_payment_1:$('#'+uid+' .atp_unsecured_atp_template_projected_late_payment_1').maskMoney('unmasked')[0],
projected_late_payment_2:$('#'+uid+' .atp_unsecured_atp_template_projected_late_payment_2').maskMoney('unmasked')[0],
agency_fee_rate_1:$('#'+uid+' .atp_unsecured_atp_template_agency_fee_rate_1').maskMoney('unmasked')[0],
agency_fee_rate_2:$('#'+uid+' .atp_unsecured_atp_template_agency_fee_rate_2').maskMoney('unmasked')[0],
net_charge_off_amount_1:$('#'+uid+' .atp_unsecured_atp_template_net_charge_off_amount_1').maskMoney('unmasked')[0],
settlement_proposal:$('#'+uid+' .atp_unsecured_atp_template_settlement_proposal').maskMoney('unmasked')[0],
// atp_unsecured_atp_template_composition_of_waiver_interest_total_os
// atp_unsecured_atp_template_composition_of_waiver_interest_proposed_sum
// atp_unsecured_atp_template_composition_of_waiver_interest_waiver
// atp_unsecured_atp_template_composition_of_waiver_interest_waiver_percent
//Section H
judgement_total_os:$('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_total_os').maskMoney('unmasked')[0],
judgement_proposed_sum:$('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_proposed_sum').maskMoney('unmasked')[0],
judgement_waiver:$('#'+uid+' .atp_secured_atp_template_judgment_computation_judgement_waiver').maskMoney('unmasked')[0],
h_interest_total_os:$('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_total_os').maskMoney('unmasked')[0],
h_interest_proposed_sum:$('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_proposed_sum').maskMoney('unmasked')[0],
h_interest_waiver:$('#'+uid+' .atp_secured_atp_template_judgment_computation_interest_waiver').maskMoney('unmasked')[0],
cost_awarded_total_os:$('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_total_os').maskMoney('unmasked')[0],
cost_awarded_proposed_sum:$('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_proposed_sum').maskMoney('unmasked')[0],
cost_awarded_waiver:$('#'+uid+' .atp_secured_atp_template_judgment_computation_cost_awarded_waiver').maskMoney('unmasked')[0],
payment_compensation_total_os:$('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_total_os').maskMoney('unmasked')[0],
payment_compensation_proposed_sum:$('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_proposed_sum').maskMoney('unmasked')[0],
payment_compensation_waiver:$('#'+uid+' .atp_secured_atp_template_judgment_computation_payment_compensation_waiver').maskMoney('unmasked')[0],
os_balance_total_os:$('#'+uid+' .atp_secured_atp_template_judgment_computation_os_balance_total_os').maskMoney('unmasked')[0],
os_balance_proposed_sum:$('#'+uid+' .atp_secured_atp_template_judgment_computation_os_balance_proposed_sum').maskMoney('unmasked')[0],
//Section G
is_partial_write_off:$('#'+uid+' .atp_secured_atp_template_basis_is_partial_write_off').prop("checked") ? 1:0,
comments:$('#'+uid+' .atp_unsecured_atp_template_basis_comments').val(),
//Approval Section
created_by:$('#'+uid+' .atp_unsecured_atp_template_created_by').val(),
created_by_id:$('#'+uid+' .atp_unsecured_atp_template_created_by').attr('volare-collector_user_id'),
// created_by_name:$('#'+uid+' .atp_unsecured_atp_template_created_by').val(),
reviewed_by:$('#'+uid+' select.atp_unsecured_atp_template_review_decision_by option:selected').text(),
reviewed_by_id:$('#'+uid+' select.atp_unsecured_atp_template_review_decision_by').val(),
// reviewed_by_name:$('#'+uid+' .atp_unsecured_atp_template_review_decision_by option:selected').text(),
reviewed_by_decision:$('#'+uid+' .atp_unsecured_atp_template_review_decision').val(),
// reviewed_by_decision_date:$('#'+uid+' .atp_unsecured_atp_template_review_decision_date').val(),
reviewed_by_decision_date:'null',
reviewed_by_remark:$('#'+uid+' .atp_unsecured_atp_template_review_remarks').val(),
atp_status: mode == "draft" ? '4' : '0' ,
};
if(enable_atp_letter_offer){
atp_history.contact_number_id = $('#'+uid+' .atp_unsecured_atp_letter_offer_contact_number').val();
}
if(enable_irl_inquiry_atp){
if(mode == "submit"){
atp_history.irl_inquiry = global.debtordata[debtor_id].irl_inquiry;
atp_history.irl_inquiry_retrieval_date = global.debtordata[debtor_id].irl_inquiry_retrieval_date;
}
atp_history.irl_inquiry_remark = $('#'+uid+' .atp_unsecured_atp_template_irl_inquiry_remark').val();
}
if(enable_ge_enhancement){
atp_history.email_validity = '0';
atp_history.email_validity_failed_reason = 'null';
atp_history.email_validity_sent_datetime = 'null';
atp_history.email_validity_result_datetime = 'null';
if(atp_history.email_address != null && atp_history.email_address != ''){
atp_history.email_validity = $('#'+uid+' .atp_unsecured_atp_template_submit').attr('volare-email_status');
atp_history.email_validity_failed_reason = $('#'+uid+' .atp_unsecured_atp_template_submit').attr('volare-email_validity_failed_reason');
atp_history.email_validity_sent_datetime = $('#'+uid+' .atp_unsecured_atp_template_submit').attr('volare-email_validity_sent_datetime');
atp_history.email_validity_result_datetime = $('#'+uid+' .atp_unsecured_atp_template_submit').attr('volare-email_validity_result_datetime');
}
}
if(global.general.atp_uid[uid] == 'secured'){
atp_history.creditor_petition_filed_date = $('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_creditor_petition_filed_date').val();
atp_history.adj_receive_order_date = $('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_adj_receive_order_date').val();
atp_history.proof_of_debt_date = $('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_proof_of_debt_date').val();
atp_history.aoro_date = $('#'+uid+' .atp_secured_atp_template_legal_status_civil_action_aoro_date').val();
}
var atp_relationship_section = [];
$('#'+uid+' .atp_secured_atp_template_customer_list').each(function(index, el) {
atp_relationship_section.push({
relation_name:$(el).find('.atp_secured_atp_template_customer_list_relation_name').val(),
is_connected_party:$(el).find('.atp_secured_atp_template_customer_list_connected_party').prop("checked") ? 1:0,
relationship:$(el).find('select.atp_secured_atp_template_customer_list_relationship').val(),
is_guarantor:0,
});
});
$('#'+uid+' .atp_secured_atp_template_guarantor_list').each(function(index, el) {
atp_relationship_section.push({
relation_name:$(el).find('.atp_secured_atp_template_guarantor_list_relation_name').val(),
is_connected_party:$(el).find('.atp_secured_atp_template_guarantor_list_connected_party').prop("checked") ? 1:0,
relationship:$(el).find('select.atp_secured_atp_template_guarantor_list_relationship').val(),
is_guarantor:1,
});
});
var atp_account_list_section = [];
$('#'+uid+' .atp_unsecured_atp_template_short_fall').each(function(index, el) {
atp_account_list_section.push({
debtor_id:$(el).attr('volare-debtor_id'),
account:$(el).attr('volare-account'),
card_no:$(el).attr('volare-card_no'),
account_status:$(el).attr('volare-account_status'),
since:$(el).attr('volare-charge_off_date'),
short_non_clean:$(el).val(),
});
});
var atp_tiering_info_section = global.general.atp_tier[uid];
// $('#'+uid+' .atp_unsecured_atp_template_payment_term_total_instalment_payment_tier_row').each(function(index, el) {
// atp_tiering_info_section.push({
// tier:$(el).find('select.atp_unsecured_atp_template_payment_term_tier').val(),
// first_payment_date:moment($(el).find('.atp_unsecured_atp_template_payment_term_first_payment_date').val(),momentDateFormat).format(momentSqlDateFormat),
// last_payment_date:moment($(el).find('.atp_unsecured_atp_template_payment_term_last_payment_date').val(),momentDateFormat).format(momentSqlDateFormat),
// tenure:$(el).find('.atp_unsecured_atp_template_payment_term_tenure').val(),
// installment_payment_amount:$(el).find('.atp_unsecured_atp_template_payment_term_instalment_amount').maskMoney('unmasked')[0],
// remarks:$(el).find('.atp_unsecured_atp_template_payment_term_remarks').val(),
// indicator_to_stop_legal:$(el).find('.atp_unsecured_atp_template_payment_term_stop_legal').prop("checked") ? 0:1,
// });
// });
var atp_properties_section = [];
$('#'+uid+' .atp_secured_atp_template_collateral_properties_list').each(function(index, el) {
atp_properties_section.push({
address_line:$(el).find('.atp_secured_atp_template_collateral_properties_property_address').val(),
valuation_date:$(el).find('.atp_secured_atp_template_collateral_properties_valuation_date').val(),
market_value:$(el).find('.atp_secured_atp_template_collateral_properties_market_value').maskMoney('unmasked')[0],
});
});
// var vehicle_model = $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_model').val();
// var vehicle_market_value = $('#'+uid+' .atp_secured_atp_template_collateral_vehicle_market_value').val();
// if(vehicle_model != '' || vehicle_market_value != ''){
// atp_properties_section.push({
// model:vehicle_model,
// vehicle_market_value:vehicle_market_value,
// });
// }
var atp_existing_account_section = [];
$('#'+uid+' .atp_unsecured_atp_template_existing_acount_row').each(function(index, el) {
atp_existing_account_section.push({
debtor_id:$(el).attr('volare-debtor_id'),
client_screen:$(el).attr('volare-client_screen'),
facility_type:$(el).find('.atp_unsecured_atp_template_existing_acount_facility_type').val(),
limit_amount:$(el).find('.atp_unsecured_atp_template_existing_acount_limit_amount').maskMoney('unmasked')[0],
total_due:$(el).find('.atp_unsecured_atp_template_existing_acount_total_due').maskMoney('unmasked')[0],
late_payment_charges:$(el).find('.atp_unsecured_atp_template_existing_acount_late_payment_charge').maskMoney('unmasked')[0],
profit_charges:$(el).find('.atp_unsecured_atp_template_existing_acount_finance_profit_charges').maskMoney('unmasked')[0],
misc_charges:$(el).find('.atp_unsecured_atp_template_existing_acount_others_misc_charges').maskMoney('unmasked')[0],
unbill_legal:$(el).find('.atp_unsecured_atp_template_existing_acount_unbill_legal').maskMoney('unmasked')[0],
total_outstanding_balance:$(el).find('.atp_unsecured_atp_template_existing_acount_total_outstanding_balance').maskMoney('unmasked')[0],
balance:$(el).find('.atp_unsecured_atp_template_existing_acount_total_outstanding_balance').attr('volare-debtor_balance'),
approved_loan_date:$(el).find('.atp_unsecured_atp_template_existing_acount_drawdown_date').val(),
arrears_month:$(el).find('.atp_unsecured_atp_template_existing_acount_mia').val(),
overdue_term:$(el).find('.atp_unsecured_atp_template_existing_acount_instalment_in_arrears').maskMoney('unmasked')[0],
last_billed_late_charge:$(el).find('.atp_unsecured_atp_template_existing_acount_lpi').maskMoney('unmasked')[0],
// total_due:$(el).find('.atp_unsecured_atp_template_existing_acount_total_arrears').val(),
});
});
var atp_approval_decision = [];
$.each(global.general.atp_decision[uid],function(index, el) {
atp_approval_decision.push({
// activity:el.activity_id,
activity:el.activity,
decision_by:el.decision_by,
decision_by_id:el.decision_by_id,
decision:el.decision,
decision_date:'null',
remark:el.remark,
});
});
// console.log(atp_approval_decision,atp_existing_account_section,atp_tiering_info_section,atp_account_list_section,atp_history);
var atp = {
atp_history:atp_history,
atp_relationship_section:atp_relationship_section,
atp_properties_section:atp_properties_section,
atp_account_list_section:atp_account_list_section,
atp_tiering_info_section:atp_tiering_info_section,
atp_existing_account_section:atp_existing_account_section,
atp_approval_decision:atp_approval_decision,
};
if(atp_history_id != false){
atp.atp_history_id = atp_history_id;
}
// console.log(atp);
volareApi("createATP",{action: 'createATP',debtor_id:debtor_id,atp:atp,},{uid:uid});
}
function viewMOA(uid,debtor_id,moa_history_id){
volareApi("viewMOA",{action: 'viewMOA',debtor_id:debtor_id,moa:{id:moa_history_id},},{uid:uid});
}
function viewATPB(uid,debtor_id,moa_history_id){
volareApi("viewATPB",{action: 'viewATPB',debtor_id:debtor_id,moa:{id:moa_history_id},},{uid:uid});
}
function viewATP(uid,debtor_id,atp_history_id){
volareApi("viewATP",{action: 'viewATP',debtor_id:debtor_id,atp:{id:atp_history_id},},{uid:uid});
}
function getFvStatus(fv_status){
var result = "";
switch(fv_status){
case "0":
result = "requested";
break;
case "1":
result = "approved";
break;
case "2":
result = "assigned";
break;
case "3":
result = "aborted";
break;
case "4":
result = "rejected";
break;
case "5":
result = "completed";
break;
default:break;
}
return result;
}
function checkGIGTimeSlot(){
var result = false;
$.each(global.general.gig_user_time_slot,function(index, el) {
// console.log('checking gig time....');
// console.log(el.start_date_time,el.end_date_time,moment().isBetween(el.start_date_time, el.end_date_time));
if(moment().isBetween(el.start_date_time, el.end_date_time)){
result = true;
}
});
return result;
}
function checkGIGPredictiveTimeExceeded(){
var result = false;
if(enable_gig_workforce && global.access.is_gig_workforce_enabled != null && global.access.is_gig_workforce_enabled == "1"){
if(!global.predictive_dispo){
if(!checkGIGTimeSlot()){
global.vicidial_i.retry_count = 0;
swal({
title:lang.lang_reminder,
html:lang.lang_you_have_reached_the_end_of_slot,
confirmButtonColor: '#3085d6',
confirmButtonText: lang.lang_ok,
});
$('.main_predictive_disconnect').click();
result = true;
}
}
}
return result;
}
function intercomEndedProcess(e,session){
var uid = session.data.volareuid;
ringtone.pause();
var timespan = stopIntercomCallDurationCounter(uid);
global.calldata[uid].timespan = timespan;
global.calldata[uid].callstoptime = moment().format('YYYY-MM-DD HH:mm:ss');
if(global.general.intercom_call[uid] !== undefined && global.general.intercom_call[uid].notify !== undefined){
global.general.intercom_call[uid].notify.close();
busynow('iamfree');
}
dialerlog = {
debtorId: 0,
telNo: global.calldata[uid].destinationNumber,
callouttime: global.calldata[uid].callstarttime,
hanguptime: global.calldata[uid].callstoptime,
phonenumber: global.calldata[uid].destinationNumber,
dialerremark: "",
timespan: global.calldata[uid].timespan,
dialercalltype: 2,
flagpredictive: 0,
isPredictive:0,
sipcallid: global.calldata[uid].sipcallid,
talktime: global.calldata[uid].callansweredtime,
};
volareApi("dialerLogEntry",{action: 'dialerLogEntry',debtor_id:0,dialerlog:dialerlog});
appendCallLog(0,0,global.calldata[uid].destinationNumber,global.calldata[uid].calltype,global.calldata[uid].callstarttime,global.calldata[uid].timespan);
//tobeverify
if(global.calldata[uid] != null && global.calldata[uid].pretransfer_mode){
busynow('iamfree');
}
document.getElementById("intercom_audio_remote").srcObject = null;
global.sipIntercomOutgoingSession = null;
}
function manualCallEndedProcess(e,session){
console.log(e.cause);
var uid = session.data.volareuid;
var local_cause = '';
switch(e.cause){
case JsSIP.C.causes.CANCELED:
local_cause = "487";
break;
case JsSIP.C.causes.BUSY:
case JsSIP.C.causes.REJECTED:
local_cause = "486";
break;
case JsSIP.C.causes.NOT_FOUND:
local_cause = "404";
break;
case JsSIP.C.causes.UNAVAILABLE:
local_cause = "503";
break;
default:break;
}
callTerminateProcess(uid,"outgoing");
if(!global.calldata[uid].has_pre_cause_code){
preselectRPCByCauseCodev2(uid,local_cause);
// preselectRPCByCauseCodev2(uid,e.getSipResponseCode());
}
document.getElementById("audio_remote").srcObject = null;
global.sipOutgoingSession = null;
}
function incomingEndedProcess(e,session){
var uid = session.data.volareuid;
callTerminateProcess(uid,"incoming");
var call_type = 1;
if(!global.calldata[uid]['answered']){
call_type = 4;
}
dialerlog = {
debtorId: 0,
telNo: global.calldata[uid].destinationNumber,
callouttime: global.calldata[uid].callstarttime,
hanguptime: moment().format('YYYY-MM-DD HH:mm:ss'),
phonenumber: global.calldata[uid].destinationNumber,
dialerremark: "",
timespan: global.calldata[uid].timespan,
dialercalltype: call_type,
flagpredictive: 0,
isPredictive:0,
sipcallid: global.calldata[uid].sipcallid,
talktime: global.calldata[uid].callansweredtime,
};
global.incoming_call_ended = true;
if(call_type == 4){
volareApi("dialerLogEntry",{action: 'dialerLogEntry',debtor_id:0,dialerlog:dialerlog});
appendCallLog(0,0,global.calldata[uid].destinationNumber,call_type,global.calldata[uid].callstarttime,global.calldata[uid].timespan);
}
}
function prepareIncomingHandlers(){
global.sipIncomingSession.on("accepted",function(e){
console.log(e);
console.log(this);
// the call has answered
var uid = this.data.volareuid;
global.incoming_call_ended = false;
global.calldata[uid]['answered'] = true;
global.calldata[uid]['callansweredtime'] = moment().format('YYYY-MM-DD HH:mm:ss');
setMainStatus(words('lang_incoming_call','number',maskNumberAdditional(global.calldata[uid].destinationNumber)));
ringtone.pause();
startIncomingCallDurationCounter(uid);
// this.connection.ontrack = function(e) {
// console.log(e);
// document.getElementById("audio_remote").srcObject = e.streams[0];
// }
// this.connection.addEventListener("track", e => {
// console.log(e);
// document.getElementById("audio_remote").srcObject = e.streams[0];
// }, false);
});
global.sipIncomingSession.on("ended",function(e){
console.log(e);
incomingEndedProcess(e,this);
});
global.sipIncomingSession.on("failed",function(e){
console.log(e);
incomingEndedProcess(e,this);
});
global.sipIncomingSession.on("sdp",function(e) {
console.log(e);
this.connection.ontrack = function(e) {
console.log(e);
document.getElementById("audio_remote").srcObject = e.streams[0];
}
});
}
function prepareIncomingIntercomHandlers(){
global.sipIncomingSession.on("accepted",function(e){
console.log(e);
var uid = this.data.volareuid;
startIntercomCallDurationCounter(uid);
global.calldata[uid].callansweredtime = moment().format('YYYY-MM-DD HH:mm:ss');
global.calldata[uid].answered = true;
ringtone.pause();
// global.sipIncomingSession.connection.ontrack = function(e) {
// console.log(e);
// document.getElementById("audio_remote").srcObject = e.streams[0];
// }
});
global.sipIncomingSession.on("ended",function(e){
console.log(e);
intercomEndedProcess(e,this);
global.sipIncomingSession = null;
});
global.sipIncomingSession.on("failed",function(e){
console.log(e);
intercomEndedProcess(e,this);
global.sipIncomingSession = null;
});
global.sipIncomingSession.on("sdp",function(e) {
console.log(e);
this.connection.ontrack = function(e) {
console.log(e);
document.getElementById("audio_remote").srcObject = e.streams[0];
}
});
}
function getHeaderValue(data_array){
var result = "";
$.each(data_array,function(index, el) {
if(el != null && el != ""){
result = el;
return false;
}
});
return result;
}
function appendPredictiveTimeoutLog(data){
var old = localStorage.getItem('predictive_timeout_log');
if(old === null) old = "";
if(old != '')
data = old +"\r\n"+ data;
localStorage.setItem('predictive_timeout_log', data);
}
function clearPredictiveTimeoutLog(){
localStorage.setItem('predictive_timeout_log','Predictive Timeout Log for '+global.general.collector_extension+'');
}
function downloadPredictiveTimeoutLog(){
const data = localStorage['predictive_timeout_log'];
const datablob = new Blob([data], {type: 'text/plain'});
const downloadLink = document.getElementById('predictive_timeout_log_download');
downloadLink.download = 'predictive_timeout_log.txt';
if (window.URL !== null) {
// Chrome allows the link to be clicked without actually adding it to the DOM
downloadLink.href = window.URL.createObjectURL(datablob);
downloadLink.target = `_blank`;
} else {
downloadLink.href = window.URL.createObjectURL(datablob);
downloadLink.target = `_blank`;
downloadLink.style.display = 'none';
// add .download so works in Firefox desktop.
document.body.appendChild(downloadLink.download);
}
downloadLink.click();
}
function appendPredictiveFullLog(data){
var old = localStorage.getItem('predictive_full_log');
if(old === null) old = "";
if(old != '')
data = old +"\r\n"+moment().format(momentSqlDateTimeSecondFormat)+" - "+ data;
localStorage.setItem('predictive_full_log', data);
}
function clearPredictiveFullLog(){
localStorage.setItem('predictive_full_log','Predictive Full Log for '+global.general.collector_extension+'');
}
function downloadPredictiveFullLog(){
const data = localStorage['predictive_full_log'];
const datablob = new Blob([data], {type: 'text/plain'});
const downloadLink = document.getElementById('predictive_timeout_log_download');
downloadLink.download = 'predictive_full_log.txt';
if (window.URL !== null) {
// Chrome allows the link to be clicked without actually adding it to the DOM
downloadLink.href = window.URL.createObjectURL(datablob);
downloadLink.target = `_blank`;
} else {
downloadLink.href = window.URL.createObjectURL(datablob);
downloadLink.target = `_blank`;
downloadLink.style.display = 'none';
// add .download so works in Firefox desktop.
document.body.appendChild(downloadLink.download);
}
downloadLink.click();
}
function changeTableToDevExtreme(el,debtor_id){
var debtor = {id:debtor_id};
var headers = [];
var header_index = null;
headers.push({caption: 'No.',dataType: "number",allowReordering:false,sortIndex: 0,width:"auto",alignment:"right",cellTemplate: function(cellElement, cellInfo) {cellElement.text(cellElement.parent().attr('aria-rowIndex')-cellElement.parent().prevAll('.dx-group-row').length);}});
$(el).find('thead > tr > th').each(function(iindex,eel){
if($(eel).text() == "No."){
header_index = iindex;
if($(eel).hasClass('dxtable_fixed_left')){
headers[0]['fixed'] = true;
headers[0]['fixedPosition'] = "left";
}
return true;
}
var dxtable_field = $(this).attr('volare-dxtable_field');
var this_row = {};
var datatype = "string";
var format = "";
var cellTemplate = "";
var customizeText = "";
var alignment = "left";
var allowSearch = true;
var allowFiltering = true;
var fixedPosition = "";
if($(eel).hasClass('dxtable_date')){
datatype = "date";
format = devextremeDateFormat;
}
if($(eel).hasClass('dxtable_datetime')){
datatype = "datetime";
format = devextremeDateTimeFormat;
}
if($(eel).hasClass('dxtable_mask_phone')){
customizeText = function(row) {
return maskNumber(row.valueText);
};
}
if($(eel).hasClass('dxtable_sms_inbox_status')){
customizeText = function(row) {
switch(row.value){
case '0':
row.valueText = 'UNREAD';
break;
case '1':
row.valueText = 'READ';
break;
default:break;
}
return row.valueText;
};
}
if($(eel).hasClass('dxtable_sms_outbox_status')){
customizeText = function(row) {
switch(row.value){
case '0':
row.valueText = 'PENDING';
break;
case '1':
row.valueText = 'DELIVERED';
break;
case '3':
row.valueText = 'FAILED';
break;
case '4':
row.valueText = 'SENT';
break;
case '5':
row.valueText = 'CANCELLED';
break;
case '6':
row.valueText = 'QUEUED';
break;
case '7':
row.valueText = 'UNDELIVERED';
break;
case '8':
row.valueText = 'REJECTED';
break;
case '9':
row.valueText = 'EXPIRED';
break;
default:break;
}
return row.valueText;
};
}
if($(eel).hasClass('dxtable_sms_outbox_vendor')){
customizeText = function(row) {
switch(row.value){
case '2':
row.valueText = 'Infobip';
break;
case '4':
row.valueText = 'Stampede';
break;
default:
row.valueText = 'M3tech';
break;
}
return row.valueText;
};
}
if($(eel).hasClass('debtor_detail_moa_edit')){
// console.log('nuha');
alignment = "center";
allowSearch = false;
allowFiltering = false;
cellTemplate = function(cellElement, cellInfo) {
// console.log(cellInfo);
var ids = cellInfo.value.split(',');
// if(Number(global.access.ATP_calculator) >= 3){
if(Number(global.access.ATP_calculator) >= 1){
cellElement.append(' ');
}else{
cellElement.append('');
}
};
}
if($(eel).hasClass('debtor_detail_atpb_edit')){
// console.log('nuha');
alignment = "center";
allowSearch = false;
allowFiltering = false;
cellTemplate = function(cellElement, cellInfo) {
// console.log(cellInfo);
var ids = cellInfo.value.split(',');
// if(Number(global.access.ATP_calculator) >= 3){
if(Number(global.access.ATP_calculator) >= 1){
cellElement.append(' ');
}else{
cellElement.append('');
}
};
}
if($(eel).hasClass('debtor_detail_atp_edit')){
// console.log('nuha');
alignment = "center";
allowSearch = false;
allowFiltering = false;
cellTemplate = function(cellElement, cellInfo) {
// console.log(cellInfo);
var ids = cellInfo.value.split(',');
// if(Number(global.access.ATP_calculator) >= 3){
if(Number(global.access.ATP_calculator) >= 1){
cellElement.append(' ');
}else{
cellElement.append('');
}
};
}
if($(eel).hasClass('debtor_detail_atp_delete')){
// console.log('nuha');
alignment = "center";
allowSearch = false;
allowFiltering = false;
cellTemplate = function(cellElement, cellInfo) {
// console.log(cellInfo);
var ids = cellInfo.value.split(',');
if(Number(global.access.ATP_calculator) >= 4){
cellElement.append(' ');
}else{
cellElement.append('');
}
};
}
if($(eel).hasClass('debtor_detail_complaint_edit')){
// console.log('nuha');
alignment = "center";
allowSearch = false;
allowFiltering = false;
cellTemplate = function(cellElement, cellInfo) {
// console.log(cellInfo);
var ids = cellInfo.value.split(',');
// if(Number(global.access.ATP_calculator) >= 3){
// if(Number(global.access.ATP_calculator) >= 1){
cellElement.append(' ');
// }else{
// cellElement.append('');
// }
};
}
if($(eel).hasClass('debtor_detail_complaint_delete')){
// console.log('nuha');
alignment = "center";
allowSearch = false;
allowFiltering = false;
cellTemplate = function(cellElement, cellInfo) {
// console.log(cellInfo);
var ids = cellInfo.value.split(',');
// if(Number(global.access.ATP_calculator) >= 4){
cellElement.append(' ');
// }else{
// cellElement.append('');
// }
};
}
if($(eel).hasClass('debtor_detail_jump_to_debtor')){
// console.log('nuha');
cellTemplate = function(cellElement, cellInfo) {
// console.log(cellInfo);
cellElement.append(' ');
};
}
if($(eel).hasClass('debtor_detail_jump_to_debtor_secondary_ic_employment_history')){
// console.log('nuha');
cellTemplate = function(cellElement, cellInfo) {
// console.log(cellInfo);
cellElement.append(' ');
};
}
if($(eel).hasClass('dxtable_module_type_id')){
customizeText = function(row) {
switch(row.value){
case "1":
row.valueText = lang.lang_followup;
break;
case "2":
row.valueText = lang.lang_internal_remark;
break;
case "3":
row.valueText = lang.lang_payment;
break;
case "4":
row.valueText = lang.lang_sms;
break;
case "5":
row.valueText = lang.lang_fieldvisit;
break;
case "6":
row.valueText = lang.lang_legal;
break;
case "7":
row.valueText = lang.lang_letter;
break;
case "8":
row.valueText = lang.lang_work_collection_file;
break;
case "9":
row.valueText = lang.lang_permanent_message;
break;
case "10":
row.valueText = lang.lang_electronic_diary;
break;
case "11":
row.valueText = lang.lang_escalation;
break;
case "13":
row.valueText = lang.lang_voicebot;
break;
default:break;
}
return row.valueText;
};
}
if($(eel).hasClass('dxtable_call_type')){
customizeText = function(row) {
switch(row.value){
case "1":
row.valueText = lang.lang_incomingcall;
break;
case "2":
row.valueText = lang.lang_intercom;
break;
case "3":
row.valueText = lang.lang_outgoing_call_titleonly;
break;
case "4":
row.valueText = lang.lang_missed_call;
break;
case "5":
row.valueText = lang.lang_predictive_call;
break;
case "12":
row.valueText = lang.lang_voicebot;
break;
default:break;
}
return row.valueText;
};
}
this_row = {dataField:""+iindex,caption:$(eel).html(),cssClass:'font-weight-lighter',width:"auto",allowSearch:allowSearch,alignment:alignment,dataType:datatype,allowFiltering:allowFiltering,format:format,cellTemplate:cellTemplate,customizeText:customizeText};
if(dxtable_field != null && dxtable_field != '')
this_row['dataField'] = dxtable_field;
if(dxtable_field == "id"){
this_row['visible'] = false;
this_row['dataType'] = "number";
this_row['allowFiltering'] = false;
}
if(debtor_detail_hlb12){
if($(eel).hasClass('hlb12')){
this_row['visible'] = true;
}else if($(eel).hasClass('hlb11')){
this_row['visible'] = false;
}
}else{
if($(eel).hasClass('hlb12')){
this_row['visible'] = false;
}else if($(eel).hasClass('hlb11')){
this_row['visible'] = true;
}
}
if(disableCallStatus && $(eel).hasClass('general_callstatus_related')){
this_row['visible'] = false;
}
if($(eel).hasClass('dxtable_fixed_left')){
this_row['fixed'] = true;
this_row['fixedPosition'] = "left";
}
if($(eel).hasClass('dxtable_currency')){
this_row['dataType'] = "double";
this_row['alignment'] = "right";
this_row['customizeText'] = function(row) {return formatCurrency(row.valueText)}
}
if($(eel).hasClass('dxtable_percentage_4')){
this_row['dataType'] = "double";
this_row['alignment'] = "right";
this_row['customizeText'] = function(row) {return formatCurrency(row.valueText,4)}
}
if($(eel).hasClass('dxtable_timesecond')){
this_row['customizeText'] = function(row) {return formatDateTime(row.valueText,"timesecond")}
}
if($(eel).hasClass('dxtable_mpm')){
this_row['customizeText'] = function(row) {return maskManualNumber(row.valueText)}
}
if($(eel).hasClass('dxtable_sort_desc')){
this_row.sortOrder = "desc";
}else if($(eel).hasClass('dxtable_sort_asc')){
this_row.sortOrder = "asc";
}
headers.push(this_row);
});
var remoteOperations = {};
var scrolling = {};
var paging = {enabled:false};
var bodys = [];
var dxtable_target = $(el).attr('volare-dxtable_target');
var dxtable_master_detail = $(el).attr('volare-master_detail');
var dxtable_master_detail_enable = false;
if(dxtable_master_detail != null && dxtable_master_detail != '')
dxtable_master_detail_enable = true;
if(dxtable_target != null && dxtable_target != ''){
bodys = {
store: DevExpress.data.AspNet.createStore({
// key: "id",
loadUrl: "./volare_api.php",
loadMethod: "POST",
// insertUrl: url,
// updateUrl: url,
// deleteUrl: url
onBeforeSend: function(method, options) {
// options.data.color = global.filtercolor;
// var loadOptions =
options.data = {loadOptions:$.extend(true,{},options.data)};
switch(dxtable_target){
case "payment_cc":
options.data.section = 'payment';
options.data.params = {account:debtor.account,card_no:debtor.card_no,mode:'cc'};
break;
case "statement_cc":
options.data.section = 'statement';
options.data.params = {
account:debtor.account,
card_no:debtor.card_no,
last_purchase_date:debtor.last_purchase_date != null ? debtor.last_purchase_date : '',
last_purchase_amount:debtor.last_purchase_amount != null ? debtor.last_purchase_amount : '',
opening_total_debt:debtor.opening_total_debt,
mode:'cc'
}
break;
case "loan_rate_status":
options.data.section = 'payment';
options.data.params = {mode:'loan_rate_status'};
break;
case "loan_transaction_detail_od":
options.data.section = 'payment';
options.data.params = {mode:'loan_transaction_detail_od'};
break;
case "loan_transaction_detail_non_od":
options.data.section = 'payment';
options.data.params = {mode:'loan_transaction_detail_non_od'};
break;
case "loan_rewrite_history":
options.data.section = 'loan_rewrite_history';
options.data.params = {mode:'loan_rewrite_history'};
break;
case "statement_cc_archive":
options.data.section = 'statement_archive';
options.data.params = {mode:'cc_archive'};
break;
case "loan_transaction_detail_od_archive":
options.data.section = 'payment_archive_od';
options.data.params = {mode:'loan_transaction_detail_od_archive'};
break;
case "sms_history_cc_inbox":
options.data.section = 'sms_history';
options.data.params = {mode:'cc_inbox'}
break;
case "sms_history_cc_outbox":
options.data.section = 'sms_history';
options.data.params = {mode:'cc_outbox'}
break;
case "sms_history_loan_inbox":
options.data.section = 'sms_history';
options.data.params = {mode:'loan_inbox'}
break;
case "sms_history_loan_outbox":
options.data.section = 'sms_history';
options.data.params = {mode:'loan_outbox'}
break;
case "sms_history_dca_inbox":
options.data.section = 'sms_history';
options.data.params = {mode:'dca_inbox'};
break;
case "sms_history_dca_outbox":
options.data.section = 'sms_history';
options.data.params = {mode:'dca_outbox'};
break;
case "followup_history":
options.data.section = 'followup_history';
options.data.params = {mode:'followup_history'}
break;
case "email_history":
options.data.section = 'email_history';
options.data.params = {mode:'email_history'};
break;
case "payment_cc_rs":
options.data.section = 'payment';
options.data.params = {account:debtor.account,card_no:debtor.card_no,mode:'cc_rs'};
break;
case "loan_transaction_detail_od_rs":
options.data.section = 'payment';
options.data.params = {mode:'loan_transaction_detail_od_rs'};
break;
case "loan_transaction_detail_non_od_rs":
options.data.section = 'payment';
options.data.params = {mode:'loan_transaction_detail_non_od_rs'};
break;
case "property_collateral_history":
options.data.section = 'property_collateral_history';
options.data.params = {mode:'property_collateral_history'};
break;
default:break;
}
options.data.debtor_id = debtor.id;
options.data.action = 'getDebtorDetailInfo';
// console.log("aaa",options);
}
}),
// store :new DevExpress.data.CustomStore({
// load: function (loadOptions) {
// var deferred = $.Deferred(),
// args = {};
// loadOptions
// switch(dxtable_target){
// case "payment_cc":
// args.section = 'payment';
// args.params = {account:debtor.account,card_no:debtor.card_no,mode:'cc'};
// // if(loadOptions.sort == null){
// // loadOptions.sort = [{selector:'date',desc:true}];
// // }
// break;
// case "statement_cc":
// args.section = 'statement';
// args.params = {
// account:debtor.account,
// card_no:debtor.card_no,
// last_purchase_date:debtor.last_purchase_date,
// last_purchase_amount:debtor.last_purchase_amount,
// mode:'cc'
// }
// // if(loadOptions.sort == null){
// // loadOptions.sort = [{selector:'statement_date',desc:true}];
// // };
// break;
// default:break;
// }
// args.debtor_id = debtor.id;
// args.action = 'getDebtorDetailInfo';
// args.loadOptions = JSON.stringify(loadOptions);
// $.ajax({
// url: "./volare_api.php",
// dataType: "json",
// type:'POST',
// data: args,
// success: function(result) {
// deferred.resolve(result);
// },
// error: function() {
// deferred.resolve([], { totalCount: 0 });
// },
// });
// return deferred.promise();
// }
// }),
}
remoteOperations = {
filtering: true,
grouping: true,
groupPaging: true,
paging: true,
sorting: true,
summary: true
};
scrolling = {
mode: "virtual"
};
paging = {};
}else{
$(el).find('tbody > tr').each(function(iindex,eel){
var subbody = {};
$(eel).children().each(function(iiindex,eeel){
if(header_index != null && iiindex == header_index)
return true;
// subbody[headers[iiindex].dataField] = $(eeel).html();
subbody[iiindex] = $(eeel).html();
subbody[iiindex] = $('').html(subbody[iiindex]).val();
});
bodys.push(subbody);
});
}
$(el).dxDataGrid({
columns:headers,
dataSource:bodys,
onContentReady: function(e) {
// $(el).find('.dx-datagrid-table').addClass('table table-sm table-responsive-sm table-bordered mb-0 small text-truncate');
$(el).find('.dx-header-row').addClass('bg-light text-muted');
},
onCellPrepared: function (e) {
e.cellElement.addClass('pt-1 pb-1');
},
height: "300px",
showBorders:false,
showColumnLines:true,
searchPanel: { visible: true },
headerFilter: { visible: true },
filterRow: { visible: true },
paging:paging,
scrolling: scrolling,
sorting: {
mode: "multiple"
},
allowColumnReordering:true,
allowColumnResizing:true,
columnResizingMode:"widget",
columnChooser:{
enabled:true
},
remoteOperations: remoteOperations,
masterDetail : {
enabled : dxtable_master_detail_enable,
template : function(container , options) {
var finaldata = '';
switch(dxtable_master_detail){
case "loan_rewrite_history_listing":
var loan_rewrite_history_listing = "";
var loan_rewrite_history_listing_div = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'loan_rewrite_history_listing').html());
var loan_rewrite_history_listing_div_var = {};
loan_rewrite_history_listing_div_var = options.data;
loan_rewrite_history_listing += loan_rewrite_history_listing_div(loan_rewrite_history_listing_div_var);
finaldata = loan_rewrite_history_listing;
break;
default:break;
}
container.append(finaldata);
}
},
// summary: {
// totalItems: [
// {
// name: "totalrecordcount",
// displayFormat: "{0}",
// showInColumn: "#",
// summaryType: "count",
// }]
// }
});
// $('#'+uid+'_DebtorPage-content .dxtable .dx-header-row').addClass('bg-light text-muted');
}
function showPredictivePauseLogoutReasonModal(row_id,event_type){
if(global.general.pd_pause_logout_reason != null && global.general.pd_pause_logout_reason.length > 0){
var action_word = "";
var button_word = "";
switch(event_type){
case "pause":
action_word = lang.lang_reason_for_pause;
button_word = lang.lang_pause;
break;
case "logout":
action_word = lang.lang_reason_for_disconnect;
button_word = lang.lang_disconnect;
break;
default:break;
}
Swal.fire({
title: action_word,
text : lang.lang_please_state_your_reason,
imageUrl: 'images/campaign_pause.png',
html: global.general.predictive_pause_logout_reason_modal,
reverseButtons: true,
showCancelButton: enforce_predictive_pause_logout_reason ? false : true,
allowOutsideClick: enforce_predictive_pause_logout_reason ? false : true,
confirmButtonClass: 'ml-1 btn btn-primary',
cancelButtonClass: 'btn btn-light',
buttonsStyling: false,
confirmButtonText: button_word,
}).then((result) => {
if (result.value) {
var reason_id = $('select.predictive_pause_logout_reason_select').val();
var reason = $('select.predictive_pause_logout_reason_select option:selected').text();
volareApi("updatePredictivePauseLogoutReason", {action: 'updatePredictivePauseLogoutReason',predictiveinfo:{id:row_id,log_out_reason:reason,log_out_reason_id:reason_id}});
}
});
$('.predictive_pause_logout_reason_select').selectpicker({
liveSearch: true,
actionsBox: true,
selectedTextFormat: 'count > 3'
});
}
}
function insertPredictivePauseLogoutReason(campaign_id,event_type,reason,reason_id){
var event_datetime = moment().format(momentSqlDateTimeFormat);
var event_date = moment().format(momentSqlDateFormat);
volareApi("insertPredictivePauseLogoutReason", {action: 'insertPredictivePauseLogoutReason',predictiveinfo:{campaign_id:campaign_id,event_type:event_type,event_datetime:event_datetime,event_date:event_date,log_out_reason:reason,log_out_reason_id:reason_id}});
}
function checkProceedForAddSMSNumber(row){
var proceed_for_add_sms_number = true;
if(limitSMSContactType != null && limitSMSContactType.length > 0){
proceed_for_add_sms_number = false;
if(row.contact_number_type_name != null && row.contact_number_type_name != "" && limitSMSContactType.indexOf(row.contact_number_type_name) > -1 && (cleanNumber(row.ContactNo).substr(0,limitSMSContactRule.length) == limitSMSContactRule || cleanNumber(row.ContactNo).substr(0,limitSMSContactRuleWithCountryCode.length) == limitSMSContactRuleWithCountryCode)){
proceed_for_add_sms_number = true;
}
}
if(row.is_do_not_sms == "1")
proceed_for_add_sms_number = false;
// if(row.FlagContactable != 2)
// basevar.debtor_call_numbers += numbers(numvars);
if(debtor_detail_additional_logic == "bimb" && row.is_contact_number_from_client != "1")
proceed_for_add_sms_number = false;
return proceed_for_add_sms_number;
}
function updateUndisposedDialerLogSIPCALLID(uid){
if(enable_undisposed_dialer_log){
if(global.calldata[uid] != null && global.calldata[uid].sipcallid != null && global.calldata[uid].sipcallid != "" && global.calldata[uid].undisposed_dialer_log_id != null && global.calldata[uid].undisposed_dialer_log_id != ""){
volareApi("update_undisposed_dialer_log_sipcallid",{action:"updateUndisposedDialerLogSIPCALLID",debtor_id:global.calldata[uid].debtorId,additional_param:{sipcallid:global.calldata[uid].sipcallid,undisposed_dialer_log_id:global.calldata[uid].undisposed_dialer_log_id}});
}
}
}
function getUndisposedDialerLogAdditionalParam(call_type,targetnumber,sipcallid = "",agent_log_id = "",uid = ""){
var additional_param = {};
if(enable_undisposed_dialer_log){
if(call_type == "3" && global.sipstatus.manual != "registered")
return additional_param;
if(uid != null && uid != "" && global.calldata[uid].undisposed_dialer_log_id != null && global.calldata[uid].undisposed_dialer_log_id != ""){
additional_param.undisposed_dialer_log_id = global.calldata[uid].undisposed_dialer_log_id;
}
additional_param.call_type = call_type;
additional_param.contact_number = targetnumber;
additional_param.prefix = $('select.general_dial_prefix').val() != "" ?$('select.general_dial_prefix').val():"";
additional_param.sipcallid = sipcallid;
additional_param.agent_log_id = agent_log_id;
}
return additional_param;
}
function initWhatsappMessage(){
$('.general_main_whatsapp_chat_body_no_message').addClass('hideMe');
$('.general_main_whatsapp_chat_input').addClass('hideMe');
$('.general_main_whatsapp_chat_body_message').addClass('hideMe');
$('.general_main_whatsapp_chat_body_message').html('');
$('.general_main_whatsapp_chat_input_submit').attr('volare-debtor_id','');
$('.general_main_whatsapp_chat_input_submit').attr('volare-contact_number_id','');
$('.general_main_whatsapp_chat_input_submit').attr('volare-contact_number','');
$('.general_main_whatsapp_chat_input_submit').attr('volare-client_id','');
}
function appendWhatsappMessage(data){
console.log(data);
var general_main_whatsapp_chat_body_message = "";
var general_main_whatsapp_chat_body_message_recipient = Handlebars.compile($('#template-general_main_whatsapp_chat_body_message_recipient').html());
var general_main_whatsapp_chat_body_message_recipient_var = {};
var general_main_whatsapp_chat_body_message_sender = Handlebars.compile($('#template-general_main_whatsapp_chat_body_message_sender').html());
var general_main_whatsapp_chat_body_message_sender_var = {};
$.each(data,function(index, el) {
if(el.message_type == "0"){
general_main_whatsapp_chat_body_message_recipient_var = el;
general_main_whatsapp_chat_body_message += general_main_whatsapp_chat_body_message_recipient(general_main_whatsapp_chat_body_message_recipient_var);
}else if(el.message_type == "1"){
general_main_whatsapp_chat_body_message_sender_var = el;
general_main_whatsapp_chat_body_message += general_main_whatsapp_chat_body_message_sender(general_main_whatsapp_chat_body_message_sender_var);
}
});
// console.log(general_main_whatsapp_chat_body_message);
$('.general_main_whatsapp_chat_body_message').append(general_main_whatsapp_chat_body_message);
$('.general_main_whatsapp_chat_body_message').removeClass('hideMe');
$('.general_main_whatsapp_chat_input').removeClass('hideMe');
$('.general_main_whatsapp_chat_body_no_message').addClass('hideMe');
$('.general_main_whatsapp_chat_body_message_sender').tooltip({
trigger: 'hover'
});
setTimeout(function(){
$(".general_main_whatsapp_chat_section").animate({ scrollTop: $('.general_main_whatsapp_chat_section').prop("scrollHeight")}, 1000);
},1000);
}
function showMFAInitForm(data,mode = "init"){
var finaldata = "";
var mfa_first_time_screen = Handlebars.compile($('#template-mfa_first_time_screen').html());
var mfa_first_time_screen_var = {};
mfa_first_time_screen_var = data;
mfa_first_time_screen_var.lang = lang;
finaldata = mfa_first_time_screen(mfa_first_time_screen_var);
$('#login_base_placeholder').addClass('hideMe');
$('#change_password_placeholder').addClass('hideMe');
$('#mfa_placeholder').removeClass('hideMe');
$('#mfa_placeholder').html(finaldata);
// $('#login_base_placeholder').html(finaldata);
}
function showMFAVerificationForm(data,mode = "init"){
var finaldata = "";
var mfa_main_screen = Handlebars.compile($('#template-mfa_main_screen').html());
var mfa_main_screen_var = {};
// mfa_main_screen_var = data;
mfa_main_screen_var.lang = lang;
finaldata = mfa_main_screen(mfa_main_screen_var);
$('#login_base_placeholder').addClass('hideMe');
$('#change_password_placeholder').addClass('hideMe');
$('#mfa_placeholder').removeClass('hideMe');
$('#mfa_placeholder').html(finaldata);
// $('#login_base_placeholder').html(finaldata);
}
function login_google_mfa_verfication_submit(){
var code = $('.login_google_mfa_verfication_code').val();
var username = $('#login_username').val();
var password = $('#login_password').val();
var force_login = $('#login_force_login').val();
if($('#login_update_password_new_password_confirm').val() != null && $('#login_update_password_new_password_confirm').val() != ''){
password = $('#login_update_password_new_password_confirm').val();
}
if(code != ""){
volareApi("login",{action:"login",username:username,password:password,force_login:1,grace_login:1,mfa_info:{code:code}});
}
}
function processATPIrlTbodyUpdate(uid,debtor_id){
setInterval(function () {
if($('#'+uid+" .debtor_detail_as400_online_message_110436_atp_tbody").is(":visible") && $('#'+uid+" .debtor_detail_as400_online_message_110436_atp_tbody").attr('volare-irl_inquiry_refresh') == "1"){
$('#'+uid+" .debtor_detail_as400_online_message_110436_atp_tbody").html($('#'+uid+" .debtor_detail_as400_online_message_110436_tbody").html());
if(global.debtordata[debtor_id].irl_inquiry != null){
for (var i = 0; i < global.debtordata[debtor_id].irl_inquiry.length; i++) {
var row = global.debtordata[debtor_id].irl_inquiry[i];
var current_name = row.Name.replace(/[^a-z0-9]/gi, '').toLowerCase();
var proceed_to_toggle = false;
if(enable_irl_inquiry_atp_dynamic_connected_party){
var current_char_code = row.CharCode != null ?row.CharCode:'';
var target_char_codes = global.general.char_code_auto_cp_check.split(',');
if(current_char_code != '' && target_char_codes.includes(current_char_code)){
proceed_to_toggle = true;
}
}else{
proceed_to_toggle = true;
}
if(proceed_to_toggle){
$('#'+uid+" .atp_unsecured_atp_template_connected_party_"+current_name).bootstrapToggle("on");
$('#'+uid+" .atp_secured_atp_template_customer_list_connected_party_"+current_name).bootstrapToggle("on");
$('#'+uid+" .atp_secured_atp_template_guarantor_list_connected_party_"+current_name).bootstrapToggle("on");
}
}
}
$('#'+uid+" .atp_unsecured_atp_template_connected_party").prop('disabled',true);
$('#'+uid+" .atp_secured_atp_template_customer_list_connected_party").prop('disabled',true);
$('#'+uid+" .atp_secured_atp_template_guarantor_list_connected_party").prop('disabled',true);
}
}, 1000);
}
function process_temp_callback_view_limit(debtor_id,mode = "add"){
switch(mode){
case 'add':
if(global.general.debtor_temp_callback_view_limit[debtor_id] == null || global.general.debtor_temp_callback_view_limit[debtor_id] == ""){
volareApi("insertTempViewDebtorLogin",{action:"insertTempViewDebtorLogin",debtor_id:debtor_id});
// global.general.debtor_temp_callback_view_limit[debtor_id] = global.general.collector_user_id;
}else{
var current_report_id = $('.callback_incoming_call_search_submit').attr('volare-ivr_return_call_report_id');
if(current_report_id != null && current_report_id != "" && global.general.debtor_temp_callback_view_limit[debtor_id] != current_report_id){
global.general.debtor_temp_callback_view_limit[debtor_id] = current_report_id;
}
showDebtorSideBar(debtor_id);
showDebtorDetail(debtor_id);
}
break;
case 'delete':
if(global.general.debtor_temp_callback_view_limit[debtor_id] != null && global.general.debtor_temp_callback_view_limit[debtor_id] != ""){
volareApi("deleteTempViewDebtorLogin",{action:"deleteTempViewDebtorLogin",debtor_id:debtor_id});
}
break;
default:break;
}
}
function checkRequestCallbackLimitation(debtor_id){
var result = false;
// console.log(debtor_id);
// console.log(global.general.debtor_temp_callback_view_limit[debtor_id]);
if(enable_ivr_request_callback && global.access.is_request_call_back_restriction_enabled > 0){
if($('.general_dialer_modal_ivr_return_call_count').attr('volare-request_callback_count') > 0 && global.general.debtor_temp_callback_view_limit[debtor_id] == null){
notifyFailed(lang.lang_error,lang.lang_you_need_to_attend_to_the_request_call_back);
result = true;
}
}
return result;
}
function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
function displayDebtorDetailSavingInformationSection(uid,debtor){
var debtor_detail_saving_balance_information_section = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_saving_balance_information_section').html());
var debtor_detail_saving_balance_information_section_var = {};
debtor_detail_saving_balance_information_section_var.lang = lang;
debtor_detail_saving_balance_information_section_var.debtor = debtor;
// console.log(uid,debtor_detail_saving_balance_information_section(debtor_detail_saving_balance_information_section_var));
$('#'+uid+'_DebtorPage-content .debtor_detail_saving_balance_information_section').html(debtor_detail_saving_balance_information_section(debtor_detail_saving_balance_information_section_var));
$('#'+uid+'_DebtorPage-content .debtor_detail_customer_account_balance_info_requested_date').html(
getLanguageDateTime(debtor.account_balance_tws.created_at));
// console.log($('#'+uid+' .debtor_detail_saving_balance_information_section').html());
}
function populateCustomerComplaintHistoryModal(uid,debtor_id,complaint = false){
// var atp_calculator_modal_cc = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'atp_calculator_modal_cc').html());
var customer_complaint_history_modal_cc = Handlebars.compile($('#template-cc_customer_complaint_history_modal_cc').html());
var customer_complaint_history_modal_cc_var = {};
var debtor = global.debtordata[debtor_id].debtor;
// global.general.atp_debtor_id[uid] = debtor_id;
customer_complaint_history_modal_cc_var.uid = uid;
customer_complaint_history_modal_cc_var.lang = lang;
customer_complaint_history_modal_cc_var.debtor = debtor;
customer_complaint_history_modal_cc_var.debtor_id = debtor.id;
customer_complaint_history_modal_cc_var.complaint_management_structure = global.general.complaint_management_structure;
customer_complaint_history_modal_cc_var.customer_complaint_entry = global.access.customer_complaint_entry;
customer_complaint_history_modal_cc_var.customer_complaint_entry_section = {};
customer_complaint_history_modal_cc_var.customer_complaint_entry_section.customer_request = ((global.access.customer_complaint_entry_section & 1) == 1)?1:0;
customer_complaint_history_modal_cc_var.customer_complaint_entry_section.complaint_details = ((global.access.customer_complaint_entry_section & 2) == 2)?1:0;
customer_complaint_history_modal_cc_var.customer_complaint_entry_section.findings_resolutions = ((global.access.customer_complaint_entry_section & 4) == 4)?1:0;
customer_complaint_history_modal_cc_var.deleteAttachment = false;
if(Number(global.access.attachment) >= 3)
customer_complaint_history_modal_cc_var.deleteAttachment = true;
if(complaint.complaint_audit_trail != null)
customer_complaint_history_modal_cc_var.complaint_audit_trail = complaint.complaint_audit_trail;
if(complaint.complaint_attachment != null)
customer_complaint_history_modal_cc_var.complaint_attachment = complaint.complaint_attachment;
var show_draft_button = true;
if(complaint.is_draft != null){
customer_complaint_history_modal_cc_var.is_draft = complaint.is_draft;
if(complaint.is_draft == "0"){
show_draft_button = false;
}
}
customer_complaint_history_modal_cc_var.show_draft_button = show_draft_button;
// atp_calculator_modal_cc_var.collector_name = global.general.collector_name;
// atp_calculator_modal_cc_var.collector_user_id = global.general.collector_user_id;
// atp_calculator_modal_cc_var.debtor = global.debtordata[debtor_id].debtor;
// atp_calculator_modal_cc_var.atp_dropdown = global.general.atp_dropdown;
// atp_calculator_modal_cc_var.atp_activity = global.general.atp_activity;
// atp_calculator_modal_cc_var.collector_list = global.general.collector_list;
customer_complaint_history_modal_cc_var.collector_full_list = global.general.collector_full_list;
// atp_calculator_modal_cc_var.uid = uid;
// atp_calculator_modal_cc_var.smsnumbers = global.debtordata[debtor_id].smsnumbers;
// global.general.atp_tier[uid] = [];
// global.general.atp_decision[uid] = [];
// var atp_status = "";
// if(atp != false){
// }
customer_complaint_history_modal_cc_var.collector_name = global.general.collector_name;
customer_complaint_history_modal_cc_var.collector_fullname = global.general.collector_fullname;
customer_complaint_history_modal_cc_var.collector_user_id = global.general.collector_user_id;
$('#'+uid+' .customer_complaint_history_modal_cc').html(customer_complaint_history_modal_cc(customer_complaint_history_modal_cc_var));
if( complaint != false ){
$('#'+uid+' .debtor_detail_complaint_customer_request_reporter').val(complaint.reporter);
$('#'+uid+' .debtor_detail_complaint_customer_request_supervisor').val(complaint.supervisor);
$('#'+uid+' select.debtor_detail_complaint_customer_request_type_of_issue').val(complaint.complaint_type);
$('#'+uid+' select.debtor_detail_complaint_customer_request_case_acknowledged_via').val(complaint.complaint_case_acknowledged_id);
$('#'+uid+' .debtor_detail_complaint_customer_request_case_received_date').val(getLanguageDate(complaint.date_case_received));
$('#'+uid+' .debtor_detail_complaint_customer_request_case_received_time').val(moment(complaint.date_case_received,momentSqlDateTimeSecondFormat).format(momentSqlTimeFormat));
$('#'+uid+' .debtor_detail_complaint_customer_request_case_created_date').val(getLanguageDate(complaint.created_at));
$('#'+uid+' .debtor_detail_complaint_customer_request_case_closed_date').val(getLanguageDate(complaint.date_case_closed));
$('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_date').val(getLanguageDate(complaint.date_case_acknowledged));
$('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_time').val(moment(complaint.date_case_acknowledged,momentSqlDateTimeSecondFormat).format(momentSqlTimeFormat));
$('#'+uid+' select.debtor_detail_complaint_customer_request_request_source').val(complaint.complaint_request_source_id);
$('#'+uid+' select.debtor_detail_complaint_customer_request_status').val(complaint.complaint_status_id);
$('#'+uid+' .debtor_detail_complaint_customer_request_case_details').val(complaint.case_details);
$('#'+uid+' .debtor_detail_complaint_complaint_details_due_date').val(getLanguageDate(complaint.due_date));
$('#'+uid+' .debtor_detail_complaint_complaint_details_case_ref_no').val(complaint.case_ref_no);
$('#'+uid+' select.debtor_detail_complaint_complaint_details_complaint_channel').val(complaint.complaint_channel_id);
if(complaint.complainant_name != null && complaint.complainant_name != '')
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_name').val(complaint.complainant_name);
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_phone_number').val(complaint.complainant_phone_number);
if(complaint.complainant_nric != null && complaint.complainant_nric != '')
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_nric').val(complaint.complainant_nric);
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_email_address').val(complaint.complainant_email_address);
$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_issue_summary').val(complaint.complaint_issue_summary);
$('#'+uid+' .debtor_detail_complaint_complaint_details_detail_of_complaint_issue').val(complaint.details_of_complaint_issue);
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_date').val(getLanguageDate(complaint.resolved_date));
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_by').val(complaint.resolved_by);
$('#'+uid+' select.debtor_detail_complaint_complaint_details_resolved_via').val(complaint.complaint_resolved_id);
$('#'+uid+' .debtor_detail_complaint_complaint_details_resolution_details').val(complaint.resolution_details);
$('#'+uid+' .debtor_detail_complaint_findings_resolution_complaint_staff').val(complaint.complaint_staff);
$('#'+uid+' .debtor_detail_complaint_findings_resolution_staff_id').val(complaint.staff_id);
$('#'+uid+' .debtor_detail_complaint_findings_resolution_aging').val(complaint.aging);
$('#'+uid+' .debtor_detail_complaint_findings_resolution_supervisor_id').val(complaint.supervisor_id);
$('#'+uid+' select.debtor_detail_complaint_findings_resolution_root_cause').val(complaint.complaint_root_cause_id);
$('#'+uid+' select.debtor_detail_complaint_findings_resolution_unit').val(complaint.complaint_unit_id);
$('#'+uid+' select.debtor_detail_complaint_findings_resolution_valid').val(complaint.is_valid);
$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_name').val(complaint.service_provider_name);
$('#'+uid+' select.debtor_detail_complaint_findings_resolution_reason').val(complaint.complaint_reason_id);
$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_staff').val(complaint.service_provider_staff);
$('#'+uid+' .debtor_detail_complaint_findings_resolution_action_plan_remarks').val(complaint.action_plan_remarks);
$('#'+uid+' .debtor_detail_complaint_savedraft').attr('volare-complaint_id',complaint.id);
$('#'+uid+' .debtor_detail_complaint_submit').attr('volare-complaint_id',complaint.id);
$('#'+uid+' .debtor_detail_complaint_complaint_details_attachment_add').attr('volare-complaint_id',complaint.id);
if(complaint.is_draft == "0"){
$('#'+uid+' .debtor_detail_complaint_submit').html(lang.lang_update);
}
// atp_status = atp.atp_history.atp_status;
// // 0 = Pending 1 = Approved 2 = Rejected 3 = Void 4 = Draft
// switch(atp.atp_history.atp_status){
// case '0':
// case '1':
// case '2':
// case '3':
// $('#'+uid+' .atp_unsecured_atp_template_save_draft').prop('disabled',true);
// $('#'+uid+' .atp_unsecured_atp_template_submit').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc input').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc textarea').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc select').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc .atp_rebate_calculator_calculate_rebate').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_payment_term_total_instalment_payment_tier_delete').prop('disabled',true);
// $('#'+uid+' .atp_calculator_modal_cc .atp_unsecured_atp_template_decision_by_delete').prop('disabled',true);
// break;
// default:break;
// }
}
$('#'+uid+' .volare_date').datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+" .volare_time").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
format: datetimepickerTimeFormat,
timepickerScrollbar: false,
timepicker:true,
datepicker:false,
step:1,
});
$('#'+uid+' .debtor_detail_complaint_findings_resolution_complaint_staff').selectpicker({
showSubtext: "true"
});
$('#'+uid+' .customer_complaint_history_modal_cc').modal('show');
setTimeout(function(){
realtimeValidateComplaintManagement(uid);
},500);
// realtimeValidateComplaintManagement(uid);
}
function upsertCustomerComplaintHistory(uid,debtor_id,mode = 'draft' ,complaint_id = false){
var complaint = {
is_draft: mode == "draft" ? '1' : '0' ,
};
if($('#'+uid+' .debtor_detail_complaint_customer_request').is(":visible")){
complaint.customer_request = {
reporter:$('#'+uid+' .debtor_detail_complaint_customer_request_reporter').val(),
supervisor:$('#'+uid+' .debtor_detail_complaint_customer_request_supervisor').val(),
complaint_type:$('#'+uid+' select.debtor_detail_complaint_customer_request_type_of_issue').val(),
complaint_case_acknowledged_id:$('#'+uid+' select.debtor_detail_complaint_customer_request_case_acknowledged_via').val(),
date_case_received:'',
date_case_acknowledged:'',
created_at:'',
date_case_closed:'',
complaint_request_source_id:$('#'+uid+' select.debtor_detail_complaint_customer_request_request_source').val(),
complaint_status_id:$('#'+uid+' select.debtor_detail_complaint_customer_request_status').val(),
case_details:$('#'+uid+' .debtor_detail_complaint_customer_request_case_details').val(),
};
var date_case_received_date = $('#'+uid+' .debtor_detail_complaint_customer_request_case_received_date').val();
var date_case_received_time = $('#'+uid+' .debtor_detail_complaint_customer_request_case_received_time').val();
if(date_case_received_date != '' && date_case_received_time != ''){
var date_case_received = moment(date_case_received_date +' '+ date_case_received_time,momentDateTimeFormat).format(momentSqlDateTimeFormat);
if(date_case_received != "Invalid date"){
complaint.customer_request.date_case_received = date_case_received;
}
}
var date_case_acknowledged_date = $('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_date').val();
var date_case_acknowledged_time = $('#'+uid+' .debtor_detail_complaint_customer_request_case_acknowledged_time').val();
if(date_case_acknowledged_date != '' && date_case_acknowledged_time != ''){
var date_case_acknowledged = moment(date_case_acknowledged_date +' '+ date_case_acknowledged_time,momentDateTimeFormat).format(momentSqlDateTimeFormat);
if(date_case_acknowledged != "Invalid date"){
complaint.customer_request.date_case_acknowledged = date_case_acknowledged;
}
}
}
if($('#'+uid+' .debtor_detail_complaint_complaint_details').is(":visible")){
complaint.complaint_details = {
// due_date:$('#'+uid+' .debtor_detail_complaint_complaint_details_due_date').val(),
case_ref_no:$('#'+uid+' .debtor_detail_complaint_complaint_details_case_ref_no').val(),
complaint_channel_id:$('#'+uid+' select.debtor_detail_complaint_complaint_details_complaint_channel').val(),
complainant_name:$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_name').val(),
complainant_phone_number:$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_phone_number').val(),
complainant_nric:$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_nric').val(),
complainant_email_address:$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_email_address').val(),
complaint_issue_summary:$('#'+uid+' .debtor_detail_complaint_complaint_details_complainant_issue_summary').val(),
details_of_complaint_issue:$('#'+uid+' .debtor_detail_complaint_complaint_details_detail_of_complaint_issue').val(),
// resolved_date:$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_date').val(),
resolved_date:'',
resolved_by:$('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_by').val(),
complaint_resolved_id:$('#'+uid+' select.debtor_detail_complaint_complaint_details_resolved_via').val(),
resolution_details:$('#'+uid+' .debtor_detail_complaint_complaint_details_resolution_details').val(),
};
var resolved_date = moment($('#'+uid+' .debtor_detail_complaint_complaint_details_resolved_date').val(),momentDateFormat).format(momentSqlDateFormat);
if(resolved_date != 'Invalid date'){
complaint.complaint_details.resolved_date = resolved_date;
}
}
if($('#'+uid+' .debtor_detail_complaint_findings_resolution').is(":visible")){
complaint.findings_resolutions = {
complaint_staff:$('#'+uid+' select.debtor_detail_complaint_findings_resolution_complaint_staff').val(),
staff_id:$('#'+uid+' .debtor_detail_complaint_findings_resolution_staff_id').val(),
// aging:$('#'+uid+' .debtor_detail_complaint_findings_resolution_aging').val(),
supervisor_id:$('#'+uid+' .debtor_detail_complaint_findings_resolution_supervisor_id').val(),
complaint_root_cause_id:$('#'+uid+' select.debtor_detail_complaint_findings_resolution_root_cause').val(),
complaint_unit_id:$('#'+uid+' select.debtor_detail_complaint_findings_resolution_unit').val(),
is_valid:$('#'+uid+' select.debtor_detail_complaint_findings_resolution_valid').val(),
service_provider_name:$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_name').val(),
complaint_reason_id:$('#'+uid+' select.debtor_detail_complaint_findings_resolution_reason').val(),
service_provider_staff:$('#'+uid+' .debtor_detail_complaint_findings_resolution_service_provider_staff').val(),
action_plan_remarks:$('#'+uid+' .debtor_detail_complaint_findings_resolution_action_plan_remarks').val(),
};
}
// var atp = {
// atp_history:atp_history,
// atp_relationship_section:atp_relationship_section,
// atp_properties_section:atp_properties_section,
// atp_account_list_section:atp_account_list_section,
// atp_tiering_info_section:atp_tiering_info_section,
// atp_existing_account_section:atp_existing_account_section,
// atp_approval_decision:atp_approval_decision,
// };
if(complaint_id != false){
complaint.id = complaint_id;
}
// console.log(complaint);
volareApi("createCustomerComplaintHistory",{action: 'createCustomerComplaintHistory',debtor_id:debtor_id,complaint:complaint,},{uid:uid});
}
function viewCustomerComplaintHistory(uid,debtor_id,complaint_id){
volareApi("viewCustomerComplaintHistory",{action: 'viewCustomerComplaintHistory',debtor_id:debtor_id,complaint:{id:complaint_id},},{uid:uid});
}
function updateDebtorOtherAmountsDynamic(uid,debtor_id,data) {
// const formattedDate = moment().format('YYYY-MM-DD HH:mm:ss');
//
$('#'+uid+' .debtor_detail_other_amounts_dynamic_requested_date').html(moment().format(momentDateTimeSecondFormat));
// console.log($('#'+uid+' .debtor_detail_other_amounts_dynamic_requested_date').html());
// $('#requested-date-placeholder').text(formattedDate);
$('#'+uid+' .debtor_detail_other_amounts_dynamic_tbody').html('');
var debtor_detail_other_amounts_dynamic_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'debtor_detail_other_amounts_dynamic_tbody_tr').html());
var debtor_detail_other_amounts_dynamic_tbody_tr_var = {};
var debtor_detail_other_amounts_dynamic_tbody = "";
if(data != false){
$.each(data, function(index, el) {
debtor_detail_other_amounts_dynamic_tbody_tr_var = el;
debtor_detail_other_amounts_dynamic_tbody_tr_var.index = index;
debtor_detail_other_amounts_dynamic_tbody += debtor_detail_other_amounts_dynamic_tbody_tr(debtor_detail_other_amounts_dynamic_tbody_tr_var);
});
}
if(debtor_detail_other_amounts_dynamic_tbody == ""){
var debtor_detail_other_amounts_dynamic_tbody_tr_nodata = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'debtor_detail_other_amounts_dynamic_tbody_tr_nodata').html());
var debtor_detail_other_amounts_dynamic_tbody_tr_nodata_var = {};
debtor_detail_other_amounts_dynamic_tbody_tr_nodata_var.lang = lang;
debtor_detail_other_amounts_dynamic_tbody += debtor_detail_other_amounts_dynamic_tbody_tr_nodata(debtor_detail_other_amounts_dynamic_tbody_tr_nodata_var);
}
// console.log(debtor_detail_other_amounts_dynamic_tbody);
$('#'+uid+' .debtor_detail_other_amounts_dynamic_tbody').html(debtor_detail_other_amounts_dynamic_tbody);
// let tbody = $('#dynamic-amounts-table-body');
// tbody.empty();
// if (data && Array.isArray(data) && data.length > 0) {
// data.forEach((item, index) => {
// tbody.append(`
//
// ${index + 1}
// ${item.code}
// ${item.description}
// ${parseFloat(item.amount).toLocaleString('en-US', { minimumFractionDigits: 2 })}
//
// `);
// });
// } else {
// // If no data is returned, show a fallback message
// tbody.append(`
//
// No records found.
//
// `);
// }
}
function generateSMSPreview(sms_template_id){
var custom_merge_fields = {};
$.each($('.main_sms_template_list_custom_merge_field_values'),function(index, el) {
var field = $(el).attr('volare-field');
var field_keys = $(el).attr('volare-field_keys');
var value = $(el).val();
custom_merge_fields[field] = value;
custom_merge_fields[field_keys] = value;
});
var smsformattemp = "";
smsformattemp = ""+global.general.smstemplate[sms_template_id].data.format;
smsformattemp = fillDataInPlaceholderv2(smsformattemp,global.callscript.callscriptvariable,false,custom_merge_fields);
$('.main_sms_preview').html(smsformattemp);
var smscontent = smsformattemp
var smstotalcharcount = $('').html(smscontent).text().length;
var smsblockcount = 0;
smsblockcount = Math.ceil(smstotalcharcount/153);
$('.main_sms_total_characters').html(smstotalcharcount);
$('.main_sms_block_count').html(smsblockcount);
}
function triggerMQ(uid,debtor,mq_code){
if(uid != "" && debtor != "" && mq_code != ""){
if(mq_code == "200047"){
$.ajax({
url : mq_api_url,
type : "POST",
data : {primaryaccountno:debtor.card_no,cardno:debtor.card_no,tcode:'200047'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
var details = $(response).find('Body>AIPA>Response>Detail')
var finaldata = [];
if(details.length > 0){
$.each(details,function(index, el) {
if($(el).find('Tpfdesc2').text().search(/(AT40|ET40)/) > -1 && moment($(el).find('Trandate').text(),"YYYYMMDD").isSame(moment(),'d'))
finaldata.push({Tpfdesc2:$(el).find('Tpfdesc2').text(),Trandate:$(el).find('Trandate').text(),Tranamt:$(el).find('Tranamt').text(),Trantime:$(el).find('Trantime').text()});
});
}
var debtor_detail_asccend_online_message_tbody = "";
var debtor_detail_asccend_online_message_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_asccend_online_message_tbody_tr').html());
var debtor_detail_asccend_online_message_tbody_tr_var = {};
$.each(finaldata,function(index, el) {
debtor_detail_asccend_online_message_tbody_tr_var = el;
debtor_detail_asccend_online_message_tbody_tr_var.index = Number(index)+1;
debtor_detail_asccend_online_message_tbody_tr_var.Trandate = moment(el.Trandate,"YYYYMMDD").format(momentDateFormat);
debtor_detail_asccend_online_message_tbody_tr_var.Trantime = moment(el.Trantime,"HHmmss").format(momentTimeFormat);
debtor_detail_asccend_online_message_tbody += debtor_detail_asccend_online_message_tbody_tr(debtor_detail_asccend_online_message_tbody_tr_var);
});
var last_updated_text = "No data";
if(finaldata.length > 0){
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
$('#'+uid+"_DebtorPage-content .debtor_detail_asccend_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_asccend_online_message_tbody").html(debtor_detail_asccend_online_message_tbody);
}
});
}else if(mq_code == "110436_cc"){
if(enable_irl_inquiry){
var mq_parameter = [];
if(debtor.new_ic != null && debtor.new_ic != ""){
mq_parameter.push({'indicator':'I','search':debtor.new_ic});
}
if(debtor.old_ic != null && debtor.old_ic != ""){
mq_parameter.push({'indicator':'I','search':debtor.old_ic});
}
if(debtor.passport != null && debtor.passport != ""){
mq_parameter.push({'indicator':'I','search':debtor.passport});
}
if(mq_parameter.length > 0){
$.ajax({
url : mq_api_url,
type : "POST",
data : {tcode:'110436',data:mq_parameter},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
var details = $(response).find('Response>Detail');
var finaldata = [];
if(details.length > 0){
$.each(details,function(index, el) {
finaldata.push({
Name:$(el).find('Name').text(),
CharCode:$(el).find('CharCode').text(),
OldIC:$(el).find('OldIC').text(),
NewIC:$(el).find('NewIC').text(),
PassportNum:$(el).find('PassportNum').text(),
LocalNum:$(el).find('LocalNum').text(),
SSMNum:$(el).find('SSMNum').text(),
OtherRegNum:$(el).find('OtherRegNum').text(),
DateBirth:$(el).find('DateBirth').text(),
EntryDate:$(el).find('EntryDate').text(),
Reference:$(el).find('Reference').text(),
Remark1:$(el).find('Remark1').text(),
Remark2:$(el).find('Remark2').text(),
Remark3:$(el).find('Remark3').text(),
Originator:$(el).find('Originator').text(),
});
});
}
var response_headers = $(response).find('Header');
var response_trans_date =$(response_headers).find('SC_TransDate').text();
if(enable_irl_inquiry_atp){
global.debtordata[debtor.id].irl_inquiry = finaldata;
global.debtordata[debtor.id].irl_inquiry_retrieval_date = response_trans_date;
}
var debtor_detail_as400_online_message_110436_tbody = "";
var debtor_detail_as400_online_message_110436_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_110436_tbody_tr').html());
var debtor_detail_as400_online_message_110436_tbody_tr_var = {};
$.each(finaldata,function(index, el) {
debtor_detail_as400_online_message_110436_tbody_tr_var = el;
debtor_detail_as400_online_message_110436_tbody_tr_var.SC_TransDate = response_trans_date;
debtor_detail_as400_online_message_110436_tbody += debtor_detail_as400_online_message_110436_tbody_tr(debtor_detail_as400_online_message_110436_tbody_tr_var);
});
var last_updated_text = "No data";
if(finaldata.length > 0){
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
$('#'+uid+"_DebtorPage-content .debtor_detail_asccend_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110436_tbody").html(debtor_detail_as400_online_message_110436_tbody);
if(enable_irl_inquiry_atp){
if($('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110436_atp_tbody").is(":visible") && $('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110436_atp_tbody").attr('volare-irl_inquiry_refresh') == "1"){
processATPIrlTbodyUpdate(uid+"_DebtorPage-content",debtor.id);
}
}
}
});
}
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110436_related").removeClass('hideMe');
}
}else if(mq_code == "110141"){
$.ajax({
url : mq_api_url,
type : "POST",
// data : {acntnum:'374003300',acnttyp:'L',tcode:'110141'},
data : {acntnum:debtor.account,acnttyp:debtor.account_type,tcode:'110141'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
// console.log(response);
var details = $(response).find('Response')
var finaldata = [];
var finaldata_success = [];
var finaldata_fail = [];
// console.log(details);
$.each(debtor.tlast_code,function(index, el) {
var tlast_result = "N";
if($(details).find(el['code']).text() != null && $(details).find(el['code']).text() == "Y"){
tlast_result = "Y";
}
// if(el[sprintf('',el['id'])] != null && el[sprintf('',el['id'])] == "Y"){
// tlast_result = "Y";
// }
if(tlast_result == "N")
finaldata_fail[el['id']] = {id:el['id'],description:el['description'],result:tlast_result};
else
finaldata_success[el['id']] = {id:el['id'],description:el['description'],result:tlast_result};
});
finaldata = $.merge(finaldata_success,finaldata_fail);
// finaldata.sort(function(a,b){
// if(a.resultb.result) return 1;
// return 0;
// });
// console.log(finaldata);
// if(details.length > 0){
// $.each(details,function(index, el) {
// if($(el).find('Tpfdesc2').text().search(/(^AT|^MT)/) > -1 && moment($(el).find('Trandate').text(),"YYYYMMDD").isSame(moment(),'d'))
// finaldata.push({Tpfdesc2:$(el).find('Tpfdesc2').text(),Trandate:$(el).find('Trandate').text(),Tranamt:$(el).find('Tranamt').text(),Trantime:$(el).find('Trantime').text()});
// });
// }
var debtor_detail_as400_online_message_110141_tbody = "";
var debtor_detail_as400_online_message_110141_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_110141_tbody_tr').html());
var debtor_detail_as400_online_message_110141_tbody_tr_var = {};
// console.log(debtor_detail_as400_online_message_110141_tbody_tr);
$.each(finaldata,function(index, el) {
if(el != null){
debtor_detail_as400_online_message_110141_tbody_tr_var = el;
debtor_detail_as400_online_message_110141_tbody += debtor_detail_as400_online_message_110141_tbody_tr(debtor_detail_as400_online_message_110141_tbody_tr_var);
}
});
var last_updated_text = "No data";
if(finaldata.length > 0){
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110141_tbody").html(debtor_detail_as400_online_message_110141_tbody);
}
});
}else if(mq_code == "110139"){
$.ajax({
url : mq_api_url,
type : "POST",
// data : {acntnum:'374003300',acnttyp:'L',tcode:'110141'},
data : {acntnum:debtor.account,acnttyp:debtor.account_type,tcode:'110139'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
// console.log(response);
var details = $(response).find('Response>Detail')
var finaldata = [];
var finaldata_success = [];
var finaldata_fail = [];
// console.log(details);
$.each(details,function(index, el) {
finaldata.push({
Date:$(el).find('Date').text(),
EfectvDt:$(el).find('EfectvDt').text(),
AxlryTrnCd:$(el).find('AxlryTrnCd').text(),
TrnCd:$(el).find('TrnCd').text(),
TrnCdDes:$(el).find('TrnCdDes').text(),
Source:$(el).find('Source').text(),
UserId:$(el).find('UserId').text(),
TrnAmt:$(el).find('TrnAmt').text(),
OutstndAmt:$(el).find('OutstndAmt').text(),
});
});
// finaldata = $.merge(finaldata_success,finaldata_fail);
// finaldata.sort(function(a,b){
// if(a.resultb.result) return 1;
// return 0;
// });
// console.log(finaldata);
// if(details.length > 0){
// $.each(details,function(index, el) {
// if($(el).find('Tpfdesc2').text().search(/(^AT|^MT)/) > -1 && moment($(el).find('Trandate').text(),"YYYYMMDD").isSame(moment(),'d'))
// finaldata.push({Tpfdesc2:$(el).find('Tpfdesc2').text(),Trandate:$(el).find('Trandate').text(),Tranamt:$(el).find('Tranamt').text(),Trantime:$(el).find('Trantime').text()});
// });
// }
var debtor_detail_as400_online_message_110139_tbody = "";
var debtor_detail_as400_online_message_110139_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_110139_tbody_tr').html());
var debtor_detail_as400_online_message_110139_tbody_tr_var = {};
// console.log(debtor_detail_as400_online_message_110139_tbody_tr);
$.each(finaldata,function(index, el) {
if(el != null){
debtor_detail_as400_online_message_110139_tbody_tr_var = el;
debtor_detail_as400_online_message_110139_tbody += debtor_detail_as400_online_message_110139_tbody_tr(debtor_detail_as400_online_message_110139_tbody_tr_var);
}
});
var last_updated_text = "No data";
if(finaldata.length > 0){
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110139_tbody").html(debtor_detail_as400_online_message_110139_tbody);
}
});
}else if(mq_code == "120002"){
$.ajax({
url : mq_api_url,
type : "POST",
data : {cifnum:debtor.cif_number,tcode:'120002'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
// console.log(response);
var details = $(response).find('Response>Detail')
var finaldata = [];
var finaldata_success = [];
var finaldata_fail = [];
// console.log(details);
$.each(details,function(index, el) {
finaldata.push({
AccountNo:$(el).find('AccountNo').text(),
ProductType:$(el).find('ProductType').text(),
AccountRelationship:$(el).find('AccountRelationship').text(),
LedgerBalance:$(el).find('LedgerBalance').text(),
});
});
// console.log(finaldata);
var debtor_detail_as400_online_message_120002_tbody = "";
var debtor_detail_as400_online_message_120002_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_120002_tbody_tr').html());
var debtor_detail_as400_online_message_120002_tbody_tr_var = {};
// console.log(debtor_detail_as400_online_message_120002_tbody_tr);
$.each(finaldata,function(index, el) {
if(el != null){
debtor_detail_as400_online_message_120002_tbody_tr_var = el;
debtor_detail_as400_online_message_120002_tbody += debtor_detail_as400_online_message_120002_tbody_tr(debtor_detail_as400_online_message_120002_tbody_tr_var);
}
});
var last_updated_text = "No data";
if(finaldata.length > 0){
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_120002_tbody").html(debtor_detail_as400_online_message_120002_tbody);
}
});
}else if(mq_code == "110138"){
$.ajax({
url : mq_api_url,
type : "POST",
data : {acntnum:debtor.account,tcode:'110138'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
// console.log(response);
var details = $(response).find('Response>Detail')
var finaldata = [];
var finaldata_success = [];
var finaldata_fail = [];
// console.log(details);
$.each(details,function(index, el) {
finaldata.push({
PosDt1:$(el).find('PosDt1').text(),
EfctvDt:$(el).find('EfctvDt').text(),
AuxlTrnCd:$(el).find('AuxlTrnCd').text(),
TrnCd:$(el).find('TrnCd').text(),
TrnCdDes:$(el).find('TrnCdDes').text(),
InputSrc:$(el).find('InputSrc').text(),
UserId:$(el).find('UserId').text(),
AcntBrc:$(el).find('AcntBrc').text(),
TrnAmt:$(el).find('TrnAmt').text(),
CurBal:$(el).find('CurBal').text(),
});
});
// console.log(finaldata);
var debtor_detail_as400_online_message_110138_tbody = "";
var debtor_detail_as400_online_message_110138_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_110138_tbody_tr').html());
var debtor_detail_as400_online_message_110138_tbody_tr_var = {};
// console.log(debtor_detail_as400_online_message_110138_tbody_tr);
$.each(finaldata,function(index, el) {
if(el != null){
debtor_detail_as400_online_message_110138_tbody_tr_var = el;
debtor_detail_as400_online_message_110138_tbody += debtor_detail_as400_online_message_110138_tbody_tr(debtor_detail_as400_online_message_110138_tbody_tr_var);
}
});
var last_updated_text = "No data";
if(finaldata.length > 0){
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110138_tbody").html(debtor_detail_as400_online_message_110138_tbody);
}
});
}else if(mq_code == "110142"){
if(debtor.collateral_vehicle_number != ''){
$.ajax({
url : mq_api_url,
type : "POST",
data : {acntnum:debtor.account,acnttyp:debtor.account_type,coltrlid:debtor.collateral_vehicle_number,tcode:'110142'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
// console.log(response);
var details = $(response).find('Response')
var finaldata = [];
var finaldata_success = [];
var finaldata_fail = [];
// console.log(details);
var DtOfRepo1 = $(details).find('DtOfRepo1').text();
var last_updated_text = "No data";
if(DtOfRepo1 != null && DtOfRepo1 != ''){
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110142").val(DtOfRepo1);
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
}
});
}
}else if(mq_code == "110143"){
$.ajax({
url : mq_api_url,
type : "POST",
data : {acntnum:debtor.account,acnttyp:debtor.account_type,tcode:'110143'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
// console.log(response);
var details = $(response).find('Response')
var finaldata = [];
var finaldata_success = [];
var finaldata_fail = [];
// console.log(details);
$.each(details,function(index, el) {
finaldata.push({
ChequeTyp:$(el).find('ChequeTyp').text(),
AccptBrnch:$(el).find('AccptBrnch').text(),
DtEntered1:$(el).find('DtEntered1').text(),
DtEntered2:$(el).find('DtEntered2').text(),
DtOfChque1:$(el).find('DtOfChque1').text(),
DtOfChque2:$(el).find('DtOfChque2').text(),
ChequeNo:$(el).find('ChequeNo').text(),
ChequeAmt:$(el).find('ChequeAmt').text(),
});
});
// console.log(finaldata);
var debtor_detail_as400_online_message_110143_tbody = "";
var debtor_detail_as400_online_message_110143_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_110143_tbody_tr').html());
var debtor_detail_as400_online_message_110143_tbody_tr_var = {};
// console.log(debtor_detail_as400_online_message_110143_tbody_tr);
$.each(finaldata,function(index, el) {
if(el != null){
debtor_detail_as400_online_message_110143_tbody_tr_var = el;
debtor_detail_as400_online_message_110143_tbody += debtor_detail_as400_online_message_110143_tbody_tr(debtor_detail_as400_online_message_110143_tbody_tr_var);
}
});
var last_updated_text = "No data";
if(finaldata.length > 0){
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110143_tbody").html(debtor_detail_as400_online_message_110143_tbody);
}
});
}else if(mq_code == "110150"){
$.ajax({
url : mq_api_url,
type : "POST",
data : {accno:debtor.account,acctype:debtor.account_type,tcode:'110150'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
// console.log(response);
var details = $(response).find('Response>Detail')
var finaldata = [];
var finaldata_success = [];
var finaldata_fail = [];
// console.log(details);
$.each(details,function(index, el) {
finaldata.push({
SeqNo:$(el).find('SeqNo').text(),
MsgCode:$(el).find('MsgCode').text(),
Msg:$(el).find('Msg').text(),
Date:$(el).find('Date').text(),
});
});
// console.log(finaldata);
var debtor_detail_as400_online_message_110150_tbody = "";
var debtor_detail_as400_online_message_110150_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_110150_tbody_tr').html());
var debtor_detail_as400_online_message_110150_tbody_tr_var = {};
// console.log(debtor_detail_as400_online_message_110150_tbody_tr);
$.each(finaldata,function(index, el) {
if(el != null){
debtor_detail_as400_online_message_110150_tbody_tr_var = el;
debtor_detail_as400_online_message_110150_tbody += debtor_detail_as400_online_message_110150_tbody_tr(debtor_detail_as400_online_message_110150_tbody_tr_var);
}
});
var last_updated_text = "No data";
if(finaldata.length > 0){
last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
}
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110150_tbody").html(debtor_detail_as400_online_message_110150_tbody);
}
});
}else if(mq_code == "110400"){
$.ajax({
url : mq_api_url,
type : "POST",
data : {accno:debtor.account,acctype:debtor.account_type,tcode:'110400'},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
// console.log(response);
var details = $(response).find('Response>Detail')
var finaldata = [];
var finaldata_success = [];
var finaldata_fail = [];
// console.log(details);
$.each(details,function(index, el) {
finaldata.push({
DueDate2:$(el).find('DueDate2').text(),
OrgBilledPrinAmt:$(el).find('OrgBilledPrinAmt').text(),
BilledPrinAmt:$(el).find('BilledPrinAmt').text(),
OrgBilledIntAmt:$(el).find('OrgBilledIntAmt').text(),
BilledIntAmt:$(el).find('BilledIntAmt').text(),
});
});
// console.log(finaldata);
var debtor_detail_as400_online_message_110400_tbody = "";
var debtor_detail_as400_online_message_110400_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_110400_tbody_tr').html());
var debtor_detail_as400_online_message_110400_tbody_tr_var = {};
// console.log(debtor_detail_as400_online_message_110400_tbody_tr);
$.each(finaldata,function(index, el) {
if(el != null){
debtor_detail_as400_online_message_110400_tbody_tr_var = el;
debtor_detail_as400_online_message_110400_tbody += debtor_detail_as400_online_message_110400_tbody_tr(debtor_detail_as400_online_message_110400_tbody_tr_var);
}
});
// var last_updated_text = "No data";
// if(finaldata.length > 0){
// last_updated_text = 'Updated on '+moment().format(momentDateTimeFormat)+'.';
// }
// $('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_updated_date").html(last_updated_text);
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110400_tbody").html(debtor_detail_as400_online_message_110400_tbody);
}
});
}else if(mq_code == "110436_loan"){
if(enable_irl_inquiry && debtor.all_debtor_customer != null && debtor.all_debtor_customer != ""){
var mq_parameter = [];
var customer_cif_class = "";
for (var iiiii = 0; iiiii < debtor.all_debtor_customer.length; iiiii++) {
var temp_debtor_customer = debtor.all_debtor_customer[iiiii];
if(temp_debtor_customer.cif_class != null && temp_debtor_customer.cif_class == "I"){
customer_cif_class = "I";
// }else if(debtor.customer.cif_class != null && debtor.customer.cif_class == "C"){
}else{
customer_cif_class = "C";
}
if(temp_debtor_customer.new_ic != null && temp_debtor_customer.new_ic != ""){
mq_parameter.push({'indicator':customer_cif_class,'search':temp_debtor_customer.new_ic});
}
if(temp_debtor_customer.old_ic != null && temp_debtor_customer.old_ic != ""){
mq_parameter.push({'indicator':customer_cif_class,'search':temp_debtor_customer.old_ic});
}
if(temp_debtor_customer.passport != null && temp_debtor_customer.passport != ""){
mq_parameter.push({'indicator':customer_cif_class,'search':temp_debtor_customer.passport});
}
if(temp_debtor_customer.customer_secondary != null && temp_debtor_customer.customer_secondary != "" && temp_debtor_customer.customer_secondary.length > 0){
$.each(temp_debtor_customer.customer_secondary,function(d_index, d_el) {
if(d_el.ic != null && d_el.ic != ""){
mq_parameter.push({'indicator':customer_cif_class,'search':d_el.ic});
}
});
}
}
if(mq_parameter.length > 0){
$.ajax({
url : mq_api_url,
type : "POST",
data : {tcode:'110436',data:mq_parameter},
dataType : "json"
})
.done(function(data, textStatus, xhr){
if(data.code != 0 && data.message != null){
var response = $.parseXML(data.message);
var details = $(response).find('Response>Detail');
var finaldata = [];
if(details.length > 0){
$.each(details,function(index, el) {
finaldata.push({
Name:$(el).find('Name').text(),
CharCode:$(el).find('CharCode').text(),
OldIC:$(el).find('OldIC').text(),
NewIC:$(el).find('NewIC').text(),
PassportNum:$(el).find('PassportNum').text(),
LocalNum:$(el).find('LocalNum').text(),
SSMNum:$(el).find('SSMNum').text(),
OtherRegNum:$(el).find('OtherRegNum').text(),
DateBirth:$(el).find('DateBirth').text(),
EntryDate:$(el).find('EntryDate').text(),
Reference:$(el).find('Reference').text(),
Remark1:$(el).find('Remark1').text(),
Remark2:$(el).find('Remark2').text(),
Remark3:$(el).find('Remark3').text(),
Originator:$(el).find('Originator').text(),
});
});
}
var response_headers = $(response).find('Header');
var response_trans_date =$(response_headers).find('SC_TransDate').text();
if(enable_irl_inquiry_atp){
global.debtordata[debtor.id].irl_inquiry = finaldata;
global.debtordata[debtor.id].irl_inquiry_retrieval_date = response_trans_date;
}
var debtor_detail_as400_online_message_110436_tbody = "";
var debtor_detail_as400_online_message_110436_tbody_tr = Handlebars.compile($('#template-'+global.client_prefix[debtor.id]+'debtor_detail_as400_online_message_110436_tbody_tr').html());
var debtor_detail_as400_online_message_110436_tbody_tr_var = {};
$.each(finaldata,function(index, el) {
debtor_detail_as400_online_message_110436_tbody_tr_var = el;
debtor_detail_as400_online_message_110436_tbody_tr_var.SC_TransDate = response_trans_date;
debtor_detail_as400_online_message_110436_tbody += debtor_detail_as400_online_message_110436_tbody_tr(debtor_detail_as400_online_message_110436_tbody_tr_var);
});
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110436_tbody").html(debtor_detail_as400_online_message_110436_tbody);
if(enable_irl_inquiry_atp){
if($('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110436_atp_tbody").is(":visible") && $('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110436_atp_tbody").attr('volare-irl_inquiry_refresh') == "1"){
processATPIrlTbodyUpdate(uid+"_DebtorPage-content",debtor.id);
}
}
}
});
}
$('#'+uid+"_DebtorPage-content .debtor_detail_as400_online_message_110436_related").removeClass('hideMe');
}
}else if(mq_code == "110141"){
}
}
}
function populateDebtorDetailCollateralList(uid,debtor_id,collateral_list,preselect_id = ""){
var debtor_detail_collateral_list = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'debtor_detail_collateral_list').html());
var debtor_detail_collateral_list_var = {};
var debtor_detail_collateral_detail = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'debtor_detail_collateral_detail').html());
var debtor_detail_collateral_detail_var = {};
debtor_detail_collateral_detail_var.disabled = true;
debtor_detail_collateral_detail_var.contact_number_type = global.general.contact_number_type;
debtor_detail_collateral_detail_var.relation_type = global.callscript.collector_callscript_relationtype;
debtor_detail_collateral_detail_var.tpslist = global.general.tpslist;
debtor_detail_collateral_detail_var.fvcollectorlist = global.general.fvcollectorlist;
debtor_detail_collateral_detail_var.lang = lang;
$('#'+uid+'_DebtorPage-content .debtor_detail_collateral_list').html('');
$('#'+uid+'_DebtorPage-content .debtor_detail_collateral_detail').html(debtor_detail_collateral_detail(debtor_detail_collateral_detail_var));
global.debtordata[debtor_id].collaterals = {};
for (var i = 0; i < collateral_list.length; i++) {
var row = collateral_list[i];
row.uid = uid;
row.debtorid = debtor_id;
row.lang = lang;
global.debtordata[debtor_id].collaterals[row.id] = row;
debtor_detail_collateral_list_var = row;
$('#'+uid+'_DebtorPage-content .debtor_detail_collateral_list').append(debtor_detail_collateral_list(debtor_detail_collateral_list_var));
}
if(preselect_id != ""){
$('#'+uid+'_DebtorPage-content .debtor_detail_collateral_view_'+preselect_id).click();
}
}
function populateDebtorDetailCollateralDetail(uid,debtor_id,collateral_id,mode = "add",submode = ""){
var original_mode = mode;
if(mode == "edit" || mode == "view" )
var row = global.debtordata[debtor_id].collaterals[collateral_id];
var debtor_detail_collateral_detail = Handlebars.compile($('#template-'+global.client_prefix[debtor_id]+'debtor_detail_collateral_detail').html());
var debtor_detail_collateral_detail_var = {};
debtor_detail_collateral_detail_var.showEditButton = false;
debtor_detail_collateral_detail_var.showDeleteButton = false;
debtor_detail_collateral_detail_var.showReactivateButton = false;
debtor_detail_collateral_detail_var.showSaveButton = false;
debtor_detail_collateral_detail_var.showCancelButton = false;
debtor_detail_collateral_detail_var.isFromHost = false;
debtor_detail_collateral_detail_var.deleted = false;
var showContactabilityDiv = false;
var disabled = true;
var triggervalidatefield = false;
if(mode == "add"){
disabled = false;
triggervalidatefield = true;
}
if(uid != ''){
debtor_detail_collateral_detail_var.debtor_customer_relation_name = [];
debtor_detail_collateral_detail_var.debtor_customer_relation_type = [];
if(global.debtordata[debtor_id].debtor_customer_relation_name != null)
debtor_detail_collateral_detail_var.debtor_customer_relation_name = global.debtordata[debtor_id].debtor_customer_relation_name;
if(global.debtordata[debtor_id].debtor_customer_relation_type != null)
debtor_detail_collateral_detail_var.debtor_customer_relation_type = global.debtordata[debtor_id].debtor_customer_relation_type;
if(mode == "add"){
debtor_detail_collateral_detail_var.showEditButton = false;
debtor_detail_collateral_detail_var.showDeleteButton = false;
debtor_detail_collateral_detail_var.showSaveButton = true;
debtor_detail_collateral_detail_var.showCancelButton = true;
showContactabilityDiv = true;
}
if(mode == "edit" || mode == "view"){
$.each(row,function(index, el) {
debtor_detail_collateral_detail_var[index] = el;
});
if(row.is_from_host != null && row.is_from_host == "1"){
debtor_detail_collateral_detail_var.isFromHost = true;
}
if(mode == "edit"){
debtor_detail_collateral_detail_var.showEditButton = false;
debtor_detail_collateral_detail_var.showDeleteButton = false;
debtor_detail_collateral_detail_var.showSaveButton = true;
debtor_detail_collateral_detail_var.showCancelButton = true;
disabled = false;
showContactabilityDiv = true;
triggervalidatefield = true;
}
if(mode == "view"){
debtor_detail_collateral_detail_var.showEditButton = getAccessCondition("collateral","edit");
debtor_detail_collateral_detail_var.showDeleteButton = getAccessCondition("collateral","delete");
debtor_detail_collateral_detail_var.showSaveButton = false;
debtor_detail_collateral_detail_var.showCancelButton = false;
mode = "edit";
}
}
if(submode == "cancel"){
if(mode == "add"){
debtor_detail_collateral_detail_var.showEditButton = false;
debtor_detail_collateral_detail_var.showDeleteButton = false;
debtor_detail_collateral_detail_var.showSaveButton = false;
debtor_detail_collateral_detail_var.showCancelButton = false;
disabled = true;
}else if(mode == "edit"){
debtor_detail_collateral_detail_var.showEditButton = getAccessCondition("collateral","edit");
debtor_detail_collateral_detail_var.showDeleteButton = getAccessCondition("collateral","delete");
debtor_detail_collateral_detail_var.showSaveButton = false;
debtor_detail_collateral_detail_var.showCancelButton = false;
disabled = true;
}
showContactabilityDiv = false;
triggervalidatefield = false;
}
debtor_detail_collateral_detail_var.fvcollectorlist = global.general.fvcollectorlist;
debtor_detail_collateral_detail_var.contact_number_type = global.general.contact_number_type;
debtor_detail_collateral_detail_var.tpslist = global.general.tpslist;
debtor_detail_collateral_detail_var.relation_type = global.callscript.collector_callscript_relationtype;
if(global.access.contact_number < 4)
showContactabilityDiv = false;
debtor_detail_collateral_detail_var.showContactabilityDiv = showContactabilityDiv;
debtor_detail_collateral_detail_var.mode = mode;
debtor_detail_collateral_detail_var.disabled = disabled;
debtor_detail_collateral_detail_var.lang = lang;
debtor_detail_collateral_detail_var.debtor_id = debtor_id;
// debtor_detail_collateral_detail_var.contactnoid = contactnoid;
debtor_detail_collateral_detail_var.uid = uid;
}
if(original_mode == "view" && showDeletedContactNumber && row.deleted_at != null){
debtor_detail_collateral_detail_var.showEditButton = false;
debtor_detail_collateral_detail_var.showDeleteButton = false;
debtor_detail_collateral_detail_var.deleted = true;
debtor_detail_collateral_detail_var.showReactivateButton = getAccessCondition("collateral","edit");
}
$('#'+uid+' .debtor_detail_collateral_detail').html(debtor_detail_collateral_detail(debtor_detail_collateral_detail_var));
if(mode == "add"){
// $('#'+uid+" input:radio.debtor_detail_contact_fieldset_contactability[value='0']").prop('checked',true);
// $('#'+uid+' .debtor_detail_contact_fieldset_contactability_label.btn-new').button('toggle');
}
if(debtor_detail_collateral_detail_var.isFromHost){
$('#'+uid+' .debtor_detail_collateral_collateral_id').attr('volare-is_from_host','1');
$('#'+uid+' .debtor_detail_collateral_collateral_description').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_address_line_1').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_address_line_2').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_address_line_3').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_collateral_type_id').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_security_document_date').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_security_document_value').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_insurance_company_name').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_notary_name').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_title_issued_date').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_insurance_premium').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_valuation_value').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_market_value').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_valuation_date').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_valuer_name').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_proof_of_ownership').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_dealer_name').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_security_document_type').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_official_value').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_expiry_date').prop('disabled',true);
$('#'+uid+' .debtor_detail_collateral_fieldset_deletebutton').hide();
}else{
$('#'+uid+' .debtor_detail_collateral_collateral_id').attr('volare-is_from_host','0');
// if(enforceAddContactSourceID != null && enforceAddContactSourceID != ""){
// // $('#'+uid+' .'+populate_target_subclass+' .debtor_detail_contact_fieldset_source').selectpicker('val',enforceAddContactSourceID);
// if(mode == "add" && $('#'+uid+' .'+populate_target_subclass+' select.debtor_detail_contact_fieldset_source').val() == '')
// $('#'+uid+' .'+populate_target_subclass+' select.debtor_detail_contact_fieldset_source').val(enforceAddContactSourceID);
// if(!enable_skip_trace_contact_number || (enable_skip_trace_contact_number && global.access.skip_trace_contact_number == "0") ){
// // $('#'+uid+' .'+populate_target_subclass+' select.debtor_detail_contact_fieldset_source').val(enforceAddContactSourceID);
// $('#'+uid+' .'+populate_target_subclass+' .debtor_detail_contact_fieldset_source').prop('disabled',true);
// }
// }
$('#'+uid+" .debtor_detail_collateral_security_document_date").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
}
// $('#'+uid+" .debtor_detail_collateral_security_document_date").datetimepicker({
// scrollInput: false,
// scrollTime: false,
// scrollMonth: false,
// formatDate:datetimepickerDateFormat,
// format: datetimepickerDateFormat,
// timepicker:false,
// });
$('#'+uid+" .debtor_detail_collateral_title_issued_date").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+" .debtor_detail_collateral_valuation_date").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+" .debtor_detail_collateral_expiry_date").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+" .debtor_detail_collateral_new_valuation_date").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+" .debtor_detail_collateral_new_expiry_date").datetimepicker({
scrollInput: false,
scrollTime: false,
scrollMonth: false,
formatDate:datetimepickerDateFormat,
format: datetimepickerDateFormat,
timepicker:false,
});
$('#'+uid+" .debtor_detail_collateral_collateral_type_id").selectpicker();
$('#'+uid+" .debtor_detail_collateral_linked_collateral").selectpicker();
$('#'+uid+" .debtor_detail_collateral_auction_progress").selectpicker();
$('#'+uid+" .debtor_detail_collateral_proof_of_ownership").selectpicker();
$('#'+uid+" .debtor_detail_collateral_valuer_name").selectpicker();
$('#'+uid+" .debtor_detail_collateral_new_valuer_name").selectpicker();
$('#'+uid+" .debtor_detail_collateral_security_document_type").selectpicker();
$('#'+uid+" .debtor_detail_collateral_detail .volare_currency").maskMoney({thousands:currencyThousands, decimal:currencyDecimal});
if((original_mode == "view" || original_mode == "edit")){
// console.log(row.collateral_type_id);
$('#'+uid+' .debtor_detail_collateral_collateral_type_id').val(row.collateral_type_id);
$('#'+uid+' .debtor_detail_collateral_collateral_type_id').selectpicker('refresh');
if(row.auction_progress != null && row.auction_progress != ""){
$('#'+uid+' .debtor_detail_collateral_auction_progress').val(row.auction_progress);
$('#'+uid+" .debtor_detail_collateral_auction_progress").selectpicker('refresh');
}
if(row.linked_accounts){
$('#'+uid+' .debtor_detail_collateral_linked_collateral').val(row.linked_accounts);
$('#'+uid+" .debtor_detail_collateral_linked_collateral").selectpicker('refresh');
}
if(row.proof_of_ownership){
$('#'+uid+' .debtor_detail_collateral_proof_of_ownership').val(row.proof_of_ownership);
$('#'+uid+" .debtor_detail_collateral_proof_of_ownership").selectpicker('refresh');
}
if(row.security_document_type){
$('#'+uid+' .debtor_detail_collateral_security_document_type').val(row.security_document_type);
$('#'+uid+" .debtor_detail_collateral_security_document_type").selectpicker('refresh');
}
if(row.valuer_name){
$('#'+uid+' .debtor_detail_collateral_valuer_name').val(row.valuer_name);
$('#'+uid+" .debtor_detail_collateral_valuer_name").selectpicker('refresh');
}
if(row.new_valuer_name){
$('#'+uid+' .debtor_detail_collateral_new_valuer_name').val(row.new_valuer_name);
$('#'+uid+" .debtor_detail_collateral_new_valuer_name").selectpicker('refresh');
}
if(row.security_document_value){
$('#'+uid+" .debtor_detail_collateral_security_document_value").maskMoney('mask', getDecimal(row.security_document_value));
}
if(row.insurance_premium){
$('#'+uid+" .debtor_detail_collateral_insurance_premium").maskMoney('mask', getDecimal(row.insurance_premium));
}
if(row.valuation_value){
$('#'+uid+" .debtor_detail_collateral_valuation_value").maskMoney('mask', getDecimal(row.valuation_value));
}
if(row.market_value){
$('#'+uid+" .debtor_detail_collateral_market_value").maskMoney('mask', getDecimal(row.market_value));
}
if(row.official_value){
$('#'+uid+" .debtor_detail_collateral_official_value").maskMoney('mask', getDecimal(row.official_value));
}
if(row.new_security_document_value){
$('#'+uid+" .debtor_detail_collateral_new_security_document_value").maskMoney('mask', getDecimal(row.new_security_document_value));
}
if(row.new_market_value){
$('#'+uid+" .debtor_detail_collateral_new_market_value").maskMoney('mask', getDecimal(row.new_market_value));
}
if(row.new_valuation_value){
$('#'+uid+" .debtor_detail_collateral_new_valuation_value").maskMoney('mask', getDecimal(row.new_valuation_value));
}
if(row.middle_value){
$('#'+uid+" .debtor_detail_collateral_middle_value").maskMoney('mask', getDecimal(row.middle_value));
}
}
if((original_mode == "edit" || original_mode == "add") && submode != "cancel" ){
// $('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral_div').removeClass('hideMe');
$('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').bootstrapToggle();
$('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').prop('disabled',false);
if(original_mode == "add"){
if(global.debtordata[debtor_id].collaterals != null && !Object.values(global.debtordata[debtor_id].collaterals).some(row => row.is_primary == 1)){
$('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').bootstrapToggle('on');
$('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').prop('disabled',true);
}
}
if($('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').is(':checked')){
$('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').prop('disabled',true);
}
// $('#'+uid+' .debtor_detail_collateral_fieldset_is_do_not_sms').bootstrapToggle();
// $('#'+uid+' .debtor_detail_collateral_fieldset_is_preferred_sms').bootstrapToggle();
}else{
// $('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral_div').addClass('hideMe');
$('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').bootstrapToggle();
$('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').prop('disabled',true);
}
if(triggervalidatefield){
validateCollateralFields(uid,"",original_mode);
}else{
validateCollateralFields(uid,"clear",original_mode);
}
$('#'+uid+" .debtor_detail_contact_fieldset_sms").prop('checked',false);
if(row != null && row.IsSmsNo == "1"){
$('#'+uid+" .debtor_detail_contact_fieldset_sms").prop('checked',true);
}
}
function submitDebtorDetailCollateral(uid,debtor_id,collateral_id,mode){
if(uid != ""){
var set_as_primary_collateral = $('#'+uid+' .debtor_detail_collateral_set_as_primary_collateral').is(':checked') ? "1":"0";
var collateral_id = $('#'+uid+' .debtor_detail_collateral_collateral_id').val();
var collateral_description = $('#'+uid+' .debtor_detail_collateral_collateral_description').val();
var address_line_1 = $('#'+uid+' .debtor_detail_collateral_address_line_1').val();
var address_line_2 = $('#'+uid+' .debtor_detail_collateral_address_line_2').val();
var address_line_3 = $('#'+uid+' .debtor_detail_collateral_address_line_3').val();
var collateral_type_id = $('#'+uid+' select.debtor_detail_collateral_collateral_type_id').val();
var security_document_date = $('#'+uid+' .debtor_detail_collateral_security_document_date').val();
var security_document_value = $('#'+uid+' .debtor_detail_collateral_security_document_value').maskMoney('unmasked')[0];
var insurance_company_name = $('#'+uid+' .debtor_detail_collateral_insurance_company_name').val();
var notary_name = $('#'+uid+' .debtor_detail_collateral_notary_name').val();
// var debtor_detail_collateral_title_issued_date = $('#'+uid+' .debtor_detail_collateral_title_issued_date').val();
var insurance_premium = $('#'+uid+' .debtor_detail_collateral_insurance_premium').maskMoney('unmasked')[0];
var valuation_value = $('#'+uid+' .debtor_detail_collateral_valuation_value').maskMoney('unmasked')[0];
var market_value = $('#'+uid+' .debtor_detail_collateral_market_value').maskMoney('unmasked')[0];
// var debtor_detail_collateral_valuation_date = $('#'+uid+' .debtor_detail_collateral_valuation_date').val();
var valuer_name = $('#'+uid+' select.debtor_detail_collateral_valuer_name').val();
var proof_of_ownership = $('#'+uid+' select.debtor_detail_collateral_proof_of_ownership').val();
var dealer_name = $('#'+uid+' .debtor_detail_collateral_dealer_name').val();
var security_document_type = $('#'+uid+' select.debtor_detail_collateral_security_document_type').val();
var official_value = $('#'+uid+' .debtor_detail_collateral_official_value').maskMoney('unmasked')[0];
// var debtor_detail_collateral_expiry_date = $('#'+uid+' .debtor_detail_collateral_expiry_date').val();
var linked_collateral = $('#'+uid+' select.debtor_detail_collateral_linked_collateral').val();
var auction_progress = $('#'+uid+' select.debtor_detail_collateral_auction_progress').val();
// var debtor_detail_collateral_new_valuation_date = $('#'+uid+' .debtor_detail_collateral_new_valuation_date').val();
var new_security_document_value = $('#'+uid+' .debtor_detail_collateral_new_security_document_value').maskMoney('unmasked')[0];
var new_market_value = $('#'+uid+' .debtor_detail_collateral_new_market_value').maskMoney('unmasked')[0];
var new_valuation_value = $('#'+uid+' .debtor_detail_collateral_new_valuation_value').maskMoney('unmasked')[0];
var new_valuer_name = $('#'+uid+' select.debtor_detail_collateral_new_valuer_name').val();
var middle_value = $('#'+uid+' .debtor_detail_collateral_middle_value').maskMoney('unmasked')[0];
// var debtor_detail_collateral_new_expiry_date = $('#'+uid+' .debtor_detail_collateral_new_expiry_date').val();
// var security_document_date = null
// if($('#'+uid+' .debtor_detail_collateral_security_document_date').val() != ''){
// security_document_date = moment($('#'+uid+' .debtor_detail_collateral_security_document_date').val(),momentDateFormat).format(momentSqlDateFormat);
// }
var title_issued_date = null
if($('#'+uid+' .debtor_detail_collateral_title_issued_date').val() != ''){
title_issued_date = moment($('#'+uid+' .debtor_detail_collateral_title_issued_date').val(),momentDateFormat).format(momentSqlDateFormat);
}
var valuation_date = null
if($('#'+uid+' .debtor_detail_collateral_valuation_date').val() != ''){
valuation_date = moment($('#'+uid+' .debtor_detail_collateral_valuation_date').val(),momentDateFormat).format(momentSqlDateFormat);
}
var expiry_date = null
if($('#'+uid+' .debtor_detail_collateral_expiry_date').val() != ''){
expiry_date = moment($('#'+uid+' .debtor_detail_collateral_expiry_date').val(),momentDateFormat).format(momentSqlDateFormat);
}
var new_valuation_date = null
if($('#'+uid+' .debtor_detail_collateral_new_valuation_date').val() != ''){
new_valuation_date = moment($('#'+uid+' .debtor_detail_collateral_new_valuation_date').val(),momentDateFormat).format(momentSqlDateFormat);
}
var new_expiry_date = null
if($('#'+uid+' .debtor_detail_collateral_new_expiry_date').val() != ''){
new_expiry_date = moment($('#'+uid+' .debtor_detail_collateral_new_expiry_date').val(),momentDateFormat).format(momentSqlDateFormat);
}
if(mode == "add"){
var collateralinfo = {
debtor_id: debtor_id,
set_as_primary_collateral:set_as_primary_collateral,
collateral_type_id:collateral_type_id,
security_document_value:security_document_value,
insurance_company_name:insurance_company_name,
notary_name:notary_name,
insurance_premium:insurance_premium,
valuation_value:valuation_value,
market_value:market_value,
valuer_name:valuer_name,
proof_of_ownership:proof_of_ownership,
dealer_name:dealer_name,
security_document_type:security_document_type,
official_value:official_value,
linked_collateral:linked_collateral,
auction_progress:auction_progress,
new_security_document_value:new_security_document_value,
new_market_value:new_market_value,
new_valuation_value:new_valuation_value,
new_valuer_name:new_valuer_name,
middle_value:middle_value,
security_document_date:security_document_date,
title_issued_date:title_issued_date,
valuation_date:valuation_date,
expiry_date:expiry_date,
new_valuation_date:new_valuation_date,
new_expiry_date:new_expiry_date,
collateral_id:collateral_id,
collateral_description:collateral_description,
address_line_1:address_line_1,
address_line_2:address_line_2,
address_line_3:address_line_3,
};
volareApi("addDebtorCollateral",{action: 'addDebtorCollateral',debtor_id:debtor_id,collateralinfo: collateralinfo},{debtor_id:debtor_id,uid:uid});
}else if(mode == "edit"){
var collateralinfo = {
debtor_id: debtor_id,
set_as_primary_collateral:set_as_primary_collateral,
collateral_type_id:collateral_type_id,
security_document_value:security_document_value,
insurance_company_name:insurance_company_name,
notary_name:notary_name,
insurance_premium:insurance_premium,
valuation_value:valuation_value,
market_value:market_value,
valuer_name:valuer_name,
proof_of_ownership:proof_of_ownership,
dealer_name:dealer_name,
security_document_type:security_document_type,
official_value:official_value,
linked_collateral:linked_collateral,
auction_progress:auction_progress,
new_security_document_value:new_security_document_value,
new_market_value:new_market_value,
new_valuation_value:new_valuation_value,
new_valuer_name:new_valuer_name,
middle_value:middle_value,
security_document_date:security_document_date,
title_issued_date:title_issued_date,
valuation_date:valuation_date,
expiry_date:expiry_date,
new_valuation_date:new_valuation_date,
new_expiry_date:new_expiry_date,
collateral_id:collateral_id,
collateral_description:collateral_description,
address_line_1:address_line_1,
address_line_2:address_line_2,
address_line_3:address_line_3,
};
volareApi("updateDebtorCollateral", {action: 'updateDebtorCollateral',debtor_id:debtor_id,collateralinfo: collateralinfo},{debtor_id:debtor_id,uid:uid});
}
}
}
function validateCollateralFields(uid,mode = "",original_mode = ""){
// var error = false;
var invalid = 0;
var is_from_host = 0;
if($('#'+uid+' .debtor_detail_collateral_collateral_id').attr('volare-is_from_host') == "1"){
is_from_host = 1;
}
if(mode == ""){
if(is_from_host == "0"){
if($('#'+uid+" .debtor_detail_collateral_collateral_description").val() == ""){
$('#'+uid+" .debtor_detail_collateral_collateral_description").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_collateral_description").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_address_line_1").val() == ""){
$('#'+uid+" .debtor_detail_collateral_address_line_1").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_address_line_1").removeClass('is-invalid');
}
// if($('#'+uid+" .debtor_detail_collateral_address_line_2").val() == ""){
// $('#'+uid+" .debtor_detail_collateral_address_line_2").addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+" .debtor_detail_collateral_address_line_2").removeClass('is-invalid');
// }
// if($('#'+uid+" .debtor_detail_collateral_address_line_3").val() == ""){
// $('#'+uid+" .debtor_detail_collateral_address_line_3").addClass('is-invalid');
// invalid++;
// }else{
// $('#'+uid+" .debtor_detail_collateral_address_line_3").removeClass('is-invalid');
// }
if($('#'+uid+" select.debtor_detail_collateral_collateral_type_id").val() == ""){
$('#'+uid+" .debtor_detail_collateral_collateral_type_id").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_collateral_type_id").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_security_document_date").val() == ""){
$('#'+uid+" .debtor_detail_collateral_security_document_date").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_security_document_date").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_security_document_value").val() == ""){
$('#'+uid+" .debtor_detail_collateral_security_document_value").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_security_document_value").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_insurance_company_name").val() == ""){
$('#'+uid+" .debtor_detail_collateral_insurance_company_name").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_insurance_company_name").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_title_issued_date").val() == ""){
$('#'+uid+" .debtor_detail_collateral_title_issued_date").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_title_issued_date").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_insurance_premium").val() == ""){
$('#'+uid+" .debtor_detail_collateral_insurance_premium").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_insurance_premium").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_valuation_value").val() == ""){
$('#'+uid+" .debtor_detail_collateral_valuation_value").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_valuation_value").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_market_value").val() == ""){
$('#'+uid+" .debtor_detail_collateral_market_value").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_market_value").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_valuation_date").val() == ""){
$('#'+uid+" .debtor_detail_collateral_valuation_date").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_valuation_date").removeClass('is-invalid');
}
if($('#'+uid+" select.debtor_detail_collateral_valuer_name").val() == ""){
$('#'+uid+" .debtor_detail_collateral_valuer_name").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_valuer_name").removeClass('is-invalid');
}
if($('#'+uid+" select.debtor_detail_collateral_proof_of_ownership").val() == ""){
$('#'+uid+" .debtor_detail_collateral_proof_of_ownership").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_proof_of_ownership").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_dealer_name").val() == ""){
$('#'+uid+" .debtor_detail_collateral_dealer_name").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_dealer_name").removeClass('is-invalid');
}
if($('#'+uid+" select.debtor_detail_collateral_security_document_type").val() == ""){
$('#'+uid+" .debtor_detail_collateral_security_document_type").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_security_document_type").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_official_value").val() == ""){
$('#'+uid+" .debtor_detail_collateral_official_value").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_official_value").removeClass('is-invalid');
}
if($('#'+uid+" .debtor_detail_collateral_expiry_date").val() == ""){
$('#'+uid+" .debtor_detail_collateral_expiry_date").addClass('is-invalid');
invalid++;
}else{
$('#'+uid+" .debtor_detail_collateral_expiry_date").removeClass('is-invalid');
}
if(invalid > 0){
$('#'+uid+" .debtor_detail_collateral_fieldset_savebutton").prop('disabled',true);
}else{
$('#'+uid+" .debtor_detail_collateral_fieldset_savebutton").prop('disabled',false);
}
}
}else{
$('#'+uid+" debtor_detail_collateral_collateral_description").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_address_line_1").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_address_line_2").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_address_line_3").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_collateral_type_id").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_security_document_date").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_security_document_value").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_insurance_company_name").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_title_issued_date").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_insurance_premium").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_valuation_value").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_market_value").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_valuation_date").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_valuer_name").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_proof_of_ownership").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_dealer_name").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_security_document_type").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_official_value").removeClass('is-invalid');
$('#'+uid+" debtor_detail_collateral_expiry_date").removeClass('is-invalid');
$('#'+uid+" .debtor_detail_collateral_fieldset_savebutton").prop('disabled',false);
}
}
function deleteCollateralConfirmation(uid,debtor_id,collateral_id){
swal({
title: lang.lang_delete_confirmation,
text: lang.lang_are_you_sure_you_want_to_delete_this_item.replace("#item#",lang.lang_collateral),
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: lang.lang_yes,
cancelButtonText: lang.lang_cancel
}).then((result) => {
if (result.value) {
volareApi("deleteDebtorCollateral",{action: 'deleteDebtorCollateral',debtor_id:debtor_id,collateralinfo:{id:collateral_id}},{uid:uid});
}
});
}