| 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'])) {
// 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);
}
// Read the uploaded CSV
$tmpName = $_FILES['csv_file']['tmp_name'];
$rows = [];
if (($handle = fopen($tmpName, "r")) !== false) {
$header = fgetcsv($handle); // read header
$rows[] = $header;
// Find the "Customer" column index
$customerCol = array_search("Customer", $header);
// Loop through each row and map the customer name
while (($data = fgetcsv($handle)) !== false) {
if ($customerCol !== false && isset($data[$customerCol])) {
$original = trim($data[$customerCol]);
if (isset($map[$original])) {
$data[$customerCol] = $map[$original];
}
}
$rows[] = $data;
}
fclose($handle);
}
// Output the modified CSV for download
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=Mapped_QBO_Customers.csv');
$output = fopen('php://output', 'w');
foreach ($rows as $row) {
fputcsv($output, $row);
}
fclose($output);
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Map Customer Names to QBO Format</title>
</head>
<body>
<h2>QBO Customer Name Mapper</h2>
<p>Upload your CSV export file. The system will map the "Customer" column using <code>qbo-customer-match.csv</code> and return a corrected version.</p>
<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 Map Names">
</form>
</body>
</html>