Ejemplo n.º 1
0
function fn_exim_1c_build_order_products($xml, $order_data)
{
    $cml = fn_get_cml_tag_names();
    $xml->startElement($cml['products']);
    $schema_version = Registry::get('addons.rus_exim_1c.exim_1c_schema_version');
    if (Registry::get('addons.rus_exim_1c.exim_1c_order_shipping') == 'Y' && $order_data['shipping_cost'] > 0) {
        $xml->startElement($cml['product']);
        $xml->writeElement($cml['id'], 'ORDER_DELIVERY');
        $xml->writeElement($cml['name'], $cml['delivery_order']);
        $xml->writeElement($cml['price_per_item'], $order_data['shipping_cost']);
        $xml->writeElement($cml['amount'], 1);
        $xml->writeElement($cml['total'], $order_data['shipping_cost']);
        $xml->startElement($cml['value_fields']);
        $xml->startElement($cml['value_field']);
        $xml->writeElement($cml['name'], $cml['spec_nomenclature']);
        $xml->writeElement($cml['value'], $cml['service']);
        $xml->endElement();
        $xml->startElement($cml['value_field']);
        $xml->writeElement($cml['name'], $cml['type_nomenclature']);
        $xml->writeElement($cml['value'], $cml['service']);
        $xml->endElement();
        $xml->endElement();
        $xml->endElement();
    }
    foreach ($order_data['products'] as $product) {
        $external_id = db_get_field("SELECT external_id FROM ?:products WHERE product_id = ?i", $product['product_id']);
        $xml->startElement($cml['product']);
        $xml->writeElement($cml['id'], $external_id);
        $xml->writeElement($cml['code'], $product['product_id']);
        $xml->writeElement($cml['article'], $product['product_code']);
        $xml->writeElement($cml['name'], $product['product']);
        if ($schema_version == '2.07') {
            $xml->startElement($cml['base_unit']);
            $xml->writeAttribute($cml['code'], '796');
            $xml->writeAttribute($cml['full_name_unit'], $cml['item']);
            $xml->text($cml['item']);
            $xml->endElement();
        } else {
            $xml->writeElement($cml['base_unit'], $cml['item']);
        }
        $xml->startElement($cml['discounts']);
        $xml->startElement($cml['discount']);
        $xml->writeElement($cml['name'], $cml['product_discount']);
        $xml->writeElement($cml['total'], $product['discount']);
        $xml->writeElement($cml['in_total'], 'true');
        $xml->endElement();
        $xml->endElement();
        $xml->writeElement($cml['price_per_item'], $product['base_price']);
        $xml->writeElement($cml['amount'], $product['amount']);
        $xml->writeElement($cml['total'], $product['subtotal']);
        $xml->startElement($cml['value_fields']);
        $xml->startElement($cml['value_field']);
        $xml->writeElement($cml['name'], $cml['spec_nomenclature']);
        $xml->writeElement($cml['value'], $cml['product']);
        $xml->endElement();
        $xml->startElement($cml['value_field']);
        $xml->writeElement($cml['name'], $cml['type_nomenclature']);
        $xml->writeElement($cml['value'], $cml['product']);
        $xml->endElement();
        $xml->endElement();
        $xml->endElement();
    }
    $xml->endElement();
    return $xml;
}
Ejemplo n.º 2
0
        }
        if (Registry::get('addons.rus_exim_1c.exim_1c_add_tax') == 'Y') {
            $taxes_1c = $_REQUEST['taxes_1c'];
            db_query("DELETE FROM ?:rus_exim_1c_taxes");
            foreach ($taxes_1c as $tax_1c) {
                if (!empty($tax_1c['tax_1c'])) {
                    db_query("INSERT INTO ?:rus_exim_1c_taxes ?e", $tax_1c);
                }
            }
        }
        $suffix = '.offers';
    }
    return array(CONTROLLER_STATUS_OK, "1c{$suffix}");
}
if ($mode == 'offers') {
    $cml = fn_get_cml_tag_names();
    if (Registry::get('addons.rus_exim_1c.exim_1c_create_prices') == 'Y') {
        $prices_data = db_get_array("SELECT * FROM ?:rus_exim_1c_prices");
        $prices = array();
        $list_price_1c = $base_price_1c = '';
        foreach ($prices_data as $price) {
            if ($price['type'] == 'base') {
                $base_price_1c .= $price['price_1c'] . ',';
            } elseif ($price['type'] == 'list') {
                $list_price_1c .= $price['price_1c'] . ',';
            } else {
                $prices[] = $price;
            }
        }
        Tygh::$app['view']->assign('list_price_1c', trim($list_price_1c, ','));
        Tygh::$app['view']->assign('base_price_1c', trim($base_price_1c, ','));