53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
class WinShop
|
|
{
|
|
public function export()
|
|
{
|
|
$orders = sqlQuery('SELECT id, order_no FROM orders WHERE date_created > DATE_SUB(NOW(), INTERVAL 30 DAY)');
|
|
foreach ($orders as $order) {
|
|
$this->export_order($order['id'], $order['order_no']);
|
|
}
|
|
}
|
|
|
|
public function export_order($order_id, $code)
|
|
{
|
|
$file = "data/import/Import/{$code}.xml";
|
|
|
|
if (file_exists($file)) {
|
|
return false;
|
|
}
|
|
|
|
$xml = $this->get_order_xml($order_id);
|
|
|
|
$handle = fopen($file, 'w');
|
|
fwrite($handle, $xml);
|
|
fclose($handle);
|
|
|
|
return true;
|
|
}
|
|
|
|
public function get_order_xml($order_id)
|
|
{
|
|
$order = new Order();
|
|
$order->createFromDB($order_id, true, false, true);
|
|
$order->fetchRawDates();
|
|
$order->fetchItems();
|
|
|
|
$smarty = createSmarty(true);
|
|
$smarty->assign([
|
|
'order' => $order,
|
|
'winshop' => $this,
|
|
]);
|
|
|
|
return $smarty->fetch('export/order.WinShop.tpl');
|
|
}
|
|
|
|
public function get_order_item_variation($item)
|
|
{
|
|
preg_match('/\(Velikost.*?: ([^\)]+)/i', $item['descr'], $matches);
|
|
|
|
return $matches[1];
|
|
}
|
|
}
|