Ejemplo n.º 1
0
 function Add($arFields)
 {
     global $DB;
     if (!CExtra::CheckFields('ADD', $arFields)) {
         return false;
     }
     $arInsert = $DB->PrepareInsert("b_catalog_extra", $arFields);
     $strSql = "INSERT INTO b_catalog_extra(" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $ID = intval($DB->LastID());
     CExtra::ClearCache();
     return $ID;
 }
Ejemplo n.º 2
0
 function Add($arFields)
 {
     global $DB;
     if (!CExtra::CheckFields('ADD', $arFields, 0)) {
         return false;
     }
     $intID = '';
     if (!CExtra::PrepareInsert($arFields, $intID)) {
         return false;
     }
     $res = $DB->Insert('b_catalog_extra', $arFields, "File: " . __FILE__ . "<br>Line: " . __LINE__, false, $intID);
     unset($GLOBALS["MAIN_EXTRA_LIST_CACHE"]);
     return $res;
 }
Ejemplo n.º 3
0
	function ReCountFromBase(&$arFields, &$boolBase)
	{
		$arBaseGroup = CCatalogGroup::GetBaseGroup();
		if (!empty($arBaseGroup))
		{
			if ($arFields['CATALOG_GROUP_ID'] == $arBaseGroup['ID'])
			{
				$boolBase = true;
			}
			else
			{
				if (!empty($arFields['EXTRA_ID']) && intval($arFields['EXTRA_ID']) > 0)
				{
					$arExtra = CExtra::GetByID($arFields['EXTRA_ID']);
					if (!empty($arExtra))
					{
						$arFilter = array('PRODUCT_ID' => $arFields['PRODUCT_ID'],'CATALOG_GROUP_ID' => $arBaseGroup['ID']);
						if (isset($arFields['QUANTITY_FROM']))
							$arFilter['QUANTITY_FROM'] = $arFields['QUANTITY_FROM'];
						if (isset($arFields['QUANTITY_TO']))
							$arFilter['QUANTITY_TO'] = $arFields['QUANTITY_TO'];
						$rsBasePrices = CPrice::GetListEx(
							array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC"),
							$arFilter,
							false,
							array('nTopCount' => 1),
							array('PRICE','CURRENCY')
						);
						if ($arBasePrice = $rsBasePrices->Fetch())
						{
							$arFields['CURRENCY'] = $arBasePrice['CURRENCY'];
							$arFields['PRICE'] = RoundEx($arBasePrice["PRICE"] * (1 + DoubleVal($arExtra["PERCENTAGE"])/100), CATALOG_VALUE_PRECISION);
						}
						else
						{
							$arFields['EXTRA_ID'] = 0;
						}
					}
					else
					{
						$arFields['EXTRA_ID'] = 0;
					}
				}
			}
		}
	}
Ejemplo n.º 4
0
                ?>
_<?php 
                echo $ind;
                ?>
" name="CAT_QUANTITY_TO_<?php 
                echo $arCatalogGroup["ID"];
                ?>
_<?php 
                echo $ind;
                ?>
" value="" size="3">

						</td>
						<td valign="top" align="center">
							<?php 
                echo CExtra::SelectBox("CAT_EXTRA_" . $arCatalogGroup["ID"] . "_" . $ind, "", GetMessage("VAL_NOT_SET"), "ChangeExtraEx(this)", ($bReadOnly ? "disabled readonly" : "") . ' id="' . "CAT_EXTRA_" . $arCatalogGroup["ID"] . "_" . $ind . '" ');
                ?>

						</td>
						<td valign="top" align="center">
							<input type="text" <?php 
                if ($bReadOnly) {
                    echo "disabled readonly";
                }
                ?>
 id="CAT_PRICE_<?php 
                echo $arCatalogGroup["ID"];
                ?>
_<?php 
                echo $ind;
                ?>
Ejemplo n.º 5
0
			false,
			false,
			array('ID', 'NAME', 'NAME_LANG')
		);
	while ($arCatalogGroup = $dbCatalogGroups->Fetch())
	{
		$arHeader[] = array(
			"id" => "CATALOG_GROUP_".$arCatalogGroup["ID"],
			"content" => htmlspecialcharsex(!empty($arCatalogGroup["NAME_LANG"]) ? $arCatalogGroup["NAME_LANG"] : $arCatalogGroup["NAME"]),
			"align" => "right",
			"sort" => "CATALOG_PRICE_".$arCatalogGroup["ID"],
		);
		$arCatGroup[$arCatalogGroup["ID"]] = $arCatalogGroup;
	}
	$arCatExtra = array();
	$db_extras = CExtra::GetList(array("NAME" =>"ASC"));
	while ($extras = $db_extras->Fetch())
		$arCatExtra[] = $extras;
}

if ($bBizproc)
{
	$arWorkflowTemplates = CBPDocument::GetWorkflowTemplatesForDocumentType(array(MODULE_ID, ENTITY, DOCUMENT_TYPE));
	foreach ($arWorkflowTemplates as $arTemplate)
	{
		$arHeader[] = array(
			"id" => "WF_".$arTemplate["ID"],
			"content" => $arTemplate["NAME"],
		);
	}
	$arHeader[] = array(
Ejemplo n.º 6
0
                break;
        }
    }
}
$arHeaders = array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "NAME", "content" => GetMessage("EXTRA_NAME"), "sort" => "NAME", "default" => true), array("id" => "PERCENTAGE", "content" => GetMessage('EXTRA_PERCENTAGE'), "sort" => "PERCENTAGE", "default" => true));
if (!$bReadOnly) {
    $arHeaders[] = array("id" => "RECALCULATE", "content" => GetMessage("EXTRA_RECALCULATE"), "default" => true);
}
$lAdmin->AddHeaders($arHeaders);
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
if (array_key_exists("mode", $_REQUEST) && $_REQUEST["mode"] == "excel") {
    $arNavParams = false;
} else {
    $arNavParams = array("nPageSize" => CAdminResult::GetNavSize($sTableID));
}
$dbResultList = CExtra::GetList(array($by => $order), $arFilter, false, $arNavParams);
$dbResultList = new CAdminResult($dbResultList, $sTableID);
$dbResultList->NavStart();
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("cat_extra_nav")));
while ($arExtra = $dbResultList->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arExtra);
    $row->AddField("ID", $f_ID);
    if ($bReadOnly) {
        $row->AddViewField("NAME", $f_NAME);
        $row->AddViewField("PERCENTAGE", $f_PERCENTAGE);
    } else {
        $row->AddInputField("NAME", array("size" => "35"));
        $row->AddInputField("PERCENTAGE", array("size" => "10"));
        $row->AddCheckField("RECALCULATE");
        $row->AddViewField("RECALCULATE", '');
    }
Ejemplo n.º 7
0
        } else {
            LocalRedirect("/bitrix/admin/cat_extra_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $ID);
        }
    } else {
        $bVarsFromForm = true;
    }
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/catalog/prolog.php";
if ($ID > 0) {
    $APPLICATION->SetTitle(GetMessage("CEEN_UPDATING"));
} else {
    $APPLICATION->SetTitle(GetMessage("CEEN_ADDING"));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
if ($ID > 0) {
    $arExtra = CExtra::GetByID($ID);
    if (!$arExtra) {
        $ID = 0;
    } else {
        $str_NAME = $arExtra["NAME"];
        $str_PERCENTAGE = $arExtra["PERCENTAGE"];
        $str_RECALCULATE = "N";
    }
}
if ($bVarsFromForm) {
    $str_NAME = $NAME;
    $str_PERCENTAGE = $PERCENTAGE;
    $str_RECALCULATE = $RECALCULATE == "Y" ? 'Y' : 'N';
}
$aMenu = array(array("TEXT" => GetMessage("CEEN_2FLIST"), "ICON" => "btn_list", "LINK" => "/bitrix/admin/cat_extra.php?lang=" . LANGUAGE_ID));
if ($ID > 0 && !$bReadOnly) {
Ejemplo n.º 8
0
 $arCatalogPrice_tmp = array();
 $intBasePriceCount = count($arCatalogBasePrices);
 $dbCatGroups = CCatalogGroup::GetList(array(), array("!BASE" => "Y"));
 while ($arCatGroups = $dbCatGroups->Fetch()) {
     unset($arCatalogPrice_tmp);
     $arCatalogPrice_tmp = array();
     for ($i = 0; $i < $intBasePriceCount; $i++) {
         ${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]} = str_replace(",", ".", ${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]});
         $arCatalogPrice_tmp[$i] = array("ID" => IntVal(${"CAT_ID_" . $arCatGroups["ID"]}[$arCatalogBasePrices[$i]["IND"]]), "EXTRA_ID" => ${"CAT_EXTRA_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]} ? IntVal(${"CAT_EXTRA_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}) : 0, "PRICE" => ${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}, "CURRENCY" => Trim(${"CAT_CURRENCY_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}), "QUANTITY_FROM" => $arCatalogBasePrices[$i]["QUANTITY_FROM"], "QUANTITY_TO" => $arCatalogBasePrices[$i]["QUANTITY_TO"]);
         if (strlen($arCatalogPrice_tmp[$i]["CURRENCY"]) <= 0) {
             $arCatalogPrice_tmp[$i]["CURRENCY"] = $arCatalogBasePrices[$i]["CURRENCY"];
         }
         if ($arCatalogPrice_tmp[$i]["EXTRA_ID"] > 0) {
             if (0 < doubleval($arCatalogBasePrices[$i]["PRICE"])) {
                 $arCatalogPrice_tmp[$i]["CURRENCY"] = $arCatalogBasePrices[$i]["CURRENCY"];
                 $arCatalogExtra = CExtra::GetByID($arCatalogPrice_tmp[$i]["EXTRA_ID"]);
                 $arCatalogPrice_tmp[$i]["PRICE"] = RoundEx($arCatalogBasePrices[$i]["PRICE"] * (1 + DoubleVal($arCatalogExtra["PERCENTAGE"]) / 100), CATALOG_VALUE_PRECISION);
             } else {
                 $arCatalogPrice_tmp[$i]["EXTRA_ID"] = 0;
             }
         }
     }
     $arCatalogPrices[$arCatGroups["ID"]] = $arCatalogPrice_tmp;
 }
 $arUpdatedIDs = array();
 $availCanBuyZero = COption::GetOptionString("catalog", "default_can_buy_zero");
 $quantityTrace = $_POST['CAT_BASE_QUANTITY_TRACE'];
 if (!$quantityTrace || $quantityTrace == '') {
     $quantityTrace = 'D';
 }
 $useStore = $_POST['USE_STORE'];
Ejemplo n.º 9
0
 /**
  * <p>Удаляет запись наценки из базы. Цены, которые были заданы в виде наценки от базовой цены, становятся заданными абсолютным значением. Сама величина цены не меняется. </p>
  *
  *
  *
  *
  * @param int $ID  Код наценки.
  *
  *
  *
  * @return bool <p>Возвращается <i>true</i> в случае успешного удаления и <i>false</i> - в
  * противном случае </p> <br><br>
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/catalog/classes/cextra/cextra__delete.ca4c66fe.php
  * @author Bitrix
  */
 public static function Delete($ID)
 {
     global $DB;
     $ID = intval($ID);
     if (0 >= $ID) {
         return false;
     }
     $DB->Query("UPDATE b_catalog_price SET EXTRA_ID = NULL WHERE EXTRA_ID = " . $ID);
     CExtra::ClearCache();
     return $DB->Query("DELETE FROM b_catalog_extra WHERE ID = " . $ID, true);
 }
Ejemplo n.º 10
0
        $arWFStatus[$arWF["~REFERENCE_ID"]] = $arWF["~REFERENCE"];
    }
}
if ($boolSubCatalog) {
    $arHeader[] = array("id" => "CATALOG_QUANTITY", "content" => GetMessage("IBEL_CATALOG_QUANTITY"), "align" => "right", "sort" => "CATALOG_QUANTITY");
    $arHeader[] = array("id" => "CATALOG_QUANTITY_TRACE", "content" => GetMessage("IBEL_CATALOG_QUANTITY_TRACE"), "align" => "right");
    $arHeader[] = array("id" => "CATALOG_WEIGHT", "content" => GetMessage("IBEL_CATALOG_WEIGHT"), "align" => "right", "sort" => "CATALOG_WEIGHT");
    $arCatGroup = array();
    $arBaseGroup = CCatalogGroup::GetBaseGroup();
    $dbCatalogGroups = CCatalogGroup::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID));
    while ($arCatalogGroup = $dbCatalogGroups->Fetch()) {
        $arHeader[] = array("id" => "CATALOG_GROUP_" . $arCatalogGroup["ID"], "content" => htmlspecialcharsex(!empty($arCatalogGroup["NAME_LANG"]) ? $arCatalogGroup["NAME_LANG"] : $arCatalogGroup["NAME"]), "align" => "right", "sort" => "CATALOG_PRICE_" . $arCatalogGroup["ID"], "default" => $arBaseGroup['ID'] == $arCatalogGroup["ID"] ? true : false);
        $arCatGroup[$arCatalogGroup["ID"]] = $arCatalogGroup;
    }
    $arCatExtra = array();
    $db_extras = CExtra::GetList($by3 = "NAME", $order3 = "ASC");
    while ($extras = $db_extras->Fetch()) {
        $arCatExtra[] = $extras;
    }
}
if ($boolSubBizproc) {
    $arWorkflowTemplates = CBPDocument::GetWorkflowTemplatesForDocumentType(array("iblock", "CIBlockDocument", "iblock_" . $intSubIBlockID));
    foreach ($arWorkflowTemplates as $arTemplate) {
        $arHeader[] = array("id" => "WF_" . $arTemplate["ID"], "content" => $arTemplate["NAME"]);
    }
    $arHeader[] = array("id" => "BIZPROC", "content" => GetMessage("IBEL_A_BP_H"));
    $arHeader[] = array("id" => "BP_PUBLISHED", "content" => GetMessage("IBLOCK_FIELD_BP_PUBLISHED"), "sort" => "status", "default" => true);
}
$lAdmin->AddHeaders($arHeader);
$arSelectedFields = $lAdmin->GetVisibleHeaderColumns();
$arSelectedProps = array();
Ejemplo n.º 11
0
                    array("SORT" => "ASC"), array("LID" => LANGUAGE_ID), false, false, array('ID', 'NAME', 'NAME_LANG')
    );
    while ($arCatalogGroup = $dbCatalogGroups->Fetch()) {
        $arHeader[] = array(
            "id" => "CATALOG_GROUP_" . $arCatalogGroup["ID"],
            "content" => htmlspecialcharsex(!empty($arCatalogGroup["NAME_LANG"]) ? $arCatalogGroup["NAME_LANG"] : $arCatalogGroup["NAME"]),
            "title" => "",
            "align" => "right",
            "sort" => "CATALOG_PRICE_" . $arCatalogGroup["ID"],
            "default" => false,
        );
        $arCatGroup[$arCatalogGroup["ID"]] = $arCatalogGroup;
    }

    $arCatExtra = array();
    $db_extras = CExtra::GetList(($by3 = "NAME"), ($order3 = "ASC"));
    while ($extras = $db_extras->Fetch())
        $arCatExtra[] = $extras;
}

if ($bBizproc) {
    $arWorkflowTemplates = CBPDocument::GetWorkflowTemplatesForDocumentType(array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID));
    foreach ($arWorkflowTemplates as $arTemplate) {
        $arHeader[] = array(
            "id" => "WF_" . $arTemplate["ID"],
            "content" => $arTemplate["NAME"],
        );
    }
    $arHeader[] = array(
        "id" => "BIZPROC",
        "content" => GetMessage("IBEL_A_BP_H"),
Ejemplo n.º 12
0
 function CheckFields($strAction, &$arFields, $ID = 0)
 {
     global $APPLICATION;
     $arMsg = array();
     $boolResult = true;
     if ($strAction != 'ADD' && $strAction != 'UPDATE') {
         $boolResult = false;
     }
     $ID = intval($ID);
     if ($strAction == 'UPDATE' && $ID <= 0) {
         $arMsg[] = $arMsg[] = array('id' => 'ID', 'text' => GetMessage('CAT_EXTRA_ERR_UPDATE_NOT_ID'));
         $boolResult = false;
     }
     if ($boolResult) {
         if (isset($arFields['ID'])) {
             if ($strAction == 'UPDATE') {
                 unset($arFields['ID']);
             } else {
                 $arFields['ID'] = intval($arFields['ID']);
                 if ($arFields['ID'] <= 0) {
                     unset($arFields['ID']);
                 } else {
                     $mxRes = CExtra::GetByID($arFields['ID']);
                     if ($mxRes) {
                         $arMsg[] = $arMsg[] = array('id' => 'ID', 'text' => GetMessage('CAT_EXTRA_ERR_ADD_EXISTS_ID'));
                         $boolResult = false;
                     }
                 }
             }
         }
     }
     if ($boolResult) {
         $arFields["NAME"] = trim($arFields["NAME"]);
         if (empty($arFields["NAME"])) {
             $arMsg[] = array('id' => 'NAME', 'text' => GetMessage('CAT_EXTRA_ERROR_NONAME'));
             $boolResult = false;
         }
         if (empty($arFields["PERCENTAGE"])) {
             $arFields["PERCENTAGE"] = 0;
         }
         $arFields["PERCENTAGE"] = DoubleVal($arFields["PERCENTAGE"]);
     }
     if (!$boolResult) {
         if (!empty($arMsg)) {
             $obError = new CAdminException($arMsg);
             $APPLICATION->ThrowException($obError);
         }
     }
     return $boolResult;
 }
Ejemplo n.º 13
0
									</td>
								</tr>
							</table>
						</td>
					<?endforeach?>
				<?else: ?>
					<tr>
						<td colspan="2" align="center" style="padding: 10px 0px">
							<table cellpadding="0" cellspacing="0" border="0" class="nopadding" width="85%" id="markup_parm_brend">
								<tr>
									<td>
										<span>Название "Бренда":
											<input class="js_input_text" name="brend_name[]" value="" size="20" type="text" />
										</span>
										<span>
											<?= CExtra::SelectBox('brend_markup[]', COption::GetOptionInt('markup', 'type_3', 0), GetMessage('QTZ_MARKUP_NONE')) ?>
										</span>
										<input type="button" value="Удалить параметр" onclick="deleteRow(this, 'markup_parm_brend')" />
									</td>
								</tr>
								<tr>
									<td style="padding: 20px 10px 10px 0px; text-align: right; vertical-align: bottom">
										<input type="button" value="Добавить параметр" onclick="addNewRow('markup_parm_brend')" />
									</td>
								</tr>
							</table>
						</td>
					</tr>
				<?endif?>
				<?break;?>
		<?endswitch;?>
 public static function priceRecalc()
 {
     $dbExtra = CExtra::GetList(array('ID' => 'ASC'));
     while ($extra = $dbExtra->Fetch()) {
         $fields = array('NAME' => $extra['NAME'], 'PERCENTAGE' => $extra['PERCENTAGE'], 'RECALCULATE' => 'Y');
         CExtra::Update($extra['ID'], $fields);
     }
 }
Ejemplo n.º 15
0
                @set_time_limit(0);
                $DB->StartTransaction();
                if (!CExtra::Delete($ID)) {
                    $DB->Rollback();
                    if ($ex = $APPLICATION->GetException()) {
                        $lAdmin->AddGroupError($ex->GetString(), $ID);
                    } else {
                        $lAdmin->AddGroupError(GetMessage("EXTRA_DELETE_ERROR"), $ID);
                    }
                }
                $DB->Commit();
                break;
        }
    }
}
$dbResultList = CExtra::GetList(array($by => $order), $arFilter);
$dbResultList = new CAdminResult($dbResultList, $sTableID);
$dbResultList->NavStart();
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("cat_extra_nav")));
$arHeaders = array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "NAME", "content" => GetMessage("EXTRA_NAME"), "sort" => "NAME", "default" => true), array("id" => "PERCENTAGE", "content" => GetMessage('EXTRA_PERCENTAGE'), "sort" => "PERCENTAGE", "default" => true));
if (!$bReadOnly) {
    $arHeaders[] = array("id" => "RECALCULATE", "content" => GetMessage("EXTRA_RECALCULATE"), "default" => true);
}
$lAdmin->AddHeaders($arHeaders);
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
while ($arExtra = $dbResultList->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arExtra);
    $row->AddField("ID", $f_ID);
    if ($bReadOnly) {
        $row->AddViewField("NAME", $f_NAME);
        $row->AddViewField("PERCENTAGE", $f_PERCENTAGE);