diff --git a/utils/load_warranty_serial/load_serials.php b/utils/load_warranty_serial/load_serials.php index 9df178bc..323f3156 100644 --- a/utils/load_warranty_serial/load_serials.php +++ b/utils/load_warranty_serial/load_serials.php @@ -9,7 +9,7 @@ $output_file = $argv[5]; $output_fh = fopen($output_file, "w"); -if (!file_exists($csv)) +if (!file_exists($argv[1])) { $err_message = "No csv input file found." . "\n"; fwrite($output_fh, $err_message); @@ -34,6 +34,7 @@ while (($row = fgetcsv($csv)) !== false) // (2) No available data // (3) CH2000012071,WCHD23BL-CPN00-LX,0,2020-08-11 04:05:27.090,0,4,CHAMPION MF // (4) Empty line + // (5) empty sku // check if No available data if ($row[0] == 'No available data') @@ -43,25 +44,22 @@ while (($row = fgetcsv($csv)) !== false) continue; } - // check if new line - if (empty($row[0])) + // check if empty line + if ($row == array(null)) { // skip error_log('Skipping empty line...'); continue; } - // check if csv file has a header by checking contents of line - if (($row[0] == 'SerialNumber') || ($row[1] == 'Sku') || - ($row[2] == 'DispatchStatus') || ($row[3] == 'CreatedDate') || - ($row[4] == 'InventoryStatus') || ($row[5] == 'CategoryID') || - ($row[6] == 'CategoryName')) + // check if empty serial + if (empty($row[0])) { - // skip the header - error_log('Skipping the headers... '); + $err_message = "Empty serial. " . "\n"; + fwrite($output_fh, $err_message); continue; } - + // sample of line in output file: // serial number, sku, dispatch status, created date, inventory status, category id, category name // CH2000012071,WCHD23BL-CPN00-LX,0,2020-08-11 04:05:27.090,0,4,CHAMPION MF