24 $this->fields =
new Fields();
32 return Main\Localization\Loc::loadLanguageFile($_SERVER[
"DOCUMENT_ROOT"].
'/bitrix/components/bitrix/sale.export.1c/component.php', self::CML_LANG_ID);
41 Main\Localization\
Loc::loadLanguageFile($_SERVER[
"DOCUMENT_ROOT"].
'/bitrix/components/bitrix/sale.export.1c/component.php', self::CML_LANG_ID),
42 Main\Localization\
Loc::loadLanguageFile($_SERVER[
"DOCUMENT_ROOT"].
'/bitrix/modules/sale/general/export.php', self::CML_LANG_ID)
60 foreach ($values as $key=>$value)
72 $this->fields->set($name, $value);
81 return $this->fields->get($name);
89 return $this->fields->getValues();
125 $operation = $document[
'#'][$message[
'CC_BSC1_OPERATION']][0][
'#'];
126 return static::resolveDocumentTypeId($operation);
139 if(!empty($operation))
141 if($operation == $message[
"CC_BSC1_ORDER"])
145 elseif($operation == $message[
"CC_BSC1_PAYMENT_C"])
149 elseif($operation == $message[
"CC_BSC1_PAYMENT_B"])
153 elseif($operation == $message[
"CC_BSC1_PAYMENT_A"])
157 elseif($operation == $message[
"CC_BSC1_SHIPMENT"])
170 if(!DocumentType::IsDefined($typeId))
180 $name = $message[
"CC_BSC1_ORDER"];
184 $name = $message[
"CC_BSC1_PAYMENT_C"];
188 $name = $message[
"CC_BSC1_PAYMENT_B"];
192 $name = $message[
"CC_BSC1_PAYMENT_A"];
196 $name = $message[
"CC_BSC1_SHIPMENT"];
224 case 'MARKING_GROUP':
247 if (is_array($document[
"#"][$message[
"CC_BSC1_ITEMS"]][0][
"#"]) &&
248 is_array($document[
"#"][$message[
"CC_BSC1_ITEMS"]][0][
"#"][$message[
"CC_BSC1_ITEM"]]))
250 $items = $document[
"#"][$message[
"CC_BSC1_ITEMS"]][0][
"#"][$message[
"CC_BSC1_ITEM"]];
252 foreach ($items as $val)
257 foreach($fieldsInfo[
'FIELDS'] as $name => $info)
259 if(!empty($val[
"#"][$message[
"CC_BSC1_".$name]]))
261 if($info[
'TYPE'] ===
'array')
267 $value = $val[
"#"][$message[
"CC_BSC1_".$name]][0][
"#"];
292 if (isset($value[
"#"][$message[
"CC_BSC1_CASHBOX_CHECKS"]][0][
"#"][$message[
"CC_BSC1_CASHBOX_CHECK"]][0][
'#'])
293 && !empty($value[
"#"][$message[
"CC_BSC1_CASHBOX_CHECKS"]][0][
"#"][$message[
"CC_BSC1_CASHBOX_CHECK"]][0][
'#']))
295 $properties = array();
296 $val = $value[
"#"][$message[
"CC_BSC1_CASHBOX_CHECKS"]][0][
"#"][$message[
"CC_BSC1_CASHBOX_CHECK"]][0];
298 $id = $val[
"#"][$message[
"CC_BSC1_ID"]][0][
"#"];
302 if (isset($val[
"#"][$message[
"CC_BSC1_PROPERTY_VALUES"]][0][
"#"][$message[
"CC_BSC1_PROPERTY_VALUE"]]) &&
303 isset($val[
"#"][$message[
"CC_BSC1_PROPERTY_VALUES"]][0][
"#"][$message[
"CC_BSC1_PROPERTY_VALUE"]][0][
'#']) &&
304 !empty($val[
"#"][$message[
"CC_BSC1_PROPERTY_VALUES"]][0][
"#"][$message[
"CC_BSC1_PROPERTY_VALUE"]][0][
'#']))
306 foreach($val[
"#"][$message[
"CC_BSC1_PROPERTY_VALUES"]][0][
"#"][$message[
"CC_BSC1_PROPERTY_VALUE"]] as $property)
308 $propertyName = $property[
"#"][$message[
"CC_BSC1_ID"]][0][
"#"];
309 $propertyValue = $property[
"#"][$message[
"CC_BSC1_VALUE"]][0][
"#"];
310 if($propertyValue <>
'')
311 $properties[$propertyName] = $propertyValue;
315 foreach($fieldsInfo[
'PROPERTIES'][
'FIELDS'] as $name => $fieldInfo)
317 if(!empty($properties[$message[
"CC_BSC1_".$name]]))
319 $fieldValue = $properties[$message[
"CC_BSC1_".$name]];
323 $result[$name] = $fieldValue;
341 if (is_array($value[
"#"][$message[
"CC_BSC1_REK_VALUES"]][0][
"#"][$message[
"CC_BSC1_REK_VALUE"]])
342 && !empty($value[
"#"][$message[
"CC_BSC1_REK_VALUES"]][0][
"#"][$message[
"CC_BSC1_REK_VALUE"]]))
345 foreach($value[
"#"][$message[
"CC_BSC1_REK_VALUES"]][0][
"#"][$message[
"CC_BSC1_REK_VALUE"]] as $val)
347 $traitName = $val[
"#"][$message[
"CC_BSC1_NAME"]][0][
"#"];
348 $traitValue = $val[
"#"][$message[
"CC_BSC1_VALUE"]][0][
"#"];
349 if($traitValue <>
'')
350 $traits[$traitName] = $traitValue;
353 foreach($fieldsInfo[
'FIELDS'] as $name => $fieldInfo)
356 if($name ==
'PROPERTY_VALUE_BASKET')
358 foreach($traits as $k=>$v)
360 $namePropertyBaslet = $message[
"CC_BSC1_PROP_BASKET"];
361 if (mb_strpos($k, $namePropertyBaslet.
"#") === 0)
363 $position = mb_strpos($k, $namePropertyBaslet.
"#");
364 $idBasketProperty = mb_substr($k, $position + mb_strlen($namePropertyBaslet.
"#"));
368 $result[
'PROP_BASKET'][$idBasketProperty] = $v;
372 elseif($name ==
'TYPE_OF_NOMENKLATURA')
374 if($traits[$message[
"CC_BSC1_ITEM_TYPE"]] == $message[
"CC_BSC1_ITEM"])
375 $fieldValue = Exchange\ImportBase::ITEM_ITEM;
376 elseif($traits[$message[
"CC_BSC1_ITEM_TYPE"]] == $message[
"CC_BSC1_SERVICE"])
377 $fieldValue = Exchange\ImportBase::ITEM_SERVICE;
381 $result[
'ITEM_TYPE'] = $fieldValue;
383 elseif(!empty($traits[$message[
"CC_BSC1_".$name]]))
385 $fieldValue = $traits[$message[
"CC_BSC1_".$name]];
389 $result[$name] = $fieldValue;
406 if (is_array($value[
"#"][$message[
"CC_BSC1_TAXES"]][0][
"#"][$message[
"CC_BSC1_TAX"]])
407 && !empty($value[
"#"][$message[
"CC_BSC1_TAXES"]][0][
"#"][$message[
"CC_BSC1_TAX"]]))
409 $field = $value[
"#"][$message[
"CC_BSC1_TAXES"]][0][
"#"][$message[
"CC_BSC1_TAX"]];
410 foreach($fieldsInfo[
'FIELDS'] as $name => $info)
412 if(!empty($field[0][
"#"][$message[
"CC_BSC1_".$name]][0][
"#"]))
414 $fieldValue = $field[0][
"#"][$message[
"CC_BSC1_".$name]][0][
"#"];
417 $result[$name] = $fieldValue;
434 if (is_array($value[
"#"][$message[
"CC_BSC1_DISCOUNTS"]][0][
"#"][$message[
"CC_BSC1_DISCOUNT"]])
435 && !empty($value[
"#"][$message[
"CC_BSC1_DISCOUNTS"]][0][
"#"][$message[
"CC_BSC1_DISCOUNT"]]))
437 $field = $value[
"#"][$message[
"CC_BSC1_DISCOUNTS"]][0][
"#"][$message[
"CC_BSC1_DISCOUNT"]];
438 foreach($fieldsInfo[
'FIELDS'] as $name => $info)
440 if(!empty($field[0][
"#"][$message[
"CC_BSC1_".$name]][0][
"#"]))
442 $fieldValue = $field[0][
"#"][$message[
"CC_BSC1_".$name]][0][
"#"];
445 $result[$name] = $fieldValue;
462 if (is_array($value[
"#"][$message[
"CC_BSC1_ITEM_UNIT"]])
463 && !empty($value[
"#"][$message[
"CC_BSC1_ITEM_UNIT"]]))
465 $field = $value[
"#"][$message[
"CC_BSC1_ITEM_UNIT"]];
467 foreach($fieldsInfo[
'FIELDS'] as $name => $info)
469 if(is_array($field[0][
"#"]))
471 if(!empty($field[0][
"#"][$message[
"CC_BSC1_".$name]][0][
"#"]))
473 $fieldValue = $field[0][
"#"][$message[
"CC_BSC1_".$name]][0][
"#"];
475 $result[$name] = $fieldValue;
483 $fieldValue = $field[0][
"#"];
486 $result[$name] = $fieldValue;
503 if (is_array($value[
"#"][$message[
"CC_BSC1_MARKING_GROUP"]])
504 && !empty($value[
"#"][$message[
"CC_BSC1_MARKING_GROUP"]]))
506 $field = $value[
"#"][$message[
"CC_BSC1_MARKING_GROUP"]];
508 foreach($fieldsInfo[
'FIELDS'] as $name => $info)
510 if(is_array($field[0][
"#"]))
512 if(!empty($field[0][
"#"][$message[
"CC_BSC1_MARKING_GROUP_".$name]][0][
"#"]))
514 $fieldValue = $field[0][
"#"][$message[
"CC_BSC1_MARKING_GROUP_".$name]][0][
"#"];
516 $result[$name] = $fieldValue;
534 if (is_array($value[
"#"][$message[
"CC_BSC1_MARKINGS"]][0][
"#"][$message[
"CC_BSC1_MARKING"]])
535 && !empty($value[
"#"][$message[
"CC_BSC1_MARKINGS"]][0][
"#"][$message[
"CC_BSC1_MARKING"]]))
537 $fields = $value[
"#"][$message[
"CC_BSC1_MARKINGS"]][0][
"#"][$message[
"CC_BSC1_MARKING"]];
541 foreach($fieldsInfo[
'FIELDS'] as $name => $info)
543 if(!empty($field[
"#"][$message[
"CC_BSC1_MARKING_".$name]][0][
"#"]))
545 $fieldValue = $field[
"#"][$message[
"CC_BSC1_MARKING_".$name]][0][
"#"];
548 $result[] = $fieldValue;
565 $basketItems = array();
566 foreach(
$fields[
'ITEMS_FIELDS'] as $item)
568 $priceone = $item[
'PRICE_PER_UNIT'];
569 if (DoubleVal($priceone) <= 0)
570 $priceone = $item[
"PRICE_ONE"];
574 if (doubleval($item[
'QUANTITY']) > 0)
579 if(isset($item[
'DISCOUNTS'][
'SUMM']) && $item[
'DISCOUNTS'][
'SUMM']<>
'')
581 if ($priceone != $price)
583 $discountPrice = DoubleVal($priceone - $price);
586 elseif ($priceone > 0)
592 if (!empty($item[
'TAXES'][
'TAX_VALUE']))
594 $taxValue = (float)$item[
'TAXES'][
'TAX_VALUE'];
595 $vatRate = $taxValue / 100;
598 $basketItems = Array(
600 'NAME' => $item[
'NAME'],
602 'PRICE_ONE' => $priceone,
603 'QUANTITY' => $item[
'QUANTITY'],
604 'TYPE' => $item[
'REK_VALUES'][
'ITEM_TYPE'],
605 'MEASURE_CODE' => !empty($item[
'ITEM_UNIT']) ? $item[
'ITEM_UNIT'][
'ITEM_UNIT_CODE']:
null,
606 'MEASURE_NAME' => !empty($item[
'ITEM_UNIT']) ? $item[
'ITEM_UNIT'][
'ITEM_UNIT_NAME']:
null,
607 'ATTRIBUTES' => !empty($item[
'REK_VALUES'][
'PROP_BASKET']) ? $item[
'REK_VALUES'][
'PROP_BASKET']:
null,
608 'MARKING_GROUP' => !empty($item[
'MARKING_GROUP'][
'CODE']) ? $item[
'MARKING_GROUP'][
'CODE']:
null,
609 'MARKINGS' => !empty($item[
'MARKINGS']) ? $item[
'MARKINGS']:
null,
611 'VAT_RATE' => $vatRate,
612 'VAT_INCLUDED' => !empty($item[
'TAXES'][
'IN_PRICE']) ? $item[
'TAXES'][
'IN_PRICE'] :
'Y'
615 'PRICE' => $discountPrice
620 $result[][$item[
'ID']] = $basketItems;
633 switch($fieldInfo[
'TYPE'])
636 $date = str_replace(
"T",
" ", $value);
637 $value =
new Type\DateTime(\CDatabase::FormatDate($date,
"YYYY-MM-DD HH:MI:SS", \CSite::GetDateFormat(
"FULL", LANG)));
640 $value = $value ==
"true" ?
'Y':
'N';
658 $saleOrderLoader = new \CSaleOrderLoader();
659 return $saleOrderLoader->ToFloat($value);
666 protected static function toInt($value)
668 $saleOrderLoader = new \CSaleOrderLoader();
669 return $saleOrderLoader->ToInt($value);
682 foreach(static::getFieldsInfo() as $k=>$v)
687 $value = $document[
"#"][$message[
"CC_BSC1_NUMBER"]][0][
"#"];
692 $value = $document[
"#"][$message[
"CC_BSC1_ID"]][0][
"#"];
697 $value = $document[
"#"][$message[
"CC_BSC1_NUMBER_BASE"]][0][
"#"];
705 $value = $document[
"#"][$message[
"CC_BSC1_".$k]][0][
"#"];
710 $date1C = $document[
"#"][$message[
"CC_BSC1_1C_DATE"]][0][
"#"];
713 $value = $date1C.
" ".$document[
"#"][$message[
"CC_BSC1_".$k]][0][
"#"];
723 $value = $document[
"#"][$message[
"CC_BSC1_SUMM"]][0][
"#"];
727 case 'CASH_BOX_CHECKS':
736 if(!empty(
$fields[
'ITEMS_FIELDS']))
742 if(!empty(
$fields[
'ITEMS_FIELDS']))
744 foreach(
$fields[
'ITEMS_FIELDS'] as $items)
746 foreach ($items as $item)
748 $taxValueTmp = isset($item[
'TAX_VALUE']) ? $item[
'TAX_VALUE']:0;
750 if (intval($taxValueTmp) > intval($taxValue))
752 $taxName = $item[
'NAME'];
753 $taxValue = $taxValueTmp;
759 if(intval($taxValue)>0)
762 $fields[$k][
'VALUE'] = $taxValue;
763 $fields[$k][
'NAME'] = $taxName;
769 $mess = Main\Localization\Loc::loadLanguageFile($_SERVER[
"DOCUMENT_ROOT"].
'/bitrix/modules/sale/general/export.php');
771 if(is_array($document[
"#"][$mess[
"SALE_EXPORT_CONTRAGENTS"]][0][
"#"][$mess[
"SALE_EXPORT_CONTRAGENT"]][0][
"#"]))
773 $fields[$k] = $documentProfile::prepareFieldsData($document[
"#"][$mess[
"SALE_EXPORT_CONTRAGENTS"]][0][
"#"][$mess[
"SALE_EXPORT_CONTRAGENT"]][0][
"#"]);
793 $name = static::getLangByCodeField($name);
794 return str_repeat(
"\t", $level).
"<".$name.
">\n";
799 $name = static::getLangByCodeField($name);
800 return str_repeat(
"\t", $level).
"</".$name.
">\n";
803 protected function formatXMLNode($level, $name, $value, $parameters=array())
806 if(count($parameters)>0)
808 foreach ($parameters as $code=>$v)
809 $params .=
' '.static::getLangByCodeField($code).
'="'.$v.
'" ';
812 $name = static::getLangByCodeField($name);
813 return str_repeat(
"\t", $level).
"<".$name.$params.
">".\CDataXML::xmlspecialchars($value).
"</".$name.
">\n";
833 foreach (
$fields as $name=>$value)
847 $profile->setFields($value);
850 $xml .= $profile->output($level+1);
878 $message = static::getMessageExport();
880 if(isset($message[
'CC_BSC1_'.$code]))
882 return $message[
'CC_BSC1_'.$code];
884 elseif(isset($message[
'SALE_EXPORT_'.$code]))
886 return $message[
'SALE_EXPORT_'.$code];
898 foreach ($value as $list)
901 foreach ($list as $k=>$v)
913 foreach ($list as $k=>$v)
924 "FULL_NAME_UNIT"=>static::getLangByCodeField(
"SHTUKA"),
925 "INTERNATIONAL_ABR"=>static::getLangByCodeField(
"RCE")
934 foreach ($items as $item)
938 foreach ($item as $code=>$value)
961 elseif ($code ==
'BASE_UNIT')
976 foreach ($addresses as $code=>$address)
978 if(is_array($address))
980 foreach ($address as $values)
983 foreach ($values as $k=>$v)
999 foreach ($stories as $store)
1002 foreach ($store as $code=>$value)
1004 if(is_array($value))
1031 foreach ($taxes as $tax)
1035 foreach ($tax as $k=>$v)
1049 foreach ($taxes as $tax)
1053 foreach ($tax as $k=>$v)
1068 foreach ($discounts as $k=>$v)
static loadLanguageFile($file, $language=null, $normalize=true)
static prepareFieldsData(array $document)
openNodeDirectory($level, $name)
outputXmlStories($level, $name, $stories)
outputXml(array $fields, $level=0)
static fillItemsFields(array $fields)
outputXmlUnits($level, $name, $list)
static resolveDocumentTypeId($operation)
static resolveUnitParams($value, array $fieldsInfo)
static resolveRawDocumentTypeId(array $document)
outputXmlAddress($level, $addresses)
outputXmlBaseUnit($level, $name, $value)
outputXmlRekValue($level, $name, $value)
static resolveMarkingGroupParams($value, array $fieldsInfo)
static resolveDocumentTypeName($typeId)
outputXmlDiscounts($level, $name, $discounts)
static getMessageExport()
outputXmlItems($level, $name, $items)
static resolveCashBoxCheksParams(array $value, array $fieldsInfo)
static resolveItemsParams(array $document, array $fieldsInfo)
formatXMLNode($level, $name, $value, $parameters=array())
static resolveItemsArrayParams($value, $fieldName, array $fieldsInfo, array $document)
static getLangByCodeField($code)
outputXmlTaxRates($level, $name, $taxes)
outputXmlTaxes($level, $name, $taxes)
static resolveDiscountsParams(array $value, array $fieldsInfo)
static resolveTaxParams(array $value, array $fieldsInfo)
closeNodeDirectory($level, $name)
static internalizeFields(&$value, $fieldInfo=null)
static resolveMarkingParams(array $value, array $fieldsInfo)
static resolveTraitsParams(array $value, array $fieldsInfo)
static resolveName($typeID)
const PAYMENT_CARD_TRANSACTION
static roundPrecision($value)