Exemplo n.º 1
0
 function Delete($ID)
 {
     global $DB;
     $ID = IntVal($ID);
     if ($ID <= 0) {
         return False;
     }
     $db_events = GetModuleEvents("sale", "OnBeforeUserAccountDelete");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             return false;
         }
     }
     $arOldUserAccount = CSaleUserAccount::GetByID($ID);
     $dbTrans = CSaleUserTransact::GetList(array(), array("USER_ID" => $arOldUserAccount["USER_ID"], "CURRENCY" => $arOldUserAccount["CURRENCY"]), false, false, array("ID", "USER_ID"));
     while ($arTrans = $dbTrans->Fetch()) {
         CSaleUserTransact::Delete($arTrans["ID"]);
     }
     unset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE_" . $ID]);
     unset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE1_" . $arOldUserAccount["USER_ID"] . "_" . $arOldUserAccount["CURRENCY"]]);
     $res = $DB->Query("DELETE FROM b_sale_user_account WHERE ID = " . $ID . " ", true);
     $dbEvents = GetModuleEvents("sale", "OnAfterUserAccountDelete");
     while ($arEvent = $dbEvents->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     return $res;
 }
Exemplo n.º 2
0
 function Delete($ID)
 {
     global $DB;
     $ID = IntVal($ID);
     if ($ID <= 0) {
         return False;
     }
     $arOldUserAccount = CSaleUserAccount::GetByID($ID);
     $dbTrans = CSaleUserTransact::GetList(array(), array("USER_ID" => $arOldUserAccount["USER_ID"], "CURRENCY" => $arOldUserAccount["CURRENCY"]), false, false, array("ID", "USER_ID"));
     while ($arTrans = $dbTrans->Fetch()) {
         CSaleUserTransact::Delete($arTrans["ID"]);
     }
     unset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE_" . $ID]);
     unset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE1_" . $arOldUserAccount["USER_ID"] . "_" . $arOldUserAccount["CURRENCY"]]);
     return $DB->Query("DELETE FROM b_sale_user_account WHERE ID = " . $ID . " ", true);
 }
Exemplo n.º 3
0
<?php

if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule('sale')) {
    ShowError(GetMessage("SMOT_SALE_NOT_INSTALLED"));
    return;
}
if (!CModule::IncludeModule('mobileapp')) {
    ShowError("SMOT_MOBILEAPP_NOT_INSTALLED");
    return;
}
if (isset($_REQUEST['id'])) {
    $orderId = $_REQUEST['id'];
} else {
    return;
}
$bUserCanViewOrder = CSaleOrder::CanUserViewOrder($orderId, $GLOBALS["USER"]->GetUserGroupArray(), $GLOBALS["USER"]->GetID());
if (!$bUserCanViewOrder) {
    echo ShowError(GetMessage("SMOT_NO_PERMS2VIEW"));
    return;
}
$arResult["ORDER"] = CSaleMobileOrderUtils::getOrderInfoDetail($orderId);
$arResult["TYPES"] = array("ORDER_PAY" => GetMessage("SMOT_TR_TYPE_PAYMENT"), "CC_CHARGE_OFF" => GetMessage("SMOT_TR_TYPE_FROM_CARD"), "OUT_CHARGE_OFF" => GetMessage("SMOT_TR_TYPE_INPUT"), "ORDER_UNPAY" => GetMessage("SMOT_TR_TYPE_CANCEL_PAYMENT"), "ORDER_CANCEL_PART" => GetMessage("SMOT_TR_TYPE_CANCEL_SEMIPAYMENT"), "MANUAL" => GetMessage("SMOT_TR_TYPE_HAND"), "DEL_ACCOUNT" => GetMessage("SMOT_TR_TYPE_DELETE"), "AFFILIATE" => GetMessage("SMOT_MOBILEAPP_NOT_INSTALLED"));
$dbTransact = CSaleUserTransact::GetList(array("TRANSACT_DATE" => "DESC"), array("ORDER_ID" => $orderId), false, false, array("ID", "USER_ID", "AMOUNT", "CURRENCY", "DEBIT", "ORDER_ID", "DESCRIPTION", "NOTES", "TIMESTAMP_X", "TRANSACT_DATE"));
while ($arTransact = $dbTransact->Fetch()) {
    $arTransact["AMOUNT_PREPARED"] = ($arTransact["DEBIT"] == "Y" ? "+" : "-") . SaleFormatCurrency($arTransact["AMOUNT"], $arTransact["CURRENCY"]);
    $arResult["TRANSACTS"][] = $arTransact;
}
$this->IncludeComponentTemplate();
Exemplo n.º 4
0
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);
}
if (IntVal($filter_order_id) > 0) {
    $arFilter["ORDER_ID"] = IntVal($filter_order_id);
}
$dbTransactList = CSaleUserTransact::GetList(array($by => $order), $arFilter, false, array("nPageSize" => CAdminResult::GetNavSize($sTableID)), array("*"));
$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("STA_TRANS_DATE1"), "sort" => "transact_date", "default" => true), array("id" => "USER_ID", "content" => GetMessage('STA_USER1'), "sort" => "user_id", "default" => true), array("id" => "AMOUNT", "content" => GetMessage("STA_SUM"), "sort" => "amount", "default" => true), array("id" => "ORDER_ID", "content" => GetMessage("STA_ORDER"), "sort" => "order_id", "default" => true), array("id" => "TYPE", "content" => GetMessage("STA_TYPE"), "sort" => "description", "default" => true), array("id" => "DESCR", "content" => GetMessage("STA_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/user_edit.php?ID=" . $f_USER_ID . "&lang=" . LANG . "\" title=\"" . GetMessage("STA_USER_INFO") . "\">" . $f_USER_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["USER_LOGIN"]) . "&nbsp;&nbsp;&nbsp; ";
    $fieldValue .= "<a href=\"mailto:" . htmlspecialcharsEx($arTransact["USER_EMAIL"]) . "\" title=\"" . GetMessage("STA_MAILTO") . "\">" . htmlspecialcharsEx($arTransact["USER_EMAIL"]) . "</a>";
    $row->AddField("USER_ID", $fieldValue);
    $row->AddField("AMOUNT", ($arTransact["DEBIT"] == "Y" ? "+" : "-") . SaleFormatCurrency($arTransact["AMOUNT"], $arTransact["CURRENCY"]) . "<br><small>" . ($arTransact["DEBIT"] == "Y" ? GetMessage("STA_TO_ACCOUNT") : GetMessage("STA_FROM_ACCOUNT")) . "</small>");
Exemplo n.º 5
0
$arResult['REQUEST_DATE_TO'] = trim($_REQUEST['date_to']);
if (CModule::IncludeModule('currency')) {
    $rsCurrency = CCurrency::GetList($by = 'name', $order = 'desc', LANGUAGE_ID);
    while ($arCurrency = $rsCurrency->Fetch()) {
        $arResult['CURRENCY'][$arCurrency['CURRENCY']] = $arCurrency['FULL_NAME'];
    }
    if (count($arResult['CURRENCY']) == 1) {
        $arResult['CURRENCY'] = array();
    }
}
$arFilter = array('USER_ID' => $USER->GetID());
if ($arResult['REQUEST_CURR'] != '') {
    $arFilter['CURRENCY'] = $arResult['REQUEST_CURR'];
}
if ($arResult['REQUEST_DATE_FROM'] != '') {
    $arFilter['>=TRANSACT_DATE'] = $arResult['REQUEST_DATE_FROM'];
}
if ($arResult['REQUEST_DATE_TO'] != '') {
    $arFilter['<=TRANSACT_DATE'] = $arResult['REQUEST_DATE_TO'];
}
$rsTransacts = CSaleUserTransact::GetList(array('TRANSACT_DATE' => 'DESC', 'ID' => 'DESC'), $arFilter, false, false, array('AMOUNT', 'CURRENCY', 'DEBIT', 'DESCRIPTION', 'NOTES', 'ORDER_ID', 'TRANSACT_DATE'));
$rsTransacts->NavStart($arParams['PAGE_COUNT']);
while ($arTransact = $rsTransacts->GetNext()) {
    $arTransact['AMOUNT_FORMATED'] = SaleFormatCurrency($arTransact['AMOUNT'], $arTransact['CURRENCY']);
    $arResult['ITEMS'][] = $arTransact;
}
$arResult['NAV_STRING'] = $rsTransacts->GetPageNavStringEx($navComponentObject, GetMessage('NP_TITLE'), $arParams['PAGER_TEMPLATE']);
if ($arParams['SET_TITLE'] == 'Y') {
    $APPLICATION->SetTitle(GetMessage('SPT_TITLE'));
}
$this->IncludeComponentTemplate();
Exemplo n.º 6
0
        $filter_transact_date_to = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), mktime($arDate["HH"], $arDate["MI"], $arDate["SS"], $arDate["MM"], $arDate["DD"], $arDate["YYYY"]));
        $arFilter["<=TRANSACT_DATE"] = $filter_transact_date_to;
    } else {
        $filter_transact_date_to = "";
    }
}
$nPageSize = CAdminResult::GetNavSize($sTableID);
$dbTransactList = CSaleUserTransact::GetList(array($by => $order), $arFilter, false, array("nPageSize" => $nPageSize), array("*"));
$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("STA_TRANS_DATE1"), "sort" => "transact_date", "default" => true), array("id" => "USER_ID", "content" => GetMessage('STA_USER1'), "sort" => "user_id", "default" => true), array("id" => "AMOUNT", "content" => GetMessage("STA_SUM"), "sort" => "amount", "default" => true), array("id" => "ORDER_ID", "content" => GetMessage("STA_ORDER"), "sort" => "order_id", "default" => true), array("id" => "TYPE", "content" => GetMessage("STA_TYPE"), "sort" => "description", "default" => true), array("id" => "DESCR", "content" => GetMessage("STA_DESCR"), "sort" => "", "default" => true)));
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
$LOCAL_TRANS_USER_CACHE = array();
if (in_array("DESCR", $arVisibleColumns)) {
    $dbTransactList1 = CSaleUserTransact::GetList(array($by => $order), $arFilter, false, array("nPageSize" => $nPageSize), array("ID", "EMPLOYEE_ID"));
    $arTrUsers = array();
    while ($arTransact = $dbTransactList1->Fetch()) {
        $tmpTrans[] = $arTransact;
        if (IntVal($arTransact["EMPLOYEE_ID"]) > 0 && !in_array($arTransact["EMPLOYEE_ID"], $arTrUsers)) {
            $arTrUsers[] = $arTransact["EMPLOYEE_ID"];
        }
    }
    if (!empty($arTrUsers)) {
        $dbUser = CUser::GetList($by = "ID", $or = "ASC", array("ID" => implode(' || ', array_keys($arTrUsers))), array("FIELDS" => array("ID", "LOGIN", "NAME", "LAST_NAME")));
        while ($arUser = $dbUser->Fetch()) {
            $LOCAL_TRANS_USER_CACHE[$arUser["ID"]] = htmlspecialcharsEx($arUser["NAME"] . (strlen($arUser["NAME"]) <= 0 || strlen($arUser["LAST_NAME"]) <= 0 ? "" : " ") . $arUser["LAST_NAME"] . " (" . $arUser["LOGIN"] . ")");
        }
    }
}
while ($arTransact = $dbTransactList->NavNext(true, "f_")) {
Exemplo n.º 7
0
 /**
  * @param Sale\Order $order
  * @return int
  */
 public static function getUserBudgetTransForOrder(Sale\Order $order)
 {
     $ignoreTypes = array(static::BUDGET_TYPE_ORDER_PAY);
     $sumTrans = 0;
     if ($order->getId() > 0) {
         $resTrans = \CSaleUserTransact::GetList(array("TRANSACT_DATE" => "DESC"), array("ORDER_ID" => $order->getId()), false, false, array("AMOUNT", "CURRENCY", "DEBIT"));
         while ($transactDat = $resTrans->Fetch()) {
             if ($transactDat['DEBIT'] == "Y") {
                 $sumTrans += $transactDat['AMOUNT'];
             } else {
                 $sumTrans -= $transactDat['AMOUNT'];
             }
         }
     }
     if ($userBudgetPool = static::getUserBudgetPool($order->getUserId())) {
         foreach ($userBudgetPool->get() as $userBudgetDat) {
             if (in_array($userBudgetDat['TYPE'], $ignoreTypes)) {
                 continue;
             }
             $sumTrans += $userBudgetDat['SUM'];
         }
     }
     return $sumTrans;
 }
Exemplo n.º 8
0
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("SAA_NAV")));
$lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "id", "default" => true), array("id" => "USER_ID", "content" => GetMessage("SAA_USER1"), "sort" => "user_id", "default" => true), array("id" => "CURRENT_BUDGET", "content" => GetMessage('SAA_SUM'), "sort" => "current_budget", "default" => true), array("id" => "LOCKED", "content" => GetMessage("SAAN_LOCK_ACCT"), "sort" => "locked", "default" => true), array("id" => "TRANSACT", "content" => GetMessage("SAAN_TRANSACT"), "sort" => "", "default" => true)));
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
while ($arAccount = $dbResultList->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arAccount, "sale_account_edit.php?ID=" . $f_ID . "&lang=" . LANG . GetFilterParams("filter_"), GetMessage("SAA_UPDATE_ALT"));
    $row->AddField("ID", $f_ID);
    $fieldValue = "[<a href=\"/bitrix/admin/user_edit.php?ID=" . $f_USER_ID . "&lang=" . LANG . "\" title=\"" . GetMessage("SAA_USER_INFO") . "\">" . $f_USER_ID . "</a>] ";
    $fieldValue .= htmlspecialcharsEx($arAccount["USER_NAME"] . (strlen($arAccount["USER_NAME"]) <= 0 || strlen($arAccount["USER_LAST_NAME"]) <= 0 ? "" : " ") . $arAccount["USER_LAST_NAME"]) . "<br>";
    $fieldValue .= htmlspecialcharsEx($arAccount["USER_LOGIN"]) . "&nbsp;&nbsp;&nbsp; ";
    $fieldValue .= "<a href=\"mailto:" . htmlspecialcharsEx($arAccount["USER_EMAIL"]) . "\" title=\"" . GetMessage("SAA_MAILTO") . "\">" . htmlspecialcharsEx($arAccount["USER_EMAIL"]) . "</a>";
    $row->AddField("USER_ID", $fieldValue);
    $row->AddField("CURRENT_BUDGET", SaleFormatCurrency($arAccount["CURRENT_BUDGET"], $arAccount["CURRENCY"]));
    $row->AddField("LOCKED", $arAccount["LOCKED"] != "Y" ? GetMessage("SAA_NO") : GetMessage("SAA_YES"));
    $fieldValue = "";
    if (in_array("TRANSACT", $arVisibleColumns)) {
        $numTrans = CSaleUserTransact::GetList(array(), array("USER_ID" => $f_USER_ID, "CURRENCY" => $f_CURRENCY), array());
        if (IntVal($numTrans) > 0) {
            $fieldValue .= "<a href=\"sale_transact_admin.php?lang=" . LANG . "&filter_user_id=" . $f_USER_ID . "&filter_currency=" . $f_CURRENCY . "&set_filter=Y\" title=\"" . GetMessage("SAA_TRANS_TITLE") . "\">";
            $fieldValue .= IntVal($numTrans);
            $fieldValue .= "</a>";
        } else {
            $fieldValue .= 0;
        }
    }
    $row->AddField("TRANSACT", $fieldValue);
    $arActions = array();
    $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("SAA_UPDATE_ALT"), "ACTION" => $lAdmin->ActionRedirect("sale_account_edit.php?ID=" . $f_ID . "&lang=" . LANG . GetFilterParams("filter_")), "DEFAULT" => true);
    if ($saleModulePermissions >= "W") {
        $arActions[] = array("SEPARATOR" => true);
        $arActions[] = array("ICON" => "delete", "TEXT" => GetMessage("SAA_DELETE_ALT"), "ACTION" => "if(confirm('" . GetMessage('SAA_DELETE_CONFIRM') . "')) " . $lAdmin->ActionDoGroup($f_ID, "delete"));
    }