Пример #1
0
 public static function LocalComponentCausedUpdater()
 {
     global $stackCacheManager;
     $bResult = true;
     $errMsg = array();
     // at first, check last update version
     if (COption::GetOptionString('crm', '~CRM_QUOTE_14_1_11', 'N') === 'Y') {
         return $bResult;
     }
     try {
         // Copy perms from deals to quotes
         $CCrmRole = new CCrmRole();
         $dbRoles = $CCrmRole->GetList();
         while ($arRole = $dbRoles->Fetch()) {
             $arPerms = $CCrmRole->GetRolePerms($arRole['ID']);
             if (!isset($arPerms['QUOTE']) && is_array($arPerms['DEAL'])) {
                 foreach ($arPerms['DEAL'] as $key => $value) {
                     if (isset($value['-'])) {
                         $arPerms['QUOTE'][$key]['-'] = $value['-'];
                     } else {
                         $arPerms['QUOTE'][$key]['-'] = null;
                     }
                 }
             }
             $arFields = array('RELATION' => $arPerms);
             $CCrmRole->Update($arRole['ID'], $arFields);
         }
         // Create default quote status list (if not exists)
         $arStatus = CCrmStatus::GetStatus('QUOTE_STATUS');
         if (empty($arStatus)) {
             $CCrmStatus = new CCrmStatus('QUOTE_STATUS');
             $arAdd = array(array('NAME' => GetMessage('CRM_QUOTE_STATUS_DRAFT'), 'STATUS_ID' => 'DRAFT', 'SORT' => 10, 'SYSTEM' => 'Y'), array('NAME' => GetMessage('CRM_QUOTE_STATUS_SENT'), 'STATUS_ID' => 'SENT', 'SORT' => 20, 'SYSTEM' => 'N'), array('NAME' => GetMessage('CRM_QUOTE_STATUS_RECEIVED'), 'STATUS_ID' => 'RECEIVED', 'SORT' => 30, 'SYSTEM' => 'N'), array('NAME' => GetMessage('CRM_QUOTE_STATUS_APPROVED'), 'STATUS_ID' => 'APPROVED', 'SORT' => 40, 'SYSTEM' => 'Y'), array('NAME' => GetMessage('CRM_QUOTE_STATUS_UNANSWERED'), 'STATUS_ID' => 'UNANSWERED', 'SORT' => 50, 'SYSTEM' => 'N'), array('NAME' => GetMessage('CRM_QUOTE_STATUS_DECLAINED'), 'STATUS_ID' => 'DECLAINED', 'SORT' => 60, 'SYSTEM' => 'Y'));
             foreach ($arAdd as $ar) {
                 $CCrmStatus->Add($ar);
             }
             $stackCacheManager->Clear('b_crm_status', 'QUOTE_STATUS');
         }
         unset($arStatus);
     } catch (Exception $e) {
         $errMsg[] = $e->getMessage();
     }
     if (empty($errMsg)) {
         COption::SetOptionString('crm', '~CRM_QUOTE_14_1_11', 'Y');
     } else {
         $errString = implode('<br>', $errMsg);
         ShowError($errString);
         $bResult = false;
     }
     return $bResult;
 }
Пример #2
0
                    COption::SetOptionString('crm', '~CRM_INVOICE_PRODUCTS_CONVERTED_12_5_7', 'Y');
                } else {
                    $errMsg[] = Loc::getMessage('CRM_UPDATE_ERR_005');
                    return;
                }
            }
        } else {
            $errMsg[] = Loc::getMessage('CRM_UPDATE_ERR_004');
            return;
        }
    }
}
if (empty($errMsg)) {
    //Copy perms from deals to invoices
    $CCrmRole = new CCrmRole();
    $dbRoles = $CCrmRole->GetList();
    while ($arRole = $dbRoles->Fetch()) {
        $arPerms = $CCrmRole->GetRolePerms($arRole['ID']);
        if (!isset($arPerms['INVOICE']) && is_array($arPerms['DEAL'])) {
            foreach ($arPerms['DEAL'] as $key => $value) {
                if (isset($value['-']) && $value['-'] != 'O') {
                    $arPerms['INVOICE'][$key]['-'] = $value['-'];
                } else {
                    $arPerms['INVOICE'][$key]['-'] = 'X';
                }
            }
        }
        $arFields = array('RELATION' => $arPerms);
        $CCrmRole->Update($arRole['ID'], $arFields);
    }
}