--- a/admin/import.php +++ b/admin/import.php @@ -70,7 +70,7 @@ $agencyInsertQ = $conn->prepare($agencyInsertQ); function processFile($fpath, $tablename) { - global $conn, $contractNoticeQ, $supplierInsertQ, $agencyInsertQ; + global $conn, $contractNoticeFields, $contractNoticeInsertQ, $supplierFields, $supplierInsertQ,$agencyFields, $agencyInsertQ; $row = 1; $handle = fopen($fpath, "r"); //"t" mode string translates windows line breaks to unix @@ -131,13 +131,13 @@ if (in_array(($datamapping0711[$headers[$c]]), $contractNoticeFields)) { if (($datamapping0711[$headers[$c]]) == "parentCN" || ($datamapping0711[$headers[$c]]) == "CNID") { $data[$c] = substr($data[$c], 2); // take off the "CN" prefix - if ($data[$c] > 0) { + if ($data[$c] > 0 && $data[$c] != '0') { $contractNoticeInsert[] = $data[$c]; } else { - $contractNoticeInsert[] = 0; + $contractNoticeInsert[] = null; } } elseif (($datamapping0711[$headers[$c]]) == "supplierABN") { - if ($data[$c] > 0) { + if ($data[$c] > 0 && $data[$c] != '0') { $contractNoticeInsert[] = $data[$c]; } else { $contractNoticeInsert[] = null; @@ -229,9 +229,14 @@ // loop through all of the files while (false !== ($fname = readdir($dhandle))) { if (($fname != '.') && ($fname != '..')) { - echo "<a href=\"import.php?fname=$fname\">$fname</a> " . filesize($path . $fname) . " " . date("c", filemtime($path . $fname)) . "<br/>"; - } + $files[date("c", filemtime($path . $fname)).md5($fname)] = $fname; + } } + } + ksort($files); + foreach ($files as $date => $fname) { + echo "<a href=\"import.php?fname=$fname\">$fname</a> " . filesize($path . $fname) . " " . $date . "<br/>"; + } } else { $success = 0;