
class Pagination {

    getJsonInPaginationFormate(JsonData,recordsPerPage) {
        //console.log(recordsPerPage);
        var PaginationArray = []; // array
        //var count = 0;
        var PageLimit = recordsPerPage-1;
        var tempArray = []; //

        var jsonLength = JsonData.length;
        for (var index = 0; index < jsonLength; index++) {
            JsonData[index].sno=index+1;
            tempArray.push(JsonData[index]);

            if (index == jsonLength - 1) { // last index in array (if index not reaches the Pagelimit push remaining excess data next page)
                //console.log(tempArray);
                PaginationArray.push(tempArray);
            }else if (index === PageLimit) { // if index at page-limit
                if (JsonData[index].date == JsonData[index + 1].date && JsonData[index].empId == JsonData[index + 1].empId) {
                    // checking last record in page ending with the next record data with same empid and siteDate
                    PageLimit += 1; //if so ski one record in same page
                } else {
                    PaginationArray.push(tempArray);
                    tempArray = [];
                    PageLimit += recordsPerPage; // records per page
                }

            }

        }
        //console.log(PaginationArray);
        return PaginationArray;


    }

}



// ;;