Skip to content

Instantly share code, notes, and snippets.

@Theaxiom
Last active October 14, 2015 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Theaxiom/0f88183a95ba8c4c20fd to your computer and use it in GitHub Desktop.
Save Theaxiom/0f88183a95ba8c4c20fd to your computer and use it in GitHub Desktop.
Export from unicentapos
<?php
mysql_connect("localhost", "root", "") or
die("Could not connect: " . mysql_error());
mysql_select_db("unicentapos");
$limit = 100;
if (!empty($_GET["limit"])) {
$limit = $_GET["limit"];
}
$start = 0;
if (!empty($_GET["start"])) {
$start = $_GET["start"];
}
$result = mysql_query("SELECT * FROM products LIMIT $start, $limit");
$out = null;
//$out .= 'Product Code Product ID (Matching Only) Description Family UPC Class Tax Status Supplier Currency Supplier Code Cost Sell Sell (Tax Inclusive) Minimum Margin No Profit Creation Date Modification Date Color Size Height Length Weight Width Photo Notes Current Inventoried Serialized Editable Editable Sell Auto Add Related Inventory Quantity Web Web Price Web Keyword 1 Web Keyword 2 Web Keyword 3 Web Long Description Web Short Description Web Category 1 Web Category 2 Web Category 3 POS Category 1 POS Category 2 POS Category 3 Reorder Type Reorder Point Reorder Amount Master Model (0/n or 1/y) Master Product Code Pricing Level 1 Cost Pricing Level 2 Cost Pricing Level 3 Cost Pricing Level 4 Cost Pricing Level 5 Cost Pricing Level 6 Cost Pricing Level 7 Cost Pricing Level 8 Cost Pricing Level 9 Cost Pricing Level 10 Cost Pricing Level 1 Pricing Level 2 Pricing Level 3 Pricing Level 4 Pricing Level 5 Pricing Level 6 Pricing Level 7 Pricing Level 8 Pricing Level 9 Pricing Level 10 GL Inventory/Asset Account GL Income Account GL COGS/Expense Account GL Payable Expense Custom Text Field 1 Custom Text Field 2 Custom Text Field 3 Custom Text Field 4 Custom Text Field 5 Custom Text Field 6 Custom Text Field 7 Custom Text Field 8 Custom Text Field 9 Custom Text Field 10 Custom Date Field 1 Custom Date Field 2 Custom Date Field 3 Custom Date Field 4 Custom Date Field 5 Custom Date Field 6 Custom Date Field 7 Custom Date Field 8 Custom Date Field 9 Custom Date Field 10 Custom Check Field 1 Custom Check Field 2 Custom Check Field 3 Custom Check Field 4 Custom Check Field 5 Custom Check Field 6 Custom Check Field 7 Custom Check Field 8 Custom Check Field 9 Custom Check Field 10 Quantity Discount 1 (Qty) Quantity Discount 1 (Sell) Quantity Discount 2 (Qty) Quantity Discount 2 (Sell) Quantity Discount 3 (Qty) Quantity Discount 3 (Sell) Quantity Discount 4 (Qty) Quantity Discount 4 (Sell) Quantity Discount 5 (Qty) Quantity Discount 5 (Sell)';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$out .= $row['CODE'] . "\t" . $row['CODE'] . "\t" . 'UPC CLASS' . "\t" . '' . "\t" . 'Default' . "\t" . 'Supplier' . "\t" . 'US' . "\t" . 'Supplier Code' . "\t" . $row['PRICEBUY'] . "\t" . $row['PRICESELL'] . "\t" . '' . "10" . "\n";
}
// echo '<pre>' . $out . '</pre>';
$nextStart = $start + $limit;
$file = 'export.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new product to the file
$current .= $out;
// Write the contents back to the file
file_put_contents($file, $current);
//mysql_free_result($result);
?>
<a href="?start=<?php echo $nextStart; ?>&limit=<?php echo $limit; ?>">export</a><hr />
<?php echo $out; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment