public static function orderStatusXml($data_auth, $order_id = 0, $shipment_id = 0) { $data_status = array(); if (!empty($order_id)) { unset($data_auth['Number']); unset($data_auth['OrderCount']); } else { $period_sdek = $data_auth['ChangePeriod']; unset($data_auth['ChangePeriod']); } $data_auth['ShowHistory'] = "1"; $xml = ' ' . RusSdek::arraySimpleXml('StatusReport', $data_auth, 'open'); if (!empty($order_id)) { $order_sdek = array('Number' => $order_id . '_' . $shipment_id, 'Date' => $data_auth['Date']); $xml .= ' ' . RusSdek::arraySimpleXml('Order', $order_sdek); } elseif (!empty($period_sdek)) { $xml .= ' ' . RusSdek::arraySimpleXml('ChangePeriod', $period_sdek); } $xml .= ' ' . '</StatusReport>'; $response = RusSdek::xmlRequest('http://gw.edostavka.ru:11443/status_report_h.php', $xml, $data_auth); if (!empty($response)) { $_result = json_decode(json_encode((array) @simplexml_load_string($response)), true); if (!empty($_result['Order'])) { $_result = empty($_result['Order']['@attributes']) ? $_result['Order'] : array($_result['Order']); foreach ($_result as $data_order) { $order = explode('_', $data_order['@attributes']['Number']); $d_status = !empty($data_order['Status']['State']) ? $data_order['Status']['State'] : $data_order['Status']; if (!empty($d_status['@attributes'])) { $status[] = $d_status; unset($d_status['@attributes']); if (empty($d_status) && !empty($status)) { $d_status = $status; } } if (!empty($order[1])) { foreach ($d_status as $state) { $data_status[$order[0] . '_' . $order[1] . '_' . $state['@attributes']['Code']] = array('status_id' => $state['@attributes']['Code'], 'order_id' => $order[0], 'shipment_id' => $order[1], 'timestamp' => strtotime($state['@attributes']['Date']), 'status' => $state['@attributes']['Description'], 'city_code' => $state['@attributes']['CityCode'], 'city_name' => db_get_field("SELECT a.city FROM ?:rus_city_sdek_descriptions as a LEFT JOIN ?:rus_cities_sdek as b ON a.city_id=b.city_id WHERE b.city_code = ?s", $state['@attributes']['CityCode']), 'date' => date("d-m-Y", strtotime($state['@attributes']['Date']))); } } } } } return $data_status; }
function fn_sdek_get_ticket_order($data_auth, $order_id, $chek_id) { unset($data_auth['Number']); $xml = ' ' . RusSdek::arraySimpleXml('OrdersPrint', $data_auth, 'open'); $order_sdek = array('Number' => $order_id . '_' . $chek_id, 'Date' => $data_auth['Date']); $xml .= ' ' . RusSdek::arraySimpleXml('Order', $order_sdek); $xml .= ' ' . '</OrdersPrint>'; $response = RusSdek::xmlRequest('http://gw.edostavka.ru:11443/orders_print.php', $xml, $data_auth); $download_file_dir = fn_get_files_dir_path() . '/sdek' . '/' . $chek_id . '/'; fn_rm($download_file_dir); fn_mkdir($download_file_dir); $name = $order_id . '.pdf'; $download_file_path = $download_file_dir . $name; if (!fn_is_empty($response)) { fn_put_contents($download_file_path, $response); } }