| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wcfs/tabs/ |
Upload File : |
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
echo "<pre>";
// Load customer name mapping
$map = [];
if (($handle = fopen("qbo-customer-match.csv", "r")) !== false) {
$header = fgetcsv($handle); // skip header
while (($data = fgetcsv($handle)) !== false) {
$map[trim($data[0])] = trim($data[1]);
}
fclose($handle);
}
echo "Loaded customer map:\n";
print_r($map);
// Read the uploaded CSV
$tmpName = $_FILES['csv_file']['tmp_name'];
$rows = [];
if (($handle = fopen($tmpName, "r")) !== false) {
$header = fgetcsv($handle); // read header
$rows[] = $header;
$customerCol = array_search("Customer", $header);
echo "\nCustomer column index: $customerCol\n";
while (($data = fgetcsv($handle)) !== false) {
if ($customerCol !== false && isset($data[$customerCol])) {
$original = trim($data[$customerCol]);
if (isset($map[$original])) {
echo "Mapping $original to {$map[$original]}\n";
$data[$customerCol] = $map[$original];
} else {
echo "No map for $original\n";
}
}
$rows[] = $data;
}
fclose($handle);
}
echo "</pre>";
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Debug Customer Name Mapper</title>
</head>
<body>
<h2>QBO Customer Name Mapper - Debug Mode</h2>
<form method="POST" enctype="multipart/form-data">
<label>Select CSV File:</label><br>
<input type="file" name="csv_file" accept=".csv" required><br><br>
<input type="submit" value="Upload and Debug Mapping">
</form>
</body>
</html>