Пример #1
1
 public static function ConvertFromDB($arProperty, $value)
 {
     if (strlen($value["VALUE"]) > 0) {
         $value["VALUE"] = CDatabase::FormatDate($value["VALUE"], "YYYY-MM-DD", CLang::GetDateFormat("SHORT"));
     }
     return $value;
 }
Пример #2
0
 function GetEditFormHTML($arUserField, $arHtmlControl)
 {
     $arHtmlControl["VALIGN"] = "middle";
     if ($arUserField["EDIT_IN_LIST"] == "Y") {
         if ($arUserField["ENTITY_VALUE_ID"] < 1 && $arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] != "NONE") {
             if ($arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] == "NOW") {
                 $arHtmlControl["VALUE"] = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL");
             } else {
                 $arHtmlControl["VALUE"] = str_replace(" 00:00:00", "", CDatabase::FormatDate($arUserField["SETTINGS"]["DEFAULT_VALUE"]["VALUE"], "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL")));
             }
         }
         return CAdminCalendar::CalendarDate($arHtmlControl["NAME"], $arHtmlControl["VALUE"], 20, true);
     } elseif (strlen($arHtmlControl["VALUE"]) > 0) {
         return $arHtmlControl["VALUE"];
     } else {
         return '&nbsp;';
     }
 }
Пример #3
0
 function GetEditFormHTML($arUserField, $arHtmlControl)
 {
     $arHtmlControl["VALIGN"] = "middle";
     if ($arUserField["EDIT_IN_LIST"] == "Y") {
         if ($arUserField["ENTITY_VALUE_ID"] < 1 && $arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] != "NONE") {
             if ($arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] == "NOW") {
                 $arHtmlControl["VALUE"] = ConvertTimeStamp(time(), "SHORT");
             } else {
                 $arHtmlControl["VALUE"] = CDatabase::FormatDate($arUserField["SETTINGS"]["DEFAULT_VALUE"]["VALUE"], "YYYY-MM-DD", CLang::GetDateFormat("SHORT"));
             }
         }
         return CAdminCalendar::CalendarDate($arHtmlControl["NAME"], $arHtmlControl["VALUE"]);
     } elseif (strlen($arHtmlControl["VALUE"]) > 0) {
         return $arHtmlControl["VALUE"];
     } else {
         return '&nbsp;';
     }
 }
Пример #4
0
 function CharToDateFunction($value, $format_type = "FULL", $lang = false)
 {
     $value = trim($value);
     if (strlen($value) <= 0) {
         return "NULL";
     }
     $value = CDatabase::FormatDate($value, CLang::GetDateFormat($format_type, $lang), "YYYY-MM-DD HH:MI:SS");
     return "convert (datetime, '" . $this->ForSql($value) . "', 120)";
 }
Пример #5
0
 public function AddOrderHistory($OldFields, $NewFields)
 {
     global $DB, $USER;
     foreach (GetModuleEvents("sale", "OnBeforeOrderAddHistory", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$NewFields)) === false) {
             return false;
         }
     }
     if ($OldFields["ID"] <= 0) {
         return false;
     }
     if (isset($NewFields["ID"])) {
         unset($NewFields["ID"]);
     }
     $bChange = false;
     $strSql = '';
     $arInsert = array("H_USER_ID" => $USER->GetID(), "H_ORDER_ID" => $OldFields["ID"], "H_CURRENCY" => $OldFields["CURRENCY"]);
     $arDeleteFields = array("ID", "EMP_CANCELED_ID", "EMP_MARKED_ID", "EMP_DEDUCTED_ID", "EMP_STATUS_ID", "EMP_ALLOW_DELIVERY_ID", "LOCKED_BY", "DATE_LOCK", "UPDATED_1C", "DATE_INSERT", "DATE_UPDATE", "USER_DESCRIPTION", "ADDITIONAL_INFO", "COMMENTS", "RECOUNT_FLAG", "RECURRING_ID");
     foreach ($NewFields as $key => $val) {
         if ($key == "PAY_VOUCHER_DATE" || $key == "DELIVERY_DOC_DATE") {
             $valOld = $val;
             $val = CDatabase::FormatDate(trim($val), false, "Y-M-D");
         }
         if (array_key_exists($key, $OldFields) && strlen($val) > 0 && $val != $OldFields[$key] && !in_array($key, $arDeleteFields)) {
             if ($key == "PAY_VOUCHER_DATE" || $key == "DELIVERY_DOC_DATE") {
                 $val = $valOld;
             }
             $bChange = true;
             $arInsert[$key] = $val;
         }
     }
     if ($bChange) {
         $arPrepare = $DB->PrepareInsert("b_sale_order_history", $arInsert);
         $arPrepare[0] .= ", H_DATE_INSERT";
         $arPrepare[1] .= ", " . $DB->GetNowFunction();
         $strSql = "INSERT INTO b_sale_order_history (" . $arPrepare[0] . ") " . "VALUES (" . $arPrepare[1] . ");";
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     foreach (GetModuleEvents("sale", "OnAfterOrderAddHistory", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($NewFields));
     }
     return true;
 }
Пример #6
0
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
?>
<div class="fields integer" id="main_<?php 
echo $arParams["arUserField"]["FIELD_NAME"];
?>
"><?php 
$index = 0;
$fIndex = $arResult["RANDOM"];
foreach ($arResult["VALUE"] as $res) {
    if ($index == 0 && $arParams["arUserField"]["ENTITY_VALUE_ID"] < 1 && $arParams["arUserField"]["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] != "NONE") {
        if ($arParams["arUserField"]["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] == "NOW") {
            $res = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL");
        } else {
            $res = str_replace(" 00:00:00", "", CDatabase::FormatDate($arParams["arUserField"]["SETTINGS"]["DEFAULT_VALUE"]["VALUE"], "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL")));
        }
    }
    $name = $arParams["arUserField"]["FIELD_NAME"];
    if ($arParams["arUserField"]["MULTIPLE"] == "Y") {
        $name = $arParams["arUserField"]["~FIELD_NAME"] . "[" . $index . "]";
    }
    ?>
<div class="fields datetime">
<input type="text" name="<?php 
    echo $name;
    ?>
" value="<?php 
    echo $res;
    ?>
"<?php 
Пример #7
0
 public function Authorize()
 {
     global $APPLICATION, $USER;
     $errorCode = 1;
     if ($arOpenID = $this->Validate()) {
         $arFields = array('EXTERNAL_AUTH_ID' => 'OPENID#' . $arOpenID['server'], 'XML_ID' => $arOpenID['identity'], 'PASSWORD' => randString(30), 'LID' => SITE_ID, "PERSONAL_WWW" => $arOpenID['identity']);
         if (array_key_exists('openid_sreg_email', $_GET)) {
             $arFields['EMAIL'] = $_GET['openid_sreg_email'];
         }
         if (array_key_exists('openid_sreg_gender', $_GET) && ($_GET['openid_sreg_gender'] == 'M' || $_GET['openid_sreg_gender'] == 'F')) {
             $arFields['PERSONAL_GENDER'] = $_GET['openid_sreg_gender'];
         }
         if (array_key_exists('openid_sreg_fullname', $_GET)) {
             $fullname = defined("BX_UTF") ? $_GET['openid_sreg_fullname'] : CharsetConverter::ConvertCharset($_GET['openid_sreg_fullname'], 'UTF-8', LANG_CHARSET);
             $fullname = trim($fullname);
             if (($pos = strpos($fullname, ' ')) !== false) {
                 $arFields['NAME'] = substr($fullname, 0, $pos);
                 $arFields['LAST_NAME'] = substr($fullname, $pos + 1);
             } else {
                 $arFields['NAME'] = $fullname;
             }
         }
         if (array_key_exists('openid_sreg_postcode', $_GET)) {
             $arFields['PERSONAL_ZIP'] = $_GET['openid_sreg_postcode'];
         }
         if (array_key_exists('openid_sreg_timezone', $_GET)) {
             $arFields['TIME_ZONE'] = $_GET['openid_sreg_timezone'];
         }
         if (array_key_exists('openid_sreg_country', $_GET)) {
             $arFields['PERSONAL_COUNTRY'] = GetCountryIdByCode($_GET['openid_sreg_country']);
         }
         if (array_key_exists('openid_sreg_dob', $_GET)) {
             $arFields['PERSONAL_BIRTHDAY'] = CDatabase::FormatDate($_GET['openid_sreg_dob'], "YYYY-MM-DD", FORMAT_DATE);
         }
         if (array_key_exists('BX_OPENID_IDENTITY', $_SESSION)) {
             $arFields['LOGIN'] = $_SESSION['BX_OPENID_IDENTITY'];
         } else {
             $arFields['LOGIN'] = $arOpenID['identity'];
         }
         $arFields['LOGIN'] = preg_replace("#^(http://|https://)#i", "", $arFields['LOGIN']);
         $USER_ID = 0;
         if ($GLOBALS["USER"]->IsAuthorized() && $GLOBALS["USER"]->GetID()) {
             if (!CSocServAuth::isSplitDenied()) {
                 $arFields['USER_ID'] = $GLOBALS["USER"]->GetID();
                 CSocServAuthDB::Add($arFields);
                 self::CleanParam();
             } else {
                 $errorCode = SOCSERV_REGISTRATION_DENY;
             }
         } else {
             $dbUsersOld = $GLOBALS["USER"]->GetList($by, $ord, array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => $arFields['EXTERNAL_AUTH_ID'], 'ACTIVE' => 'Y'), array('NAV_PARAMS' => array("nTopCount" => "1")));
             $dbUsersNew = $GLOBALS["USER"]->GetList($by, $ord, array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => 'socservices', 'ACTIVE' => 'Y'), array('NAV_PARAMS' => array("nTopCount" => "1")));
             $dbSocUser = CSocServAuthDB::GetList(array(), array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => $arFields['EXTERNAL_AUTH_ID']), false, false, array("USER_ID", "ACTIVE"));
             if ($arUser = $dbSocUser->Fetch()) {
                 if ($arUser["ACTIVE"] === 'Y') {
                     $USER_ID = $arUser["USER_ID"];
                 }
             } elseif ($arUser = $dbUsersOld->Fetch()) {
                 $USER_ID = $arUser['ID'];
             } elseif ($arUser = $dbUsersNew->Fetch()) {
                 $USER_ID = $arUser["ID"];
             } elseif (COption::GetOptionString("main", "new_user_registration", "N") == "Y") {
                 $def_group = COption::GetOptionString('main', 'new_user_registration_def_group', '');
                 if ($def_group != '') {
                     $arFields['GROUP_ID'] = explode(',', $def_group);
                 }
                 if (!empty($arFields['GROUP_ID']) && CSocServAuth::isAuthDenied($arFields['GROUP_ID'])) {
                     $errorCode = SOCSERV_REGISTRATION_DENY;
                 } else {
                     foreach (GetModuleEvents("main", "OnBeforeOpenIDUserAdd", true) as $arEvent) {
                         ExecuteModuleEventEx($arEvent, array($arFields));
                     }
                     $arFieldsUser = $arFields;
                     $arFieldsUser["EXTERNAL_AUTH_ID"] = "socservices";
                     if (!($USER_ID = $GLOBALS["USER"]->Add($arFieldsUser))) {
                         return false;
                     }
                     $arFields['CAN_DELETE'] = 'N';
                     $arFields['USER_ID'] = $USER_ID;
                     CSocServAuthDB::Add($arFields);
                     unset($arFields['CAN_DELETE']);
                 }
             } elseif (COption::GetOptionString("main", "new_user_registration", "N") == "N") {
                 $errorCode = 2;
             }
             if (intval($USER_ID) > 0) {
                 $arGroups = $USER->GetUserGroup($USER_ID);
                 if (CSocServAuth::isAuthDenied($arGroups)) {
                     $errorCode = SOCSERV_AUTHORISATION_ERROR;
                 } else {
                     $USER->AuthorizeWithOtp($USER_ID);
                     $arKillParams = array("auth_service_id", "check_key");
                     foreach (array_keys($_GET) as $k) {
                         if (strpos($k, 'openid_') === 0) {
                             $arKillParams[] = $k;
                         }
                     }
                     $redirect_url = $APPLICATION->GetCurPageParam('', $arKillParams, false);
                     foreach (GetModuleEvents("main", "OnBeforeOpenIDAuthFinalRedirect", true) as $arEvent) {
                         ExecuteModuleEventEx($arEvent, array($redirect_url, $USER_ID, $arFields));
                     }
                     if ($redirect_url) {
                         LocalRedirect($redirect_url, true);
                     }
                     return $USER_ID;
                 }
             }
         }
     }
     $arKillParams = array("check_key");
     foreach (array_keys($_GET) as $k) {
         if (strpos($k, 'openid') === 0) {
             $arKillParams[] = $k;
         }
     }
     $redirect_url = $APPLICATION->GetCurPageParam('auth_service_error=' . $errorCode, $arKillParams, false);
     LocalRedirect($redirect_url, true);
     return false;
 }
Пример #8
0
		echo $str;?></td>
		<td ondblclick="<?echo htmlspecialcharsbx("DoAction(event, 'version_down', 'main')")?>" id="version_for_main">0.1</td>
		<td nowrap>xxx</td>
		<td><?php 
echo GetMessage("MOD_INSTALLED");
?>
</td>
		<td>&nbsp;</td>
	</tr>
<?
foreach($arModules as $info) :
?>
	<tr>
		<td><b><?echo htmlspecialcharsex($info["MODULE_NAME"])?></b> <?echo htmlspecialcharsex(strlen($info["MODULE_PARTNER"]) > 0? " <b><i>(".str_replace(array("#NAME#", "#URI#"), array($info["MODULE_PARTNER"], $info["MODULE_PARTNER_URI"]), GetMessage("MOD_PARTNER_NAME")).")</i></b>" : "(".$info["MODULE_ID"].")") ?><br><?echo $info["MODULE_DESCRIPTION"]?></td>
		<td ondblclick="<?echo htmlspecialcharsbx("DoAction(event, 'version_down', '".CUtil::AddSlashes($info["MODULE_ID"])."')")?>" id="version_for_<?echo htmlspecialcharsbx($info["MODULE_ID"])?>"><?echo $info["MODULE_VERSION"]?></td>
		<td nowrap><?echo CDatabase::FormatDate($info["MODULE_VERSION_DATE"], "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("SHORT"));?></td>
		<td nowrap><?if($info["IsInstalled"]):?><?echo GetMessage("MOD_INSTALLED")?><?else:?><span class="required"><?echo GetMessage("MOD_NOT_INSTALLED")?></span><?endif?></td>
		<td>
			<form action="<?echo $APPLICATION->GetCurPage()?>" method="GET" id="form_for_<?echo htmlspecialcharsbx($info["MODULE_ID"])?>">
				<input type="hidden" name="action" value="" id="action_for_<?echo htmlspecialcharsbx($info["MODULE_ID"])?>">
				<input type="hidden" name="lang" value="<?echo LANG?>">
				<input type="hidden" name="id" value="<?echo htmlspecialcharsbx($info["MODULE_ID"])?>">
				<?php 
echo freetrix_sessid_post();
?>
				<?if($info["IsInstalled"]):?>
					<input <?if (!$isAdmin || $info["MODULE_ID"] == 'fileman' || $info["MODULE_ID"] == 'intranet') echo "disabled" ?> type="submit" name="uninstall" value="<?echo GetMessage("MOD_DELETE")?>">
				<?else:?>
					<input <?if (!$isAdmin) echo "disabled" ?> type="submit" class="adm-btn-green" name="install" value="<?echo GetMessage("MOD_INSTALL_BUTTON")?>">
				<?endif?>
			</form>
Пример #9
0
    die;
}
?>

<div class="fields integer" id="main_<?php 
echo $arParams["arUserField"]["FIELD_NAME"];
?>
"><?php 
$index = 0;
$fIndex = time();
foreach ($arResult["VALUE"] as $res) {
    if ($index == 0 && $arParams["arUserField"]["ENTITY_VALUE_ID"] < 1 && $arParams["arUserField"]["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] != "NONE") {
        if ($arParams["arUserField"]["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] == "NOW") {
            $res = ConvertTimeStamp(time(), "SHORT");
        } else {
            $res = CDatabase::FormatDate($arParams["arUserField"]["SETTINGS"]["DEFAULT_VALUE"]["VALUE"], "YYYY-MM-DD", CLang::GetDateFormat("SHORT"));
        }
    }
    $name = $arParams["arUserField"]["FIELD_NAME"];
    if ($arParams["arUserField"]["MULTIPLE"] == "Y") {
        $name = $arParams["arUserField"]["~FIELD_NAME"] . "[" . $index . "]";
    }
    ?>
<div class="fields datetime">
<input type="text" name="<?php 
    echo $name;
    ?>
" value="<?php 
    echo $res;
    ?>
"<?php 
Пример #10
0
         } elseif ($arDocumentFields[$newKey]["BaseType"] == "user") {
             $value = CBPHelper::UsersStringToArray($value, $documentType, $arErrors);
             if (is_array($value) && count($value) > 0) {
                 $value = $value[0];
             }
             if (substr($value, 0, strlen("user_")) == "user_") {
                 $value = substr($value, strlen("user_"));
             }
         } elseif ($arDocumentFields[$newKey]["BaseType"] == "datetime" && strlen($value) > 0 && CheckDateTime($value)) {
             $isShort = strlen(trim($value)) <= 10;
             $appendTime = $op == '<=' ? '23:59:59' : '00:00:00';
             if (strpos($newKey, 'PROPERTY_') === 0) {
                 if ($timeZoneOffset != 0) {
                     $value = date("Y-m-d " . ($isShort ? $appendTime : 'H:i:s'), MakeTimeStamp($value, CLang::GetDateFormat("FULL")) - $timeZoneOffset);
                 } else {
                     $value = CDatabase::FormatDate($value, CLang::GetDateFormat("FULL"), "YYYY-MM-DD " . ($isShort ? $appendTime : 'HH:MI:SS'));
                 }
             } elseif ($isShort) {
                 $value .= ' ' . $appendTime;
             }
         }
         if ($newKey == "ACTIVE_FROM") {
             $newKey = "DATE_ACTIVE_FROM";
         }
         if ($newKey == "ACTIVE_TO") {
             $newKey = "DATE_ACTIVE_TO";
         }
         $arFilter[$op . $newKey] = $value;
     }
 }
 $arResult["SORT"] = $gridSort["sort"];
Пример #11
0
 function __InTaskCompare($arTask1, $arTask2, $arOrder)
 {
     foreach ($arOrder as $ord) {
         if (Array_Key_Exists($ord["ORDER"], $arTask1["FIELDS"])) {
             $v1 = $arTask1["FIELDS"][$ord["ORDER"]];
             $v2 = $arTask2["FIELDS"][$ord["ORDER"]];
             if ($ord["TYPE"] == "datetime") {
                 $v1 = CDatabase::FormatDate($v1, CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS");
                 $v2 = CDatabase::FormatDate($v2, CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS");
             }
             if ($ord["NULLS"]) {
                 if (StrLen($v1) <= 0 && StrLen($v2) > 0) {
                     return $ord["DIRECTION"] == "ASC" ? true : false;
                 } elseif (StrLen($v1) > 0 && StrLen($v2) <= 0) {
                     return $ord["DIRECTION"] == "ASC" ? false : true;
                 }
             }
             if ($v1 > $v2) {
                 return $ord["DIRECTION"] == "ASC" ? true : false;
             } elseif ($v1 < $v2) {
                 return $ord["DIRECTION"] == "ASC" ? false : true;
             }
         } else {
             foreach ($arTask1["PROPS"] as $key => $value) {
                 if (StrToUpper($key) == $ord["ORDER"]) {
                     $v1 = $value["VALUE"];
                     $v2 = $arTask2["PROPS"][$key]["VALUE"];
                     if ($ord["TYPE"] == "datetime") {
                         $v1 = CDatabase::FormatDate($v1, CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS");
                         $v2 = CDatabase::FormatDate($v2, CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS");
                     }
                     if ($ord["NULLS"]) {
                         if (StrLen($v1) <= 0 && StrLen($v2) > 0) {
                             return $ord["DIRECTION"] == "ASC" ? true : false;
                         } elseif (StrLen($v1) > 0 && StrLen($v2) <= 0) {
                             return $ord["DIRECTION"] == "ASC" ? false : true;
                         }
                     }
                     if ($v1 > $v2) {
                         return $ord["DIRECTION"] == "ASC" ? true : false;
                     } elseif ($v1 < $v2) {
                         return $ord["DIRECTION"] == "ASC" ? false : true;
                     }
                     break;
                 }
             }
         }
     }
     return true;
 }
Пример #12
0
/* - product XML_ID (with mnemonic code PRODUCT.XML_ID).                    */
/****************************************************************************/
$SALER_COMPANY_XML_ID = "1";
IncludeModuleLangFile(__FILE__);
if (!isset($arFilter) || !is_array($arFilter)) {
    die("Wrong use 1");
}
$dbOrderList = CSaleOrder::GetList(array($by => $order), $arFilter, false, false, array("ID", "LID", "PERSON_TYPE_ID", "PAYED", "DATE_PAYED", "EMP_PAYED_ID", "CANCELED", "DATE_CANCELED", "EMP_CANCELED_ID", "REASON_CANCELED", "STATUS_ID", "DATE_STATUS", "PAY_VOUCHER_NUM", "PAY_VOUCHER_DATE", "EMP_STATUS_ID", "PRICE_DELIVERY", "ALLOW_DELIVERY", "DATE_ALLOW_DELIVERY", "EMP_ALLOW_DELIVERY_ID", "PRICE", "CURRENCY", "DISCOUNT_VALUE", "SUM_PAID", "USER_ID", "PAY_SYSTEM_ID", "DELIVERY_ID", "DATE_INSERT", "DATE_INSERT_FORMAT", "DATE_UPDATE", "USER_DESCRIPTION", "ADDITIONAL_INFO", "PS_STATUS", "PS_STATUS_CODE", "PS_STATUS_DESCRIPTION", "PS_STATUS_MESSAGE", "PS_SUM", "PS_CURRENCY", "PS_RESPONSE_DATE", "COMMENTS", "TAX_VALUE", "STAT_GID", "RECURRING_ID"));
ob_start();
echo "<" . "?xml version=\"1.0\" encoding=\"" . LANG_CHARSET . "\"?" . ">\n";
echo "<BizTalk xmlns=\"urn:schemas-biztalk-org:biztalk/biztalk-0.81.xml\"><Route><From locationID=\"\" locationType=\"\" process=\"\" path=\"\" handle=\"\"/><To locationID=\"\" locationType=\"\" process=\"\" path=\"\" handle=\"\"/></Route><Body>\n";
echo "\t<" . GetMessage("CommerceInfo") . " xmlns=\"urn:CommerceML\">\n";
$arContra = array();
while ($dbOrderList->NavNext(true, "f_")) {
    echo "\t\t<" . GetMessage("Document") . " " . GetMessage("Operation") . "=\"Order\" " . GetMessage("NumberDoc") . "=\"" . $f_ID . "\" ";
    echo "" . GetMessage("DateDoc") . "=\"" . CDatabase::FormatDate($f_DATE_INSERT, CLang::GetDateFormat("FULL", LANG), "Y-M-D") . "\" " . GetMessage("TimeDoc") . "=\"" . CDatabase::FormatDate($f_DATE_INSERT, CLang::GetDateFormat("FULL", LANG), "HH:MI:SS") . "\" " . GetMessage("PaymentDate") . "=\"\" ";
    echo "" . GetMessage("Sum") . "=\"" . $f_PRICE . "\" " . GetMessage("Comment") . "=\"\" " . GetMessage("Currency") . "=\"" . $f_CURRENCY . "\">\n";
    echo "\t\t\t<" . GetMessage("CompanyInDocument") . " " . GetMessage("Role") . "=\"Saler\" " . GetMessage("Company") . "=\"" . $SALER_COMPANY_XML_ID . "\"/>\n";
    echo "\t\t\t<" . GetMessage("CompanyInDocument") . " " . GetMessage("Role") . "=\"Buyer\" " . GetMessage("Company") . "=\"BC" . $f_USER_ID . "\"/>\n";
    $dbOrderTax = CSaleOrderTax::GetList(array(), array("ORDER_ID" => $f_ID), false, false, array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE"));
    while ($arOrderTax = $dbOrderTax->Fetch()) {
        echo "\t\t\t<" . GetMessage("TaxSum") . " " . GetMessage("Tax") . "=\"" . htmlspecialcharsbx($arOrderTax["TAX_NAME"]) . "\" " . GetMessage("TaxRate") . "=\"" . htmlspecialcharsbx($arOrderTax["VALUE"]) . "\" " . GetMessage("Sum") . "=\"" . htmlspecialcharsbx($arOrderTax["VALUE_MONEY"]) . "\" " . GetMessage("IncludedInSum") . "=\"" . ($arOrderTax["IS_IN_PRICE"] == "Y" ? 1 : 0) . "\"/>\n";
    }
    $dbBasket = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $f_ID));
    while ($arBasket = $dbBasket->Fetch()) {
        $CATALOG_XML_ID = $arBasket["CATALOG_XML_ID"];
        $PRODUCT_XML_ID = $arBasket["PRODUCT_XML_ID"];
        if (strlen($PRODUCT_XML_ID) <= 0 && strlen($CATALOG_XML_ID) <= 0) {
            $dbBasketProps = CSaleBasket::GetPropsList(array("CODE" => "ASC"), array("BASKET_ID" => $arBasket["ID"]));
            while ($arBasketProps = $dbBasketProps->Fetch()) {
                if ($arBasketProps["CODE"] == "CATALOG.XML_ID") {
Пример #13
0
while ($arRes = $myData->GetNext()) {
    $arRes["STATUS"] = $status[$arRes["STATUS"]];
    $row =& $lAdmin->AddRow($arRes["ID"], $arRes);
    $StatusHTML = '<select name="FIELDS[' . $arRes["ID"] . '][STATUS]">';
    foreach ($status as $key => $value) {
        $selected = "";
        if ($key == $arRes["~STATUS"]) {
            $selected = "selected";
        }
        $StatusHTML .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
    }
    $StatusHTML .= '</select>';
    $row->AddEditField("STATUS", $StatusHTML);
    $row->AddViewField("ID", $arRes["ID"]);
    $row->AddInputField("NAME", array("SIZE" => "30"));
    $row->AddViewField("CREATED", CDatabase::FormatDate($f_DATETIME, "YYYY-MM-DD HH:MI:SS", CSite::GetDateFormat("FULL")));
    $row->AddInputField("PHONE", array("SIZE" => "30"));
    $sHTML = "<textarea cols='30' rows='4'name='FIELDS[" . $arRes["ID"] . "][USER_COMMENT]'>" . $arRes["USER_COMMENT"] . "</textarea>";
    $row->AddEditField("USER_COMMENT", $sHTML);
    $sHTML = "<textarea cols='30' rows='4'name='FIELDS[" . $arRes["ID"] . "][ADMIN_COMMENT]'>" . $arRes["ADMIN_COMMENT"] . "</textarea>";
    $row->AddEditField("ADMIN_COMMENT", $sHTML);
    //echo "<pre style='display: none'>";
    //print_r($arRes);
    //echo "</pre>";
    $arActions = array();
    $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("EDIT"), "ACTION" => $lAdmin->ActionRedirect("softbalance_callback_edit.php?ID=" . urlencode($arRes["ID"]) . '&amp;lang=' . LANGUAGE_ID), "DEFAULT" => true);
    $arActions[] = array("ICON" => "delete", "TEXT" => GetMessage("DELETE"), "ACTION" => "if(confirm('" . GetMessageJS("DELETE_CONF") . "')) " . $lAdmin->ActionDoGroup($arRes["ID"], "delete"));
    $row->AddActions($arActions);
}
$lAdmin->AddFooter(array(array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $myData->SelectedRowsCount()), array("counter" => true, "title" => GetMessage("MAIN_ADMIN_LIST_CHECKED"), "value" => "0")));
$lAdmin->AddGroupActionTable(array("delete" => GetMessage("MAIN_ADMIN_LIST_DELETE")));
Пример #14
0
     $arResult['FIELD']['IB_IBLOCK_ID'] = $arResult['FIELD']['SETTINGS']['IBLOCK_ID'];
     $arResult['FIELD']['IB_DEFAULT_VALUE'] = $arResult['FIELD']['SETTINGS']['DEFAULT_VALUE'];
     $arResult['FIELD']['IB_DISPLAY'] = $arResult['FIELD']['SETTINGS']['DISPLAY'];
     $arResult['FIELD']['IB_LIST_HEIGHT'] = $arResult['FIELD']['SETTINGS']['LIST_HEIGHT'];
     $arResult['FIELD']['IB_ACTIVE_FILTER'] = $arResult['FIELD']['SETTINGS']['ACTIVE_FILTER'] == 'Y' ? 'Y' : 'N';
     break;
 case 'iblock_element':
     $arResult['FIELD']['IB_IBLOCK_TYPE_ID'] = $arResult['FIELD']['SETTINGS']['IBLOCK_TYPE_ID'];
     $arResult['FIELD']['IB_IBLOCK_ID'] = $arResult['FIELD']['SETTINGS']['IBLOCK_ID'];
     $arResult['FIELD']['IB_DEFAULT_VALUE'] = $arResult['FIELD']['SETTINGS']['DEFAULT_VALUE'];
     $arResult['FIELD']['IB_DISPLAY'] = $arResult['FIELD']['SETTINGS']['DISPLAY'];
     $arResult['FIELD']['IB_LIST_HEIGHT'] = $arResult['FIELD']['SETTINGS']['LIST_HEIGHT'];
     $arResult['FIELD']['IB_ACTIVE_FILTER'] = $arResult['FIELD']['SETTINGS']['ACTIVE_FILTER'] == 'Y' ? 'Y' : 'N';
     break;
 case 'datetime':
     $arResult['FIELD']['DT_DEFAULT_VALUE'] = CDatabase::FormatDate($arResult['FIELD']['SETTINGS']['DEFAULT_VALUE']['VALUE'], 'YYYY-MM-DD HH:MI:SS', CLang::GetDateFormat('FULL'));
     $arResult['FIELD']['DT_TYPE'] = $arResult['FIELD']['SETTINGS']['DEFAULT_VALUE']['TYPE'];
     break;
 case 'enumeration':
     $arResult['LIST'] = array();
     $arResult['LIST_DEF'] = array();
     if (is_callable(array($arResult['FIELD']['USER_TYPE']['CLASS_NAME'], 'GetList'))) {
         $rsEnum = call_user_func_array(array($arResult['FIELD']['USER_TYPE']['CLASS_NAME'], 'GetList'), array($arResult['FIELD']));
         while ($ar = $rsEnum->GetNext()) {
             $arResult['LIST'][$ar['ID']] = $ar;
             if ($ar['DEF'] == 'Y') {
                 $arResult['LIST_DEF'][$ar['ID']] = true;
             }
         }
     }
     $arResult['LIST'][] = array('ID' => 'n0', 'SORT' => 500, 'NAME' => '');
Пример #15
0
	function Authorize()
	{
		global $APPLICATION, $USER;

		if ($arOpenID = $this->Validate())
		{
			$arFields = array(
				'EXTERNAL_AUTH_ID' => 'OPENID#' . $arOpenID['server'],
				'XML_ID' => $arOpenID['identity'],
				'PASSWORD' => randString(30),
				'LID' => SITE_ID,
			);
			if (array_key_exists('openid_sreg_email', $_GET))
				$arFields['EMAIL'] = $_GET['openid_sreg_email'];

			if (array_key_exists('openid_sreg_gender', $_GET) && ($_GET['openid_sreg_gender'] == 'M' || $_GET['openid_sreg_gender'] == 'F'))
				$arFields['PERSONAL_GENDER'] = $_GET['openid_sreg_gender'];

			if (array_key_exists('openid_sreg_fullname', $_GET))
			{
				if(!defined("BX_UTF"))
					$fullname = CharsetConverter::ConvertCharset($_GET['openid_sreg_fullname'], 'UTF-8', LANG_CHARSET);

				$fullname = trim($fullname);
				if (($pos = strpos($fullname, ' ')) !== false)
				{
					$arFields['NAME'] = substr($fullname, 0, $pos);
					$arFields['LAST_NAME'] = substr($fullname, $pos + 1);
				}
				else
				{
					$arFields['NAME'] = $fullname;
				}
			}

			if (array_key_exists('openid_sreg_postcode', $_GET))
				$arFields['PERSONAL_ZIP'] = $_GET['openid_sreg_postcode'];

			if (array_key_exists('openid_sreg_timezone', $_GET))
				$arFields['TIME_ZONE'] = $_GET['openid_sreg_timezone'];

			if (array_key_exists('openid_sreg_country', $_GET))
				$arFields['PERSONAL_COUNTRY'] = GetCountryIdByCode($_GET['openid_sreg_country']);

			if (array_key_exists('openid_sreg_dob', $_GET))
				$arFields['PERSONAL_BIRTHDAY'] = CDatabase::FormatDate($_GET['openid_sreg_dob'], "YYYY-MM-DD", FORMAT_DATE);

			if (array_key_exists('BX_OPENID_IDENTITY', $_SESSION))
				$arFields['LOGIN'] = $_SESSION['BX_OPENID_IDENTITY'];
			else
				$arFields['LOGIN'] = $arOpenID['identity'];

			$arFields['LOGIN'] = preg_replace("#^(http://|https://)#i", "", $arFields['LOGIN']);

			$USER_ID = 0;

			$rsUsers = $USER->GetList($B, $O, array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => $arFields['EXTERNAL_AUTH_ID']));
			if ($arUser = $rsUsers->Fetch())
			{
				$USER_ID = $arUser['ID'];
			}
			else
			{
				$def_group = COption::GetOptionString('main', 'new_user_registration_def_group', '');
				if($def_group != '')
					$arFields['GROUP_ID'] = explode(',', $def_group);

				$rsEvents = GetModuleEvents('main', 'OnBeforeOpenIDUserAdd');
				while ($arEvent = $rsEvents->Fetch())
					$arFields = ExecuteModuleEventEx($arEvent, array($arFields));

				if ( !($USER_ID = $USER->Add($arFields)) )
					return false;
			}
			if (intval($USER_ID) > 0)
			{
				$USER->Authorize($USER_ID);

				$arKillParams = array("auth_service_id");
				foreach (array_keys($_GET) as $k)
					if (strpos($k, 'openid_') === 0)
						$arKillParams[] = $k;

				$redirect_url = $APPLICATION->GetCurPageParam('', $arKillParams, false);

				$rsEvents = GetModuleEvents('main', 'OnBeforeOpenIDAuthFinalRedirect');
				while ($arEvent = $rsEvents->Fetch())
					$redirect_url = ExecuteModuleEventEx($arEvent, array($redirect_url, $USER_ID, $arFields));

				if ($redirect_url)
					LocalRedirect($redirect_url, true);

				return $USER_ID;
			}
		}
		return false;
	}
Пример #16
0
 protected static function GetSqlByFilter($arFilter, $userID, $sAliasPrefix, $bGetZombie, $bMembersTableJoined = false)
 {
     global $DB;
     $bFullJoin = null;
     if (!is_array($arFilter)) {
         throw new TasksException('GetSqlByFilter: expected array, but something other given: ' . var_export($arFilter, true));
     }
     $logicStr = ' AND ';
     if (isset($arFilter['::LOGIC'])) {
         switch ($arFilter['::LOGIC']) {
             case 'AND':
                 $logicStr = ' AND ';
                 break;
             case 'OR':
                 $logicStr = ' OR ';
                 break;
             default:
                 throw new TasksException('Unknown logic in filter');
                 break;
         }
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         // Skip meta-key
         if ($key === '::LOGIC') {
             continue;
         }
         // Skip markers
         if ($key === '::MARKERS') {
             continue;
         }
         // Subfilter?
         if (substr($key, 0, 12) === '::SUBFILTER-') {
             $arSqlSearch[] = self::GetSqlByFilter($val, $userID, $sAliasPrefix, $bGetZombie, $bMembersTableJoined);
             continue;
         }
         $key = ltrim($key);
         // This type of operations should be processed in special way
         // Fields like "META:DEADLINE_TS" will be replaced to "DEADLINE"
         if (substr($key, -3) === '_TS') {
             $arSqlSearch = array_merge($arSqlSearch, self::getSqlForTimestamps($key, $val, $userID, $sAliasPrefix, $bGetZombie));
             continue;
         }
         $res = CTasks::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case 'META::ID_OR_NAME':
                 if (strtoupper($DB->type) == "ORACLE") {
                     $arSqlSearch[] = " (" . $sAliasPrefix . "T.ID = '" . intval($val) . "' OR (UPPER(" . $sAliasPrefix . "T.TITLE) UPPER('%" . $DB->ForSqlLike($val) . "%')) ) ";
                 } else {
                     $arSqlSearch[] = " (" . $sAliasPrefix . "T.ID = '" . intval($val) . "' OR (UPPER(" . $sAliasPrefix . "T.TITLE) LIKE UPPER('%" . $DB->ForSqlLike($val) . "%')) ) ";
                 }
                 break;
             case "PARENT_ID":
             case "GROUP_ID":
             case "STATUS_CHANGED_BY":
             case "FORUM_TOPIC_ID":
                 $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T." . $key, $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "ID":
             case "PRIORITY":
             case "CREATED_BY":
             case "RESPONSIBLE_ID":
             case 'TIME_ESTIMATE':
                 $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T." . $key, $val, "number_wo_nulls", $bFullJoin, $cOperationType);
                 break;
             case "REFERENCE:RESPONSIBLE_ID":
                 $key = 'RESPONSIBLE_ID';
                 $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T." . $key, $val, 'reference', $bFullJoin, $cOperationType);
                 break;
             case 'META:GROUP_ID_IS_NULL_OR_ZERO':
                 $key = 'GROUP_ID';
                 $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T." . $key, $val, "null_or_zero", $bFullJoin, $cOperationType, false);
                 break;
             case "CHANGED_BY":
                 $arSqlSearch[] = CTasks::FilterCreate("CASE WHEN " . $sAliasPrefix . "T." . $key . " IS NULL THEN " . $sAliasPrefix . "T.CREATED_BY ELSE " . $sAliasPrefix . "T." . $key . " END", $val, "number", $bFullJoin, $cOperationType);
                 break;
             case 'GUID':
             case 'TITLE':
                 $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T." . $key, $val, "string", $bFullJoin, $cOperationType);
                 break;
             case "TAG":
                 if (!is_array($val)) {
                     $val = array($val);
                 }
                 $arConds = array();
                 foreach ($val as $tag) {
                     if ($tag) {
                         $arConds[] = "(" . $sAliasPrefix . "TT.NAME = '" . $DB->ForSql($tag) . "')";
                     }
                 }
                 if (sizeof($arConds)) {
                     $arSqlSearch[] = "EXISTS(\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t'x'\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tb_tasks_tag " . $sAliasPrefix . "TT\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(" . implode(" OR ", $arConds) . ")\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t" . $sAliasPrefix . "TT.TASK_ID = " . $sAliasPrefix . "T.ID\n\t\t\t\t\t\t)";
                 }
                 break;
             case 'REAL_STATUS':
                 $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T.STATUS", $val, "number", $bFullJoin, $cOperationType);
                 break;
             case 'DEADLINE_COUNTED':
                 $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T.DEADLINE_COUNTED", $val, "number_wo_nulls", $bFullJoin, $cOperationType);
                 break;
             case 'VIEWED':
                 $arSqlSearch[] = CTasks::FilterCreate("\n\t\t\t\t\t\tCASE\n\t\t\t\t\t\t\tWHEN\n\t\t\t\t\t\t\t\t" . $sAliasPrefix . "TV.USER_ID IS NULL\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t(" . $sAliasPrefix . "T.STATUS = 1 OR " . $sAliasPrefix . "T.STATUS = 2)\n\t\t\t\t\t\t\tTHEN\n\t\t\t\t\t\t\t\t'0'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t'1'\n\t\t\t\t\t\tEND\n\t\t\t\t\t", $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "STATUS":
                 $arSqlSearch[] = CTasks::FilterCreate("\n\t\t\t\t\t\tCASE\n\t\t\t\t\t\t\tWHEN\n\t\t\t\t\t\t\t\t" . $sAliasPrefix . "T.DEADLINE < " . $DB->CurrentTimeFunction() . " AND " . $sAliasPrefix . "T.STATUS != '4' AND " . $sAliasPrefix . "T.STATUS != '5' AND (" . $sAliasPrefix . "T.STATUS != '7' OR " . $sAliasPrefix . "T.RESPONSIBLE_ID != " . $userID . ")\n\t\t\t\t\t\t\tTHEN\n\t\t\t\t\t\t\t\t'-1'\n\t\t\t\t\t\t\tWHEN\n\t\t\t\t\t\t\t\t" . $sAliasPrefix . "TV.USER_ID IS NULL\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t" . $sAliasPrefix . "T.CREATED_BY != " . $userID . "\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t(" . $sAliasPrefix . "T.STATUS = 1 OR " . $sAliasPrefix . "T.STATUS = 2)\n\t\t\t\t\t\t\tTHEN\n\t\t\t\t\t\t\t\t'-2'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t" . $sAliasPrefix . "T.STATUS\n\t\t\t\t\t\tEND\n\t\t\t\t\t", $val, "number", $bFullJoin, $cOperationType);
                 break;
             case 'MARK':
             case 'XML_ID':
             case 'SITE_ID':
             case 'ZOMBIE':
             case 'ADD_IN_REPORT':
             case 'ALLOW_TIME_TRACKING':
                 $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                 break;
             case "END_DATE_PLAN":
             case "START_DATE_PLAN":
             case "DATE_START":
             case "DEADLINE":
             case "CREATED_DATE":
             case "CLOSED_DATE":
                 if ($val === false || $val === '') {
                     $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T." . $key, $val, "date", $bFullJoin, $cOperationType, $bSkipEmpty = false);
                 } else {
                     $arSqlSearch[] = CTasks::FilterCreate($sAliasPrefix . "T." . $key, $DB->CharToDateFunction($val), "date", $bFullJoin, $cOperationType);
                 }
                 break;
             case "CHANGED_DATE":
                 $arSqlSearch[] = CTasks::FilterCreate("CASE WHEN " . $sAliasPrefix . "T." . $key . " IS NULL THEN " . $sAliasPrefix . "T.CREATED_DATE ELSE " . $sAliasPrefix . "T." . $key . " END", $DB->CharToDateFunction($val), "date", $bFullJoin, $cOperationType);
                 break;
             case "ACCOMPLICE":
                 if (!is_array($val)) {
                     $val = array($val);
                 }
                 $val = array_filter($val);
                 $arConds = array();
                 if ($bMembersTableJoined) {
                     if ($cOperationType !== 'N') {
                         foreach ($val as $id) {
                             $arConds[] = "(" . $sAliasPrefix . "TM.USER_ID = '" . intval($id) . "')";
                         }
                         if (!empty($arConds)) {
                             $arSqlSearch[] = '(' . $sAliasPrefix . "TM.TYPE = 'A' AND (" . implode(" OR ", $arConds) . '))';
                         }
                     } else {
                         foreach ($val as $id) {
                             $arConds[] = "(" . $sAliasPrefix . "TM.USER_ID != '" . intval($id) . "')";
                         }
                         if (!empty($arConds)) {
                             $arSqlSearch[] = '(' . $sAliasPrefix . "TM.TYPE = 'A' AND (" . implode(" AND ", $arConds) . '))';
                         }
                     }
                 } else {
                     foreach ($val as $id) {
                         $arConds[] = "(" . $sAliasPrefix . "TM.USER_ID = '" . intval($id) . "')";
                     }
                     if (!empty($arConds)) {
                         $arSqlSearch[] = ($cOperationType !== 'N' ? 'EXISTS' : 'NOT EXISTS') . "(\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t'x'\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tb_tasks_member " . $sAliasPrefix . "TM\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(" . implode(" OR ", $arConds) . ")\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t" . $sAliasPrefix . "TM.TASK_ID = " . $sAliasPrefix . "T.ID\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t" . $sAliasPrefix . "TM.TYPE = 'A'\n\t\t\t\t\t\t\t)";
                     }
                 }
                 break;
             case "PERIOD":
             case "ACTIVE":
                 if ($val["START"] || $val["END"]) {
                     $strDateStart = $strDateEnd = false;
                     if (MakeTimeStamp($val['START']) > 0) {
                         $strDateStart = $DB->CharToDateFunction($DB->ForSql(CDatabase::FormatDate($val['START'], FORMAT_DATETIME)));
                     }
                     if (MakeTimeStamp($val['END'])) {
                         $strDateEnd = $DB->CharToDateFunction($DB->ForSql(CDatabase::FormatDate($val['END'], FORMAT_DATETIME)));
                     }
                     if ($strDateStart !== false && $strDateEnd !== false) {
                         $arSqlSearch[] = "(\n\t\t\t\t\t\t\t\t\t(T.CREATED_DATE >= {$strDateStart} AND T.CREATED_DATE <= {$strDateEnd})\n\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t(T.CLOSED_DATE >= {$strDateStart} AND T.CLOSED_DATE <= {$strDateEnd})\n\t\t\t\t\t\t\t\t)";
                     } elseif ($strDateStart !== false && $strDateEnd === false) {
                         $arSqlSearch[] = "(\n\t\t\t\t\t\t\t\t\t(T.CREATED_DATE >= {$strDateStart})\n\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t(T.CLOSED_DATE >= {$strDateStart})\n\t\t\t\t\t\t\t\t)";
                     } elseif ($strDateStart === false && $strDateEnd !== false) {
                         $arSqlSearch[] = "(\n\t\t\t\t\t\t\t\t\t(T.CREATED_DATE <= {$strDateEnd})\n\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t(T.CLOSED_DATE <= {$strDateEnd})\n\t\t\t\t\t\t\t\t)";
                     }
                 }
                 break;
             case "AUDITOR":
                 if (!is_array($val)) {
                     $val = array($val);
                 }
                 $val = array_filter($val);
                 $arConds = array();
                 if ($bMembersTableJoined) {
                     if ($cOperationType !== 'N') {
                         foreach ($val as $id) {
                             $arConds[] = "(" . $sAliasPrefix . "TM.USER_ID = '" . intval($id) . "')";
                         }
                         if (!empty($arConds)) {
                             $arSqlSearch[] = '(' . $sAliasPrefix . "TM.TYPE = 'U' AND (" . implode(" OR ", $arConds) . '))';
                         }
                     } else {
                         foreach ($val as $id) {
                             $arConds[] = "(" . $sAliasPrefix . "TM.USER_ID != '" . intval($id) . "')";
                         }
                         if (!empty($arConds)) {
                             $arSqlSearch[] = '(' . $sAliasPrefix . "TM.TYPE = 'U' AND (" . implode(" AND ", $arConds) . '))';
                         }
                     }
                 } else {
                     foreach ($val as $id) {
                         $arConds[] = "(" . $sAliasPrefix . "TM.USER_ID = '" . intval($id) . "')";
                     }
                     if (!empty($arConds)) {
                         $arSqlSearch[] = ($cOperationType !== 'N' ? 'EXISTS' : 'NOT EXISTS') . "(\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t'x'\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tb_tasks_member " . $sAliasPrefix . "TM\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t(" . implode(" OR ", $arConds) . ")\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t" . $sAliasPrefix . "TM.TASK_ID = " . $sAliasPrefix . "T.ID\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t" . $sAliasPrefix . "TM.TYPE = 'U'\n\t\t\t\t\t\t\t)";
                     }
                 }
                 break;
             case "DOER":
                 $val = intval($val);
                 $arSqlSearch[] = "(" . $sAliasPrefix . "T.RESPONSIBLE_ID = " . $val . " OR EXISTS(SELECT 'x' FROM b_tasks_member " . $sAliasPrefix . "TM WHERE " . $sAliasPrefix . "TM.TASK_ID = " . $sAliasPrefix . "T.ID AND " . $sAliasPrefix . "TM.USER_ID = '" . $val . "' AND " . $sAliasPrefix . "TM.TYPE = 'A'))";
                 break;
             case "MEMBER":
                 $val = intval($val);
                 $arSqlSearch[] = "(" . $sAliasPrefix . "T.CREATED_BY = " . intval($val) . " OR " . $sAliasPrefix . "T.RESPONSIBLE_ID = " . intval($val) . " OR EXISTS(SELECT 'x' FROM b_tasks_member " . $sAliasPrefix . "TM WHERE " . $sAliasPrefix . "TM.TASK_ID = " . $sAliasPrefix . "T.ID AND " . $sAliasPrefix . "TM.USER_ID = '" . $val . "'))";
                 break;
             case "DEPENDS_ON":
                 if (!is_array($val)) {
                     $val = array($val);
                 }
                 $arConds = array();
                 foreach ($val as $id) {
                     if ($id) {
                         $arConds[] = "(" . $sAliasPrefix . "TD.TASK_ID = '" . intval($id) . "')";
                     }
                 }
                 if (sizeof($arConds)) {
                     $arSqlSearch[] = "EXISTS(\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t'x'\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tb_tasks_dependence " . $sAliasPrefix . "TD\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(" . implode(" OR ", $arConds) . ")\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t" . $sAliasPrefix . "TD.DEPENDS_ON_ID = " . $sAliasPrefix . "T.ID\n\t\t\t\t\t\t)";
                 }
                 break;
             case "ONLY_ROOT_TASKS":
                 if ($val == "Y") {
                     $arSqlSearch[] = "(" . $sAliasPrefix . "T.PARENT_ID IS NULL OR NOT EXISTS (" . CTasks::GetRootSubquery($arFilter, $bGetZombie) . "))";
                 }
                 break;
             case "SUBORDINATE_TASKS":
                 if ($val == "Y") {
                     $arSubSqlSearch = array($sAliasPrefix . "T.CREATED_BY = " . $userID, $sAliasPrefix . "T.RESPONSIBLE_ID = " . $userID, "EXISTS(SELECT 'x' FROM b_tasks_member " . $sAliasPrefix . "TM WHERE " . $sAliasPrefix . "TM.TASK_ID = " . $sAliasPrefix . "T.ID AND " . $sAliasPrefix . "TM.USER_ID = " . $userID . ")");
                     // subordinate check
                     if ($strSql = CTasks::GetSubordinateSql($sAliasPrefix, array('USER_ID' => $userID))) {
                         $arSubSqlSearch[] = "EXISTS(" . $strSql . ")";
                     }
                     $arSqlSearch[] = "(" . implode(" OR ", $arSubSqlSearch) . ")";
                 }
                 break;
             case "OVERDUED":
                 if ($val == "Y") {
                     $arSqlSearch[] = $sAliasPrefix . "T.CLOSED_DATE IS NOT NULL AND " . $sAliasPrefix . "T.DEADLINE IS NOT NULL AND " . $sAliasPrefix . "T.DEADLINE < CLOSED_DATE";
                 }
                 break;
             case "SAME_GROUP_PARENT":
                 if ($val == "Y" && !array_key_exists("ONLY_ROOT_TASKS", $arFilter)) {
                     $arSqlSearch[] = "EXISTS(\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t'x'\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tb_tasks " . $sAliasPrefix . "PT\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t" . $sAliasPrefix . "T.PARENT_ID = " . $sAliasPrefix . "PT.ID\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t(" . $sAliasPrefix . "PT.GROUP_ID = " . $sAliasPrefix . "T.GROUP_ID \n\t\t\t\t\t\t\t\tOR (" . $sAliasPrefix . "PT.GROUP_ID IS NULL AND " . $sAliasPrefix . "T.GROUP_ID IS NULL)\n\t\t\t\t\t\t\t\tOR (" . $sAliasPrefix . "PT.GROUP_ID = 0 AND " . $sAliasPrefix . "T.GROUP_ID IS NULL)\n\t\t\t\t\t\t\t\tOR (" . $sAliasPrefix . "PT.GROUP_ID IS NULL AND " . $sAliasPrefix . "T.GROUP_ID = 0)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t" . ($bGetZombie ? "" : " AND " . $sAliasPrefix . "PT.ZOMBIE = 'N' ") . "\n\t\t\t\t\t\t)";
                 }
                 break;
             case "DEPARTMENT_ID":
                 if ($strSql = CTasks::GetDeparmentSql($val, $sAliasPrefix)) {
                     $arSqlSearch[] = "EXISTS(" . $strSql . ")";
                 }
                 break;
             case 'CHECK_PERMISSIONS':
                 break;
             default:
                 if (strlen($key) >= 3 && substr($key, 0, 3) === 'UF_') {
                     // It's OK, this fields will be processed by UserFieldManager
                 } else {
                     $extraData = '';
                     if (isset($_POST['action']) && $_POST['action'] === 'group_action') {
                         $extraData = '; Extra data: <data0>' . serialize(array($_POST['arFilter'], $_POST['action'], $arFilter)) . '</data0>';
                     } else {
                         $extraData = '; Extra data: <data1>' . serialize($arFilter) . '</data1>';
                     }
                     CTaskAssert::logError('[0x6024749e] unexpected field in filter: ' . $key . $extraData);
                     throw new TasksException('', TasksException::TE_WRONG_ARGUMENTS);
                 }
                 break;
         }
     }
     $sql = implode($logicStr, array_filter($arSqlSearch));
     if ($sql == '') {
         $sql = '1=1';
     }
     return '(' . $sql . ')';
 }
Пример #17
0
	function ExportElements($PROPERTY_MAP, $SECTION_MAP, $start_time, $INTERVAL, $counter_limit = 0, $arElementFilter = false)
	{
		$counter = 0;
		$arSelect = array(
			"ID",
			"IBLOCK_ID",
			"XML_ID",
			"ACTIVE",
			"CODE",
			"NAME",
			"PREVIEW_TEXT",
			"PREVIEW_TEXT_TYPE",
			"ACTIVE_FROM",
			"ACTIVE_TO",
			"SORT",
			"TAGS",
			"DETAIL_TEXT",
			"DETAIL_TEXT_TYPE",
			"PREVIEW_PICTURE",
			"DETAIL_PICTURE",
		);

		if(is_array($arElementFilter))
		{
			$arFilter = $arElementFilter;
		}
		else
		{
			if($arElementFilter === "none")
				return 0;
			$arFilter = array (
				"IBLOCK_ID"=> $this->arIBlock["ID"],
				"ACTIVE" => "Y",
				">ID" => $this->next_step["LAST_ID"],
			);
			if($arElementFilter === "all")
				unset($arFilter["ACTIVE"]);
		}

		$arOrder = array(
			"ID" => "ASC",
		);
		$arPropOrder = array(
			"sort" => "asc",
			"id" => "asc",
			"enum_sort" => "asc",
			"value_id" => "asc",
		);

		$rsElements = CIBlockElement::GetList($arOrder, $arFilter, false, false, $arSelect);
		while($arElement = $rsElements->Fetch())
		{
			if($this->next_step["catalog"])
				fwrite($this->fp, "\t\t\t<".GetMessage("IBLOCK_XML2_OFFER").">\n");
			else
				fwrite($this->fp, "\t\t\t<".GetMessage("IBLOCK_XML2_POSITION").">\n");

			if(strlen($arElement["XML_ID"])>0)
				$xml_id = $arElement["XML_ID"];
			else
				$xml_id = $arElement["ID"];

			if($this->PRODUCT_IBLOCK_ID > 0)
			{
				$rsLink = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE"=>"Y", "CODE" => "CML2_LINK"));
				$arLink = $rsLink->Fetch();
				if(is_array($arLink) && !is_array($arLink["VALUE"]) && $arLink["VALUE"] > 0)
					$xml_id = $this->GetElementXML_ID($this->PRODUCT_IBLOCK_ID, $arLink["VALUE"])."#".$xml_id;
			}

			fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($xml_id)."</".GetMessage("IBLOCK_XML2_ID").">\n");

			if(!$this->only_price)
			{
				fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_NAME").">".htmlspecialcharsbx($arElement["NAME"])."</".GetMessage("IBLOCK_XML2_NAME").">\n");
				if($this->bExtended)
					fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_BX_TAGS").">".htmlspecialcharsbx($arElement["TAGS"])."</".GetMessage("IBLOCK_XML2_BX_TAGS").">\n");

				$arSections = array();
				$rsSections = CIBlockElement::GetElementGroups($arElement["ID"], true);
				while($arSection = $rsSections->Fetch())
					if(array_key_exists($arSection["ID"], $SECTION_MAP))
						$arSections[] = $SECTION_MAP[$arSection["ID"]];

				fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_GROUPS").">\n");
				foreach($arSections as $xml_id)
					fwrite($this->fp, "\t\t\t\t\t<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($xml_id)."</".GetMessage("IBLOCK_XML2_ID").">\n");
				fwrite($this->fp, "\t\t\t\t</".GetMessage("IBLOCK_XML2_GROUPS").">\n");

				if(!$this->bExtended)
					fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_DESCRIPTION").">".htmlspecialcharsbx(FormatText($arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"]))."</".GetMessage("IBLOCK_XML2_DESCRIPTION").">\n");

				fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_PICTURE"), $this->ExportFile($arElement["DETAIL_PICTURE"])));

				fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTIES_VALUES").">\n");

				if($this->bExtended)
				{
					$this->ExportPropertyValue("CML2_ACTIVE", ($arElement["ACTIVE"]=="Y"? "true": "false"));
					$this->ExportPropertyValue("CML2_CODE", $arElement["CODE"]);
					$this->ExportPropertyValue("CML2_SORT", intval($arElement["SORT"]));
					$this->ExportPropertyValue("CML2_ACTIVE_FROM", CDatabase::FormatDate($arElement["ACTIVE_FROM"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS"));
					$this->ExportPropertyValue("CML2_ACTIVE_TO", CDatabase::FormatDate($arElement["ACTIVE_TO"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS"));
					$this->ExportPropertyValue("CML2_PREVIEW_TEXT", $arElement["PREVIEW_TEXT"], $arElement["PREVIEW_TEXT_TYPE"]);
					$this->ExportPropertyValue("CML2_DETAIL_TEXT", $arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"]);
					$this->ExportPropertyValue("CML2_PREVIEW_PICTURE", $this->ExportFile($arElement["PREVIEW_PICTURE"]));
				}

				$rsProps = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE"=>"Y"));
				$arProps = array();
				while($arProp = $rsProps->Fetch())
				{
					$pid = $arProp["ID"];
					if(!array_key_exists($pid, $arProps))
						$arProps[$pid] = array(
							"PROPERTY_TYPE" => $arProp["PROPERTY_TYPE"],
							"LINK_IBLOCK_ID" => $arProp["LINK_IBLOCK_ID"],
							"VALUES" => array(),
						);

					if($arProp["PROPERTY_TYPE"] == "L")
						$arProps[$pid]["VALUES"][] = array(
							"VALUE" => $arProp["VALUE_ENUM"],
							"DESCRIPTION" => $arProp["DESCRIPTION"],
							"VALUE_ENUM_ID" => $arProp["VALUE"],
						);
					else
						$arProps[$pid]["VALUES"][] = array(
							"VALUE" => $arProp["VALUE"],
							"DESCRIPTION" => $arProp["DESCRIPTION"],
							"VALUE_ENUM_ID" => $arProp["VALUE_ENUM_ID"],
						);
				}

				foreach($arProps as $pid => $arProp)
				{
					$bEmpty = true;
					fwrite($this->fp, "\t\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTY_VALUES").">\n");
					fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($PROPERTY_MAP[$pid])."</".GetMessage("IBLOCK_XML2_ID").">\n");
					foreach($arProp["VALUES"] as $arValue)
					{
						$value = $arValue["VALUE"];
						if(is_array($value) || strlen($value))
						{
							$bEmpty = false;
							$bSerialized = false;
							if($this->bExtended)
							{
								if($arProp["PROPERTY_TYPE"]=="L")
								{
									$value = CIBlockPropertyEnum::GetByID($arValue["VALUE_ENUM_ID"]);
									$value = $value["XML_ID"];
								}
								elseif($arProp["PROPERTY_TYPE"]=="F")
								{
									$value = $this->ExportFile($value);
								}
								elseif($arProp["PROPERTY_TYPE"]=="G")
								{
									$value = $this->GetSectionXML_ID($arProp["LINK_IBLOCK_ID"], $value);
								}
								elseif($arProp["PROPERTY_TYPE"]=="E")
								{
									$value = $this->GetElementXML_ID($arProp["LINK_IBLOCK_ID"], $value);
								}

								if(is_array($value) && $arProp["PROPERTY_TYPE"]!=="F")
								{
									$bSerialized = true;
									$value = serialize($value);
								}
							}
							fwrite($this->fp, $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_VALUE"), $value));
							if($this->bExtended)
							{
								fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTY_VALUE").">\n");
								if($bSerialized)
									fwrite($this->fp, "\t\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_SERIALIZED").">true</".GetMessage("IBLOCK_XML2_SERIALIZED").">\n");
								fwrite($this->fp, $this->formatXMLNode(7, GetMessage("IBLOCK_XML2_VALUE"), $value));
								fwrite($this->fp, "\t\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_DESCRIPTION").">".htmlspecialcharsbx($arValue["DESCRIPTION"])."</".GetMessage("IBLOCK_XML2_DESCRIPTION").">\n");
								fwrite($this->fp, "\t\t\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTY_VALUE").">\n");
							}
						}
					}
					if($bEmpty)
						fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_VALUE")."></".GetMessage("IBLOCK_XML2_VALUE").">\n");
					fwrite($this->fp, "\t\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTY_VALUES").">\n");
				}
				fwrite($this->fp, "\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTIES_VALUES").">\n");
			}

			if($this->next_step["catalog"])
			{
				$arPrices = array();
				$rsPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $arElement["ID"]));
				while($arPrice = $rsPrices->Fetch())
				{
					if(!$arPrice["QUANTITY_FROM"] && !$arPrice["QUANTITY_TO"])
					{
						$arPrices[] = array(
							GetMessage("IBLOCK_XML2_PRICE_TYPE_ID") => $this->prices[$arPrice["CATALOG_GROUP_ID"]],
							GetMessage("IBLOCK_XML2_PRICE_FOR_ONE") => $arPrice["PRICE"],
							GetMessage("IBLOCK_XML2_CURRENCY") => $arPrice["CURRENCY"],
							GetMessage("IBLOCK_XML2_MEASURE") => GetMessage("IBLOCK_XML2_PCS"),
						);
					}
				}
				if(count($arPrices)>0)
				{
					fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_PRICES").">\n");
					foreach($arPrices as $arPrice)
					{
						fwrite($this->fp, "\t\t\t\t\t<".GetMessage("IBLOCK_XML2_PRICE").">\n");
						foreach($arPrice as $key=>$value)
						{
							fwrite($this->fp, "\t\t\t\t\t\t<".$key.">".htmlspecialcharsbx($value)."</".$key.">\n");
						}
						fwrite($this->fp, "\t\t\t\t\t</".GetMessage("IBLOCK_XML2_PRICE").">\n");
					}
					fwrite($this->fp, "\t\t\t\t</".GetMessage("IBLOCK_XML2_PRICES").">\n");
					$arCatalogProduct = CCatalogProduct::GetByID($arElement["ID"]);
					if($arCatalogProduct)
						fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_AMOUNT").">".htmlspecialcharsbx($arCatalogProduct["QUANTITY"])."</".GetMessage("IBLOCK_XML2_AMOUNT").">\n");
				}
			}

			if($this->next_step["catalog"])
				fwrite($this->fp, "\t\t\t</".GetMessage("IBLOCK_XML2_OFFER").">\n");
			else
				fwrite($this->fp, "\t\t\t</".GetMessage("IBLOCK_XML2_POSITION").">\n");

			$this->next_step["LAST_ID"] = $arElement["ID"];
			$counter++;
			if($INTERVAL > 0 && (time()-$start_time) > $INTERVAL)
				break;
			if($counter_limit > 0 && ($counter >= $counter_limit))
				break;
		}
		return $counter;
	}
Пример #18
0
$rsData = new CDBResult;
$rsData->InitFromArray($arModules);
$rsData = new CAdminResult($rsData, $sTableID);
while($info = $rsData->Fetch())
{
	$row =& $lAdmin->AddRow($info["MODULE_ID"], $info);

	$name = "<b><a href=\"http://marketplace.1c-freetrix.ru/".htmlspecialcharsbx($info["MODULE_ID"])."\" target=\"_blank\">".htmlspecialcharsbx($info["MODULE_NAME"])."</a></b> (".htmlspecialcharsbx($info["MODULE_ID"]).")";
	if($info["DEMO"] == "Y")
		$name .= " <span style=\"color:red;\">".GetMessage("MOD_DEMO")."</span>";
	$name .= "<br />".htmlspecialcharsbx($info["MODULE_DESCRIPTION"]);
	$row->AddViewField("NAME", $name);
	$row->AddViewField("PARTNER", ((strlen($info["MODULE_PARTNER"]) > 0) ? " ".str_replace(array("#NAME#", "#URI#"), array($info["MODULE_PARTNER"], $info["MODULE_PARTNER_URI"]), GetMessage("MOD_PARTNER_NAME"))."" : "&nbsp;"));
	$row->AddViewField("VERSION", $info["MODULE_VERSION"]);
	$row->AddViewField("DATE_UPDATE", CDatabase::FormatDate($info["MODULE_VERSION_DATE"], "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("SHORT")));
	if($modules[$info["MODULE_ID"]]["FREE_MODULE"] != "Y")
	{
		if($info["DEMO"] == "Y")
		{
			if($linkToBuy)
			{
				if($info["DEMO_END"] == "Y")
					$row->AddViewField("DATE_TO", "<span class=\"required\">".GetMessage("MOD_DEMO_END")."</span><br /><a href=\"".str_replace("#CODE#", $info["MODULE_ID"], $linkToBuy)."\" target=\"_blank\">".GetMessage("MOD_UPDATE_BUY_DEMO")."</a>");
				else
					$row->AddViewField("DATE_TO", $info["DEMO_DATE"]."<br /><a href=\"".str_replace("#CODE#", $info["MODULE_ID"], $linkToBuy)."\" target=\"_blank\">".GetMessage("MOD_UPDATE_BUY_DEMO")."</a>");
			}
			else
			{
				if($info["DEMO_END"] == "Y")
					$row->AddViewField("DATE_TO", "<span class=\"required\">".GetMessage("MOD_DEMO_END")."</span>");
Пример #19
0
 function exportElementProperties($arElement, $PROPERTY_MAP)
 {
     if ($this->bExtended) {
         $this->ExportPropertyValue("CML2_ACTIVE", $arElement["ACTIVE"] == "Y" ? "true" : "false");
         $this->ExportPropertyValue("CML2_CODE", $arElement["CODE"]);
         $this->ExportPropertyValue("CML2_SORT", intval($arElement["SORT"]));
         $this->ExportPropertyValue("CML2_ACTIVE_FROM", CDatabase::FormatDate($arElement["ACTIVE_FROM"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS"));
         $this->ExportPropertyValue("CML2_ACTIVE_TO", CDatabase::FormatDate($arElement["ACTIVE_TO"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS"));
         $this->ExportPropertyValue("CML2_PREVIEW_TEXT", $arElement["PREVIEW_TEXT"], $arElement["PREVIEW_TEXT_TYPE"]);
         $this->ExportPropertyValue("CML2_DETAIL_TEXT", $arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"]);
         $this->ExportPropertyValue("CML2_PREVIEW_PICTURE", $this->ExportFile($arElement["PREVIEW_PICTURE"]));
     }
     $arPropOrder = array("sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc");
     $rsProps = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE" => "Y"));
     $arProps = array();
     while ($arProp = $rsProps->Fetch()) {
         $pid = $arProp["ID"];
         if (!array_key_exists($pid, $arProps)) {
             $arProps[$pid] = array("PROPERTY_TYPE" => $arProp["PROPERTY_TYPE"], "LINK_IBLOCK_ID" => $arProp["LINK_IBLOCK_ID"], "VALUES" => array());
         }
         if ($arProp["PROPERTY_TYPE"] == "L") {
             $arProps[$pid]["VALUES"][] = array("VALUE" => $arProp["VALUE_ENUM"], "DESCRIPTION" => $arProp["DESCRIPTION"], "VALUE_ENUM_ID" => $arProp["VALUE"]);
         } else {
             $arProps[$pid]["VALUES"][] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"], "VALUE_ENUM_ID" => $arProp["VALUE_ENUM_ID"]);
         }
     }
     foreach ($arProps as $pid => $arProp) {
         $bEmpty = true;
         if ($this->next_step["catalog"] && !$this->bExtended) {
             fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTE") . ">\n");
         } else {
             fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_PROPERTY_VALUES") . ">\n");
         }
         if ($this->next_step["catalog"] && !$this->bExtended) {
             fwrite($this->fp, "\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_NAME") . ">" . htmlspecialcharsbx($PROPERTY_MAP["~" . $pid]) . "</" . GetMessage("IBLOCK_XML2_NAME") . ">\n");
         } else {
             fwrite($this->fp, "\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_ID") . ">" . htmlspecialcharsbx($PROPERTY_MAP[$pid]) . "</" . GetMessage("IBLOCK_XML2_ID") . ">\n");
         }
         foreach ($arProp["VALUES"] as $arValue) {
             $value = $arValue["VALUE"];
             if (is_array($value) || strlen($value)) {
                 $bEmpty = false;
                 $bSerialized = false;
                 if ($this->bExtended) {
                     if ($arProp["PROPERTY_TYPE"] == "L") {
                         $value = CIBlockPropertyEnum::GetByID($arValue["VALUE_ENUM_ID"]);
                         $value = $value["XML_ID"];
                     } elseif ($arProp["PROPERTY_TYPE"] == "F") {
                         $value = $this->ExportFile($value);
                     } elseif ($arProp["PROPERTY_TYPE"] == "G") {
                         $value = $this->GetSectionXML_ID($arProp["LINK_IBLOCK_ID"], $value);
                     } elseif ($arProp["PROPERTY_TYPE"] == "E") {
                         $value = $this->GetElementXML_ID($arProp["LINK_IBLOCK_ID"], $value);
                     }
                     if (is_array($value) && $arProp["PROPERTY_TYPE"] !== "F") {
                         $bSerialized = true;
                         $value = serialize($value);
                     }
                 }
                 fwrite($this->fp, $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_VALUE"), $value));
                 if ($this->bExtended) {
                     fwrite($this->fp, "\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_PROPERTY_VALUE") . ">\n");
                     if ($bSerialized) {
                         fwrite($this->fp, "\t\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_SERIALIZED") . ">true</" . GetMessage("IBLOCK_XML2_SERIALIZED") . ">\n");
                     }
                     fwrite($this->fp, $this->formatXMLNode(7, GetMessage("IBLOCK_XML2_VALUE"), $value));
                     fwrite($this->fp, "\t\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_DESCRIPTION") . ">" . htmlspecialcharsbx($arValue["DESCRIPTION"]) . "</" . GetMessage("IBLOCK_XML2_DESCRIPTION") . ">\n");
                     fwrite($this->fp, "\t\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_PROPERTY_VALUE") . ">\n");
                 }
             }
         }
         if ($bEmpty) {
             fwrite($this->fp, "\t\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_VALUE") . "></" . GetMessage("IBLOCK_XML2_VALUE") . ">\n");
         }
         if ($this->next_step["catalog"] && !$this->bExtended) {
             fwrite($this->fp, "\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_ITEM_ATTRIBUTE") . ">\n");
         } else {
             fwrite($this->fp, "\t\t\t\t\t</" . GetMessage("IBLOCK_XML2_PROPERTY_VALUES") . ">\n");
         }
     }
 }
Пример #20
0
	public static function ConvertFromDB($arProperty, $value)
	{
		static $intTimeOffset = false;
		if (false === $intTimeOffset)
			$intTimeOffset = CTimeZone::GetOffset();

		if(strlen($value["VALUE"])>0)
		{
			if (0 != $intTimeOffset)
			{
				$value["VALUE"] = ConvertTimeStamp(MakeTimeStamp($value["VALUE"], 'YYYY-MM-DD HH:MI:SS') + $intTimeOffset, 'FULL');
			}
			else
			{
				$value["VALUE"] = CDatabase::FormatDate($value["VALUE"], "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL"));
			}
			$value["VALUE"] = str_replace(" 00:00:00", "", $value["VALUE"]);
		}
		return $value;
	}
Пример #21
0
 function nodeHandler(CDataXML $value)
 {
     $value = $value->GetArray();
     $value = $value[GetMessage("CC_BSC1_DOCUMENT")];
     if ($value["#"][GetMessage("CC_BSC1_OPERATION")][0]["#"] == GetMessage("CC_BSC1_ORDER")) {
         $orderId = IntVal($value["#"][GetMessage("CC_BSC1_NUMBER")][0]["#"]);
         $arOrder = array();
         $arItem = array();
         $arOrder["AMOUNT"] = $value["#"][GetMessage("CC_BSC1_SUMM")][0]["#"];
         $arOrder["AMOUNT"] = str_replace($SumFormat, ".", $arOrder["AMOUNT"]);
         $arOrder["COMMENT"] = $value["#"][GetMessage("CC_BSC1_COMMENT")][0]["#"];
         foreach ($value["#"][GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")] as $val) {
             $arOrder["TRAITS"][$val["#"][GetMessage("CC_BSC1_NAME")][0]["#"]] = $val["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
         }
         $taxValue = 0;
         $taxValueTmp = 0;
         $taxName = "";
         if (is_array($value["#"][GetMessage("CC_BSC1_ITEMS")][0]["#"][GetMessage("CC_BSC1_ITEM")])) {
             foreach ($value["#"][GetMessage("CC_BSC1_ITEMS")][0]["#"][GetMessage("CC_BSC1_ITEM")] as $val) {
                 $val = $val["#"];
                 $productID = $val[GetMessage("CC_BSC1_ID")][0]["#"];
                 $bGood = false;
                 $discountPrice = "";
                 $priceAll = str_replace($SumFormat, ".", $val[GetMessage("CC_BSC1_SUMM")][0]["#"]);
                 $priceone = str_replace($SumFormat, ".", $val[GetMessage("CC_BSC1_PRICE_PER_UNIT")][0]["#"]);
                 $quantity = str_replace($QuantityFormat, ".", $val[GetMessage("CC_BSC1_QUANTITY")][0]["#"]);
                 $price = $priceAll / $quantity;
                 if ($priceone != $price) {
                     $discountPrice = $priceone - $price;
                 }
                 //DISCOUNTS!
                 $arItem[$productID] = array("NAME" => $val[GetMessage("CC_BSC1_NAME")][0]["#"], "PRICE" => $price, "QUANTITY" => $quantity, "DISCOUNT_PRICE" => $discountPrice);
                 if (is_array($val[GetMessage("CC_BSC1_PROPS_ITEMS")][0]["#"][GetMessage("CC_BSC1_PROP_ITEM")])) {
                     foreach ($val[GetMessage("CC_BSC1_PROPS_ITEMS")][0]["#"][GetMessage("CC_BSC1_PROP_ITEM")] as $val1) {
                         $arItem[$productID]["ATTRIBUTES"][$val1["#"][GetMessage("CC_BSC1_NAME")][0]["#"]] = $val1["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
                     }
                 }
                 if (is_array($val[GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")])) {
                     foreach ($val[GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")] as $val1) {
                         if ($val1["#"][GetMessage("CC_BSC1_NAME")][0]["#"] == GetMessage("CC_BSC1_ITEM_TYPE")) {
                             $arItem[$productID]["TYPE"] = $val1["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
                         }
                     }
                 }
                 if (strlen($value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_NAME")][0]["#"]) > 0) {
                     $taxValueTmp = $val[GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_TAX_VALUE")][0]["#"];
                     $arItem[$productID]["VAT_RATE"] = $taxValueTmp / 100;
                     if (IntVal($taxValueTmp) > IntVal($taxValue)) {
                         $taxName = $val[GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_NAME")][0]["#"];
                         $taxValue = $taxValueTmp;
                     }
                 }
             }
         }
         if (IntVal($taxValue) > 0) {
             $price = str_replace($SumFormat, ".", $value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_SUMM")][0]["#"]);
             $arOrder["TAX"] = array("NAME" => $taxName, "VALUE" => $taxValue, "IS_IN_PRICE" => $value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_IN_PRICE")][0]["#"] == "true" ? "Y" : "N", "VALUE_MONEY" => $price);
         }
         $arOrder["items"] = $arItem;
         $v = $arOrder;
         if ($orderInfo = CSaleOrder::GetByID($orderId)) {
             if ($orderInfo["PAYED"] != "Y" && $orderInfo["ALLOW_DELIVERY"] != "Y" && $orderInfo["STATUS_ID"] != "F") {
                 $dbOrderTax = CSaleOrderTax::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE"));
                 $bTaxFound = false;
                 if ($arOrderTax = $dbOrderTax->Fetch()) {
                     $bTaxFound = true;
                     if (IntVal($arOrderTax["VALUE_MONEY"]) != IntVal($v["TAX"]["VALUE_MONEY"]) || IntVal($arOrderTax["VALUE"]) != IntVal($v["TAX"]["VALUE"]) || $arOrderTax["IS_IN_PRICE"] != $v["TAX"]["IS_IN_PRICE"]) {
                         if (IntVal($v["TAX"]["VALUE"]) > 0) {
                             $arFields = array("TAX_NAME" => $v["TAX"]["NAME"], "ORDER_ID" => $orderId, "VALUE" => $v["TAX"]["VALUE"], "IS_PERCENT" => "Y", "IS_IN_PRICE" => $v["TAX"]["IS_IN_PRICE"], "VALUE_MONEY" => $v["TAX"]["VALUE_MONEY"], "CODE" => "VAT1C", "APPLY_ORDER" => "100");
                             CSaleOrderTax::Update($arOrderTax["ID"], $arFields);
                             CSaleOrder::Update($orderId, array("TAX_VALUE" => $v["TAX"]["VALUE_MONEY"]));
                         } else {
                             CSaleOrderTax::Delete($arOrderTax["ID"]);
                             CSaleOrder::Update($orderId, array("TAX_VALUE" => 0));
                         }
                     }
                 }
                 if (!$bTaxFound) {
                     if (IntVal($v["TAX"]["VALUE"]) > 0) {
                         $arFields = array("TAX_NAME" => $v["TAX"]["NAME"], "ORDER_ID" => $orderId, "VALUE" => $v["TAX"]["VALUE"], "IS_PERCENT" => "Y", "IS_IN_PRICE" => $v["TAX"]["IS_IN_PRICE"], "VALUE_MONEY" => $v["TAX"]["VALUE_MONEY"]);
                         CSaleOrderTax::Add($arFields);
                         CSaleOrder::Update($orderId, array("TAX_VALUE" => $v["TAX"]["VALUE_MONEY"]));
                     }
                 }
                 $dbBasket = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $orderId));
                 $basketSum = 0;
                 while ($arBasket = $dbBasket->Fetch()) {
                     $arFields = array();
                     if (!empty($v["items"][$arBasket["PRODUCT_XML_ID"]])) {
                         if ($arBasket["QUANTITY"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["QUANTITY"]) {
                             $arFields["QUANTITY"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["QUANTITY"];
                         }
                         if ($arBasket["PRICE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["PRICE"]) {
                             $arFields["PRICE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["PRICE"];
                         }
                         if ($arBasket["VAT_RATE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["VAT_RATE"]) {
                             $arFields["VAT_RATE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["VAT_RATE"];
                         }
                         if ($arBasket["DISCOUNT_PRICE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["DISCOUNT_PRICE"]) {
                             $arFields["DISCOUNT_PRICE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["DISCOUNT_PRICE"];
                         }
                         if (count($arFields) > 0) {
                             CSaleBasket::Update($arBasket["ID"], $arFields);
                         }
                         $v["items"][$arBasket["PRODUCT_XML_ID"]]["CHECKED"] = "Y";
                     } else {
                         CSaleBasket::Delete($arBasket["ID"]);
                     }
                 }
                 foreach ($v["items"] as $itemID => $arItem) {
                     if ($arItem["CHECKED"] != "Y") {
                         if ($arItem["TYPE"] == GetMessage("CC_BSC1_ITEM")) {
                             CModule::IncludeModule("iblock");
                             $dbIBlockElement = CIBlockElement::GetList(array(), array("XML_ID" => $itemID, "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"), false, false, array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL"));
                             if ($arIBlockElement = $dbIBlockElement->GetNext()) {
                                 $dbIBlock = CIBlock::GetList(array(), array("ID" => $arIBlockElement["IBLOCK_ID"]));
                                 if ($arIBlock = $dbIBlock->Fetch()) {
                                     $arProps[] = array("NAME" => "Catalog XML_ID", "CODE" => "CATALOG.XML_ID", "VALUE" => $arIBlock["XML_ID"]);
                                 }
                                 $arProps[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $arIBlockElement["XML_ID"]);
                                 $arProduct = CCatalogProduct::GetByID($arIBlockElement["ID"]);
                                 $arFields = array("ORDER_ID" => $orderId, "PRODUCT_ID" => $arIBlockElement["ID"], "PRICE" => $arItem["PRICE"], "CURRENCY" => $orderInfo["CURRENCY"], "WEIGHT" => $arProduct["WEIGHT"], "QUANTITY" => $arItem["QUANTITY"], "LID" => $orderInfo["LID"], "DELAY" => "N", "CAN_BUY" => "Y", "NAME" => $arIBlockElement["~NAME"], "CALLBACK_FUNC" => "CatalogBasketCallback", "MODULE" => "catalog", "NOTES" => $arProduct["CATALOG_GROUP_NAME"], "ORDER_CALLBACK_FUNC" => "CatalogBasketOrderCallback", "CANCEL_CALLBACK_FUNC" => "CatalogBasketCancelCallback", "PAY_CALLBACK_FUNC" => "CatalogPayOrderCallback", "DETAIL_PAGE_URL" => $arIBlockElement["DETAIL_PAGE_URL"], "CATALOG_XML_ID" => $arIBlock["XML_ID"], "PRODUCT_XML_ID" => $arIBlockElement["XML_ID"], "IGNORE_CALLBACK_FUNC" => "Y", "VAT_RATE" => $arItem["VAT_RATE"]);
                                 CSaleBasket::Add($arFields);
                             } else {
                                 $this->strError .= "\n" . GetMessage("CC_BSC1_PRODUCT_NOT_FOUND") . $orderId . " - [" . $itemID . "] " . $arItem["NAME"];
                             }
                         } elseif ($arItem["TYPE"] == GetMessage("CC_BSC1_SERVICE")) {
                             if (IntVal($arItem["PRICE"]) != IntVal($orderInfo["PRICE_DELIVERY"])) {
                                 CSaleOrder::Update($orderId, array("PRICE_DELIVERY" => $arItem["PRICE"]));
                             }
                         }
                     }
                 }
                 $arOrderFields = array();
                 if ($v["AMOUNT"] != $orderInfo["PRICE"]) {
                     $arOrderFields = array("PRICE" => $v["AMOUNT"]);
                 }
                 if (DoubleVal($orderInfo["DISCOUNT_VALUE"]) > 0) {
                     $arOrderFields["DISCOUNT_VALUE"] = 0;
                 }
                 $arOrderFields["UPDATED_1C"] = "Y";
                 if (!empty($arOrderFields)) {
                     CSaleOrder::Update($orderId, $arOrderFields);
                 }
             } else {
                 $this->strError .= "\n" . GetMessage("CC_BSC1_FINAL_NOT_EDIT", array("#ID#" => $orderId));
             }
             $arAditFields = array();
             if ($v["TRAITS"][GetMessage("CC_BSC1_CANCELED")] == "true") {
                 if ($orderInfo["CANCELED"] == "N") {
                     CSaleOrder::CancelOrder($orderId, "Y", $v["COMMENT"]);
                 }
                 $arAditFields["UPDATED_1C"] = "Y";
             } else {
                 if ($orderInfo["CANCELED"] == "Y") {
                     CSaleOrder::CancelOrder($orderId, "N", $v["COMMENT"]);
                 }
                 $arAditFields["UPDATED_1C"] = "Y";
                 if (strlen($v["TRAITS"][GetMessage("CC_BSC1_1C_PAYED_DATE")]) > 1) {
                     if ($orderInfo["PAYED"] == "N") {
                         CSaleOrder::PayOrder($orderId, "Y");
                     }
                     $arAditFields["PAY_VOUCHER_DATE"] = CDatabase::FormatDate(str_replace("T", " ", $v["TRAITS"][GetMessage("CC_BSC1_1C_PAYED_DATE")]), "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL", LANG));
                     if (strlen($v["TRAITS"][GetMessage("CC_BSC1_1C_PAYED_NUM")]) > 0) {
                         $arAditFields["PAY_VOUCHER_NUM"] = $v["TRAITS"][GetMessage("CC_BSC1_1C_PAYED_NUM")];
                     }
                     $arAditFields["UPDATED_1C"] = "Y";
                 }
                 if (strlen($v["TRAITS"][GetMessage("CC_BSC1_1C_DELIVERY_DATE")]) > 1) {
                     if ($orderInfo["ALLOW_DELIVERY"] == "N") {
                         CSaleOrder::DeliverOrder($orderId, "Y");
                     }
                     $arAditFields["DATE_ALLOW_DELIVERY"] = CDatabase::FormatDate(str_replace("T", " ", $v["TRAITS"][GetMessage("CC_BSC1_1C_DELIVERY_DATE")]), "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL", LANG));
                     if (strlen($arParams["FINAL_STATUS_ON_DELIVERY"]) > 0 && $orderInfo["STATUS_ID"] != "F" && $orderInfo["STATUS_ID"] != $arParams["FINAL_STATUS_ON_DELIVERY"]) {
                         CSaleOrder::StatusOrder($orderId, $arParams["FINAL_STATUS_ON_DELIVERY"]);
                     }
                     $arAditFields["UPDATED_1C"] = "Y";
                 }
             }
             if (count($arAditFields) > 0) {
                 CSaleOrder::Update($orderId, $arAditFields);
             }
         } else {
             $this->strError .= "\n" . GetMessage("CC_BSC1_ORDER_NOT_FOUND", array("#ID#" => $orderId));
         }
     }
 }
Пример #22
0
function CatalogPayOrderCallback($productID, $userID, $bPaid, $orderID)
{
    global $DB;
    global $USER;
    $productID = intval($productID);
    $userID = intval($userID);
    $bPaid = $bPaid ? true : false;
    $orderID = intval($orderID);
    if ($userID <= 0) {
        return false;
    }
    $dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "N"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
    if ($arIBlockElement = $dbIBlockElement->GetNext()) {
        $arCatalog = CCatalog::GetByID($arIBlockElement["IBLOCK_ID"]);
        if ($arCatalog["SUBSCRIPTION"] == "Y") {
            $arProduct = CCatalogProduct::GetByID($productID);
            if ($bPaid) {
                if ('E' == CIBlock::GetArrayByID($arIBlockElement['IBLOCK_ID'], "RIGHTS_MODE")) {
                    $arUserRights = CIBlockElementRights::GetUserOperations($productID, $userID);
                    if (empty($arUserRights)) {
                        return false;
                    } elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
                        return false;
                    }
                } else {
                    if ('R' > CIBlock::GetPermission($arIBlockElement['IBLOCK_ID'], $userID)) {
                        return false;
                    }
                }
                $arUserGroups = array();
                $arTmp = array();
                $ind = -1;
                $curTime = time();
                $dbProductGroups = CCatalogProductGroups::GetList(array(), array("PRODUCT_ID" => $productID), false, false, array("GROUP_ID", "ACCESS_LENGTH", "ACCESS_LENGTH_TYPE"));
                while ($arProductGroups = $dbProductGroups->Fetch()) {
                    $ind++;
                    $arProductGroups['GROUP_ID'] = intval($arProductGroups['GROUP_ID']);
                    $accessType = $arProductGroups["ACCESS_LENGTH_TYPE"];
                    $accessLength = intval($arProductGroups["ACCESS_LENGTH"]);
                    $accessVal = 0;
                    if (0 < $accessLength) {
                        if ($accessType == CCatalogProduct::TIME_PERIOD_HOUR) {
                            $accessVal = mktime(date("H") + $accessLength, date("i"), date("s"), date("m"), date("d"), date("Y"));
                        } elseif ($accessType == CCatalogProduct::TIME_PERIOD_DAY) {
                            $accessVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + $accessLength, date("Y"));
                        } elseif ($accessType == CCatalogProduct::TIME_PERIOD_WEEK) {
                            $accessVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 7 * $accessLength, date("Y"));
                        } elseif ($accessType == CCatalogProduct::TIME_PERIOD_MONTH) {
                            $accessVal = mktime(date("H"), date("i"), date("s"), date("m") + $accessLength, date("d"), date("Y"));
                        } elseif ($accessType == CCatalogProduct::TIME_PERIOD_QUART) {
                            $accessVal = mktime(date("H"), date("i"), date("s"), date("m") + 3 * $accessLength, date("d"), date("Y"));
                        } elseif ($accessType == CCatalogProduct::TIME_PERIOD_SEMIYEAR) {
                            $accessVal = mktime(date("H"), date("i"), date("s"), date("m") + 6 * $accessLength, date("d"), date("Y"));
                        } elseif ($accessType == CCatalogProduct::TIME_PERIOD_YEAR) {
                            $accessVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") + $accessLength);
                        } elseif ($accessType == CCatalogProduct::TIME_PERIOD_DOUBLE_YEAR) {
                            $accessVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") + 2 * $accessLength);
                        }
                    }
                    $arUserGroups[$ind] = array("GROUP_ID" => $arProductGroups["GROUP_ID"], "DATE_ACTIVE_FROM" => date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID)), $curTime), "DATE_ACTIVE_TO" => 0 < $accessLength ? date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID)), $accessVal) : false);
                    $arTmp[$arProductGroups["GROUP_ID"]] = $ind;
                }
                if (!empty($arUserGroups)) {
                    $dbOldGroups = CUser::GetUserGroupEx($userID);
                    while ($arOldGroups = $dbOldGroups->Fetch()) {
                        $arOldGroups["GROUP_ID"] = intval($arOldGroups["GROUP_ID"]);
                        if (array_key_exists($arOldGroups["GROUP_ID"], $arTmp)) {
                            if (strlen($arOldGroups["DATE_ACTIVE_FROM"]) <= 0) {
                                $arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_FROM"] = false;
                            } else {
                                $oldDate = CDatabase::FormatDate($arOldGroups["DATE_ACTIVE_FROM"], CSite::GetDateFormat("SHORT", SITE_ID), "YYYYMMDDHHMISS");
                                $newDate = CDatabase::FormatDate($arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_FROM"], CSite::GetDateFormat("SHORT", SITE_ID), "YYYYMMDDHHMISS");
                                if ($oldDate > $newDate) {
                                    $arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_FROM"] = $arOldGroups["DATE_ACTIVE_FROM"];
                                }
                            }
                            if (strlen($arOldGroups["DATE_ACTIVE_TO"]) <= 0) {
                                $arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_TO"] = false;
                            } elseif (false !== $arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_TO"]) {
                                $oldDate = CDatabase::FormatDate($arOldGroups["DATE_ACTIVE_TO"], CSite::GetDateFormat("SHORT", SITE_ID), "YYYYMMDDHHMISS");
                                $newDate = CDatabase::FormatDate($arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_TO"], CSite::GetDateFormat("SHORT", SITE_ID), "YYYYMMDDHHMISS");
                                if ($oldDate > $newDate) {
                                    $arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_TO"] = $arOldGroups["DATE_ACTIVE_TO"];
                                }
                            }
                        } else {
                            $ind++;
                            $arUserGroups[$ind] = array("GROUP_ID" => $arOldGroups["GROUP_ID"], "DATE_ACTIVE_FROM" => $arOldGroups["DATE_ACTIVE_FROM"], "DATE_ACTIVE_TO" => $arOldGroups["DATE_ACTIVE_TO"]);
                        }
                    }
                    CUser::SetUserGroup($userID, $arUserGroups);
                    if (CCatalog::IsUserExists()) {
                        if (intval($USER->GetID()) == $userID) {
                            $arUserGroupsTmp = array();
                            foreach ($arUserGroups as &$arOneGroup) {
                                $arUserGroupsTmp[] = $arOneGroup["GROUP_ID"];
                            }
                            if (isset($arOneGroup)) {
                                unset($arOneGroup);
                            }
                            $USER->SetUserGroupArray($arUserGroupsTmp);
                        }
                    }
                }
            } else {
                $arUserGroups = array();
                $ind = -1;
                $arTmp = array();
                $dbOldGroups = CUser::GetUserGroupEx($userID);
                while ($arOldGroups = $dbOldGroups->Fetch()) {
                    $ind++;
                    $arOldGroups["GROUP_ID"] = intval($arOldGroups["GROUP_ID"]);
                    $arUserGroups[$ind] = array("GROUP_ID" => $arOldGroups["GROUP_ID"], "DATE_ACTIVE_FROM" => $arOldGroups["DATE_ACTIVE_FROM"], "DATE_ACTIVE_TO" => $arOldGroups["DATE_ACTIVE_FROM"]);
                    $arTmp[$arOldGroups["GROUP_ID"]] = $ind;
                }
                $bNeedUpdate = false;
                $dbProductGroups = CCatalogProductGroups::GetList(array(), array("PRODUCT_ID" => $productID), false, false, array("GROUP_ID"));
                while ($arProductGroups = $dbProductGroups->Fetch()) {
                    $arProductGroups["GROUP_ID"] = intval($arProductGroups["GROUP_ID"]);
                    if (array_key_exists($arProductGroups["GROUP_ID"], $arTmp)) {
                        unset($arUserGroups[$arProductGroups["GROUP_ID"]]);
                        $bNeedUpdate = true;
                    }
                }
                if ($bNeedUpdate) {
                    CUser::SetUserGroup($userID, $arUserGroups);
                    if (CCatalog::IsUserExists()) {
                        if (intval($USER->GetID()) == $userID) {
                            $arUserGroupsTmp = array();
                            foreach ($arUserGroups as &$arOneGroup) {
                                $arUserGroupsTmp[] = $arOneGroup["GROUP_ID"];
                            }
                            if (isset($arOneGroup)) {
                                unset($arOneGroup);
                            }
                            $USER->SetUserGroupArray($arUserGroupsTmp);
                        }
                    }
                }
            }
            if ($arProduct["PRICE_TYPE"] != "S") {
                if ($bPaid) {
                    $recurType = $arProduct["RECUR_SCHEME_TYPE"];
                    $recurLength = intval($arProduct["RECUR_SCHEME_LENGTH"]);
                    $recurSchemeVal = 0;
                    if ($recurType == CCatalogProduct::TIME_PERIOD_HOUR) {
                        $recurSchemeVal = mktime(date("H") + $recurLength, date("i"), date("s"), date("m"), date("d"), date("Y"));
                    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_DAY) {
                        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + $recurLength, date("Y"));
                    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_WEEK) {
                        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 7 * $recurLength, date("Y"));
                    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_MONTH) {
                        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m") + $recurLength, date("d"), date("Y"));
                    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_QUART) {
                        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m") + 3 * $recurLength, date("d"), date("Y"));
                    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_SEMIYEAR) {
                        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m") + 6 * $recurLength, date("d"), date("Y"));
                    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_YEAR) {
                        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") + $recurLength);
                    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_DOUBLE_YEAR) {
                        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") + 2 * $recurLength);
                    }
                    $arFields = array("USER_ID" => $userID, "MODULE" => "catalog", "PRODUCT_ID" => $productID, "PRODUCT_NAME" => $arIBlockElement["~NAME"], "PRODUCT_URL" => $arIBlockElement["~DETAIL_PAGE_URL"], "PRODUCT_PRICE_ID" => false, "PRICE_TYPE" => $arProduct["PRICE_TYPE"], "RECUR_SCHEME_TYPE" => $recurType, "RECUR_SCHEME_LENGTH" => $recurLength, "WITHOUT_ORDER" => $arProduct["WITHOUT_ORDER"], "PRICE" => false, "CURRENCY" => false, "CANCELED" => "N", "CANCELED_REASON" => false, "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider", "DESCRIPTION" => false, "PRIOR_DATE" => false, "NEXT_DATE" => Date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID)), $recurSchemeVal));
                    return $arFields;
                }
            }
        }
        return true;
    }
    return false;
}
Пример #23
0
	public static function InsertMainItems()
	{
		if(defined('BX_PUBLIC_MODE') && BX_PUBLIC_MODE == 1)
			return false;

		global $USER;

		if(!$USER->IsAuthorized())
			return false;

		//Updates
		if($USER->IsAdmin() || $USER->CanDoOperation('install_updates'))
		{
			$update_res = UpdateTools::GetUpdateResult();

			$updAIParams = array(
				"TITLE" => GetMessage("top_panel_ai_updates"),
				"COLOR" => 'gray',
				"SORT" => 12
			);

			//update_autocheck == true and we have something to show
			if ($update_res['result'] === true && $update_res['tooltip'])
			{
				$updAIParams["HTML"] = $update_res['tooltip'];
				$updAIParams["FOOTER"] = '<a href="/bitrix/admin/update_system.php?lang='.LANGUAGE_ID.'">'.GetMessage("top_panel_ai_upd_instl").'</a>';
				$updAIParams["ALERT"] = true;
			}
			else if ($update_res['error'] <> '') // update error
			{
				$updAIParams["TITLE"] .= " - ".GetMessage("top_panel_ai_title_err");
				$updAIParams["HTML"] = trim(self::CutErrorId($update_res['error']));
				$updAIParams["FOOTER"] = '<a href="/bitrix/admin/update_system.php?refresh=Y&lang='.LANGUAGE_ID.'">'.GetMessage("top_panel_ai_upd_chk").'</a>';
				$updAIParams["ALERT"] = true;
			}
			else // update_autocheck == false
			{
				//last update date time
				$updateDate = COption::GetOptionString("main", "update_system_update", false);
				// remove seconds
				$updateDate = $updateDate ? CDatabase::FormatDate($updateDate, "DD.MM.YYYY HH:MI:SS", "DD.MM.YYYY HH:MI") : false;

				$updAIParams["HTML"] = '<span class="adm-informer-strong-text">'.GetMessage("top_panel_ai_sys_ver").' '.SM_VERSION."</span><br>";
				$updAIParams["HTML"] .= $updateDate ? GetMessage("top_panel_ai_upd_last").'<br>'.$updateDate : GetMessage("top_panel_ai_upd_never");
				$updAIParams["FOOTER"] = '<a href="/bitrix/admin/update_system.php?refresh=Y&lang='.LANGUAGE_ID.'">'.GetMessage("top_panel_ai_upd_chk").'</a>';
				$updAIParams["ALERT"] = false;
			}

			self::AddItem($updAIParams);
		}

		//Disk space (quota)
		$maxQuota = COption::GetOptionInt("main", "disk_space", 0)*1048576;
		if ($maxQuota > 0)
		{
			$quota = new CDiskQuota();
			$free = $quota->GetDiskQuota();
			$freeMB = CFile::FormatSize($free,1);
			$free = round($free/($maxQuota)*100);

			$qAIParams = array(
				"TITLE" => GetMessage("top_panel_ai_used_space"),
				"COLOR" => "green",
				"ALERT" => ($free < 10 ? true : false)
				);

			$qAIParams["HTML"] = '
	<div class="adm-informer-item-section">
		<span class="adm-informer-item-l"><span class="adm-informer-strong-text">'.GetMessage("top_panel_ai_in_all").'</span> '.CFile::FormatSize($maxQuota,1).'</span>
		<span class="adm-informer-item-r"><span class="adm-informer-strong-text">'.GetMessage("top_panel_ai_in_aviable").'</span> '.$freeMB.'</span>
	</div>
	<div class="adm-informer-status-bar-block" >
		<div class="adm-informer-status-bar-indicator" style="width:'.(100-$free).'%; "></div>
		<div class="adm-informer-status-bar-text">'.(100-$free).'%</div>
	</div>
	<div class="adm-informer-item-section"><span class="adm-informer-strong-text">'.GetMessage("top_panel_ai_in_recomend").'</span> '.GetMessage("top_panel_ai_in_no").'</div>';

			self::AddItem($qAIParams);
		}

		if($USER->IsAdmin() && in_array(LANGUAGE_ID, array("ru", "ua")))
		{
			$cModules = COption::GetOptionString("main", "mp_modules_date", "");
			$arModules = array();
			if(strlen($cModules) > 0)
				$arModules = unserialize($cModules);

			$mCnt = count($arModules);
			if($mCnt > 0)
			{
				foreach($arModules as $id => $module)
				{
					if(isModuleInstalled($module["ID"]))
					{
						if($module["TMS"]+3600*24*14 < time())
						{
							$script = "
							<script type=\"text/javascript\">
							function hideMpAnswer(el, module)
							{
								if(el.parentNode.parentNode.parentNode)
									BX.hide(el.parentNode.parentNode.parentNode);
									BX.ajax({
										'method': 'POST',
										'dataType': 'html',
										'url': '/bitrix/admin/partner_modules.php',
										'data': 'module='+module+'&".bitrix_sessid_get()."&act=unnotify',
										'async': true,
										'processData': false

									});
							}
							</script>";
							
							$arParams = array(
									'TITLE' => GetMessage("top_panel_ai_marketplace"),
									'COLOR' => 'green',
									'FOOTER' => "<a href=\"javascript:void(0)\" onclick=\"hideMpAnswer(this, '".CUtil::JSEscape($module["ID"])."')\" style=\"float: right !important; font-size: 0.8em !important;\">".GetMessage("top_panel_ai_marketplace_hide")."</a><a href=\"http://marketplace.1c-bitrix.".LANGUAGE_ID."/solutions/#ID#/#comments\" target=\"_blank\" onclick=\"hideMpAnswer(this, '".CUtil::JSEscape($module["ID"])."')\">".GetMessage("top_panel_ai_marketplace_add")."</a>",
									GetMessage("top_panel_ai_marketplace_link", array("#ID#" => $module["ID"], "#ADIT#" => "")),
									'ALERT' => true,
									'HTML' => GetMessage("top_panel_ai_marketplace_descr", array("#NAME#" => $module["NAME"], "#ID#" => $module["ID"])).$script,
								);
							self::AddItem($arParams);
						}
					}
					else
						unset($arModules[$id]);
				}
				if($mCnt != count($arModules))
				{
					COption::SetOptionString("main", "mp_modules_date", serialize($arModules));
				}
			}

		}

		foreach(GetModuleEvents("main", "OnAdminInformerInsertItems", true) as $arHandler)
			ExecuteModuleEventEx($arHandler);

		return count(self::$items);
	}
Пример #24
0
    public static function InsertMainItems()
    {
        if (defined('BX_PUBLIC_MODE') && BX_PUBLIC_MODE == 1) {
            return false;
        }
        global $USER;
        if (!$USER->IsAuthorized()) {
            return false;
        }
        //Updates
        if ($USER->IsAdmin() || $USER->CanDoOperation('install_updates')) {
            $update_res = UpdateTools::GetUpdateResult();
            $updAIParams = array("TITLE" => GetMessage("top_panel_ai_updates"), "COLOR" => 'gray', "SORT" => 12);
            //update_autocheck == true and we have something to show
            if ($update_res['result'] === true && $update_res['tooltip']) {
                $updAIParams["HTML"] = $update_res['tooltip'];
                $updAIParams["FOOTER"] = '<a href="/bitrix/admin/update_system.php?lang=' . LANGUAGE_ID . '">' . GetMessage("top_panel_ai_upd_instl") . '</a>';
                $updAIParams["ALERT"] = true;
            } else {
                if ($update_res['error'] != '') {
                    $updAIParams["TITLE"] .= " - " . GetMessage("top_panel_ai_title_err");
                    $updAIParams["HTML"] = trim(self::CutErrorId($update_res['error']));
                    $updAIParams["FOOTER"] = '<a href="/bitrix/admin/update_system.php?refresh=Y&lang=' . LANGUAGE_ID . '">' . GetMessage("top_panel_ai_upd_chk") . '</a>';
                    $updAIParams["ALERT"] = true;
                } else {
                    //last update date time
                    $updateDate = COption::GetOptionString("main", "update_system_update", false);
                    // remove seconds
                    $updateDate = $updateDate ? CDatabase::FormatDate($updateDate, "DD.MM.YYYY HH:MI:SS", "DD.MM.YYYY HH:MI") : false;
                    $updAIParams["HTML"] = '<span class="adm-informer-strong-text">' . GetMessage("top_panel_ai_sys_ver") . ' ' . SM_VERSION . "</span><br>";
                    $updAIParams["HTML"] .= $updateDate ? GetMessage("top_panel_ai_upd_last") . '<br>' . $updateDate : GetMessage("top_panel_ai_upd_never");
                    $updAIParams["FOOTER"] = '<a href="/bitrix/admin/update_system.php?refresh=Y&lang=' . LANGUAGE_ID . '">' . GetMessage("top_panel_ai_upd_chk") . '</a>';
                    $updAIParams["ALERT"] = false;
                }
            }
            self::AddItem($updAIParams);
        }
        //Disk space (quota)
        $maxQuota = COption::GetOptionInt("main", "disk_space", 0) * 1048576;
        if ($maxQuota > 0) {
            $quota = new CDiskQuota();
            $free = $quota->GetDiskQuota();
            $freeMB = CFile::FormatSize($free, 1);
            $free = round($free / $maxQuota * 100);
            $qAIParams = array("TITLE" => GetMessage("top_panel_ai_used_space"), "COLOR" => "green", "ALERT" => $free < 10 ? true : false);
            $qAIParams["HTML"] = '
	<div class="adm-informer-item-section">
		<span class="adm-informer-item-l"><span class="adm-informer-strong-text">' . GetMessage("top_panel_ai_in_all") . '</span> ' . CFile::FormatSize($maxQuota, 1) . '</span>
		<span class="adm-informer-item-r"><span class="adm-informer-strong-text">' . GetMessage("top_panel_ai_in_aviable") . '</span> ' . $freeMB . '</span>
	</div>
	<div class="adm-informer-status-bar-block" >
		<div class="adm-informer-status-bar-indicator" style="width:' . (100 - $free) . '%; "></div>
		<div class="adm-informer-status-bar-text">' . (100 - $free) . '%</div>
	</div>
	<div class="adm-informer-item-section"><span class="adm-informer-strong-text">' . GetMessage("top_panel_ai_in_recomend") . '</span> ' . GetMessage("top_panel_ai_in_no") . '</div>';
            self::AddItem($qAIParams);
        }
        $rsHandlers = GetModuleEvents("main", "OnAdminInformerInsertItems");
        while ($arHandler = $rsHandlers->Fetch()) {
            ExecuteModuleEventEx($arHandler);
        }
        return count(self::$items);
    }
Пример #25
0
 public static function CharToDateFunction($strValue, $strType = "FULL", $lang = false)
 {
     $sFieldExpr = "'" . CDatabase::FormatDate($strValue, CLang::GetDateFormat($strType, $lang), $strType == "SHORT" ? "Y-M-D" : "Y-M-D H:I:S") . "'";
     //time zone
     if ($strType == "FULL" && CTimeZone::Enabled()) {
         static $diff = false;
         if ($diff === false) {
             $diff = CTimeZone::GetOffset();
         }
         if ($diff != 0) {
             $sFieldExpr = "DATE_ADD(" . $sFieldExpr . ", INTERVAL -(" . $diff . ") SECOND)";
         }
     }
     return $sFieldExpr;
 }
Пример #26
0
	function nodeHandler(CDataXML $value)
	{
		$value = $value->GetArray();

		if(!empty($value[GetMessage("CC_BSC1_DOCUMENT")]))
		{
			$value = $value[GetMessage("CC_BSC1_DOCUMENT")];

			$arOrder = $this->collectOrderInfo($value);

			if(!empty($arOrder))
			{
				if(strlen($arOrder["ID"]) <= 0 && strlen($arOrder["ID_1C"]) > 0)//try to search order from 1C
				{
					$dbOrder = CSaleOrder::GetList(array("ID" => "DESC"), array("ID_1C" => $arOrder["ID_1C"]), false, false, array("ID", "ID_1C"));
					if($orderInfo = $dbOrder->Fetch())
					{
						$arOrder["ID"] = $orderInfo["ID"];
					}
				}
				if(strlen($arOrder["ID"]) > 0) // exists site order
				{
					$dbOrder = CSaleOrder::GetList(array(), array("ACCOUNT_NUMBER" => $arOrder["ID"]), false, false, array("ID", "LID", "PERSON_TYPE_ID", "PAYED", "DATE_PAYED", "CANCELED", "DATE_CANCELED", "REASON_CANCELED", "STATUS_ID", "DATE_STATUS", "PAY_VOUCHER_NUM", "PAY_VOUCHER_DATE", "PRICE_DELIVERY", "ALLOW_DELIVERY", "DATE_ALLOW_DELIVERY", "PRICE", "CURRENCY", "DISCOUNT_VALUE", "USER_ID", "PAY_SYSTEM_ID", "DELIVERY_ID", "DATE_INSERT", "DATE_INSERT_FORMAT", "DATE_UPDATE", "USER_DESCRIPTION", "ADDITIONAL_INFO", "COMMENTS", "TAX_VALUE", "DELIVERY_DOC_NUM", "DELIVERY_DOC_DATE", "STORE_ID", "ACCOUNT_NUMBER", "VERSION", "VERSION_1C", "ID_1C"));
					if($orderInfo = $dbOrder->Fetch())
					{
						if($arOrder["VERSION_1C"] != $orderInfo["VERSION_1C"] || (strlen($orderInfo["VERSION_1C"]) <= 0 || strlen($arOrder["VERSION_1C"]) <= 0)) // skip update if the same version
						{
							$arOrderFields = array();
							$orderId = $orderInfo["ID"];
							CSaleOrderChange::AddRecord($orderId, "ORDER_1C_IMPORT");
							if($arOrder["ID_1C"] != $orderInfo["ID_1C"])
								$arOrderFields["ID_1C"] = $arOrder["ID_1C"];
							$arOrderFields["VERSION_1C"] = $arOrder["VERSION_1C"];

							if($orderInfo["PAYED"] != "Y" && $orderInfo["ALLOW_DELIVERY"] != "Y" && $orderInfo["STATUS_ID"] != "F")
							{
								$dbOrderTax = CSaleOrderTax::GetList(
									array(),
									array("ORDER_ID" => $orderId),
									false,
									false,
									array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE")
								);
								$bTaxFound = false;
								if($arOrderTax = $dbOrderTax->Fetch())
								{
									$bTaxFound = true;
									if(IntVal($arOrderTax["VALUE_MONEY"]) != IntVal($arOrder["TAX"]["VALUE_MONEY"]) || IntVal($arOrderTax["VALUE"]) != IntVal($arOrder["TAX"]["VALUE"]) || ($arOrderTax["IS_IN_PRICE"] != $arOrder["TAX"]["IS_IN_PRICE"]))
									{
										if(IntVal($arOrder["TAX"]["VALUE"])>0)
										{
											$arFields = Array(
												"TAX_NAME" => $arOrder["TAX"]["NAME"],
												"ORDER_ID" => $orderId,
												"VALUE" => $arOrder["TAX"]["VALUE"],
												"IS_PERCENT" => "Y",
												"IS_IN_PRICE" => $arOrder["TAX"]["IS_IN_PRICE"],
												"VALUE_MONEY" => $arOrder["TAX"]["VALUE_MONEY"],
												"CODE" => "VAT1C",
												"APPLY_ORDER" => "100"
											);
											CSaleOrderTax::Update($arOrderTax["ID"], $arFields);
											$arOrderFields["TAX_VALUE"] = $arOrder["TAX"]["VALUE_MONEY"];
										}
										else
										{
											CSaleOrderTax::Delete($arOrderTax["ID"]);
											$arOrderFields["TAX_VALUE"] = 0;
										}
									}
								}

								if(!$bTaxFound)
								{
									if(IntVal($arOrder["TAX"]["VALUE"])>0)
									{
										$arFields = Array(
											"TAX_NAME" => $arOrder["TAX"]["NAME"],
											"ORDER_ID" => $orderId,
											"VALUE" => $arOrder["TAX"]["VALUE"],
											"IS_PERCENT" => "Y",
											"IS_IN_PRICE" => $arOrder["TAX"]["IS_IN_PRICE"],
											"VALUE_MONEY" => $arOrder["TAX"]["VALUE_MONEY"]
										);
										CSaleOrderTax::Add($arFields);
										$arOrderFields["TAX_VALUE"] = $arOrder["TAX"]["VALUE_MONEY"];
									}
								}

								$arShoppingCart = array();
								$bNeedUpdate = false;
								$dbBasket = CSaleBasket::GetList(
									array("NAME" => "ASC"),
									array("ORDER_ID" => $orderId),
									false,
									false,
									array(
										"ID",
										"QUANTITY",
										"CANCEL_CALLBACK_FUNC",
										"MODULE",
										"PRODUCT_ID",
										"PRODUCT_PROVIDER_CLASS",
										"RESERVED",
										"RESERVE_QUANTITY",
										"TYPE",
										"SET_PARENT_ID",
										"PRICE",
										"VAT_RATE",
										"DISCOUNT_PRICE",
										"PRODUCT_XML_ID",
									)
								);

								while ($arBasket = $dbBasket->Fetch())
								{
									$arFields = Array();
									if(!empty($arOrder["items"][$arBasket["PRODUCT_XML_ID"]]))
									{
										if($arBasket["QUANTITY"] != $arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["QUANTITY"])
											$arFields["QUANTITY"] = $arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["QUANTITY"];
										if($arBasket["PRICE"] != $arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["PRICE"])
											$arFields["PRICE"] = $arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["PRICE"];
										if($arBasket["VAT_RATE"] != $arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["VAT_RATE"])
											$arFields["VAT_RATE"] = $arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["VAT_RATE"];
										if($arBasket["DISCOUNT_PRICE"] != $arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["DISCOUNT_PRICE"])
											$arFields["DISCOUNT_PRICE"] = $arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["DISCOUNT_PRICE"];

										if(count($arFields)>0)
										{
											$arFields["ID"] = $arBasket["ID"];
											if(DoubleVal($arFields["QUANTITY"]) <= 0)
												$arFields["QUANTITY"] = $arBasket["QUANTITY"];
											$bNeedUpdate = true;
											$arShoppingCart[] = $arFields;
										}
										else
										{
											$arShoppingCart[] = $arBasket;
										}
										//CSaleBasket::Update($arBasket["ID"], $arFields);

										$arOrder["items"][$arBasket["PRODUCT_XML_ID"]]["CHECKED"] = "Y";
									}
									else
									{
										if($arOrder["TRAITS"][GetMessage("CC_BSC1_CANCELED")] != "true" && $orderInfo["CANCELED"] == "N")
										{
											$bNeedUpdate = true;
											//CSaleBasket::Delete($arBasket["ID"]);
										}
									}
								}

								if(!empty($arOrder["items"]))
								{
									foreach ($arOrder["items"] as $itemID => $arItem)
									{
										if ($arItem["CHECKED"] != "Y")
										{
											if ($arItem["TYPE"] == GetMessage("CC_BSC1_ITEM"))
											{
												if ($arBasketFields = $this->prepareProduct4Basket($itemID, $arItem, $orderId, $orderInfo))
												{
													$arShoppingCart[] = $arBasketFields;
													$bNeedUpdate = true;
												}
											}
											elseif ($arItem["TYPE"] == GetMessage("CC_BSC1_SERVICE"))
											{
												if (IntVal($arItem["PRICE"]) != IntVal($orderInfo["PRICE_DELIVERY"]))
													$arOrderFields["PRICE_DELIVERY"] = $arItem["PRICE"];
											}
										}
									}
								}

								if($bNeedUpdate)
								{
									$arErrors = array();
									CSaleBasket::DoSaveOrderBasket($orderId, $orderInfo["LID"], $orderInfo["USER_ID"], $arShoppingCart, $arErrors);
								}

								if(DoubleVal($arOrder["AMOUNT"]) > 0 && $arOrder["AMOUNT"] != $orderInfo["PRICE"])
									$arOrderFields["PRICE"] = $arOrder["AMOUNT"];
								if(DoubleVal($orderInfo["DISCOUNT_VALUE"]) > 0)
									$arOrderFields["DISCOUNT_VALUE"] = 0;
								if(strlen($arOrder["COMMENT"]) > 0 && $arOrder["COMMENT"] != $orderInfo["COMMENTS"])
									$arOrderFields["COMMENTS"] = $arOrder["COMMENT"];
								$arOrderFields["UPDATED_1C"] = "Y";
								if(!empty($arOrderFields))
									CSaleOrder::Update($orderId, $arOrderFields);
							}
							else
							{
								$this->strError .= "\n".GetMessage("CC_BSC1_FINAL_NOT_EDIT", Array("#ID#" => $orderId));
							}
						}

						$arAditFields = Array();
						if($arOrder["TRAITS"][GetMessage("CC_BSC1_CANCELED")] == "true")
						{
							if($orderInfo["CANCELED"] == "N")
								CSaleOrder::CancelOrder($orderInfo["ID"], "Y", $arOrder["COMMENT"]);
							$arAditFields["UPDATED_1C"] = "Y";
						}
						else
						{
							if(strlen($arOrder["TRAITS"][GetMessage("CC_BSC1_1C_PAYED_DATE")])>1)
							{
								if($orderInfo["PAYED"]=="N")
									CSaleOrder::PayOrder($orderInfo["ID"], "Y");
								$arAditFields["PAY_VOUCHER_DATE"] = CDatabase::FormatDate(str_replace("T", " ", $arOrder["TRAITS"][GetMessage("CC_BSC1_1C_PAYED_DATE")]), "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL", LANG));
								if(strlen($arOrder["TRAITS"][GetMessage("CC_BSC1_1C_PAYED_NUM")])>0)
									$arAditFields["PAY_VOUCHER_NUM"] = $arOrder["TRAITS"][GetMessage("CC_BSC1_1C_PAYED_NUM")];
								$arAditFields["UPDATED_1C"] = "Y";
							}

							if(strlen($arOrder["TRAITS"][GetMessage("CC_BSC1_1C_DELIVERY_DATE")])>1)
							{
								if($orderInfo["ALLOW_DELIVERY"]=="N")
									CSaleOrder::DeliverOrder($orderInfo["ID"], "Y");
								$arAditFields["DATE_ALLOW_DELIVERY"] = CDatabase::FormatDate(str_replace("T", " ", $arOrder["TRAITS"][GetMessage("CC_BSC1_1C_DELIVERY_DATE")]), "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL", LANG));
								if(strlen($this->arParams["FINAL_STATUS_ON_DELIVERY"])>0 && $orderInfo["STATUS_ID"] != "F" && $orderInfo["STATUS_ID"] != $this->arParams["FINAL_STATUS_ON_DELIVERY"])
									CSaleOrder::StatusOrder($orderInfo["ID"], $this->arParams["FINAL_STATUS_ON_DELIVERY"]);
								$arAditFields["UPDATED_1C"] = "Y";
							}
						}

						if(count($arAditFields)>0)
							CSaleOrder::Update($orderInfo["ID"], $arAditFields);
					}
					else
						$this->strError .= "\n".GetMessage("CC_BSC1_ORDER_NOT_FOUND", Array("#ID#" => $arOrder["ID"]));
				}
				elseif($this->arParams["IMPORT_NEW_ORDERS"] == "Y") // create new order (ofline 1C)
				{
					if(!empty($arOrder["AGENT"]) && strlen($arOrder["AGENT"]["ID"]) > 0)
					{
						$arOrder["PERSON_TYPE_ID"] = 0;
						$arOrder["USER_ID"] = 0;
						$arErrors = array();
						$dbUProp = CSaleOrderUserProps::GetList(array(), array("XML_ID" => $arOrder["AGENT"]["ID"]), false, false, array("ID", "NAME", "USER_ID", "PERSON_TYPE_ID", "XML_ID", "VERSION_1C"));
						if($arUProp = $dbUProp->Fetch())
						{
							$arOrder["USER_ID"] = $arUProp["USER_ID"];
							$arOrder["PERSON_TYPE_ID"] = $arUProp["PERSON_TYPE_ID"];
							$arOrder["USER_PROFILE_ID"] = $arUProp["ID"];
							$arOrder["USER_PROFILE_VERSION"] = $arUProp["VERSION_1C"];

							$dbUPropValue = CSaleOrderUserPropsValue::GetList(array(), array("USER_PROPS_ID" => $arUProp["ID"]));
							while($arUPropValue = $dbUPropValue->Fetch())
							{
								$arOrder["USER_PROPS"][$arUPropValue["ORDER_PROPS_ID"]] = $arUPropValue["VALUE"];
							}
						}
						else
						{
							if(strlen($arOrder["AGENT"]["ID"]) > 0)
							{
								$arAI = explode("#", $arOrder["AGENT"]["ID"]);
								if(IntVal($arAI[0]) > 0)
								{
									$dbUser = CUser::GetByID($arAI[0]);
									if($arU = $dbUser->Fetch())
									{
										if(htmlspecialcharsback(substr(htmlspecialcharsbx($arU["ID"]."#".$arU["LOGIN"]."#".$arU["LAST_NAME"]." ".$arU["NAME"]." ".$arU["SECOND_NAME"]), 0, 80)) == $arOrder["AGENT"]["ID"])
										{
											$arOrder["USER_ID"] = $arU["ID"];
										}
									}
								}
							}

							if(IntVal($arOrder["USER_ID"]) <= 0)
							{
								//create new user
								$arUser = array(
									"NAME"  => $arOrder["AGENT"]["ITEM_NAME"],
									"EMAIL" => $arOrder["AGENT"]["CONTACT"]["MAIL_NEW"],
								);

								if (strlen($arUser["NAME"]) <= 0)
									$arUser["NAME"] = $arOrder["AGENT"]["CONTACT"]["CONTACT_PERSON"];
								if (strlen($arUser["EMAIL"]) <= 0)
									$arUser["EMAIL"] = "buyer".time().GetRandomCode(2)."@".$_SERVER["SERVER_NAME"];
								$arOrder["USER_ID"] = CSaleUser::DoAutoRegisterUser($arUser["EMAIL"], $arUser["NAME"], $this->arParams["SITE_NEW_ORDERS"], $arErrors);
							}
						}

						if(empty($this->arPersonTypesIDs))
						{
							$dbPT = CSalePersonType::GetList(array(), array("ACTIVE" => "Y", "LIDS" => $this->arParams["SITE_NEW_ORDERS"]));
							while($arPT = $dbPT->Fetch())
							{
								$this->arPersonTypesIDs[] = $arPT["ID"];
							}
						}

						if(empty($this->arExportInfo))
						{
							$dbExport = CSaleExport::GetList(array(), array("PERSON_TYPE_ID" => $this->arPersonTypesIDs));
							while($arExport = $dbExport->Fetch())
							{
								$this->arExportInfo[$arExport["PERSON_TYPE_ID"]] = unserialize($arExport["VARS"]);
							}
						}

						if(IntVal($arOrder["PERSON_TYPE_ID"]) <= 0)
						{
							foreach($this->arExportInfo as $pt => $value)
							{
								if(
									(($value["IS_FIZ"] == "Y" && $arOrder["AGENT"]["TYPE"] == "FIZ")
									|| ($value["IS_FIZ"] == "N" && $arOrder["AGENT"]["TYPE"] != "FIZ"))
									)
									$arOrder["PERSON_TYPE_ID"] = $pt;
							}
						}

						if(IntVal($arOrder["PERSON_TYPE_ID"]) > 0)
						{
							$arAgent = $this->arExportInfo[$arOrder["PERSON_TYPE_ID"]];
							foreach($arAgent as $k => $v)
							{
								if((strlen($v["VALUE"]) <= 0 || $v["TYPE"] != "PROPERTY") && (empty($arOrder["USER_PROPS"]) || empty($arOrder["USER_PROPS"][$v["VALUE"]])))
									unset($arAgent[$k]);
							}

							if(IntVal($arOrder["USER_ID"]) > 0)
							{
								$orderFields = array(
									"SITE_ID" => $this->arParams["SITE_NEW_ORDERS"],
									"PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"],
									"PAYED" => "N",
									"CANCELED" => "N",
									"STATUS_ID" => "N",
									"PRICE" => $arOrder["AMOUNT"],
									"CURRENCY" => CSaleLang::GetLangCurrency($this->arParams["SITE_NEW_ORDERS"]),
									"USER_ID" => $arOrder["USER_ID"],
									"TAX_VALUE" => doubleval($arOrder["TAX"]["VALUE_MONEY"]),
									"COMMENTS" => $arOrder["COMMENT"],
									"BASKET_ITEMS" => array(),
									"TAX_LIST" => array(),
									"ORDER_PROP" => array(),
								);
								$arAditFields = array(
									"EXTERNAL_ORDER" => "Y",
									"ID_1C" => $arOrder["ID_1C"],
									"VERSION_1C" => $arOrder["VERSION_1C"],
									"UPDATED_1C" => "Y",
									"DATE_INSERT" => CDatabase::FormatDate($arOrder["DATE"]." ".$arOrder["TIME"], "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL", LANG)),
								);

								foreach($arOrder["items"] as $productID => $val)
								{
									$orderFields["BASKET_ITEMS"][] = $this->prepareProduct4Basket($productID, $val, false, $orderFields);
								}

								if(!empty($arOrder["TAX"]))
								{
									$orderFields["TAX_LIST"][] = array(
										"NAME" => $arOrder["TAX"]["NAME"],
										"IS_PERCENT" => "Y",
										"VALUE" => $arOrder["TAX"]["VALUE"],
										"VALUE_MONEY" => $arOrder["TAX"]["VALUE_MONEY"],
										"IS_IN_PRICE" => $arOrder["TAX"]["IS_IN_PRICE"],
									);
								}

								foreach($arAgent as $k => $v)
								{
									if(!empty($arOrder["ORDER_PROPS"][$k]))
									{
										$orderFields["ORDER_PROP"][$v["VALUE"]] = $arOrder["ORDER_PROPS"][$k];
									}
									if(empty($orderFields["ORDER_PROP"][$v["VALUE"]]) && !empty($arOrder["USER_PROPS"][$v["VALUE"]]))
									{
										$orderFields["ORDER_PROP"][$v["VALUE"]] = $arOrder["USER_PROPS"][$v["VALUE"]];
									}
								}

								if($arOrder["ID"] = CSaleOrder::DoSaveOrder($orderFields, $arAditFields, 0, $arErrors))
								{
									$arAditFields = array("UPDATED_1C" => "Y");
									CSaleOrder::Update($arOrder["ID"], $arAditFields);

									//add/update user profile
									if(IntVal($arOrder["USER_PROFILE_ID"]) > 0)
									{
										if($arOrder["USER_PROFILE_VERSION"] != $arOrder["AGENT"]["VERSION"])
											CSaleOrderUserProps::Update($arOrder["USER_PROFILE_ID"], array("VERSION_1C" => $arOrder["AGENT"]["VERSION"], "NAME" => $arOrder["AGENT"]["AGENT_NAME"]));
										$dbUPV = CSaleOrderUserPropsValue::GetList(array(), array("USER_PROPS_ID" =>$arOrder["USER_PROFILE_ID"]));
										while($arUPV = $dbUPV->Fetch())
										{
											$arOrder["AGENT"]["PROFILE_PROPS_VALUE"][$arUPV["ORDER_PROPS_ID"]] = array("ID" => $arUPV["ID"], "VALUE" => $arUPV["VALUE"]);
										}
									}

									if(IntVal($arOrder["USER_PROFILE_ID"]) <= 0 || (IntVal($arOrder["USER_PROFILE_ID"]) > 0 && $arOrder["USER_PROFILE_VERSION"] != $arOrder["AGENT"]["VERSION"]))
									{
										$dbOrderProperties = CSaleOrderProps::GetList(
											array("SORT" => "ASC"),
											array(
												"PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"],
												"ACTIVE" => "Y",
												"UTIL" => "N",
												"USER_PROPS" => "Y",
											),
											false,
											false,
											array("ID", "TYPE", "NAME", "CODE", "USER_PROPS", "SORT", "MULTIPLE")
										);
										while ($arOrderProperties = $dbOrderProperties->Fetch())
										{
											$curVal = $orderFields["ORDER_PROP"][$arOrderProperties["ID"]];

											if (strlen($curVal) > 0)
											{
												if (IntVal($arOrder["USER_PROFILE_ID"]) <= 0)
												{
													$arFields = array(
														"NAME" => $arOrder["AGENT"]["AGENT_NAME"],
														"USER_ID" => $arOrder["USER_ID"],
														"PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"],
														"XML_ID" => $arOrder["AGENT"]["ID"],
														"VERSION_1C" => $arOrder["AGENT"]["VERSION"],
													);
													$arOrder["USER_PROFILE_ID"] = CSaleOrderUserProps::Add($arFields);
												}
												if(IntVal($arOrder["USER_PROFILE_ID"]) > 0)
												{
													$arFields = array(
														"USER_PROPS_ID" => $arOrder["USER_PROFILE_ID"],
														"ORDER_PROPS_ID" => $arOrderProperties["ID"],
														"NAME" => $arOrderProperties["NAME"],
														"VALUE" => $curVal
													);
													if(empty($arOrder["AGENT"]["PROFILE_PROPS_VALUE"][$arOrderProperties["ID"]]))
													{
														CSaleOrderUserPropsValue::Add($arFields);
													}
													elseif($arOrder["AGENT"]["PROFILE_PROPS_VALUE"][$arOrderProperties["ID"]]["VALUE"] != $curVal)
													{
														CSaleOrderUserPropsValue::Update($arOrder["AGENT"]["PROFILE_PROPS_VALUE"][$arOrderProperties["ID"]]["ID"], $arFields);
													}
												}
											}
										}
									}
								}
								else
								{
									$this->strError .= "\n".GetMessage("CC_BSC1_ORDER_ADD_PROBLEM", Array("#ID#" => $arOrder["ID_1C"]));
								}
							}
							else
							{
								$this->strError .= "\n".GetMessage("CC_BSC1_ORDER_USER_PROBLEM", Array("#ID#" => $arOrder["ID_1C"]));
								if(!empty($arErrors))
								{
									foreach($arErrors as $v)
									{
										$this->strError .= "\n".$v["TEXT"];
									}
								}
							}
						}
						else
						{
							$this->strError .= "\n".GetMessage("CC_BSC1_ORDER_PERSON_TYPE_PROBLEM", Array("#ID#" => $arOrder["ID_1C"]));
						}
					}
					else
					{
						$this->strError .= "\n".GetMessage("CC_BSC1_ORDER_NO_AGENT_ID", Array("#ID#" => $arOrder["ID_1C"]));
					}
				}
			}
		}
		elseif($this->arParams["IMPORT_NEW_ORDERS"] == "Y")
		{

			$value = $value[GetMessage("CC_BSC1_AGENT")]["#"];
			$arAgentInfo = $this->collectAgentInfo($value);

			if(!empty($arAgentInfo["AGENT"]))
			{
				$mode = false;
				$arErrors = array();
				$dbUProp = CSaleOrderUserProps::GetList(array(), array("XML_ID" => $arAgentInfo["AGENT"]["ID"]), false, false, array("ID", "NAME", "USER_ID", "PERSON_TYPE_ID", "XML_ID", "VERSION_1C"));
				if($arUProp = $dbUProp->Fetch())
				{
					if($arUProp["VERSION_1C"] != $arAgentInfo["AGENT"]["VERSION"])
					{
						$mode = "update";
						$arAgentInfo["PROFILE_ID"] = $arUProp["ID"];
						$arAgentInfo["PERSON_TYPE_ID"] = $arUProp["PERSON_TYPE_ID"];
					}
				}
				else
				{
					$arUser = array(
						"NAME" => $arAgentInfo["AGENT"]["ITEM_NAME"],
						"EMAIL" => $arAgentInfo["AGENT"]["CONTACT"]["MAIL_NEW"],
					);

					if(strlen($arUser["NAME"]) <= 0)
						$arUser["NAME"] = $arAgentInfo["AGENT"]["CONTACT"]["CONTACT_PERSON"];

					$emServer = $_SERVER["SERVER_NAME"];
					if(strpos($_SERVER["SERVER_NAME"], ".") === false)
						$emServer .= ".bx";
					if(strlen($arUser["EMAIL"]) <= 0)
						$arUser["EMAIL"] = "buyer".time().GetRandomCode(2)."@".$emServer;
					$arAgentInfo["USER_ID"] = CSaleUser::DoAutoRegisterUser($arUser["EMAIL"], $arUser["NAME"], $this->arParams["SITE_NEW_ORDERS"], $arErrors);

					if(IntVal($arAgentInfo["USER_ID"]) > 0)
					{
						$mode = "add";
					}
					else
					{
						$this->strError .= "\n".GetMessage("CC_BSC1_AGENT_USER_PROBLEM", Array("#ID#" => $arAgentInfo["AGENT"]["ID"]));
						if(!empty($arErrors))
						{
							foreach($arErrors as $v)
							{
								$this->strError .= "\n".$v["TEXT"];
							}
						}
					}
				}

				if($mode)
				{
					if(empty($this->arPersonTypesIDs))
					{
						$dbPT = CSalePersonType::GetList(array(), array("ACTIVE" => "Y", "LIDS" => $this->arParams["SITE_NEW_ORDERS"]));
						while($arPT = $dbPT->Fetch())
						{
							$this->arPersonTypesIDs[] = $arPT["ID"];
						}
					}

					if(empty($this->arExportInfo))
					{
						$dbExport = CSaleExport::GetList(array(), array("PERSON_TYPE_ID" => $this->arPersonTypesIDs));
						while($arExport = $dbExport->Fetch())
						{
							$this->arExportInfo[$arExport["PERSON_TYPE_ID"]] = unserialize($arExport["VARS"]);
						}
					}

					if(IntVal($arAgentInfo["PERSON_TYPE_ID"]) <= 0)
					{
						foreach($this->arExportInfo as $pt => $value)
						{
							if(($value["IS_FIZ"] == "Y" && $arAgentInfo["AGENT"]["TYPE"] == "FIZ")
								|| ($value["IS_FIZ"] == "N" && $arAgentInfo["AGENT"]["TYPE"] != "FIZ")
							)
								$arAgentInfo["PERSON_TYPE_ID"] = $pt;
						}
					}

					if(IntVal($arAgentInfo["PERSON_TYPE_ID"]) > 0)
					{
						$arAgentInfo["ORDER_PROPS_VALUE"] = array();
						$arAgentInfo["PROFILE_PROPS_VALUE"] = array();

						$arAgent = $this->arExportInfo[$arAgentInfo["PERSON_TYPE_ID"]];

						foreach($arAgent as $k => $v)
						{
							if(strlen($v["VALUE"]) <= 0 || $v["TYPE"] != "PROPERTY")
								unset($arAgent[$k]);
						}

						foreach($arAgent as $k => $v)
						{
							if(!empty($arAgentInfo["ORDER_PROPS"][$k]))
								$arAgentInfo["ORDER_PROPS_VALUE"][$v["VALUE"]] = $arAgentInfo["ORDER_PROPS"][$k];
						}

						if (IntVal($arAgentInfo["PROFILE_ID"]) > 0)
						{
							CSaleOrderUserProps::Update($arUProp["ID"], array("VERSION_1C" => $arAgentInfo["AGENT"]["VERSION"], "NAME" => $arAgentInfo["AGENT"]["AGENT_NAME"]));
							$dbUPV = CSaleOrderUserPropsValue::GetList(array(), array("USER_PROPS_ID" => $arAgentInfo["PROFILE_ID"]));
							while($arUPV = $dbUPV->Fetch())
							{
								$arAgentInfo["PROFILE_PROPS_VALUE"][$arUPV["ORDER_PROPS_ID"]] = array("ID" => $arUPV["ID"], "VALUE" => $arUPV["VALUE"]);
							}
						}

						if(empty($this->arOrderProps[$arAgentInfo["PERSON_TYPE_ID"]]))
						{
							$dbOrderProperties = CSaleOrderProps::GetList(
								array("SORT" => "ASC"),
								array(
									"PERSON_TYPE_ID" => $arAgentInfo["PERSON_TYPE_ID"],
									"ACTIVE" => "Y",
									"UTIL" => "N",
									"USER_PROPS" => "Y",
								),
								false,
								false,
								array("ID", "TYPE", "NAME", "CODE", "USER_PROPS", "SORT", "MULTIPLE")
							);
							while ($arOrderProperties = $dbOrderProperties->Fetch())
							{
								$this->arOrderProps[$arAgentInfo["PERSON_TYPE_ID"]][] = $arOrderProperties;
							}
						}

						foreach($this->arOrderProps[$arAgentInfo["PERSON_TYPE_ID"]] as $arOrderProperties)
						{
							$curVal = $arAgentInfo["ORDER_PROPS_VALUE"][$arOrderProperties["ID"]];

							if (strlen($curVal) > 0)
							{
								if (IntVal($arAgentInfo["PROFILE_ID"]) <= 0)
								{
									$arFields = array(
										"NAME" => $arAgentInfo["AGENT"]["AGENT_NAME"],
										"USER_ID" => $arAgentInfo["USER_ID"],
										"PERSON_TYPE_ID" => $arAgentInfo["PERSON_TYPE_ID"],
										"XML_ID" => $arAgentInfo["AGENT"]["ID"],
										"VERSION_1C" => $arAgentInfo["AGENT"]["VERSION"],
									);
									$arAgentInfo["PROFILE_ID"] = CSaleOrderUserProps::Add($arFields);
								}
								if(IntVal($arAgentInfo["PROFILE_ID"]) > 0)
								{
									$arFields = array(
										"USER_PROPS_ID" => $arAgentInfo["PROFILE_ID"],
										"ORDER_PROPS_ID" => $arOrderProperties["ID"],
										"NAME" => $arOrderProperties["NAME"],
										"VALUE" => $curVal
									);
									if(empty($arAgentInfo["PROFILE_PROPS_VALUE"][$arOrderProperties["ID"]]))
									{
										CSaleOrderUserPropsValue::Add($arFields);
									}
									elseif($arAgentInfo["PROFILE_PROPS_VALUE"][$arOrderProperties["ID"]]["VALUE"] != $curVal)
									{
										CSaleOrderUserPropsValue::Update($arAgentInfo["PROFILE_PROPS_VALUE"][$arOrderProperties["ID"]]["ID"], $arFields);
									}
								}
							}
						}
					}
					else
					{
						$this->strError .= "\n".GetMessage("CC_BSC1_AGENT_PERSON_TYPE_PROBLEM", Array("#ID#" => $arAgentInfo["AGENT"]["ID"]));
					}
				}
			}
			else
			{
				$this->strError .= "\n".GetMessage("CC_BSC1_AGENT_NO_AGENT_ID");
			}
		}
	}
Пример #27
0
	public static function import()
	{
		// include required modules
		if (!CModule::IncludeModule('forum'))
		{
			return false;
		}
		$moduleId = 'prmedia.treelikecomments';

		// retrieve or init session storage
		$sessionStorage = $_SESSION['tlc_import'];
		if ($_REQUEST['start'] == 'Y')
		{
			// get total count of comments
			$rsMessage = CForumMessage::GetList();
			$rsMessage->NavStart();
			$totalCount = $rsMessage->NavRecordCount;

			$sessionStorage = array(
				'processing_time' => time(),
				'current_count' => 0,
				'actual_count' => 0,
				'total_count' => $totalCount,
				'comment_id' => 1,
				'allow_smiles' => COption::GetOptionString($moduleId, 'smiles_enable') == 1 ? true : false,
				'allow_bb' => COption::GetOptionString($moduleId, 'bb_code_enable') == 1 ? true : false
			);
		}


		// import comments...
		$obComment = new CTreelikeComments;
		$is_finish = true;
		$currentTime = time();
		$arOrder = array(
			'ID' => 'ASC'
		);
		$arFilter = array(
			'>ID' => $sessionStorage['comment_id']
		);
		$rsMessage = CForumMessage::GetList($arOrder, $arFilter);
		while ($arMessage = $rsMessage->Fetch())
		{
			$is_finish = false;
			$sessionStorage['current_count']++;
			$sessionStorage['comment_id'] = $arMessage['ID'];

			$comment = $arMessage['POST_MESSAGE'];
			if ($sessionStorage['allow_smiles'])
			{
				$comment = CTreelikeForumImporter::setSmiles($comment);
			}
			if ($sessionStorage['allow_bb'])
			{
				$comment = CTreelikeForumImporter::setBB($comment);
			}


			$arFields = array(
				'REMOTE_ADDR' => $arMessage['AUTHOR_REAL_IP'],
				'AUTHOR_NAME' => $arMessage['AUTHOR_NAME'],
				'USER_ID' => $arMessage['AUTHOR_ID'],
				'OBJECT_ID' => $arMessage['PARAM2'],
				'COMMENT' => $comment,
				'DATE' => CDatabase::FormatDate($arMessage['POST_DATE'], "DD.MM.YYYY HH:MI:SS", "YYYY-MM-DD HH:MI:SS"),
				'ACTIVATED' => $arMessage['APPROVED'] == 'Y' ? 1 : 0
			);

			// counter
			if (!empty($arFields['USER_ID']))
			{
				$elementId = $obComment->Add($arFields);
				if (!empty($elementId))
				{
					if (empty($sessionStorage['first_element']))
					{
						$sessionStorage['first_element'] = $elementId;
					}
					$sessionStorage['actual_count']++;
					CTreelikeForumImporter::addImportedComment($elementId);
				}
			}

			// one step is one second
			if ($currentTime != time())
			{
				break;
			}
		}


		if ($is_finish)
		{
			// go to finish step
			echo '<script>document.getElementsByClassName("wizard-next-button")[0].click();</script>';
			CTreelikeForumImporter::clearCache();
			return;
		}

		// progress message
		$text = GetMessage('PRMEDIA_WIZARDS_IMPORT_FORUM_PROGRESS_MESSAGE');
		$arReplace = array(
			"#IMPORTED#" => $sessionStorage['current_count'],
			"#COUNT#" => $sessionStorage['total_count'],
			"#TIME#" => gmdate("i:s", time() - $sessionStorage['processing_time'])
		);
		$progressMessage = str_replace(array_keys($arReplace), $arReplace, $text);
		CAdminMessage::ShowMessage(array(
			"TYPE" => "PROGRESS",
			"MESSAGE" => GetMessage('PRMEDIA_SS_DIST_PROGRESS_TITLE'),
			"DETAILS" => $progressMessage,
			"HTML" => true,
			"PROGRESS_VALUE" => $sessionStorage['current_count'],
			"PROGRESS_TOTAL" => $sessionStorage['total_count']
		));
		echo "<script>jsPrmediaCommentImporter.update();</script>";

		$_SESSION['tlc_import'] = $sessionStorage;
	}
Пример #28
0
 function GetPeriodCondition($arPeriod, $field, $extraCond = "1=1")
 {
     global $DB;
     if ($arPeriod["START"]) {
         $arPeriod["START"] = CDatabase::FormatDate($arPeriod["START"], FORMAT_DATETIME);
     }
     if ($arPeriod["END"]) {
         $arPeriod["END"] = CDatabase::FormatDate($arPeriod["END"], FORMAT_DATETIME);
     }
     $condition = "CASE WHEN " . ($arPeriod["START"] || $arPeriod["END"] ? ($arPeriod["START"] ? "T." . $field . " >= " . $DB->CharToDateFunction($arPeriod["START"]) : "") . ($arPeriod["START"] && $arPeriod["END"] ? " AND " : "") . ($arPeriod["END"] ? "T." . $field . " <= " . $DB->CharToDateFunction($arPeriod["END"]) : "") . " AND " : "") . $extraCond . " THEN 1 ELSE 0 END";
     return $condition;
 }