コード例 #1
1
ファイル: ajax.php プロジェクト: mrdeadmouse/u136006
 $arFields = array('TYPE_ID' => $typeID, 'SUBJECT' => $subject, 'COMPLETED' => isset($data['completed']) ? intval($data['completed']) > 0 ? 'Y' : 'N' : 'N', 'PRIORITY' => $priority, 'DESCRIPTION' => $descr, 'DESCRIPTION_TYPE' => CCrmContentType::PlainText, 'LOCATION' => $location, 'DIRECTION' => $direction, 'NOTIFY_TYPE' => CCrmActivityNotifyType::None, 'SETTINGS' => array());
 $arBindings = array("{$ownerTypeName}_{$ownerID}" => array('OWNER_TYPE_ID' => $ownerTypeID, 'OWNER_ID' => $ownerID));
 $notify = isset($data['notify']) ? $data['notify'] : null;
 if (is_array($notify)) {
     $arFields['NOTIFY_TYPE'] = isset($notify['type']) ? intval($notify['type']) : CCrmActivityNotifyType::Min;
     $arFields['NOTIFY_VALUE'] = isset($notify['value']) ? intval($notify['value']) : 15;
 }
 // Communications
 $arComms = array();
 if ($commEntityID <= 0 && $commType === 'PHONE' && $ownerTypeName !== 'DEAL') {
     // Communication entity ID is 0 (processing of new communications)
     // Communication type must present it determines TYPE_ID (is only 'PHONE' in current context)
     // Deal does not have multi fields.
     $fieldMulti = new CCrmFieldMulti();
     $arFieldMulti = array('ENTITY_ID' => $ownerTypeName, 'ELEMENT_ID' => $ownerID, 'TYPE_ID' => 'PHONE', 'VALUE_TYPE' => 'WORK', 'VALUE' => $commValue);
     $fieldMultiID = $fieldMulti->Add($arFieldMulti);
     if ($fieldMultiID > 0) {
         $commEntityType = $ownerTypeName;
         $commEntityID = $ownerID;
     }
 }
 if ($commEntityType !== '') {
     $arComms[] = array('ID' => $commID, 'TYPE' => $commType, 'VALUE' => $commValue, 'ENTITY_ID' => $commEntityID, 'ENTITY_TYPE_ID' => CCrmOwnerType::ResolveID($commEntityType));
     $bindingKey = $commEntityID > 0 ? "{$commEntityType}_{$commEntityID}" : uniqid("{$commEntityType}_");
     if (!isset($arBindings[$bindingKey])) {
         $arBindings[$bindingKey] = array('OWNER_TYPE_ID' => CCrmOwnerType::ResolveID($commEntityType), 'OWNER_ID' => $commEntityID);
     }
 }
 $isNew = $ID <= 0;
 $arPreviousFields = $ID > 0 ? CCrmActivity::GetByID($ID) : array();
 $storageTypeID = isset($data['storageTypeID']) ? intval($data['storageTypeID']) : CCrmActivityStorageType::Undefined;