Пример #1
0
 function _proses($angka)
 {
     /* buat array angka terbilang */
     $huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
     if (doubleVal($angka) < 12) {
         return " " . $huruf[doubleVal($angka)];
     } elseif (doubleVal($angka) < 20) {
         return $this->_proses(doubleVal($angka) - 10) . "belas";
     } elseif (doubleVal($angka) < 100) {
         return $this->_proses(doubleVal($angka) / 10) . " puluh" . $this->_proses(doubleVal($angka) % 10);
     } elseif (doubleVal($angka) < 200) {
         return " seratus" . $this->_proses(doubleVal($angka) - 100);
     } elseif (doubleVal($angka) < 1000) {
         return $this->_proses(doubleVal($angka) / 100) . " ratus" . $this->_proses(doubleVal($angka) % 100);
     } elseif (doubleVal($angka) < 2000) {
         return " seribu" . $this->_proses(doubleVal($angka) - 1000);
     } elseif (doubleVal($angka) < 1000000) {
         return $this->_proses(doubleVal($angka) / 1000) . " ribu" . $this->_proses(doubleVal($angka) % 1000);
     } elseif (doubleVal($angka) < 1000000000) {
         return $this->_proses(doubleVal($angka) / 1000000) . " juta" . $this->_proses(doubleVal($angka) % 1000000);
     } elseif (doubleVal($angka) < 1000000000000) {
         return $this->_proses(doubleVal($angka) / 1000000000) . " milyar" . $this->_proses(doubleVal($angka) % 1000000000);
     }
 }
Пример #2
0
     if (strlen($arOrderProps['LOCATION_STREET']) && isset($arOrderProps['ADDRESS'])) {
         $arOrderProps['ADDRESS'] = $arOrderProps['LOCATION_STREET'] . (strlen($arOrderProps['ADDRESS']) ? ', ' . $arOrderProps['ADDRESS'] : '');
     }
 }
 $arBasketIDs = array();
 $arQuantities = array();
 if (!isset($SHOW_ALL) || $SHOW_ALL == "N") {
     $arBasketIDs_tmp = explode(",", $BASKET_IDS);
     $arQuantities_tmp = explode(",", $QUANTITIES);
     if (count($arBasketIDs_tmp) != count($arQuantities_tmp)) {
         die("INVALID PARAMS");
     }
     for ($i = 0, $countBasket = count($arBasketIDs_tmp); $i < $countBasket; $i++) {
         if (IntVal($arBasketIDs_tmp[$i]) > 0 && doubleVal($arQuantities_tmp[$i]) > 0) {
             $arBasketIDs[] = IntVal($arBasketIDs_tmp[$i]);
             $arQuantities[] = doubleVal($arQuantities_tmp[$i]);
         }
     }
     unset($countBasket);
 } else {
     $db_basket = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $ORDER_ID), false, false, array("ID", "QUANTITY"));
     while ($arBasket = $db_basket->Fetch()) {
         $arBasketIDs[] = $arBasket["ID"];
         $arQuantities[] = $arBasket["QUANTITY"];
     }
 }
 $dbUser = CUser::GetByID($arOrder["USER_ID"]);
 $arUser = $dbUser->Fetch();
 $report = "";
 $serCount = IntVal(COption::GetOptionInt("sale", "reports_count"));
 if ($serCount > 0) {
Пример #3
0
function getImageReSize2($tag_width, $tag_height, $src_width, $src_heigh)
{
    // ==========================
    // 변수의 선언
    // --------------------------
    $return_size[0] = $tag_width;
    $return_size[1] = $tag_height;
    $tag_rate = doubleVal($tag_height) / $tag_width;
    $src_rate = doubleVal($src_heigh) / $src_width;
    $tmp_num = 0;
    // ==========================
    // ==========================
    // 넓이를 기준으로 비율을 먼저 구한다.
    // --------------------------
    // 더 높이가 긴 그림이므로
    // 높이를 기준으로 작업
    $tmp_num = doubleVal($tag_width) / $src_width;
    $return_size[1] = intval($src_heigh * $tmp_num);
    return $return_size;
    // return_size[0] = width
    // return_size[1] = height
}
Пример #4
0
 public static function GetUserPoints($USER_ID, $arAddParams = array())
 {
     global $DB;
     $USER_ID = intVal($USER_ID);
     if ($USER_ID <= 0) {
         return 0;
     }
     $arAddParams = is_array($arAddParams) ? $arAddParams : array($arAddParams);
     $arAddParams["INCREMENT"] = intVal($arAddParams["INCREMENT"]);
     $arAddParams["DECREMENT"] = intVal($arAddParams["DECREMENT"]);
     $arAddParams["NUM_POSTS"] = is_set($arAddParams, "NUM_POSTS") ? $arAddParams["NUM_POSTS"] : false;
     $arAddParams["RETURN_FETCH"] = $arAddParams["RETURN_FETCH"] == "Y" ? "Y" : "N";
     $strSql = "\n\t\t\tSELECT\n\t\t\t(" . ($arAddParams["NUM_POSTS"] ? $arAddParams["NUM_POSTS"] : "FU.NUM_POSTS") . ($arAddParams["INCREMENT"] > 0 ? "+" . $arAddParams["INCREMENT"] : "") . ($arAddParams["DECREMENT"] > 0 ? "-" . $arAddParams["DECREMENT"] : "") . ") AS NUM_POSTS, FP2P.MIN_NUM_POSTS, FP2P.POINTS_PER_POST, SUM(FUP.POINTS) AS POINTS_FROM_USER\n\t\t\tFROM\n\t\t\t\tb_forum_user FU\n\t\t\t\tLEFT JOIN b_forum_points2post FP2P ON (FP2P.MIN_NUM_POSTS <= " . ($arAddParams["NUM_POSTS"] ? $arAddParams["NUM_POSTS"] : "FU.NUM_POSTS") . ($arAddParams["INCREMENT"] > 0 ? "+" . $arAddParams["INCREMENT"] : "") . ($arAddParams["DECREMENT"] > 0 ? "-" . $arAddParams["DECREMENT"] : "") . ")\n\t\t\t\tLEFT JOIN b_forum_user_points FUP ON (FUP.TO_USER_ID = FU.USER_ID)\n\t\t\tWHERE\n\t\t\t\tFU.user_id = " . $USER_ID . "\n\t\t\tGROUP BY\n\t\t\t\t" . ($arAddParams["NUM_POSTS"] ? "" : "FU.NUM_POSTS, ") . "FP2P.MIN_NUM_POSTS, FP2P.POINTS_PER_POST\n\t\t\tORDER BY FP2P.MIN_NUM_POSTS DESC";
     $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($arAddParams["RETURN_FETCH"] == "Y") {
         return $db_res;
     } elseif ($db_res && ($res = $db_res->Fetch())) {
         $result = floor(doubleVal($res["POINTS_PER_POST"]) * intVal($res["NUM_POSTS"]) + intVal($res["POINTS_FROM_USER"]));
         return $result;
     }
     return false;
 }
Пример #5
0
function CatalogBasketOrderCallback($productID, $quantity, $renewal = "N", $intUserID = 0, $strSiteID = false)
{
    global $USER;
    global $DB;
    $productID = intval($productID);
    $quantity = doubleval($quantity);
    $renewal = $renewal == "Y" ? "Y" : "N";
    $intUserID = intval($intUserID);
    if (0 > $intUserID) {
        $intUserID = 0;
    }
    $arResult = array();
    static $arUserCache = array();
    if (0 < $intUserID) {
        if (!array_key_exists($intUserID, $arUserCache)) {
            $rsUsers = CUser::GetList($by = 'ID', $order = 'DESC', array("ID_EQUAL_EXACT" => $intUserID), array('FIELDS' => array('ID')));
            if ($arUser = $rsUsers->Fetch()) {
                $arUserCache[$arUser['ID']] = CUser::GetUserGroup($arUser['ID']);
            } else {
                $intUserID = 0;
                return $arResult;
            }
        }
        $dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSION" => "N"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
        if (!($arProduct = $dbIBlockElement->GetNext())) {
            return $arResult;
        }
        if ('E' == CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], "RIGHTS_MODE")) {
            $arUserRights = CIBlockElementRights::GetUserOperations($productID, $intUserID);
            if (empty($arUserRights)) {
                return $arResult;
            } elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
                return $arResult;
            }
        } else {
            if ('R' > CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID)) {
                return $arResult;
            }
        }
    } else {
        $dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "Y", "MIN_PERMISSION" => "R"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
        if (!($arProduct = $dbIBlockElement->GetNext())) {
            return $arResult;
        }
    }
    if ($arCatalogProduct = CCatalogProduct::GetByID($productID)) {
        if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) < doubleVal($quantity))) {
            return $arResult;
        }
    } else {
        return $arResult;
    }
    if (0 < $intUserID) {
        $arCoupons = CCatalogDiscountCoupon::GetCouponsByManage($intUserID);
        CCatalogDiscountSave::SetDiscountUserID($intUserID);
    } else {
        $arCoupons = CCatalogDiscountCoupon::GetCoupons();
    }
    $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray(), $renewal, array(), 0 < $intUserID ? $strSiteID : false, $arCoupons);
    if (empty($arPrice)) {
        if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray())) {
            $quantity = $nearestQuantity;
            $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray(), $renewal, array(), 0 < $intUserID ? $strSiteID : false, $arCoupons);
        }
    }
    if (empty($arPrice)) {
        if (0 < $intUserID) {
            CCatalogDiscountSave::ClearDiscountUserID();
        }
        return $arResult;
    }
    $boolDiscountVat = 'N' != COption::GetOptionString('catalog', 'discount_vat', 'Y');
    $currentPrice = $arPrice["PRICE"]["PRICE"];
    $currentDiscount = 0.0;
    if ($boolDiscountVat) {
        if ('N' == $arPrice['PRICE']['VAT_INCLUDED']) {
            $currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
            $arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
        }
    } else {
        if ('Y' == $arPrice['PRICE']['VAT_INCLUDED']) {
            $currentPrice /= 1 + $arPrice['PRICE']['VAT_RATE'];
            $arPrice['PRICE']['VAT_INCLUDED'] = 'N';
        }
    }
    $arDiscountList = array();
    $arCouponList = array();
    if (!empty($arPrice["DISCOUNT_LIST"])) {
        $dblStartPrice = $currentPrice;
        foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
            switch ($arOneDiscount['VALUE_TYPE']) {
                case 'F':
                    if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
                        $currentDiscount = $arOneDiscount['VALUE'];
                    } else {
                        $currentDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount["VALUE"], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
                    }
                    $currentPrice = $currentPrice - $currentDiscount;
                    break;
                case 'P':
                    $currentDiscount = $currentPrice * $arOneDiscount["VALUE"] / 100.0;
                    if (0 < $arOneDiscount['MAX_DISCOUNT']) {
                        if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
                            $dblMaxDiscount = $arOneDiscount['MAX_DISCOUNT'];
                        } else {
                            $dblMaxDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount['MAX_DISCOUNT'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
                        }
                        if ($currentDiscount > $dblMaxDiscount) {
                            $currentDiscount = $dblMaxDiscount;
                        }
                    }
                    $currentPrice = $currentPrice - $currentDiscount;
                    break;
                case 'S':
                    if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
                        $currentPrice = $arOneDiscount['VALUE'];
                    } else {
                        $currentPrice = CCurrencyRates::ConvertCurrency($arOneDiscount['VALUE'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
                    }
                    break;
            }
            $arOneList = array('ID' => $arOneDiscount['ID'], 'NAME' => $arOneDiscount['NAME'], 'COUPON' => '', 'MODULE_ID' => 'catalog');
            if ($arOneDiscount['COUPON']) {
                $arOneList['COUPON'] = $arOneDiscount['COUPON'];
                $arCouponList[] = $arOneDiscount['COUPON'];
            }
            $arDiscountList[] = $arOneList;
        }
        if (isset($arOneDiscount)) {
            unset($arOneDiscount);
        }
        $currentDiscount = $dblStartPrice - $currentPrice;
    }
    if (empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"])) {
        if (!empty($arPrice["PRICE"]["CATALOG_GROUP_ID"])) {
            $rsCatGroups = CCatalogGroup::GetList(array(), array('ID' => $arPrice["PRICE"]["CATALOG_GROUP_ID"]), false, array('nTopCount' => 1), array('ID', 'NAME', 'NAME_LANG'));
            if ($arCatGroup = $rsCatGroups->Fetch()) {
                $arPrice["PRICE"]["CATALOG_GROUP_NAME"] = !empty($arCatGroup['NAME_LANG']) ? $arCatGroup['NAME_LANG'] : $arCatGroup['NAME'];
            }
        }
    }
    if (!$boolDiscountVat) {
        $currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
        $currentDiscount *= 1 + $arPrice['PRICE']['VAT_RATE'];
        $arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
    }
    $arResult = array("PRODUCT_PRICE_ID" => $arPrice["PRICE"]["ID"], "PRICE" => $currentPrice, "VAT_RATE" => $arPrice['PRICE']['VAT_RATE'], "CURRENCY" => $arPrice["PRICE"]["CURRENCY"], "QUANTITY" => $quantity, "WEIGHT" => 0, "NAME" => $arProduct["~NAME"], "CAN_BUY" => "Y", "DETAIL_PAGE_URL" => $arProduct['DETAIL_PAGE_URL'], "NOTES" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"], "DISCOUNT_PRICE" => $currentDiscount);
    if (!empty($arPrice["DISCOUNT_LIST"])) {
        $arResult["DISCOUNT_VALUE"] = 100 * $currentDiscount / ($currentDiscount + $currentPrice) . "%";
        $arResult["DISCOUNT_NAME"] = "[" . $arPrice["DISCOUNT"]["ID"] . "] " . $arPrice["DISCOUNT"]["NAME"];
        $arResult['DISCOUNT_LIST'] = $arDiscountList;
        if (strlen($arPrice["DISCOUNT"]["COUPON"]) > 0) {
            $arResult["DISCOUNT_COUPON"] = $arPrice["DISCOUNT"]["COUPON"];
        }
        if (!empty($arCouponList)) {
            foreach ($arCouponList as &$strOneCoupon) {
                $mxApply = CCatalogDiscountCoupon::CouponApply($intUserID, $strOneCoupon);
            }
            if (isset($strOneCoupon)) {
                unset($strOneCoupon);
            }
        }
    }
    if ($arCatalogProduct) {
        $arResult["WEIGHT"] = intval($arCatalogProduct["WEIGHT"]);
    }
    CCatalogProduct::QuantityTracer($productID, $quantity);
    if (0 < $intUserID) {
        CCatalogDiscountSave::ClearDiscountUserID();
    }
    return $arResult;
}
Пример #6
0
    $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", $arFields);
    $bs = new CIBlockSection();
    $bs->Update($arResult["GALLERY"]["ID"], $arFields);
    BXClearCache(true, "/bitrix/photogallery/" . $arParams["IBLOCK_ID"] . "/user/data/" . $arResult["GALLERY"]["CREATED_BY"] . "/");
    BXClearCache(true, "/bitrix/photogallery/" . $arParams["IBLOCK_ID"] . "/gallery/" . $arResult["GALLERY"]["~CODE"] . "/");
    $url = $GLOBALS['APPLICATION']->GetCurPageParam("", array("action", "status"));
    if ($bAjaxCall != "Y") {
        LocalRedirect($url);
    } elseif ($arParams["GALLERY_SIZE"] > 0) {
        $GLOBALS['APPLICATION']->RestartBuffer();
        $arFields = array("STATUS" => "DONE", "PERCENT" => intVal(doubleVal($arInfoRecalc["FILE_SIZE"]) / $arParams["GALLERY_SIZE"] * 100));
        echo CUtil::PhpToJSObject($arFields);
        die;
    }
} else {
    $arFields = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "UF_GALLERY_RECALC" => serialize($arInfoRecalc), "UF_GALLERY_SIZE" => doubleVal($arResult["GALLERY"]["UF_GALLERY_SIZE"]));
    $GLOBALS["UF_GALLERY_RECALC"] = $arFields["UF_GALLERY_RECALC"];
    $GLOBALS["UF_GALLERY_SIZE"] = $arFields["UF_GALLERY_SIZE"];
    $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", $arFields);
    $bs = new CIBlockSection();
    $bs->Update($arResult["GALLERY"]["ID"], $arFields);
    BXClearCache(true, "/bitrix/photogallery/" . $arParams["IBLOCK_ID"] . "/user/data/" . $arResult["GALLERY"]["CREATED_BY"] . "/");
    BXClearCache(true, "/bitrix/photogallery/" . $arParams["IBLOCK_ID"] . "/gallery/" . $arResult["GALLERY"]["~CODE"] . "/");
    $arResult["GALLERY"]["~UF_GALLERY_RECALC"] = $arFields["UF_GALLERY_RECALC"];
    $arResult["GALLERY"]["UF_GALLERY_RECALC"] = htmlspecialcharsEx($arFields["UF_GALLERY_RECALC"]);
    if ($bAjaxCall == "Y") {
        $GLOBALS['APPLICATION']->RestartBuffer();
        $arFields = array("STATUS" => "CONTINUE", "PERCENT" => intVal(intVal($arInfoRecalc["FILE_COUNT"]) / $arResult["GALLERY"]["ELEMENTS_CNT"] * 100));
        echo CUtil::PhpToJSObject($arFields);
        die;
    }
Пример #7
0
	public function CheckDiskQuota($params = array())
	{
		if (COption::GetOptionInt("main", "disk_space") <= 0)
			return true;

		$quota = $this->GetDiskQuota();

		if ($quota === true || $quota === false)
			return $quota;

		if (!empty($params))
		{
			if (is_array($params))
			{
				$size = false;
				if (is_set($params, "FILE_SIZE"))
					$size = $params["FILE_SIZE"];
				elseif (is_set($params, "SIZE"))
					$size = $params["SIZE"];
				elseif (is_set($params, "file_size"))
					$size = $params["file_size"];
				elseif (is_set($params, "size"))
					$size = $params["size"];
				else
					$size = strlen(serialize($params));

				if ($size !== false && ((double)$quota - $size) > 0)
					return true;
			}
			if (!is_array($params) && doubleVal($params) > 0 && ((double)$quota - $params) > 0)
				return true;
			if (((double)$quota - strLen($params)) > 0)
				return true;
		}
		return false;
	}
Пример #8
0
 public function CheckDiskQuota($params = array())
 {
     if (COption::GetOptionInt("main", "disk_space") <= 0) {
         return true;
     }
     if (defined("SKIP_DISK_QUOTA_CHECK") && constant("SKIP_DISK_QUOTA_CHECK") === true) {
         return true;
     }
     $quota = $this->GetDiskQuota();
     if ($quota === true || $quota === false) {
         return $quota;
     }
     if (!empty($params)) {
         if (is_array($params)) {
             $size = false;
             if (is_set($params, "FILE_SIZE")) {
                 $size = $params["FILE_SIZE"];
             } elseif (is_set($params, "SIZE")) {
                 $size = $params["SIZE"];
             } elseif (is_set($params, "file_size")) {
                 $size = $params["file_size"];
             } elseif (is_set($params, "size")) {
                 $size = $params["size"];
             } else {
                 $size = strlen(serialize($params));
             }
             if ($size !== false) {
                 return (double) $quota - $size > 0;
             }
         }
         if (!is_array($params) && doubleVal($params) > 0 && (double) $quota - $params > 0) {
             return true;
         }
         if ((double) $quota - strLen($params) > 0) {
             return true;
         }
     }
     return false;
 }
Пример #9
0
 private function generateLelongProductOptionsDetails($optionsData, $index, $optionsDetails, $price, $sales_price)
 {
     if ($optionsData != null && is_array($optionsData)) {
         $optionsDataCount = count($optionsData);
         if ($optionsDetails == null) {
             $optionsDetails = null;
             $count = 0;
             foreach ($optionsData[$index]['product_option_value'] as $optionValueData) {
                 if ($index + 1 < $optionsDataCount) {
                     $nextOptionType = strtolower($optionsData[$index + 1]['type']);
                     if ($nextOptionType == 'select' || $nextOptionType == 'radio' || $nextOptionType == 'image') {
                         foreach ($optionsData[$index + 1]['product_option_value'] as $nextOptionValueData) {
                             $optionsDetails[$count]['id'] = $optionValueData['product_option_value_id'] . ' | ' . $nextOptionValueData['product_option_value_id'];
                             $optionsDetails[$count]['sku'] = $optionValueData['name'] . ' | ' . $nextOptionValueData['name'];
                             $optionsDetails[$count]['usersku'] = $optionValueData['name'] . ' ' . $nextOptionValueData['name'];
                             $optionPriceAddOn = doubleVal($optionValueData['price_prefix'] . $optionValueData['price']) + doubleVal($nextOptionValueData['price_prefix'] . $nextOptionValueData['price']);
                             $optionsDetails[$count]['price'] = $optionPriceAddOn;
                             $optionsDetails[$count]['saleprice'] = $optionPriceAddOn;
                             $optionsDetails[$count]['quantity'] = intval($optionValueData['quantity']) < intval($nextOptionValueData['quantity']) ? intval($optionValueData['quantity']) : intval($nextOptionValueData['quantity']);
                             $optionsDetails[$count]['status'] = '1';
                             $optionsDetails[$count]['warningqty'] = '0';
                             /*$nextOptionValue = $this->getOptionValue($nextOptionValueData['option_value_id']);
                             		
                             		if($nextOptionValue != null && $nextOptionValue['image'] != null)
                             			$optionsDetails[$count]['image'] = $nextOptionValue['image'];*/
                             $count++;
                         }
                     }
                 } else {
                     $optionType = strtolower($optionsData[$index]['type']);
                     if ($optionType == 'select' || $optionType == 'radio' || $optionType == 'image') {
                         $optionsDetails[$count]['id'] = $optionValueData['product_option_value_id'];
                         $optionsDetails[$count]['sku'] = $optionValueData['name'];
                         $optionsDetails[$count]['usersku'] = $optionValueData['name'];
                         $optionPriceAddOn = doubleVal($optionValueData['price_prefix'] . $optionValueData['price']);
                         $optionsDetails[$count]['price'] = $optionPriceAddOn;
                         $optionsDetails[$count]['saleprice'] = $optionPriceAddOn;
                         $optionsDetails[$count]['quantity'] = intVal($optionValueData['quantity']);
                         $optionsDetails[$count]['status'] = '1';
                         $optionsDetails[$count]['warningqty'] = '0';
                         /*$optionValue = $this->getOptionValue($optionValueData['option_value_id']);
                         		
                         		if($optionValue != null && $optionValue['image'] != null)
                         			$optionsDetails[$count]['image'] = $optionValue['image'];*/
                         $count++;
                     }
                 }
             }
         } else {
             if (is_array($optionsDetails) == true) {
                 $count = 0;
                 foreach ($optionsDetails as $optionDetails) {
                     if ($index + 1 < $optionsDataCount) {
                         foreach ($optionsData[$index + 1]['product_option_value'] as $nextOptionValueData) {
                             $optionsDetails[$count]['id'] = $optionDetails['id'] . ' | ' . $nextOptionValueData['product_option_value_id'];
                             $optionsDetails[$count]['sku'] = $optionDetails['sku'] . ' | ' . $nextOptionValueData['name'];
                             $optionsDetails[$count]['usersku'] = $optionDetails['usersku'] . ' ' . $nextOptionValueData['name'];
                             $optionPriceAddOn = doubleVal($optionDetails['price']) + doubleVal($nextOptionValueData['price_prefix'] . $nextOptionValueData['price']);
                             $optionsDetails[$count]['price'] = $optionPriceAddOn;
                             $optionsDetails[$count]['saleprice'] = $optionPriceAddOn;
                             $optionsDetails[$count]['quantity'] = intval($optionDetails['quantity']) < intval($nextOptionValueData['quantity']) ? intval($optionDetails['quantity']) : intval($nextOptionValueData['quantity']);
                             $optionsDetails[$count]['status'] = '1';
                             $optionsDetails[$count]['warningqty'] = '0';
                             /*$optionValue = $this->getOptionValue($nextOptionValueData['option_value_id']);
                             		if($optionValue != null && $optionValue['image'] != null)
                             			$optionsDetails[$count]['image'] = $optionValue['image'];*/
                             $count++;
                         }
                     }
                 }
             }
         }
         if ($index + 1 < $optionsDataCount) {
             return $optionsDetails = $this->generateLelongProductOptionsDetails($optionsData, $index + 1, $optionsDetails, $price, $sales_price);
         }
         return $optionsDetails;
     }
     return false;
 }
Пример #10
0
     }
 }
 if ($_REQUEST["photo_album_id"] == "new") {
     PClearComponentCache(array("search.page", "search.tags.cloud", "photogallery.detail", "photogallery.detail.comment", "photogallery.detail.edit", "photogallery.detail.list", "photogallery.gallery.edit", "photogallery.gallery.list", "photogallery.section", "photogallery.section.edit", "photogallery.section.edit.icon", "photogallery.section.list", "photogallery.upload", "photogallery.user", "photogallery_user", "photogallery"));
 } else {
     PClearComponentCache(array("search.page", "search.tags.cloud", "photogallery.upload", "photogallery.detail.list/" . $arParams["IBLOCK_ID"] . "/detaillist/0", "photogallery.detail.list/" . $arParams["IBLOCK_ID"] . "/detaillist/" . $arSection["ID"], "photogallery.section/" . $arParams["IBLOCK_ID"] . "/section0", "photogallery.section/" . $arParams["IBLOCK_ID"] . "/section" . $arSection["ID"], "photogallery.section/" . $arParams["IBLOCK_ID"] . "/section" . $arSection["IBLOCK_SECTION_ID"], "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/section0", "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/section" . $arSection["ID"], "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/section" . $arSection["IBLOCK_SECTION_ID"], "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/sections0", "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/sections" . $arSection["ID"], "photogallery.section.list/" . $arParams["IBLOCK_ID"] . "/sections" . $arSection["IBLOCK_SECTION_ID"]));
 }
 if (intVal($ID) <= 0) {
     $bVarsFromForm = true;
     $res_file = array("status" => "error", "error" => $strError);
 } else {
     $arFields["ID"] = $ID;
     if (function_exists('BXIBlockAfterSave')) {
         BXIBlockAfterSave($arFields);
     }
     $iFileSize += doubleVal($File["REAL_PICTURE"]["size"]);
     $db_res = CIBlockElement::GetList(array("ID" => "DESC"), array("ID" => $ID), false, false, array("PREVIEW_PICTURE"));
     if ($db_res && ($res = $db_res->Fetch())) {
         $tmp = CFile::GetFileArray($res["PREVIEW_PICTURE"]);
         $res_file["path"] = $tmp["SRC"];
     }
 }
 $res_file["id"] = $arFields["ID"];
 $res_file["title"] = $arFields["NAME"];
 // Main info about file
 $result["FILE"][$File["REAL_PICTURE"]["name"]] = $res_file;
 $result["FILE"][$File["REAL_PICTURE"]["name"]]["number"] = $number;
 // Additional info about file
 $res_file["number"] = $i;
 $res_file["description"] = $arFields["PREVIEW_TEXT"];
 $result["FILE_INFO"][$File["REAL_PICTURE"]["name"]] = $res_file;
Пример #11
0
/**
 * 
 * @param $productID
 * @param $quantity
 * @param $renewal
 */
function CatalogBasketOrderCustomCallback($productID, $quantity, $renewal = "N")
{
	$productID = IntVal($productID);
	$quantity = DoubleVal($quantity);
	$renewal = (($renewal == "Y") ? "Y" : "N");
	$arResult = array();

	if ($arCatalogProduct = CCatalogProduct::GetByID($productID))
	{
		if ($arCatalogProduct["QUANTITY_TRACE"]=="Y" && DoubleVal($arCatalogProduct["QUANTITY"])<doubleVal($quantity))
			return $arResult;
	}
	
	$rs = CPrice::GetList(array(), array("CATALOG_GROUP_NAME" => GetCityPrice(), "PRODUCT_ID" => $productID), false, false);
	
	$ar = $rs -> Fetch();
	
	$arPrice = array();
	$arPrice[] = array(
		"ID" => $ar["ID"],
		"PRICE" => $ar["PRICE"],
		"CURRENCY" => $ar["CURRENCY"],
		"CATALOG_GROUP_ID" => $ar["CATALOG_GROUP_ID"]
	);
	
	$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $GLOBALS["USER"]->GetUserGroupArray(), $renewal, $arPrice);
	if (!$arPrice || count($arPrice) <= 0)
	{
		if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $GLOBALS["USER"]->GetUserGroupArray()))
		{
			$quantity = $nearestQuantity;
			$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $GLOBALS["USER"]->GetUserGroupArray(), $renewal);
		}
	}
	if (!$arPrice || count($arPrice) <= 0)
	{
		return $arResult;
	}

	$dbIBlockElement = CIBlockElement::GetList(
			array(),
			array(
					"ID" => $productID,
					"ACTIVE_DATE" => "Y",
					"ACTIVE" => "Y",
					"CHECK_PERMISSIONS" => "Y"
				)
		);
	$arProduct = $dbIBlockElement->GetNext();

	$currentPrice = $arPrice["PRICE"]["PRICE"];
	$currentDiscount = 0.0;
	
	//SIGURD: logic change. see mantiss 5036.
	// discount applied to a final price with VAT already included.
	if ($arPrice['PRICE']['VAT_INCLUDED'] == 'N')
	{
		if(DoubleVal($arPrice['PRICE']['VAT_RATE']) > 0)
		{
			$currentPrice *= (1 + $arPrice['PRICE']['VAT_RATE']);
			$arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
		}
	}

	if (isset($arPrice["DISCOUNT"]) && count($arPrice["DISCOUNT"]) > 0)
	{
		if ($arPrice["DISCOUNT"]["VALUE_TYPE"]=="F")
		{
			if ($arPrice["DISCOUNT"]["CURRENCY"] == $arPrice["PRICE"]["CURRENCY"])
				$currentDiscount = $arPrice["DISCOUNT"]["VALUE"];
			else
				$currentDiscount = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT"]["VALUE"], $arPrice["DISCOUNT"]["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
		}
		else
			$currentDiscount = $currentPrice * $arPrice["DISCOUNT"]["VALUE"] / 100.0;

		$currentDiscount = roundEx($currentDiscount, SALE_VALUE_PRECISION);

		if (DoubleVal($arPrice["DISCOUNT"]["MAX_DISCOUNT"]) > 0)
		{
			if ($arPrice["DISCOUNT"]["CURRENCY"] == $baseCurrency)
				$maxDiscount = $arPrice["DISCOUNT"]["MAX_DISCOUNT"];
			else
				$maxDiscount = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT"]["MAX_DISCOUNT"], $arPrice["DISCOUNT"]["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
			$maxDiscount = roundEx($maxDiscount, CATALOG_VALUE_PRECISION);

			if ($currentDiscount > $maxDiscount)
				$currentDiscount = $maxDiscount;
		}
		
		$currentPrice = $currentPrice - $currentDiscount;
	}
	
	$arResult = array(
			"PRODUCT_PRICE_ID" => $arPrice["PRICE"]["ID"],
			"PRICE" => $currentPrice,
			"VAT_RATE" => $arPrice['PRICE']['VAT_RATE'],
			"CURRENCY" => $arPrice["PRICE"]["CURRENCY"],
			"QUANTITY" => $quantity,
			"WEIGHT" => 0,
			"NAME" => $arProduct["~NAME"],
			"CAN_BUY" => "Y",
			"NOTES" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"],
			"DISCOUNT_PRICE" => $currentDiscount,
		);
	if(!empty($arPrice["DISCOUNT"]))
	{
		if(strlen($arPrice["DISCOUNT"]["COUPON"])>0)
			$arResult["DISCOUNT_COUPON"] = $arPrice["DISCOUNT"]["COUPON"];
			if($arPrice["DISCOUNT"]["VALUE_TYPE"]=="P")
				$arResult["DISCOUNT_VALUE"] = $arPrice["DISCOUNT"]["VALUE"]."%";
			else
				$arResult["DISCOUNT_VALUE"] = SaleFormatCurrency($arPrice["DISCOUNT"]["VALUE"], $arPrice["DISCOUNT"]["CURRENCY"]);
			$arResult["DISCOUNT_NAME"] = "[".$arPrice["DISCOUNT"]["ID"]."] ".$arPrice["DISCOUNT"]["NAME"];
			
		$dbCoupon = CCatalogDiscountCoupon::GetList(
			array(),
			array("COUPON" => $arPrice["DISCOUNT"]["COUPON"]),
			false,
			false,
			array("ID", "ONE_TIME")
		);
		if ($arCoupon = $dbCoupon->Fetch())
		{
			$arFieldsCoupon = Array("DATE_APPLY" => Date($GLOBALS["DB"]->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))));

			if ($arCoupon["ONE_TIME"] == "Y")
			{
				$arFieldsCoupon["ACTIVE"] = "N";

				foreach($_SESSION["CATALOG_USER_COUPONS"] as $k => $v)
				{
					if(trim($v) == trim($arPrice["DISCOUNT"]["COUPON"]))
					{
						unset($_SESSION["CATALOG_USER_COUPONS"][$k]);
						$_SESSION["CATALOG_USER_COUPONS"][$k] == "";
					}
				}
			}

			CCatalogDiscountCoupon::Update($arCoupon["ID"], $arFieldsCoupon);
		}
	}

	if ($arCatalogProduct)
	{
		$arResult["WEIGHT"] = IntVal($arCatalogProduct["WEIGHT"]);
	}
	CCatalogProduct::QuantityTracer($productID, $quantity);
	
	return $arResult;
}
Пример #12
0
 /**
  * Quantity is stored as an integer but fabric quantity is a decimal
  * So convert fabric quantity into a decimal by dividing by 100
  */
 public function getFabricQuantity()
 {
     return doubleVal($this->quantity / 100);
 }
Пример #13
0
	function GetUserPoints($USER_ID, $arAddParams = array())
	{
		global $DB;
		$USER_ID = intVal($USER_ID);
		if ($USER_ID <= 0) return 0;
		$arAddParams = (is_array($arAddParams) ? $arAddParams : array($arAddParams));
		$arAddParams["INCREMENT"] = intVal($arAddParams["INCREMENT"]);
		$arAddParams["DECREMENT"] = intVal($arAddParams["DECREMENT"]);
		$arAddParams["NUM_POSTS"] = (is_set($arAddParams, "NUM_POSTS") ? $arAddParams["NUM_POSTS"] : false);
		$arAddParams["RETURN_FETCH"] = ($arAddParams["RETURN_FETCH"] == "Y" ? "Y" : "N");
		$strSql = "
			SELECT
			(".
				($arAddParams["NUM_POSTS"] ? $arAddParams["NUM_POSTS"] : "FU.NUM_POSTS").
				($arAddParams["INCREMENT"] > 0 ? "+".$arAddParams["INCREMENT"] : "").
				($arAddParams["DECREMENT"] > 0 ? "-".$arAddParams["DECREMENT"] : "").
				") AS NUM_POSTS, FP2P.MIN_NUM_POSTS, FP2P.POINTS_PER_POST, SUM(FUP.POINTS) AS POINTS_FROM_USER
			FROM
				b_forum_user FU
				LEFT JOIN b_forum_points2post FP2P ON (FP2P.MIN_NUM_POSTS <= ".
				($arAddParams["NUM_POSTS"] ? $arAddParams["NUM_POSTS"] : "FU.NUM_POSTS").
				($arAddParams["INCREMENT"] > 0 ? "+".$arAddParams["INCREMENT"] : "").
				($arAddParams["DECREMENT"] > 0 ? "-".$arAddParams["DECREMENT"] : "").")
				LEFT JOIN b_forum_user_points FUP ON (FUP.TO_USER_ID = FU.USER_ID)
			WHERE
				FU.user_id = ".$USER_ID."
			GROUP BY
				".($arAddParams["NUM_POSTS"] ? "" : "FU.NUM_POSTS, ")."FP2P.MIN_NUM_POSTS, FP2P.POINTS_PER_POST
			ORDER BY FP2P.MIN_NUM_POSTS DESC";

		$db_res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		if ($arAddParams["RETURN_FETCH"] == "Y"):
			return $db_res;
		elseif ($db_res && ($res = $db_res->Fetch())):
			$result = floor(doubleVal($res["POINTS_PER_POST"])*intVal($res["NUM_POSTS"]) + intVal($res["POINTS_FROM_USER"]));
			return $result;
		endif;
		return false;
	}