Exemplo n.º 1
0
             }
         }
     }
     if ($bSuccess) {
         $DB->Commit();
     } else {
         $DB->Rollback();
         $arResult['ERROR_MESSAGE'] = !empty($arFields['RESULT_MESSAGE']) ? $arFields['RESULT_MESSAGE'] : GetMessage('UNKNOWN_ERROR');
     }
 }
 if (intval($_POST['SYNC_ORDER_ID']) > 0) {
     $imp = new CCrmExternalSaleImport($originatorId);
     if ($imp->IsInitialized()) {
         $r = $imp->GetOrderData($originId, true);
         if ($r == CCrmExternalSaleImport::SyncStatusError) {
             $arErrors = $imp->GetErrors();
             foreach ($arErrors as $err) {
                 $arResult['ERROR_MESSAGE'] .= $err[1] . '<br />';
             }
         }
     }
 }
 if (empty($arResult['ERROR_MESSAGE'])) {
     if (!$CCrmBizProc->StartWorkflow($arResult['ELEMENT']['ID'], $arBizProcParametersValues)) {
         $arResult['ERROR_MESSAGE'] = $CCrmBizProc->LAST_ERROR;
     }
 }
 $ID = isset($arResult['ELEMENT']['ID']) ? $arResult['ELEMENT']['ID'] : 0;
 if (!empty($arResult['ERROR_MESSAGE'])) {
     ShowError($arResult['ERROR_MESSAGE']);
     $arResult['ELEMENT'] = CCrmComponentHelper::PrepareEntityFields(array_merge(array('ID' => $ID), $arFields), CCrmDeal::GetFields());
Exemplo n.º 2
0
<?php

define('NO_KEEP_STATISTIC', 'Y');
define('NO_AGENT_STATISTIC', 'Y');
require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
if (!CModule::IncludeModule('crm')) {
    die;
}
$CrmPerms = new CCrmPerms($USER->GetID());
if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE') && $CrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE, 'READ')) {
    die("Permission denied");
}
$i = new CCrmExternalSaleImport($_REQUEST["id"]);
$r = $i->SyncOrderData($_REQUEST["skip_bp"] == "Y");
if ($r != CCrmExternalSaleImport::SyncStatusError) {
    echo CUtil::PhpToJSObject(array("result" => $r, "details" => $i->GetImportResult()->ToArray()));
} else {
    $str = '';
    foreach ($i->GetErrors() as $arError) {
        $str .= sprintf("[%s] %s", $arError[0], htmlspecialchars($arError[1])) . "<br>";
    }
    echo CUtil::PhpToJSObject(array("result" => CCrmExternalSaleImport::SyncStatusError, "errors" => $str));
}
require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_after.php';