Example #1
0
 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;
 }
Example #2
0
        $data['time_from'] = date("Y-01-1 00:00:00");
        $data['time_to'] = date("Y-m-d 23:59:59", $data['time_to']);
    } else {
        $data['time_from'] = date("Y-m-d 00:00:00", $data['time_from']);
        $data['time_to'] = date("Y-m-d 23:59:59", $data['time_to']);
    }
    foreach ($shipping as $shipping_id => $d_shipping) {
        $service_params = unserialize($d_shipping['service_params']);
        if (!empty($service_params['authlogin']) && !empty($service_params['authpassword'])) {
            $shipping_params['Account'] = $service_params['authlogin'];
            $shipping_params['Secure'] = md5($t_date . '&' . $service_params['authpassword']);
            $shipping_params['Date'] = $t_date;
            $shipping_params['ChangePeriod']['DateFirst'] = $data['time_from'];
            $shipping_params['ChangePeriod']['DateLast'] = $data['time_to'];
            $d_status = RusSdek::orderStatusXml($shipping_params);
            RusSdek::addStatusOrders($d_status);
        } else {
            fn_set_notification('E', __('notice'), __('shippings.sdek.account_password_error'));
        }
    }
    $params['time_from'] = $data['time_from'];
    $params['time_to'] = $data['time_to'];
    $data['time_from'] = strtotime($data['time_from']);
    $data['time_to'] = strtotime($data['time_to']);
    list($data_status, $search) = fn_rus_sdek_get_status($params, Registry::get('settings.Appearance.admin_elements_per_page'));
    Tygh::$app['view']->assign('period', $data);
    Tygh::$app['view']->assign('data_status', $data_status);
    Tygh::$app['view']->assign('search', $search);
}
function fn_rus_sdek_get_status($params = array(), $items_per_page = 0)
{
Example #3
0
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);
    }
}
Example #4
0
 private function _getRates($response)
 {
     $rates = array();
     if (!empty($response['result']['price'])) {
         $rates['price'] = $response['result']['price'];
         if (!empty($response['result']['deliveryPeriodMin']) && !empty($response['result']['deliveryPeriodMax'])) {
             $plus = $this->_shipping_info['service_params']['dateexecute'];
             $min_time = $plus + $response['result']['deliveryPeriodMin'];
             $max_time = $plus + $response['result']['deliveryPeriodMax'];
             $date = $min_time . '-' . $max_time . ' (' . __('days') . ')';
             if (!empty($date)) {
                 $rates['date'] = $date;
             }
         }
         $rec_city_code = $this->city_id;
         $tarif_id = $this->_shipping_info['service_params']['tariffid'];
         if (!empty($rec_city_code) && $tarif_id == SDEK_STOCKROOM && $tarif_id == $response['result']['tariffId']) {
             $params = array('cityid' => $rec_city_code);
             $offices = RusSdek::pvzOffices($params);
             if (!empty($offices)) {
                 $rates['offices'] = $offices;
             } else {
                 $rates['clear'] = true;
             }
         }
     }
     return $rates;
 }
Example #5
0
            }
        }
        $join = db_quote("LEFT JOIN ?:rus_cities_sdek as c ON c.city_id = d.city_id");
        $condition = db_quote(" AND c.status = ?s", 'A');
        if (!empty($params['check_country']) && $params['check_country'] != 'undefined') {
            $condition .= db_quote(" AND c.country_code = ?s", $params['check_country']);
            if (!empty($params['check_state']) && $params['check_state'] != 'undefined') {
                $condition .= db_quote(" AND c.state_code = ?s", $params['check_state']);
            }
        }
        $cities = db_get_array("SELECT d.city, c.city_code FROM ?:rus_city_sdek_descriptions as d ?p WHERE city LIKE ?l AND lang_code = ?s  ?p  LIMIT ?i", $join, $search, 'ru', $condition, 10);
        if (!empty($cities)) {
            foreach ($cities as $city) {
                $select[] = array('code' => $city['city_code'], 'value' => $city['city'], 'label' => $city['city']);
            }
        }
        Registry::get('ajax')->assign('autocomplete', $select);
        exit;
    }
} elseif ($mode == 'sdek_get_city_data') {
    $params = $_REQUEST;
    if (defined('AJAX_REQUEST')) {
        $location['country'] = 'RU';
        $location['city'] = $params['var_city'];
        $data = RusSdek::cityId($location);
        $city_data = array('from_city_id' => $data);
        Tygh::$app['view']->assign('sdek_new_city_data', $city_data);
        Tygh::$app['view']->display('addons/rus_sdek/views/shippings/components/services/sdek.tpl');
        exit;
    }
}