Exemplo n.º 1
0
 public static function Update($ID, $arFields)
 {
     global $DB;
     $ID = IntVal($ID);
     if ($ID <= 0) {
         return False;
     }
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CSaleAffiliateTransact::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     }
     $strUpdate = $DB->PrepareUpdate("b_sale_affiliate_transact", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($strUpdate) > 0) {
             $strUpdate .= ", ";
         }
         $strUpdate .= $key . "=" . $value . " ";
     }
     $strSql = "UPDATE b_sale_affiliate_transact SET " . $strUpdate . " WHERE ID = " . $ID . " ";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     return $ID;
 }
Exemplo n.º 2
0
 function Add($arFields)
 {
     global $DB;
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CSaleAffiliateTransact::CheckFields("ADD", $arFields, 0)) {
         return false;
     }
     $arInsert = $DB->PrepareInsert("b_sale_affiliate_transact", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($arInsert[0]) > 0) {
             $arInsert[0] .= ", ";
         }
         $arInsert[0] .= $key;
         if (strlen($arInsert[1]) > 0) {
             $arInsert[1] .= ", ";
         }
         $arInsert[1] .= $value;
     }
     $strSql = "INSERT INTO b_sale_affiliate_transact(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $ID = IntVal($DB->LastID());
     return $ID;
 }
Exemplo n.º 3
0
         }
         $arResult["CURRENT_PAGE_PARAM"] = $APPLICATION->GetCurPageParam("", array("filter_date_from", "filter_date_to"));
         $arResult["CURRENT_PAGE"] = $APPLICATION->GetCurPage();
         $arResult["CURRENT_DATE"] = date($DB->DateFormatToPHP(CSite::GetDateFormat("SHORT")), time());
         $arResult["PAID_SUM_INCOME"] = $arAffiliate["PAID_SUM"] >= 0 ? SaleFormatCurrency($arAffiliate["PAID_SUM"], $affiliateCurrency) : "";
         $arResult["PAID_SUM_OUTCOME"] = $arAffiliate["PAID_SUM"] < 0 ? SaleFormatCurrency(-$arAffiliate["PAID_SUM"], $affiliateCurrency) : "";
         $arResult["FILTER"] = array("filter_date_from" => $filter_date_from, "filter_date_to" => $filter_date_to);
         $arFilter = array("AFFILIATE_ID" => $arAffiliate["ID"]);
         if (StrLen($filter_date_from) > 0) {
             $arFilter[">=TRANSACT_DATE"] = Trim($filter_date_from);
         }
         if (StrLen($filter_date_to) > 0) {
             $arFilter["<=TRANSACT_DATE"] = Trim($filter_date_to);
         }
         $arResult["TRANSACT"] = array();
         $dbTransactList = CSaleAffiliateTransact::GetList(array("TRANSACT_DATE" => "ASC"), $arFilter, false, false, array("ID", "TRANSACT_DATE", "AMOUNT", "CURRENCY", "DEBIT", "DESCRIPTION"));
         while ($arTransactList = $dbTransactList->GetNext()) {
             $arTransactList["AMOUNT_FORMAT"] = SaleFormatCurrency($arTransactList["AMOUNT"], $arTransactList["CURRENCY"]);
             $arTransactList["AMOUNT_INCOME"] = $arTransactList["DEBIT"] == "Y" ? $arTransactList["AMOUNT_FORMAT"] : "";
             $arTransactList["AMOUNT_OUTCOME"] = $arTransactList["DEBIT"] != "Y" ? $arTransactList["AMOUNT_FORMAT"] : "";
             $arTransactList["DESCRIPTION_NOTES"] = array_key_exists($arTransactList["DESCRIPTION"], $arTransactTypes) ? $arTransactTypes[$arTransactList["DESCRIPTION"]] : "";
             $arResult["TRANSACT"][] = $arTransactList;
         }
         $arResult["FILTER_ID"] = rand(0, 10000);
     } else {
         $arResult = False;
     }
     $this->IncludeComponentTemplate();
 } else {
     LocalRedirect($arParams["REGISTER_PAGE"] . "?REDIRECT_PAGE=" . UrlEncode($APPLICATION->GetCurPage()));
     die;
Exemplo n.º 4
0
 function ClearAffiliateSum($affiliate)
 {
     global $DB;
     $arAffiliate = CSaleAffiliate::CheckAffiliateFunc($affiliate);
     if (!$arAffiliate) {
         return False;
     }
     $arAffiliate["PAID_SUM"] = str_replace(",", ".", $arAffiliate["PAID_SUM"]);
     $arAffiliate["PAID_SUM"] = DoubleVal($arAffiliate["PAID_SUM"]);
     if ($arAffiliate["PAID_SUM"] > 0) {
         if (!array_key_exists("BASE_LANG_CURRENCIES", $GLOBALS)) {
             $GLOBALS["BASE_LANG_CURRENCIES"] = array();
         }
         if (!array_key_exists($arAffiliate["SITE_ID"], $GLOBALS["BASE_LANG_CURRENCIES"])) {
             $GLOBALS["BASE_LANG_CURRENCIES"][$arAffiliate["SITE_ID"]] = CSaleLang::GetLangCurrency($arAffiliate["SITE_ID"]);
         }
         if (!CSaleAffiliate::Update($arAffiliate["ID"], array("PAID_SUM" => 0))) {
             if ($ex = $GLOBALS["APPLICATION"]->GetException()) {
                 $GLOBALS["APPLICATION"]->ThrowException($ex->GetString(), "AF_UPDATE_ERROR");
             } else {
                 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("ACGA1_ERROR_UPDATE_SUM"), "AF_UPDATE_ERROR");
             }
             return False;
         }
         $arFields = array("AFFILIATE_ID" => $arAffiliate["ID"], "TRANSACT_DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))), "AMOUNT" => $arAffiliate["PAID_SUM"], "CURRENCY" => $GLOBALS["BASE_LANG_CURRENCIES"][$arAffiliate["SITE_ID"]], "DEBIT" => "N", "DESCRIPTION" => "AFFILIATE_CLEAR", "EMPLOYEE_ID" => $GLOBALS["USER"]->IsAuthorized() ? $GLOBALS["USER"]->GetID() : False);
         CSaleAffiliateTransact::Add($arFields);
     }
     return True;
 }
Exemplo n.º 5
0
if (IntVal($filter_affiliate_id) > 0) {
    $arFilter["AFFILIATE_ID"] = IntVal($filter_affiliate_id);
}
if (strlen($filter_user) > 0) {
    $arFilter["%USER_USER"] = $filter_user;
}
if (strlen($filter_currency) > 0) {
    $arFilter["CURRENCY"] = $filter_currency;
}
if (strlen($filter_transact_date_from) > 0) {
    $arFilter[">=TRANSACT_DATE"] = Trim($filter_transact_date_from);
}
if (strlen($filter_transact_date_to) > 0) {
    $arFilter["<=TRANSACT_DATE"] = Trim($filter_transact_date_to);
}
$dbTransactList = CSaleAffiliateTransact::GetList(array($by => $order), $arFilter, false, array("nPageSize" => CAdminResult::GetNavSize($sTableID)), array("ID", "AFFILIATE_ID", "TIMESTAMP_X", "TRANSACT_DATE", "AMOUNT", "CURRENCY", "DEBIT", "DESCRIPTION", "EMPLOYEE_ID", "AFFILIATE_SITE_ID", "USER_LOGIN", "USER_NAME", "USER_LAST_NAME", "USER_EMAIL"));
$dbTransactList = new CAdminResult($dbTransactList, $sTableID);
$dbTransactList->NavStart();
$lAdmin->NavText($dbTransactList->GetNavPrint(GetMessage("STA_NAV")));
$lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "TRANSACT_DATE", "content" => GetMessage("SAT2_TRANSACT_DATE"), "sort" => "TRANSACT_DATE", "default" => true), array("id" => "AFFILIATE_ID", "content" => GetMessage("SAT2_AFFILIATE"), "sort" => "AFFILIATE_ID", "default" => true), array("id" => "AMOUNT", "content" => GetMessage("SAT2_SUM"), "sort" => "AMOUNT", "default" => true), array("id" => "TYPE", "content" => GetMessage("SAT2_TYPE"), "sort" => "DESCRIPTION", "default" => true), array("id" => "DESCR", "content" => GetMessage("SAT2_DESCR"), "sort" => "", "default" => true)));
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
while ($arTransact = $dbTransactList->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arTransact);
    $row->AddField("ID", $f_ID);
    $row->AddField("TRANSACT_DATE", $f_TRANSACT_DATE);
    $fieldValue = "[<a href=\"/bitrix/admin/sale_affiliate_edit.php?ID=" . $f_AFFILIATE_ID . "&lang=" . LANG . "\" title=\"" . GetMessage("SAT2_AFF_PROFILE") . "\">" . $f_AFFILIATE_ID . "</a>] ";
    $fieldValue .= htmlspecialcharsEx($arTransact["USER_NAME"] . (strlen($arTransact["USER_NAME"]) <= 0 || strlen($arTransact["USER_LAST_NAME"]) <= 0 ? "" : " ") . $arTransact["USER_LAST_NAME"]) . "<br>";
    $fieldValue .= htmlspecialcharsEx($arTransact["AFFILIATE_SITE_ID"]) . "&nbsp;&nbsp;&nbsp; ";
    $fieldValue .= htmlspecialcharsEx($arTransact["USER_LOGIN"]) . "&nbsp;&nbsp;&nbsp; ";
    $fieldValue .= "<a href=\"mailto:" . htmlspecialcharsEx($arTransact["USER_EMAIL"]) . "\" title=\"" . GetMessage("SAT2_MAIL") . "\">" . htmlspecialcharsEx($arTransact["USER_EMAIL"]) . "</a>";
    $row->AddField("AFFILIATE_ID", $fieldValue);