From 0a7f672ecdfa7a02a1e939676151711d84aacac2 Mon Sep 17 00:00:00 2001 From: Kyle Huynh Date: Fri, 12 Mar 2021 09:15:59 -0500 Subject: [PATCH] fixed bug missing last few records when bulk binding --- admin/admin.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/admin/admin.php b/admin/admin.php index cbc907d..38d3425 100755 --- a/admin/admin.php +++ b/admin/admin.php @@ -1177,9 +1177,15 @@ function doPost(index, total_data, csvResult) { // pulll preserve read data from CSV from local storage var csvResult = JSON.parse(localStorage.getItem("importCSV")); var password = JSON.parse(localStorage.getItem("syspasswd")); - var keys = csvResult[0].split(',').map(function (x) { + if (Array.isArray(csvResult)) { + var keys = csvResult[0].split(',').map(function (x) { return x.toUpperCase(); - }); + }); + } + else { + return; + } + // start binding each line of CSV file var item = csvResult[index]; @@ -1242,14 +1248,14 @@ function processPostSuccess(index, csvResult, data) { $('#total_data').text(total_data); // calculate percentage of ongoing process. - var width = Math.round(((index + 1) / total_data) * 100); + var width = ((index + 1) / total_data) * 100; // update the progress bar. $('#process_data').text(index); $('.progress-bar').css('width', width + '%'); // if the process reaches 100% - if (width >= 99) { + if (width >= 100) { // dismiss the progress bar $('#process').css('display', 'none');