Exemplo n.º 1
0
 public function execute(array $contextData = null)
 {
     /** @var DealConverter $converter */
     $converter = $this->converter;
     if (is_array($contextData) && !empty($contextData)) {
         $converter->setContextData(array_merge($converter->getContextData(), $contextData));
     }
     $result = false;
     try {
         $converter->initialize();
         do {
             $converter->executePhase();
         } while ($converter->moveToNextPhase());
         $resultData = $converter->getResultData();
         if (isset($resultData[\CCrmOwnerType::InvoiceName])) {
             $this->redirectUrl = \CCrmOwnerType::GetEditUrl(\CCrmOwnerType::Invoice, $resultData[\CCrmOwnerType::InvoiceName], false);
         } elseif (isset($resultData[\CCrmOwnerType::QuoteName])) {
             $this->redirectUrl = \CCrmOwnerType::GetEditUrl(\CCrmOwnerType::Quote, $resultData[\CCrmOwnerType::QuoteName], false);
         }
         $result = true;
     } catch (EntityConversionException $e) {
         $this->exception = $e;
         if ($e->getTargetType() === EntityConversionException::TARG_DST) {
             $this->redirectUrl = \CCrmOwnerType::GetEditUrl($e->getDestinationEntityTypeID(), 0, false) . '?conv_deal_id=' . $converter->getEntityID();
         }
     } catch (\Exception $e) {
         $this->errorText = $e->getMessage();
     }
     $this->save();
     return $result;
 }
Exemplo n.º 2
0
$settingButtonID = "{$prefix}_settings";
$disableDemoModeButtonID = "{$prefix}_disable_demo";
$demoModeInfoCloseButtonID = "{$prefix}_demo_info_close";
$demoModeInfoContainerID = "{$prefix}_demo_info";
if ($arResult['ENABLE_DEMO'] && $arResult['ENTITY_TYPE'] === CCrmOwnerType::DealName) {
    ?>
<div id="<?php 
    echo htmlspecialcharsbx($demoModeInfoContainerID);
    ?>
" class="crm-widg-white-tooltip">
	<div class="crm-widg-white-text"><?php 
    echo GetMessage('CRM_WGT_DEAL_DEMO_TITLE');
    ?>
</div>
	<div class="crm-widg-white-text"><?php 
    echo GetMessage('CRM_WGT_DEAL_DEMO_CONTENT', array('#URL#' => CCrmOwnerType::GetEditUrl(CCrmOwnerType::Deal, 0, false), '#CLASS_NAME#' => 'crm-widg-white-link'));
    ?>
</div>
	<div class="crm-widg-white-text">
		<div id="<?php 
    echo htmlspecialcharsbx($disableDemoModeButtonID);
    ?>
" class="crm-widg-white-bottom-link"><?php 
    echo GetMessage('CRM_WGT_DISABLE_DEMO');
    ?>
</div>
	</div>
	<div id="<?php 
    echo htmlspecialcharsbx($demoModeInfoCloseButtonID);
    ?>
" class="crm-widg-white-close"></div>
Exemplo n.º 3
0
 public static function GetDataForPopup($callId, $phone, $userId = 0)
 {
     if (strlen($phone) <= 0 || !CModule::IncludeModule('crm')) {
         return false;
     }
     if ($userId > 0) {
         $findParams = array('USER_ID' => $userId);
     } else {
         $findParams = array('ENABLE_EXTENDED_MODE' => false);
     }
     $crm = CCrmSipHelper::findByPhoneNumber((string) $phone, $findParams);
     if ($crm) {
         $dealStatuses = CCrmViewHelper::GetDealStageInfos();
         $entity = '';
         $entityData = array();
         $entities = array();
         $arResult = array('FOUND' => 'Y', 'CONTACT' => array(), 'COMPANY' => array(), 'ACTIVITIES' => array(), 'DEALS' => array(), 'RESPONSIBILITY' => array());
         if (isset($crm['CONTACT'])) {
             $entity = 'CONTACT';
             $entityData = $crm[$entity][0];
             $arResult['CONTACT'] = array('NAME' => $entityData['FORMATTED_NAME'], 'POST' => $entityData['POST'], 'PHOTO' => '');
             if (intval($entityData['PHOTO']) > 0) {
                 $arPhoto = CFile::ResizeImageGet($entityData['PHOTO'], array('width' => 37, 'height' => 37), BX_RESIZE_IMAGE_EXACT, false, false, true);
                 $arResult['CONTACT']['PHOTO'] = $arPhoto['src'];
             }
             $arResult['COMPANY'] = $entityData['COMPANY_TITLE'];
             $arResult['CONTACT_DATA'] = array('ID' => $entityData['ID']);
         } else {
             if (isset($crm['LEAD'])) {
                 $entity = 'LEAD';
                 $entityData = $crm[$entity][0];
                 $arResult['CONTACT'] = array('ID' => 0, 'NAME' => !empty($entityData['FORMATTED_NAME']) ? $entityData['FORMATTED_NAME'] : $entityData['TITLE'], 'POST' => $entityData['POST'], 'PHOTO' => '');
                 $arResult['COMPANY'] = $entityData['COMPANY_TITLE'];
                 $arResult['LEAD_DATA'] = array('ID' => $entityData['ID'], 'ASSIGNED_BY_ID' => $entityData['ASSIGNED_BY_ID']);
             } else {
                 if (isset($crm['COMPANY'])) {
                     $entity = 'COMPANY';
                     $entityData = $crm[$entity][0];
                     $arResult['COMPANY'] = $entityData['TITLE'];
                     $arResult['COMPANY_DATA'] = array('ID' => $entityData['ID']);
                 }
             }
         }
         if ($entityData['ASSIGNED_BY_ID'] > 0) {
             $ar = Bitrix\Main\UserTable::getById($entityData['ASSIGNED_BY_ID']);
             if ($user = $ar->fetch()) {
                 $arPhoto = CFile::ResizeImageGet($user['PERSONAL_PHOTO'], array('width' => 37, 'height' => 37), BX_RESIZE_IMAGE_EXACT, false, false, true);
                 $arResult['RESPONSIBILITY'] = array('ID' => $user['ID'], 'NAME' => CUser::FormatName(CSite::GetNameFormat(false), $user, true, false), 'PHOTO' => $arPhoto ? $arPhoto['src'] : '', 'POST' => $user['WORK_POSITION']);
             }
         }
         if (isset($entityData['SHOW_URL'])) {
             $arResult['SHOW_URL'] = $entityData['SHOW_URL'];
         }
         if (isset($entityData['ACTIVITY_LIST_URL'])) {
             $arResult['ACTIVITY_URL'] = $entityData['ACTIVITY_LIST_URL'];
         }
         if (isset($entityData['INVOICE_LIST_URL'])) {
             $arResult['INVOICE_URL'] = $entityData['INVOICE_LIST_URL'];
         }
         if (isset($entityData['DEAL_LIST_URL'])) {
             $arResult['DEAL_URL'] = $entityData['DEAL_LIST_URL'];
         }
         $activityId = CCrmActivity::GetIDByOrigin('VI_' . $callId);
         if ($activityId) {
             $arResult['CURRENT_CALL_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Activity, $activityId);
             if ($arResult['CURRENT_CALL_URL'] !== '') {
                 $arResult['CURRENT_CALL_URL'] = CCrmUrlUtil::AddUrlParams($arResult['CURRENT_CALL_URL'], array("disable_storage_edit" => 'Y'));
             }
         }
         if (isset($crm['CONTACT']) && isset($crm['COMPANY'])) {
             $entities = array('CONTACT', 'COMPANY', 'LEAD');
         } else {
             if (isset($crm['CONTACT']) && isset($crm['LEAD']) && !isset($crm['COMPANY'])) {
                 $entities = array('CONTACT', 'LEAD');
             } else {
                 if (isset($crm['LEAD']) && isset($crm['COMPANY']) && !isset($crm['CONTACT'])) {
                     $entities = array('LEAD', 'COMPANY');
                 } else {
                     $entities = array($entity);
                 }
             }
         }
         foreach ($entities as $entity) {
             if (isset($crm[$entity][0]['ACTIVITIES'])) {
                 foreach ($crm[$entity][0]['ACTIVITIES'] as $activity) {
                     if ($activity['ID'] == $activityId) {
                         continue;
                     }
                     $overdue = 'N';
                     if (strlen($activity['DEADLINE']) > 0 && MakeTimeStamp($activity['DEADLINE']) < time()) {
                         $overdue = 'Y';
                     }
                     $arResult['ACTIVITIES'][$activity['ID']] = array('TITLE' => $activity['SUBJECT'], 'DATE' => strlen($activity['DEADLINE']) > 0 ? $activity['DEADLINE'] : $activity['END_TIME'], 'OVERDUE' => $overdue, 'URL' => $activity['SHOW_URL']);
                 }
                 if (!empty($arResult['ACTIVITIES'])) {
                     $arResult['ACTIVITIES'] = array_values($arResult['ACTIVITIES']);
                 }
             }
             if (isset($crm[$entity][0]['DEALS'])) {
                 foreach ($crm[$entity][0]['DEALS'] as $deal) {
                     $opportunity = CCrmCurrency::MoneyToString($deal['OPPORTUNITY'], $deal['CURRENCY_ID']);
                     if (strpos('&', $opportunity)) {
                         $opportunity = CCrmCurrency::MoneyToString($deal['OPPORTUNITY'], $deal['CURRENCY_ID'], '#') . ' ' . $deal['CURRENCY_ID'];
                     }
                     $opportunity = str_replace('.00', '', $opportunity);
                     $arResult['DEALS'][$deal['ID']] = array('ID' => $deal['ID'], 'TITLE' => $deal['TITLE'], 'STAGE' => $dealStatuses[$deal['STAGE_ID']]['NAME'], 'STAGE_COLOR' => $dealStatuses[$deal['STAGE_ID']]['COLOR'] ? $dealStatuses[$deal['STAGE_ID']]['COLOR'] : "#5fa0ce", 'OPPORTUNITY' => $opportunity, 'URL' => $deal['SHOW_URL']);
                 }
                 if (!empty($arResult['DEALS'])) {
                     $arResult['DEALS'] = array_values($arResult['DEALS']);
                 }
             }
         }
     } else {
         $arResult = array('FOUND' => 'N');
         $userPermissions = CCrmPerms::GetUserPermissions($userId);
         if (CCrmLead::CheckCreatePermission($userPermissions)) {
             $arResult['LEAD_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Lead, 0);
             if ($arResult['LEAD_URL'] !== '') {
                 $arResult['LEAD_URL'] = CCrmUrlUtil::AddUrlParams($arResult['LEAD_URL'], array("phone" => (string) $phone, 'origin_id' => 'VI_' . $callId));
             }
         }
         if (CCrmContact::CheckCreatePermission($userPermissions)) {
             $arResult['CONTACT_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Contact, 0);
             if ($arResult['CONTACT_URL'] !== '') {
                 $arResult['CONTACT_URL'] = CCrmUrlUtil::AddUrlParams($arResult['CONTACT_URL'], array("phone" => (string) $phone, 'origin_id' => 'VI_' . $callId));
             }
         }
     }
     return $arResult;
 }