function fn_spsr_delete_addr($addr_id, $addr_owner_id) { RusSpsr::WALogin(); $result = RusSpsr::WADelAddress($addr_id, $addr_owner_id, 8); if ($result) { fn_set_notification('N', __('notice'), __('shippings.spsr.address_delete')); } else { fn_set_notification('E', __('notice'), __('shippings.spsr.not_address_delete') . ' : ' . RusSpsr::$last_error); } RusSpsr::WALogout(); return $result; }
if ($mode == 'details') { $params = $_REQUEST; $spsr_settings = Registry::get('addons.rus_spsr'); $order_info = Tygh::$app['view']->getTemplateVars('order_info'); $new_invoice = array(); $f_spsr = 0; $spsr_register = 0; list($all_shipments) = fn_get_shipments_info(array('order_id' => $params['order_id'], 'advanced_info' => true)); if (!empty($all_shipments)) { $spsr_shipments = $shipping_data = array(); foreach ($all_shipments as $key => $_shipment) { if ($_shipment['carrier'] == 'spsr') { $spsr_shipments[$_shipment['shipment_id']] = $_shipment; } } $login = RusSpsr::WALogin(); if (!empty($spsr_shipments) && $login) { $total = array('packages_count' => 0, 'shipping_cost' => 0, 'cost' => 0, 'amount' => 0); $spsr_invoice_info = array(); $register_status = 'N'; $registers = db_get_array("SELECT register_id, order_id, session_id, session_owner_id, timestamp, status FROM ?:rus_spsr_register WHERE order_id = ?i ", $order_info['order_id']); if (!empty($registers)) { foreach ($registers as $register_id => $register) { $spsr_invoices = db_get_array("SELECT * FROM ?:rus_spsr_invoices WHERE order_id = ?i AND register_id = ?i ", $order_info['order_id'], $register['register_id']); if (!empty($spsr_invoices)) { $_invoices = array(); foreach ($spsr_invoices as $invoice) { $_invoices[] = $invoice['invoice_number']; if (!empty($invoice['invoice_number'])) { $spsr_invoice_info[$invoice['invoice_number']] = $invoice; }
/** * Prepare request information * * @return array Prepared data */ public function getRequestData() { $data = array(); $login = RusSpsr::WALogin(); if ($login) { $weight_data = fn_expand_weight($this->_shipping_info['package_info']['W']); $shipping_settings = $this->_shipping_info['service_params']; $location = !empty($this->_shipping_info['package_info']['location']) ? $this->_shipping_info['package_info']['location'] : ''; $packages = !empty($this->_shipping_info['package_info']['packages']) ? $this->_shipping_info['package_info']['packages'] : array(); $code = $this->_shipping_info['service_code']; $ruble = Registry::get('currencies.RUB'); if (!empty($shipping_settings)) { $from_city = ""; $to_city = ""; $nature = $shipping_settings['default_product_type']; if (!empty($_SESSION['cart'])) { $cart = $_SESSION['cart']; $products = $uniq_types = array(); foreach ($packages as $package) { foreach ($package['products'] as $key => $product) { $products[$key] = $cart['products'][$key]['spsr_product_type']; $uniq_types[] = $cart['products'][$key]['spsr_product_type']; } } $uniq_types = array_unique($uniq_types); if (count($uniq_types) == 1) { $nature = $uniq_types[0]; } elseif (count($uniq_types) > 1) { if (array_search(18, $uniq_types)) { $amount_check = 1; $nature = 18; } } } if (!empty($shipping_settings['from_city_id'])) { $from_city = $shipping_settings['from_city_id'] . '|' . $shipping_settings['from_city_owner_id']; } else { $this->_internalError(__("shipping.spsr.not_setting_city")); } if (isset($shipping_settings['insurance_type']) && !empty($shipping_settings['insurance_type'])) { if ($shipping_settings['insurance_type'] == "INS") { $amount_check = 1; } elseif ($shipping_settings['insurance_type'] == "VAL") { $amount_check = 0; } } $city = RusSpsr::WAGetCities($location); if (!empty($city)) { $to_city = $city['City_ID'] . '|' . $city['City_owner_ID']; } else { $this->_internalError(RusSpsr::$last_error); } $weight = $weight_data['plain']; $amount = $this->_shipping_info['package_info']['C']; $sid = RusSpsr::$sid; $data = array('ToCity' => $to_city, 'FromCity' => $from_city, 'Weight' => $weight, 'Nature' => $nature, 'Amount' => $amount, 'AmountCheck' => $amount_check, 'SMS' => $shipping_settings['sms_to_shipper'], 'SMS_Recv' => $shipping_settings['sms_to_receiver'], 'PlatType' => $shipping_settings['plat_type'], 'DuesOrder' => $shipping_settings['dues_order'], 'ToBeCalledFor' => $shipping_settings['to_be_called_for'], 'ByHand' => $shipping_settings['by_hand'], 'icd' => $shipping_settings['idc'], 'SID' => $sid); } } else { fn_set_notification('E', __('notice'), RusSpsr::$last_error); } $url = 'http://www.cpcr.ru/cgi-bin/postxml.pl?TARIFFCOMPUTE_2'; $request_data = array('method' => 'post', 'url' => $url, 'data' => $data); return $request_data; }
Tygh::$app['view']->assign('url_invoice', $url_invoice); } elseif ($mode == 'invoice_info') { if (RusSpsr::WALogin() && !empty($_REQUEST['invoice_id'])) { list($invoice_info, $pieces) = fn_get_spsr_invoice_info($_REQUEST['invoice_id']); $spsr_settings = Registry::get('addons.rus_spsr'); $info_barcode = array('width' => $spsr_settings['width'], 'height' => $spsr_settings['height'], 'type' => 'C128B'); Tygh::$app['view']->assign('info_barcode', $info_barcode); Tygh::$app['view']->assign('invoice', $invoice_info); Tygh::$app['view']->assign('pieces', $pieces); RusSpsr::WALogout(); } else { return array(CONTROLLER_STATUS_OK, "spsr_invoice.manage"); } } elseif ($mode == 'print_invoice') { if (!empty($_REQUEST['invoice_id'])) { if (RusSpsr::WALogin()) { fn_print_spsr_invoice($_REQUEST['invoice_id'], !empty($_REQUEST['format']) && $_REQUEST['format'] == 'pdf'); RusSpsr::WALogout(); } else { return array(CONTROLLER_STATUS_OK, "spsr_invoice.manage"); } } exit; } function fn_print_spsr_invoice($invoice_ids, $pdf = false, $lang_code = CART_LANGUAGE) { $view = Tygh::$app['view']; $html = array(); if (!is_array($invoice_ids)) { $invoice_ids = array($invoice_ids); }
function fn_spsr_delete_courier($id, $owner_id) { RusSpsr::WALogin(); $result = RusSpsr::WACancelOrder($id, $owner_id); $save = array('courier_key' => '', 'courier_id' => '', 'courier_owner_id' => ''); db_query('UPDATE ?:rus_spsr_invoices SET ?u WHERE courier_id = ?i AND courier_owner_id = ?i', $save, $id, $owner_id); if ($result) { fn_set_notification('N', __('notice'), __('shippings.spsr.order_delete') . ' : ' . $result['order'] . ' ' . $result['order_state']); } else { fn_set_notification('E', __('notice'), __('shippings.spsr.not_order_delete') . ' : ' . RusSpsr::$last_error); } RusSpsr::WALogout(); }
if ($login) { $type_products = RusSpsr::WAGetEncloseType(); if ($_REQUEST['module'] == 'spsr') { $location['country'] = Registry::get('settings.General.default_country'); $location['city'] = Registry::get('settings.General.default_city'); $data = RusSpsr::WAGetCities($location); Tygh::$app['view']->assign('from_city_id', $data['City_ID']); Tygh::$app['view']->assign('from_city_owner_id', $data['City_owner_ID']); Tygh::$app['view']->assign('city', $location['city']); } RusSpsr::WALogout(); Tygh::$app['view']->assign('type_products', $type_products); } else { fn_set_notification('E', __('notice'), RusSpsr::$last_error); } } } if ($mode == 'spsr_get_city_data') { $params = $_REQUEST; if (defined('AJAX_REQUEST')) { $location['country'] = Registry::get('settings.General.default_country'); $location['city'] = $params['var_city']; RusSpsr::WALogin(); $data = RusSpsr::WAGetCities($location); RusSpsr::WALogout(); $city_data = array('from_city_id' => $data['City_ID'], 'from_city_owner_id' => $data['City_owner_ID']); Tygh::$app['view']->assign('spsr_new_city_data', $city_data); Tygh::$app['view']->display('addons/rus_spsr/views/shippings/components/services/spsr.tpl'); exit; } }