static function export1c() { global $CONFIG, $ST; set_time_limit(1000); $data = array('make_date' => date('Y-m-d'), 'make_time' => date('H:i:s'), 'document' => array()); $date_from = date('Y-m-d'); $date_to = date('Y-m-d', time() + 3600 * 24); if (isset($_GET['d']) && ($t = strtotime($_GET['d']))) { $date_from = date('Y-m-d', $t); $date_to = date('Y-m-d', $t + 3600 * 24); } // if($get->get('date_from')){ // $date_from=$get->get('date_from'); // } // // if($get->get('date_to')){ // $date_to=$get->get('date_to'); // } $q = "SELECT u.*,o.* FROM sc_shop_order o\r\n\t\tLEFT JOIN sc_users AS u ON u.u_id=o.userid\r\n\t\tWHERE \r\n\t\t o.create_time>='{$date_from}' AND o.create_time<='{$date_to}'\r\n\t\t"; $rs = $ST->select($q); while ($rs->next()) { $d = array('id' => $rs->get('id'), 'num' => $rs->get('id'), 'date' => dte($rs->get('create_time'), 'Y-m-d'), 'summ' => $rs->get('total_price'), 'contragent' => array('id' => $rs->get('u_id') . '#' . $rs->get('login') . '#' . $rs->get('fullname') . '#' . $rs->get('phone'), 'name' => $rs->get('type') == 'user_jur' && trim($rs->get('company')) ? $rs->get('company') : $rs->get('fullname'), 'address' => $rs->get('address'), 'mail' => $rs->get('mail')), 'time' => dte($rs->get('create_time'), 'H:i:s'), 'additionally' => $rs->get('additionally'), 'goods' => array()); $q = "SELECT *,ec.id AS ext_cat_id, oi.price AS price \t\r\n\t\t\tFROM sc_shop_order_item AS oi, sc_shop_item AS si\r\n\t\t\tLEFT JOIN sc_shop_srv_extcat AS ec ON ec.lnk=si.category\r\n\t\t\tWHERE\r\n\t\t\t\tsi.id=oi.itemid\r\n\t\t\t\tAND oi.orderid={$rs->get('id')} \r\n\t\t\t\t\r\n\t\t\t"; $q = "SELECT *, oi.price AS price \t\r\n\t\t\tFROM sc_shop_order_item AS oi, sc_shop_item AS si\r\n\t\t\t\r\n\t\t\tWHERE\r\n\t\t\t\tsi.id=oi.itemid\r\n\t\t\t\tAND oi.orderid={$rs->get('id')} "; $rs1 = $ST->select($q); while ($rs1->next()) { $g = array('name' => $rs1->get('name'), 'id' => $rs1->get('ext_id'), 'price' => $rs1->get('price'), 'count' => $rs1->get('count'), 'summ' => $rs1->get('price') * $rs1->get('count')); if ($rs1->get('unit_sale') == 2) { if ($rs1->getInt('pack_size') != 0) { //03.02.2013 $g['count'] *= $rs1->getInt('pack_size'); $g['price'] /= $rs1->getInt('pack_size'); $g['price'] = round($g['price'], 2); } } $d['goods'][] = $g; } $data['document'][] = $d; } $file = ROOT . '/' . CATALOG_EXPORT_DIR . '/' . 'order.xml'; if (isset($_GET['d']) && ($t = strtotime($_GET['d']))) { $file = ROOT . '/' . CATALOG_EXPORT_DIR . '/' . date('Y_m_d', $t) . '.xml'; } $out = '<?xml version="1.0" encoding="windows-1251"?>'; $out .= LibCatsrv::render($data, dirname(__FILE__) . '/order1c.xml.php'); if (isset($_GET['get'])) { return $out; } else { file_put_contents($file, $out); exit; } }