Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
function fn_spsr_pre_check_invoice_create($order_id, $section, $spsr_shipments = array())
{
    $shipping = array();
    if (empty($order_id)) {
        return array(CONTROLLER_STATUS_REDIRECT, "orders.manage");
    }
    $order_info = fn_get_order_info($order_id, false, true, true, true);
    if (!empty($order_info)) {
        list($_shipments) = fn_get_shipments_info(array('order_id' => $order_id, 'advanced_info' => true));
        if (!empty($_shipments)) {
            $shipments = array();
            foreach ($_shipments as $shipment) {
                if ($shipment['carrier'] == 'spsr') {
                    if (empty($spsr_shipments) || !empty($spsr_shipments[$shipment['shipment_id']])) {
                        $shipments[$shipment['shipment_id']] = $shipment;
                    }
                }
            }
        }
        if (!empty($shipments)) {
            foreach ($shipments as $shipment_id => $shipment) {
                $shipping = fn_get_shipping_info($shipment['shipping_id'], DESCR_SL);
                $shipping['rate'] = $order_info['shipping_cost'];
                $invoices[$shipment_id] = RusSpsr::preInvoiceByShipments($shipment, $order_info, $shipping);
                $shipping_data[$shipment_id] = $shipping;
            }
        } else {
            return array(CONTROLLER_STATUS_REDIRECT, "orders.details?order_id={$order_id}&selected_section={$section}");
        }
    }
    return array($order_info, $invoices, $shipments, $shipping_data);
}
Ejemplo n.º 3
0
 /**
  * Gets shipping cost and information about possible errors
  *
  * @param  string $resonse Reponse from Shipping service server
  * @return array  Shipping cost and errors
  */
 public function processResponse($response)
 {
     $return = array('cost' => false, 'error' => false);
     $xml = simplexml_load_string($response);
     if (isset($xml->Error)) {
         $this->_internalError((string) $xml->Error);
     } elseif (isset($xml->Tariff)) {
         $_result = array();
         foreach ($xml->Tariff as $shipment) {
             $_result[] = array('TariffType' => (string) $shipment->TariffType, 'Total_Dost' => (string) $shipment->Total_Dost, 'Total_DopUsl' => (string) $shipment->Total_DopUsl, 'Insurance' => (string) $shipment->id, 'worth' => (string) $shipment->Insurance, 'DP' => (string) $shipment->DP);
         }
     }
     if (!empty($_result)) {
         foreach ($_result as $ship) {
             if ($ship['TariffType'] == 'Услуги по доставке "Пеликан-стандарт"') {
                 $return['cost'] = $ship['Total_Dost'];
                 self::_fillSessionData($this->_shipping_info, $ship['DP']);
             }
         }
     }
     if (empty($return['cost'])) {
         $return['error'] = __('shippings.spsr.error_get_cost');
     }
     if (!empty($this->_error_stack)) {
         foreach ($this->_error_stack as $error) {
             $return['error'] .= '; ' . $error;
         }
     }
     RusSpsr::WALogout();
     return $return;
 }
Ejemplo n.º 4
0
} elseif ($mode == 'm_update') {
    $selected_fields = $_SESSION['selected_fields'];
    $field_groups = Tygh::$app['view']->getTemplateVars('field_groups');
    $filled_groups = Tygh::$app['view']->getTemplateVars('filled_groups');
    $field_names = Tygh::$app['view']->getTemplateVars('field_names');
    if (!empty($selected_fields['data']['spsr_product_type'])) {
        $type_products = array();
        $login = RusSpsr::WALogin();
        if ($login) {
            $type_products = RusSpsr::WAGetEncloseType();
        }
        RusSpsr::WALogout();
        $field_groups['S']['spsr_product_type']['name'] = 'products_data';
        foreach ($type_products as $type) {
            $field_groups['S']['spsr_product_type']['variants'][$type['Value']] = 'shippings.spsr.type' . $type['Value'];
        }
        $filled_groups['S']['spsr_product_type'] = __('shippings.spsr.product_type');
        unset($field_names['spsr_product_type']);
    }
    Tygh::$app['view']->assign('field_groups', $field_groups);
    Tygh::$app['view']->assign('filled_groups', $filled_groups);
    Tygh::$app['view']->assign('field_names', $field_names);
} elseif ($mode == 'update') {
    $type_products = array();
    $login = RusSpsr::WALogin();
    if ($login) {
        $type_products = RusSpsr::WAGetEncloseType();
    }
    RusSpsr::WALogout();
    Tygh::$app['view']->assign('type_products', $type_products);
}
Ejemplo n.º 5
0
function fn_get_spsr_invoice_info($invoice_id)
{
    $invoice_info_db = db_get_row("SELECT * FROM ?:rus_spsr_invoices WHERE invoice_number = ?i", $invoice_id);
    if (!empty($invoice_info_db)) {
        $add_about_order = db_get_row("SELECT company_id, timestamp FROM ?:orders WHERE order_id = ?i", $invoice_info_db['order_id']);
        $invoice_info_db['timestamp'] = $add_about_order['timestamp'];
        $invoice_info_db['company_id'] = $add_about_order['company_id'];
        $invoice_info = RusSpsr::WAGetInvoiceInfo(array($invoice_id));
        $invoice_info = array_merge($invoice_info_db, $invoice_info[$invoice_id]);
        $pieces = db_get_array("SELECT * FROM ?:rus_spsr_invoices_items WHERE ship_ref_num = ?s", $invoice_info_db['ship_ref_num']);
        $invoice_info['products_amount'] = 0;
        $invoice_info['pieces_amount'] = count($pieces);
        foreach ($pieces as $key => $piece) {
            $pieces[$key]['data'] = unserialize($piece['data']);
            $pieces[$key]['products_amount'] = 0;
            foreach ($pieces[$key]['data']['products'] as $product) {
                if (isset($product['product_id'])) {
                    $invoice_info['products_amount'] += $product['amount'];
                    $pieces[$key]['products_amount'] += $product['amount'];
                }
            }
        }
        return array($invoice_info, $pieces);
    }
}
Ejemplo n.º 6
0
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();
}