function fetch_related_images(empId, empId_date, getClaimStatus, map, TLId) {

	var siteVisitDate = $("#siteVisitDate_" + empId_date).html();
	var rotateImageDg = 0;
	$.ajax({

		url: "php/fetchImageDetails.php",
		method: "POST",
		dataType: "JSON",
		timeout:STANDARD_TIME_OUT,
		data: {
			empId: empId,
			selectedDate: siteVisitDate
		},
		success: function (data) {
			$("#billImagesBtn_" + empId_date).html("<i class='fa fa-arrow-up' aria-hidden='true'></i>");
			var len = data.length;
			if (len == 0) {
				printMessageNoData(empId_date); //function call
			} else {
				fetchImageDetails(len, data,empId_date, getClaimStatus,TLId);//function call
			}

			//Edit ImageBill
			$(".imgProfbtns.Edit").click(function () {
				$(this).hide();
				var empId_date = $(this).attr("data-common-id");
				var imagesLoopIndex = $(this).attr("data-index");
				$("#billProofAmount_" + empId_date+"_"+imagesLoopIndex).removeAttr("disabled");
				$("#billProofAmount_" + empId_date+"_"+imagesLoopIndex).focus();;
				$("#submitBtn_" + empId_date+"_"+imagesLoopIndex).show();
				$("#closeBtn_" + empId_date+"_"+imagesLoopIndex).show();
				$("#tickmark_" + empId_date+"_"+imagesLoopIndex).addClass("d-none");
				update_AllUnSaved_imageBills(empId_date);// chnaged

			});
			//Close-Edit ImageBill
			$(".imgProfbtns.Close").click(function () {
				$(this).hide();
				var empId_date = $(this).attr("data-common-id");
				var imagesLoopIndex = $(this).attr("data-index");
				$("#submitBtn_" +  empId_date+"_"+imagesLoopIndex).hide();
				$("#editBtn_" +  empId_date+"_"+imagesLoopIndex).show();
				$("#billProofAmount_" +  empId_date+"_"+imagesLoopIndex).attr("disabled", "disabled");
				
				  let imgBillRef_Val=REFERENCE_EDIT_IMGBILL_VALUES_MAP.get("billValue_"+empId_date+"_"+imagesLoopIndex);// chnaged
				  $("#billProofAmount_" +  empId_date+"_"+imagesLoopIndex).val(imgBillRef_Val);// chnaged
				 // REFERENCE_EDIT_IMGBILL_VALUES_MAP.set("billValue_"+empId_date+"_"+count,);
			//	update_AllUnSaved_imageBills(empId_date);
			});
			//submit ImageBill
			$(".imgProfbtns.Submit").click(function () {
				//calculating the all bill amount after changing one bill amount
				var presentClickedSubmitBtn = $(this);
			    var empId_date = presentClickedSubmitBtn.attr("data-common-id");
	            var imagesLoopIndex = presentClickedSubmitBtn.attr("data-index");
	            var updatedAmount = $("#billProofAmount_" + empId_date+"_"+imagesLoopIndex).val();  // storing present val 
	            	update_AllUnSaved_imageBills(empId_date);//reseting all unsaved image bills // chnaged  
	                $("#billProofAmount_" + empId_date+"_"+imagesLoopIndex).val(updatedAmount);// afetr reset storing back
			
				// var sum_of_hotelBills = 0;
				// var sum_of_otherBills = 0;
				// var siteVisitDateHotelBill = $("#editableTotalHotelBillAmount_" + empId_date).html();
				// var siteVisitDateOtherBill = $("#editableTotalOtherBillAmount_" + empId_date).html();
				// var sumOfAllBillAmount = Number(siteVisitDateHotelBill) + Number(siteVisitDateOtherBill);
				// var siteVisitDateTotal = $("#editableTotalFinalAmount_" + empId_date).html(); //before deduction total

				//Total=FTA + DA + (OtherBills + HotelBills)                     ie:(OtherBills + HotelBills)=sumOfAllBillAmount
				//Total-(OtherBills + HotelBills) = FTA + DA
				var totalFTAValue = getTotalofThisAttrValue("td input.FTAInputField.FTAinput_"+empId_date);
				var sum_of_hotelBills = getTotalofThisValue("input.billsInputField_"+empId_date + "_HOTEL_BILL");
				var sum_of_otherBills = getTotalofThisValue("input.billsInputField_"+empId_date+"_OTHER_BILL");
				var DaAmount=Number($("#editableDaAmount_"+ empId_date).attr("data-initialvalue"));
				
				
				// var FTA_And_DaAmount = Number(siteVisitDateTotal) - Number(sumOfAllBillAmount); //    FINAL-BILL = FTA+DA_AMOUNT;
				/*process done*/

				//        FINAL = FTA+DA_AMOUNT+BILL;
				//        FTA+DA_AMOUNT = FINAL-BILL;
				//        FINAL = FTA+DA_AMOUNT+ UP_BILLS

				// $("input.billsInputField_"+empId_date + "_HOTEL_BILL").each(function () {
				// 	sum_of_hotelBills += Number($(this).val());

				// });
				// $("input.billsInputField_"+empId_date+"_OTHER_BILL").each(function () {
				// 	sum_of_otherBills += Number($(this).val());

				// });
				sum_of_hotelBills = Number(sum_of_hotelBills.toFixed(2)); //   fix float value up to 2 digits
				sum_of_otherBills = Number(sum_of_otherBills.toFixed(2)); //   fix float value up to 2 digits

				// var siteVisitDateUpdatedBill = Number(sum_of_hotelBills) + Number(sum_of_otherBills);
				var siteVisitDateUpdatedTotal = totalFTAValue+ DaAmount + sum_of_hotelBills+ sum_of_otherBills;
                console.log("siteVisitDateUpdatedTotal"+siteVisitDateUpdatedTotal);
				var loggedInUserDeductAmount = Number(siteVisitDateUpdatedTotal) - Number(map.get("beforeDeductingTotalAmount" + empId_date));
				if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) { //constant variable in constant.js
					var totalLoggedInUserDeductedAmount = Number(map.get("tlDeductedAmount" + empId_date)) + loggedInUserDeductAmount;
				} else if (LOGGED_IN_DEPARTMENT == FINANCE_DEPARTMENT) { //constant variable in constant.js
					var totalLoggedInUserDeductedAmount = Number(map.get("financeDeductedAmount" + empId_date)) + loggedInUserDeductAmount;
				}
				console.log("totalFTAValue"+totalFTAValue+"sum_of_hotelBills"+sum_of_hotelBills+"sum_of_otherBills"+sum_of_otherBills+"DaAmount"+DaAmount);
				postTheEditedImageDetails(presentClickedSubmitBtn, imagesLoopIndex, updatedAmount, empId_date, sum_of_hotelBills, sum_of_otherBills, siteVisitDateUpdatedTotal, totalLoggedInUserDeductedAmount); //function call

			});



			/*---------------------------------------------------------*/
			/*fullView functionalites of billImages*/
			/*---------------------------------------------------------*/
			$(".imagehover").mouseover(function () {
				//alert("dsk");
				var imgID = $(this).attr("id");
				let empId_date = $(this).attr("data-common-id");
				var imageLoopIndex = $(this).attr("data-index");
				imageZoom(imgID, "myresult", empId_date+"_"+imageLoopIndex); //function call in "imageZoomCalculations.js"

				$("#myresult").css("visibility", "visible"); // show the result div for image zoom preview

			});

			$(".fullImageRotateLeft").click(function () {
				switch (Number(rotateImageDg)) {
					case 0:
						rotateImageDg = 270;
						break;
					case 90:
						rotateImageDg = 0;
						break;
					default:
						rotateImageDg = Number(rotateImageDg) - 90;
						break;
				}
				$("#myImageModal img").css("transform", "rotate(" + rotateImageDg + "deg)");
			});

			$(".fullImageRotateRight").click(function () {

				switch (Number(rotateImageDg)) {
					case 270:
						rotateImageDg = 0;
						break;
					default:
						rotateImageDg = Number(rotateImageDg) + 90;
						break;
				}
				$("#myImageModal img").css("transform", "rotate(" + rotateImageDg + "deg)");
			});

			$(".fullImageModelclose").click(function () {
				$("#myImageModal").css("display", "none");
			});


			$(".img-zoom-container").hover(function () {

			}, function () {
				$(".img-zoom-lens").remove();
				$("#myresult").css("visibility", "hidden"); // hide the result div for image zoom preview
			});

			/*---------------------------------------------------------*/

		},
		statusCode: {
    		404: function(){
    		alert("requesting file(php/fetchImageDetails) does not exists! in server");
    		}
    	},
		error: function (jqXHR, textStatus, errorThrown) {
		    	$("#billImagesBtn_" + empId_date).html("<i class='fas fa-redo'></i>");
		    	$("#billImagesBtn_" + empId_date).attr("data-btnstatus","Buttonclosed");
			    console.log(jqXHR); 
			    console.log("ajax error in image bill submition" + jqXHR + " textStatus=" + textStatus + " errorThrown=" + errorThrown);
		}


	});
	
	

}

/*---------------------------------------------------------*/
/*if Claim doesn't have imageproofs*/
/*---------------------------------------------------------*/
function printMessageNoData(empId_date) {
	var td_image_UI_Not_found =
		"<div class='m-auto p-2'><p style='color:red'>Images Not Found</p></div>";
	$('#imageBillsContainerDiv_' + empId_date).append(td_image_UI_Not_found);
	$('#imageBillsContainerDiv_' + empId_date).parent().css("border-top", "1px solid #dee2e6");
}
/*---------------------------------------------------------*/
/*9+(1)/2*/



/*---------------------------------------------------------*/
/*if Claim have bill-imageproofs*/
/*---------------------------------------------------------*/
function fetchImageDetails(len, data,empId_date, getClaimStatus, TLId) {
	let td_image_UI='<div class="m-auto d-flex">';
	$('#imageBillsContainerDiv_' + empId_date).empty(); 
	var SelectedTabRelatedImageBillDetails = new SelectedTabRelatedImageBillUIDetails();
	for (var forLoopIndex = 0; forLoopIndex < len; forLoopIndex++) {
	    
		 td_image_UI += getSelectedTabRelatedImageBillDetailsUi(SelectedTabRelatedImageBillDetails, getClaimStatus, data[forLoopIndex], forLoopIndex, empId_date, TLId);
		 
	    }
	    td_image_UI+'</div>';
	    $('#imageBillsContainerDiv_' + empId_date).append(td_image_UI);
		$('#imageBillsContainerDiv_' + empId_date).css("overflow-x", "scroll");
		$('#imageBillsContainerDiv_' + empId_date).parent().css("border-top", "1px solid #dee2e6");


}
/*---------------------------------------------------------*/




/*---------------------------------------------------------*/
/*Submit the updated values(bill-imageproofs details) to server*/
/*---------------------------------------------------------*/
function postTheEditedImageDetails(presentClickedSubmitBtn, imagesLoopIndex, updatedAmount, empId_date, sum_of_hotelBills, sum_of_otherBills, siteVisitDateUpdatedTotal, totalLoggedInUserDeductedAmount) {
	
	var postImageParamValues = new Map();
	var empDateArry = empId_date.split("_");
	var empId=empDateArry[0];
	var siteVisitDate=empDateArry[1];
	//console.log("empId"+empId+"siteVisitDate"+siteVisitDate);
	var imageurl = $("#billProofImg_" + empId_date+"_"+imagesLoopIndex).attr("src");
	var replaceurl = IMAGE_BASE_URL + empId + "/" + siteVisitDate + "/"; //IMAGE_BASE_URL is constant variable in contant.js
	var imageName = imageurl.replace(replaceurl, "");
	$("#submitBtn_" + empId_date+"_"+imagesLoopIndex).html("<i class='fa fa-spinner fa-spin mr-2'></i>"); //loading gif
	var uniqueId = empId + "_" + siteVisitDate;
	postImageParamValues.set("billProofAmount", updatedAmount);
	postImageParamValues.set("imageName", imageName);
	postImageParamValues.set("uniqueId", uniqueId);
	postImageParamValues.set("hotelbills", sum_of_hotelBills);
	postImageParamValues.set("otherbills", sum_of_otherBills);
	postImageParamValues.set("finalTotalAmount", siteVisitDateUpdatedTotal);
	postImageParamValues.set("loggedInUserDeductAmount", totalLoggedInUserDeductedAmount);
	var tostring = strMapToJson(postImageParamValues);
	$.ajax({

		url: "php/updateBillAmount.php",
		method: "POST",
		dataType: "JSON",
		data: {
			imageRelatedValues: tostring
		},
		success: function (data) {


			//console.log(data);
			if (data != "UNABLE TO UPDATE") {
			    REFERENCE_EDIT_IMGBILL_VALUES_MAP.set("billValue_"+empId_date+"_"+imagesLoopIndex,updatedAmount); //update the map value // chnaged
				presentClickedSubmitBtn.hide(); //submit button hide after successfull update
				$("#closeBtn_" + empId_date+"_"+imagesLoopIndex).hide();
				$("#editBtn_" + empId_date+"_"+imagesLoopIndex).show();
				$("#billProofAmount_" + empId_date+"_"+imagesLoopIndex).attr("disabled", "disabled");
				var otherBill = data.otherBills; //updating hotel->bills in UI
				var hotelBill = data.hotelBill; //updating hotel->bills in UI
				let currentDAamount=Number($("#editableDaAmount_"+ empId_date).html());
				let currentTotalFTA=getTotalofThisValue("td input.FTAInputField.FTAinput_"+empId_date);
			//	var total = data.total;
			//console.log("ajx currentTotalFTA"+currentTotalFTA+"currentDAamount"+currentDAamount+"otherBill"+otherBill+"hotelBill"+hotelBill);
				let total=currentTotalFTA+currentDAamount+otherBill+hotelBill;
				$("#editableTotalOtherBillAmount_" + empId_date).html(otherBill);
				$("#editableTotalHotelBillAmount_" + empId_date).html(hotelBill);
				$("#editableTotalFinalAmount_" + empId_date).html(total);
				$("#tickmark_" + empId_date+"_"+imagesLoopIndex).removeClass("d-none");
				$("#submitBtn_" + empId_date+"_"+imagesLoopIndex).html("Submit");
            }
		},
		error: function (jqXHR, textStatus, errorThrown) {
			$("#submitBtn_" + empId_date+"_"+imagesLoopIndex).html("Retry");
			console.log("ajax error in image bill submition" + jqXHR + " textStatus=" + textStatus + " errorThrown=" + errorThrown);
		}
	});
}
/*---------------------------------------------------------*/


function getSelectedTabRelatedImageBillDetailsUi(SelectedTabRelatedImageBillDetails, claimStatus, rowValues, forLoopIndex, empId_date, TLId) {
	var ImageUI;
	switch (claimStatus) {
		case CLAIM_PENDING:
		    if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
		        if(TLId==USER_EMPID){ // logged in user(tl) id "USER_EMPID" in index.php
				    ImageUI = SelectedTabRelatedImageBillDetails.Tab_TLEditableImageDetails(rowValues, forLoopIndex, empId_date);
		        }else{
		            ImageUI = SelectedTabRelatedImageBillDetails.Tab_TLNonEditableImageDetails(rowValues,forLoopIndex, empId_date);
		        }
			} else if (LOGGED_IN_DEPARTMENT == FINANCE_DEPARTMENT) {
				ImageUI = SelectedTabRelatedImageBillDetails.Tab_FinanceNonEditableImageDetails(rowValues,forLoopIndex, empId_date);
			}
			break;
		case CLAIM_TL_APPROVED:
			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
				ImageUI = SelectedTabRelatedImageBillDetails.Tab_TLNonEditableImageDetails(rowValues,forLoopIndex, empId_date);
			} else if (LOGGED_IN_DEPARTMENT == FINANCE_DEPARTMENT) {
				//ImageUI = SelectedTabRelatedImageBillDetails.Tab_FinaceEditableImageDetails(empId, rowValues, siteVisitedDate, forLoopIndex, empId_date);
				ImageUI = SelectedTabRelatedImageBillDetails.Tab_FinaceEditableImageDetails(rowValues,forLoopIndex, empId_date);
			}
			break;
		case CLAIM_TL_REJECTED:
		case CLAIM_PERMANENT_TL_REJECT:
			ImageUI = SelectedTabRelatedImageBillDetails.Tab_TLNonEditableImageDetails(rowValues,forLoopIndex, empId_date);
			break;
		case CLAIM_FINANCE_APPROVED:
			ImageUI = SelectedTabRelatedImageBillDetails.Tab_FinanceNonEditableImageDetails(rowValues,forLoopIndex, empId_date);
			break;
		case CLAIM_FINANCE_REJECTED:
		case CLAIM_PERMANENT_FINANCE_REJECT:
			ImageUI = SelectedTabRelatedImageBillDetails.Tab_FinanceNonEditableImageDetails(rowValues,forLoopIndex, empId_date);
			break;
		case CLAIM_PAID:
			ImageUI = SelectedTabRelatedImageBillDetails.Tab_FinanceNonEditableImageDetails(rowValues,forLoopIndex, empId_date);
			break;




	}
	return ImageUI;
}

/*updateing the image inputs field values on edit btn clicked*/// chnaged

function update_AllUnSaved_imageBills(empId_date){
    let count=0;
    $(".billsInputField_of_"+empId_date).each(function(){
       let imgBillRef_Val=REFERENCE_EDIT_IMGBILL_VALUES_MAP.get("billValue_"+empId_date+"_"+count);
       $("#billProofAmount_"+empId_date+"_"+count).val(imgBillRef_Val);
         count++;
    });
    
}
/*----------------------------------------------------------*/
/*---------------------------------------------------------*/
/*converting Map values to Json formate*/
/*---------------------------------------------------------*/
function strMapToJson(strMap) {
	return JSON.stringify(strMapToObj(strMap));
}

function strMapToObj(strMap) {
	let obj = Object.create(null);
	for (let [k, v] of strMap) {
		obj[k] = v;
	}
	return obj;
}
/*---------------------------------------------------------*/


	function getTotalofThisValue(totalOfThisObject){
	   let sum=0;
	    $(totalOfThisObject).each(function(){
	        sum+=Number($(this).val());
	    });
	    
	    return sum;
	}
	function getTotalofThisAttrValue(totalOfThisObject){
	   let sum=0;
	    $(totalOfThisObject).each(function(){
	        sum+=Number($(this).attr("data-initialvalue"));
	    });
	    
	    return sum;
	}



// ;;