Exemple #1
0
 private static function PrepareUpdateEvent($fieldName, $arNewRow, $arOldRow, &$arEvents)
 {
     $fieldName = strtoupper(strval($fieldName));
     if ($fieldName === '') {
         return false;
     }
     $typeID = isset($arNewRow['TYPE_ID']) ? intval($arNewRow['TYPE_ID']) : CCrmActivityType::Undefined;
     $changed = false;
     $oldText = $newText = '';
     if ($fieldName === 'NOTIFY') {
         $oldType = isset($arOldRow['NOTIFY_TYPE']) ? intval($arOldRow['NOTIFY_TYPE']) : CCrmActivityNotifyType::None;
         $newType = isset($arNewRow['NOTIFY_TYPE']) ? intval($arNewRow['NOTIFY_TYPE']) : CCrmActivityNotifyType::None;
         $oldVal = isset($arOldRow['NOTIFY_VALUE']) ? intval($arOldRow['NOTIFY_VALUE']) : 0;
         $newVal = isset($arNewRow['NOTIFY_VALUE']) ? intval($arNewRow['NOTIFY_VALUE']) : 0;
         if ($oldType !== $newType || $oldVal !== $newVal) {
             $changed = true;
             $oldText = $oldType === CCrmActivityNotifyType::None ? CCrmActivityNotifyType::ResolveDescription(CCrmActivityNotifyType::None) : strval($oldVal) . ' ' . CCrmActivityNotifyType::ResolveDescription($oldType);
             $newText = $newType === CCrmActivityNotifyType::None ? CCrmActivityNotifyType::ResolveDescription(CCrmActivityNotifyType::None) : strval($newVal) . ' ' . CCrmActivityNotifyType::ResolveDescription($newType);
         }
     } else {
         $old = isset($arOldRow[$fieldName]) ? strval($arOldRow[$fieldName]) : '';
         $new = isset($arNewRow[$fieldName]) ? strval($arNewRow[$fieldName]) : '';
         if (strcmp($old, $new) !== 0) {
             $changed = true;
             $oldText = $old;
             $newText = $new;
             if ($fieldName === 'COMPLETED') {
                 $oldText = CCrmActivityStatus::ResolveDescription($old === 'Y' ? CCrmActivityStatus::Completed : CCrmActivityStatus::Waiting, isset($arOldRow['TYPE_ID']) ? intval($arOldRow['TYPE_ID']) : CCrmActivityType::Undefined);
                 $newText = CCrmActivityStatus::ResolveDescription($new === 'Y' ? CCrmActivityStatus::Completed : CCrmActivityStatus::Waiting, isset($arNewRow['TYPE_ID']) ? intval($arNewRow['TYPE_ID']) : CCrmActivityType::Undefined);
             } elseif ($fieldName === 'PRIORITY') {
                 $oldText = CCrmActivityPriority::ResolveDescription($old);
                 $newText = CCrmActivityPriority::ResolveDescription($new);
             } elseif ($fieldName === 'DIRECTION') {
                 $oldText = CCrmActivityDirection::ResolveDescription($old, $typeID);
                 $newText = CCrmActivityDirection::ResolveDescription($new, $typeID);
             } elseif ($fieldName === 'RESPONSIBLE_ID') {
                 $oldID = intval($old);
                 $arOldUser = array();
                 $newID = intval($new);
                 $arNewUser = array();
                 $dbUser = CUser::GetList($by = 'id', $order = 'asc', array('ID' => "{$oldID}|{$newID}"), array('FIELDS' => array('ID', 'LOGIN', 'EMAIL', 'NAME', 'LAST_NAME', 'SECOND_NAME')));
                 while (is_array($arUser = $dbUser->Fetch())) {
                     $userID = intval($arUser['ID']);
                     if ($userID === $oldID) {
                         $arOldUser = $arUser;
                     } elseif ($userID === $newID) {
                         $arNewUser = $arUser;
                     }
                 }
                 $template = CSite::GetNameFormat(false);
                 $oldText = CUser::FormatName($template, $arOldUser);
                 $newText = CUser::FormatName($template, $arNewUser);
             }
         }
     }
     if ($changed) {
         $typeName = self::ResolveEventTypeName($typeID);
         $name = isset($arNewRow['SUBJECT']) ? strval($arNewRow['SUBJECT']) : '';
         if ($name === '') {
             $name = "[{$arNewRow['ID']}]";
         }
         $arEvents[] = array('EVENT_NAME' => GetMessage("CRM_ACTIVITY_CHANGE_{$typeName}_{$fieldName}", array('#NAME#' => $name)), 'EVENT_TEXT_1' => $oldText !== '' ? $oldText : GetMessage('CRM_ACTIVITY_FIELD_COMPARE_EMPTY'), 'EVENT_TEXT_2' => $newText !== '' ? $newText : GetMessage('CRM_ACTIVITY_FIELD_COMPARE_EMPTY'), 'USER_ID' => isset($arNewRow['EDITOR_ID']) ? $arNewRow['EDITOR_ID'] : 0);
     }
     return $changed;
 }
Exemple #2
0
    ?>
</option>
			<?php 
}
?>
		</select>
	</span>

	<span name="report-filter-value-control-DIRECTION" class="report-filter-vcc">
		<select class="reports-filter-select-small" name="value">
			<option value=""><?php 
echo GetMessage('CRM_REPORT_INCLUDE_ALL');
?>
</option>
			<?php 
$directions = CCrmActivityDirection::GetAllDescriptions(0);
unset($directions[CCrmActivityDirection::Undefined]);
$arResult['enumValues']['DIRECTION'] = $directions;
unset($directions);
?>
			<?php 
foreach ($arResult['enumValues']['DIRECTION'] as $key => $val) {
    ?>
				<option value="<?php 
    echo htmlspecialcharsbx($key);
    ?>
"><?php 
    echo htmlspecialcharsbx($val);
    ?>
</option>
			<?php 
 protected static function getActivityDirectionName($code, $typeID, $htmlEncode = false)
 {
     $name = CCrmActivityDirection::ResolveDescription($code, $typeID);
     return $htmlEncode ? htmlspecialcharsbx($name) : $name;
 }
Exemple #4
0
 public function processMethodRequest($name, $nameDetails, $arParams, $nav, $server)
 {
     $descriptions = null;
     $name = strtoupper($name);
     if ($name === 'OWNERTYPE') {
         $descriptions = CCrmOwnerType::GetDescriptions(array(CCrmOwnerType::Lead, CCrmOwnerType::Deal, CCrmOwnerType::Contact, CCrmOwnerType::Company));
     } elseif ($name === 'CONTENTTYPE') {
         $descriptions = CCrmContentType::GetAllDescriptions();
     } elseif ($name === 'ACTIVITYTYPE') {
         $descriptions = CCrmActivityType::GetAllDescriptions();
     } elseif ($name === 'ACTIVITYPRIORITY') {
         $descriptions = CCrmActivityPriority::GetAllDescriptions();
     } elseif ($name === 'ACTIVITYDIRECTION') {
         $descriptions = CCrmActivityDirection::GetAllDescriptions();
     } elseif ($name === 'ACTIVITYNOTIFYTYPE') {
         $descriptions = CCrmActivityNotifyType::GetAllDescriptions();
     }
     if (!is_array($descriptions)) {
         return parent::processMethodRequest($name, $nameDetails, $arParams, $nav, $server);
     }
     $result = array();
     foreach ($descriptions as $k => &$v) {
         $result[] = array('ID' => $k, 'NAME' => $v);
     }
     unset($v);
     return $result;
 }