function CheckFields($ACTION, &$arFields)
 {
     global $DB;
     if ((is_set($arFields, "TAX_ID") || $ACTION == "ADD") && IntVal($arFields["TAX_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGTR_EMPTY_TAX_ID"), "ERROR_NO_TAX_ID");
         return false;
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $arFields["PERSON_TYPE_ID"] = false;
     }
     if (is_set($arFields, "VALUE") || $ACTION == "ADD") {
         $arFields["VALUE"] = str_replace(",", ".", $arFields["VALUE"]);
         $arFields["VALUE"] = DoubleVal($arFields["VALUE"]);
     }
     if ((is_set($arFields, "IS_PERCENT") || $ACTION == "ADD") && $arFields["IS_PERCENT"] != "N") {
         $arFields["IS_PERCENT"] = "Y";
     }
     if ($arFields["IS_PERCENT"] == "Y") {
         $arFields["CURRENCY"] = false;
     } elseif ($arFields["IS_PERCENT"] == "N" && (!is_set($arFields, "CURRENCY") || strlen($arFields["CURRENCY"]) <= 0)) {
         return False;
     } elseif (!is_set($arFields, "IS_PERCENT") && (is_set($arFields, "CURRENCY") && $arFields["CURRENCY"] !== false)) {
         return False;
     }
     if (is_set($arFields, "TAX_ID")) {
         if (!($arTax = CSaleTax::GetByID($arFields["TAX_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["TAX_ID"], GetMessage("SKGTR_NO_TAX")), "ERROR_NO_TAX");
             return false;
         }
     }
     if (is_set($arFields, "PERSON_TYPE_ID") && $arFields["PERSON_TYPE_ID"] !== false) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGTR_NO_PERS_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     if ((is_set($arFields, "IS_IN_PRICE") || $ACTION == "ADD") && $arFields["IS_IN_PRICE"] != "Y") {
         $arFields["IS_IN_PRICE"] = "N";
     }
     if ((is_set($arFields, "ACTIVE") || $ACTION == "ADD") && $arFields["ACTIVE"] != "N") {
         $arFields["ACTIVE"] = "Y";
     }
     if ((is_set($arFields, "APPLY_ORDER") || $ACTION == "ADD") && IntVal($arFields["APPLY_ORDER"]) <= 0) {
         $arFields["APPLY_ORDER"] = "100";
     }
     return true;
 }
Exemple #2
0
$dbResultList = new CAdminResult($dbResultList, $sTableID);
$dbResultList->NavStart();
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("TAX_NAV")));
$lAdmin->AddHeaders(array(array("id" => "ID", "content" => GetMessage("TAX_ID"), "sort" => "id", "default" => true), array("id" => "TIMESTAMP_X", "content" => GetMessage("TAX_TIMESTAMP"), "sort" => "timestamp_x", "default" => true), array("id" => "NAME", "content" => GetMessage("EXEMPT_NAME"), "sort" => "name", "default" => true), array("id" => "DESCRIPTION", "content" => GetMessage("EXEMPT_DESCR"), "sort" => "description", "default" => true), array("id" => "COUNT", "content" => GetMessage("EXEMPT_COUNT"), "sort" => "", "default" => true)));
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
while ($arGroup = $dbResultList->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arGroup);
    $row->AddField("ID", $f_ID);
    $row->AddField("TIMESTAMP_X", $f_TIMESTAMP_X);
    $row->AddField("NAME", "<a href=\"group_admin.php?find_id=" . $f_ID . "&lang=" . LANG . "&set_filter=Y\">" . $f_NAME . "</a>");
    $row->AddField("DESCRIPTION", $f_DESCRIPTION);
    $fieldShow = "";
    if (in_array("COUNT", $arVisibleColumns)) {
        $dbRes = CSaleTax::GetExemptList(array("GROUP_ID" => $f_ID));
        while ($arRes = $dbRes->Fetch()) {
            if ($arTax = CSaleTax::GetByID($arRes["TAX_ID"])) {
                if (strlen($fieldShow) > 0) {
                    $fieldShow .= ", ";
                }
                $fieldShow .= "<a href=\"sale_tax_edit.php?ID=" . $arRes["TAX_ID"] . "&lang=" . LANG . "\">" . htmlspecialcharsbx($arTax["NAME"]) . "</a>";
            }
        }
    }
    if (strlen($fieldShow) <= 0) {
        $fieldShow = "&nbsp;";
    }
    $row->AddField("COUNT", $fieldShow);
    $arActions = array();
    $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("EXEMPT_EDIT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_tax_exempt_edit.php?ID=" . $f_ID . "&lang=" . LANG . GetFilterParams("filter_") . ""), "DEFAULT" => true);
    $row->AddActions($arActions);
}