Ejemplo n.º 1
0
                 CCurrencyLang::Update($currencyID, $k, $locFields);
             } else {
                 $locFields['DECIMALS'] = 2;
                 //Default decimals
                 CCurrencyLang::Add($locFields);
             }
         }
     }
     if ($result) {
         if ($currency['IS_ACCOUNTING_CURRENCY'] && $currencyID !== CCrmCurrency::GetAccountCurrencyID()) {
             CCrmCurrency::SetAccountCurrencyID($currencyID);
         } elseif (!$currency['IS_ACCOUNTING_CURRENCY'] && $currencyID === CCrmCurrency::GetAccountCurrencyID()) {
             CCrmCurrency::SetAccountCurrencyID(CCrmCurrency::GetBaseCurrencyID());
         }
         if ($currency['IS_INVOICE_CURRENCY'] && $currencyID !== CCrmCurrency::getInvoiceDefault()) {
             CCrmCurrency::setInvoiceDefault($currencyID);
         }
         LocalRedirect(isset($_POST['apply']) ? CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CURRENCY_EDIT'], array('currency_id' => $currencyID)) : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CURRENCY_LIST'], array('currency_id' => $currencyID)));
     }
 } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['delete'])) {
     $currencyID = isset($arParams['CURRENCY_ID']) ? strval($arParams['CURRENCY_ID']) : '';
     $currency = isset($currencyID[0]) ? CCrmCurrency::GetByID($currencyID) : null;
     if ($currency) {
         if (!CCrmCurrency::Delete($currencyID)) {
             $err = CCrmCurrency::GetLastError();
             ShowError(isset($err[0]) ? $err : GetMessage('CRM_CURRENCY_DELETE_UNKNOWN_ERROR'));
             return;
         }
     }
     LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CURRENCY_LIST'], array()));
 }