Exemple #1
0
 public static function RemoveVisibleColumn($gridID, $columnName)
 {
     if ($gridID == '' || $columnName == '') {
         return false;
     }
     $item = new CCrmGridOptions($gridID);
     $columns = $item->GetVisibleColumns();
     if (empty($columns)) {
         return false;
     }
     $index = array_search($columnName, $columns, true);
     if ($index === false) {
         return false;
     }
     array_splice($columns, $index, 1);
     $item->SetVisibleColumns($columns);
     return true;
 }
Exemple #2
0
                if (($k = array_search($_GET['REL_ID'], $arUserFields['UF_CRM_CAL_EVENT']['VALUE'])) !== false) {
                    unset($arUserFields['UF_CRM_CAL_EVENT']['VALUE'][$k]);
                    $USER_FIELD_MANAGER->Update('CALENDAR_EVENT', $_GET['ID'], array('UF_CRM_CAL_EVENT' => $arUserFields['UF_CRM_CAL_EVENT']['VALUE']));
                }
            } else {
                CCalendar::DeleteEvent($_GET['ID']);
            }
        }
        unset($_GET['ID'], $_POST['ID'], $_REQUEST['ID']);
        // otherwise the filter will work
    }
    if (!isset($_GET['AJAX_CALL'])) {
        LocalRedirect($bInternal ? '?' . $arParams['FORM_ID'] . '_active_tab=tab_activity' : '');
    }
}
$CGridOptions = new CCrmGridOptions($arResult['GRID_ID']);
if (isset($_REQUEST['clear_filter']) && $_REQUEST['clear_filter'] == 'Y') {
    $urlParams = array();
    foreach ($arResult['FILTER'] as $id => $arFilter) {
        if ($arFilter['type'] == 'user') {
            $urlParams[] = $arFilter['id'];
            $urlParams[] = $arFilter['id'] . '_name';
        } else {
            $urlParams[] = $arFilter['id'];
        }
    }
    $urlParams[] = 'clear_filter';
    $CGridOptions->GetFilter(array());
    LocalRedirect($APPLICATION->GetCurPageParam('', $urlParams));
}
$arNav = $CGridOptions->GetNavParams($arNavParams);
Exemple #3
0
                $fields['SETTINGS']['DEFAULT_VALUE']['VALUE'] = $data['DT_DEFAULT_VALUE'];
            }
            if (isset($data['DT_TYPE']) && $data['DT_TYPE'] !== '') {
                $fields['SETTINGS']['DEFAULT_VALUE']['TYPE'] = $data['DT_TYPE'];
            }
            break;
    }
    $fields['EDIT_FORM_LABEL'] = array();
    $fields['LIST_COLUMN_LABEL'] = array();
    $fields['LIST_FILTER_LABEL'] = array();
    $langDbResult = CLanguage::GetList($by = '', $order = '');
    while ($lang = $langDbResult->Fetch()) {
        $lid = $lang['LID'];
        $fields['EDIT_FORM_LABEL'][$lid] = $fields['LIST_COLUMN_LABEL'][$lid] = $fields['LIST_FILTER_LABEL'][$lid] = $formLabel;
    }
    global $USER_FIELD_MANAGER;
    $crmFields = new CCrmFields($USER_FIELD_MANAGER, $entityID);
    $fieldName = $fields['FIELD_NAME'] = $crmFields->GetNextFieldId();
    $userField = new CUserTypeEntity();
    $fieldID = $userField->Add($fields);
    if ($fieldID > 0) {
        CCrmGridOptions::AddVisibleColumn(CCrmGridOptions::GetDefaultGrigID(CCrmOwnerType::ResolveIDByUFEntityID($entityID)), $fieldName);
        //Clear components cache
        $GLOBALS['CACHE_MANAGER']->ClearByTag("crm_fields_list_{$entityID}");
        __CrmConfigFieldEditEndResonse(array('RESULT' => array('ID' => $fieldID, 'FIELD_NAME' => $fieldName)));
    } else {
        __CrmConfigFieldEditEndResonse(array('ERROR' => "Could not create user feld."));
    }
} else {
    __CrmConfigFieldEditEndResonse(array('ERROR' => "Action '{$action}' is not supported in current context."));
}
Exemple #4
0
}
$arResult['UID'] = $arParams['UID'];
$sort = array('LAST_NAME' => 'ASC', 'NAME' => 'ASC');
$select = array('ID', 'NAME', 'PRICE', 'CURRENCY_ID', 'SECTION_ID');
$filter = array('CATALOG_ID' => $catalogID);
if ($activeSectionID > 0) {
    $filter['SECTION_ID'] = $activeSectionID;
}
$itemPerPage = isset($arParams['ITEM_PER_PAGE']) ? intval($arParams['ITEM_PER_PAGE']) : 0;
if ($itemPerPage <= 0) {
    $itemPerPage = 20;
}
$arParams['ITEM_PER_PAGE'] = $itemPerPage;
$navParams = array('nPageSize' => $itemPerPage, 'iNumPage' => $enablePaging ? false : 1, 'bShowAll' => false);
$navigation = CDBResult::GetNavParams($navParams);
$CGridOptions = new CCrmGridOptions($arResult['UID']);
$navParams = $CGridOptions->GetNavParams($navParams);
$navParams['bShowAll'] = !$enablePaging;
if ($enableSearch) {
    $filter += $CGridOptions->GetFilter(array(array('id' => 'NAME')));
    if (!empty($filter)) {
        if (isset($filter['NAME'])) {
            $filter['%NAME'] = $filter['NAME'];
            unset($filter['NAME']);
        }
    } else {
        $enableSearch = $arResult['ENABLE_SEARCH'] = false;
    }
}
$arResult['PRODUCTS'] = array();
$arPricesSelect = $arVatsSelect = array();
Exemple #5
0
    if (isset($_REQUEST['CREATED_BY_ID_name']) && $_REQUEST['CREATED_BY_ID_name'] === '') {
        $_REQUEST['CREATED_BY_ID'] = $_GET['CREATED_BY_ID'] = array();
    }
    if (isset($_REQUEST['MODIFY_BY_ID_name']) && $_REQUEST['MODIFY_BY_ID_name'] === '') {
        $_REQUEST['MODIFY_BY_ID'] = $_GET['MODIFY_BY_ID'] = array();
    }
    if (isset($_REQUEST['ASSIGNED_BY_ID_name']) && $_REQUEST['ASSIGNED_BY_ID_name'] === '') {
        $_REQUEST['ASSIGNED_BY_ID'] = $_GET['ASSIGNED_BY_ID'] = array();
    }
}
if (intval($arParams['CONTACT_COUNT']) <= 0) {
    $arParams['CONTACT_COUNT'] = 20;
}
$arNavParams = array('nPageSize' => $arParams['CONTACT_COUNT']);
$arNavigation = CDBResult::GetNavParams($arNavParams);
$CGridOptions = new CCrmGridOptions($arResult['GRID_ID'], $arResult['FILTER_PRESETS']);
$arNavParams = $CGridOptions->GetNavParams($arNavParams);
$arNavParams['bShowAll'] = false;
$arFilter += $CGridOptions->GetFilter($arResult['FILTER']);
$USER_FIELD_MANAGER->AdminListAddFilter(CCrmContact::$sUFEntityID, $arFilter);
// converts data from filter
if (isset($arFilter['FIND_list']) && !empty($arFilter['FIND'])) {
    $arFilter[strtoupper($arFilter['FIND_list'])] = $arFilter['FIND'];
    unset($arFilter['FIND_list'], $arFilter['FIND']);
}
CCrmEntityHelper::PrepareMultiFieldFilter($arFilter);
$arImmutableFilters = array('FM', 'ID', 'COMPANY_ID', 'ASSIGNED_BY_ID', 'CREATED_BY_ID', 'MODIFY_BY_ID', 'TYPE_ID', 'SOURCE_ID');
foreach ($arFilter as $k => $v) {
    if (in_array($k, $arImmutableFilters, true)) {
        continue;
    }
Exemple #6
0
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST[$postAction])) {
    if (isset($_POST['ID']) && is_array($_POST['ID'])) {
        $arTargetItemID = $_POST['ID'];
    }
    unset($_POST['ID'], $_REQUEST['ID']);
}
$arSelect = array();
$arSort = array('DEADLINE' => 'ASC');
$arNavParams = false;
if ($enableNavigation) {
    $arNavParams = array('nPageSize' => $arParams['ITEM_COUNT']);
    if ($topCount > 0) {
        $arNavParams['nTopCount'] = $topCount;
    }
    $arNavigation = CDBResult::GetNavParams($arNavParams);
    $CGridOptions = new CCrmGridOptions($arResult['UID'], $arResult['FILTER_PRESETS']);
    $arNavParams = $CGridOptions->GetNavParams($arNavParams);
    $arNavParams['bShowAll'] = false;
    if (($arResult['TAB_ID'] === '' || $arResult['TAB_ID'] === $activeTabID) && isset($_REQUEST['clear_filter']) && $_REQUEST['clear_filter'] === 'Y') {
        $urlParams = array();
        foreach ($arResult['FILTER'] as $arFilterField) {
            $filterFieldID = $arFilterField['id'];
            if ($arFilterField['type'] == 'user') {
                $urlParams[] = $filterFieldID . '_name';
            }
            if ($arFilterField['type'] == 'date') {
                $urlParams[] = $filterFieldID . '_datesel';
                $urlParams[] = $filterFieldID . '_days';
                $urlParams[] = $filterFieldID . '_from';
                $urlParams[] = $filterFieldID . '_to';
            }
Exemple #7
0
$sEmailFrom = COption::GetOptionString('crm', 'email_from');
if (strlen($sEmailFrom) === 0) {
    // Using current user email
    $userName = $USER->GetFullName();
    $sEmailFrom = strlen($userName) > 0 ? $USER->GetFullName() . ' <' . $USER->GetEmail() . '>' : $USER->GetEmail();
}
$arResult['EMAIL_FROM'] = $sEmailFrom;
$arResult['COMMENTS'] = COption::GetOptionString('crm', 'email_template');
if ($arResult['ENTITY_ID'] == 'all') {
    $eventPage = isset($_REQUEST['EVENT_PAGE']) ? $_REQUEST['EVENT_PAGE'] : '';
    if ($eventPage !== '') {
        // HACK: for filter unique id
        $arUrl = parse_url($eventPage);
        $GLOBALS['APPLICATION']->SetCurPage($arUrl['path']);
    }
    $CGridOptions = new CCrmGridOptions('CRM_' . $arResult['ENTITY_TYPE'] . '_LIST');
    $arFilter = $CGridOptions->GetFilter(is_array($arResult['FILTER']) ? $arResult['FILTER'] : array());
    // converts data from filter
    if (isset($arFilter['FIND_list']) && !empty($arFilter['FIND'])) {
        $arFilter[strtoupper($arFilter['FIND_list'])] = $arFilter['FIND'];
        unset($arFilter['FIND_list'], $arFilter['FIND']);
    }
    // Preparing to filter by entity multi fields
    CCrmEntityHelper::PrepareMultiFieldFilter($arFilter);
    $arImmutableFilters = array('FM', 'ID', 'COMPANY_ID', 'CURRENCY_ID', 'CONTACT_ID', 'ASSIGNED_BY_ID', 'CREATED_BY_ID', 'MODIFY_BY_ID', 'PRODUCT_ROW_PRODUCT_ID');
    $arFilter2logic = array('TITLE', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'POST', 'ADDRESS', 'COMMENTS', 'BANKING_DETAILS', 'COMPANY_TITLE');
    foreach ($arFilter as $k => $v) {
        if (in_array($k, $arImmutableFilters, true)) {
            continue;
        }
        $arMatch = array();
Exemple #8
0
} else {
    $exists = intval($locID > 0) && is_array(CCrmLocations::GetByID($locID));
}
########################
########################
########################
// LIST
if ($arParams['TYPE'] == 'list') {
    $parentId = false;
    // STEP UP IN LIST
    if (CSaleLocation::isLocationProEnabled()) {
        $filterParentId = false;
        if (isset($_REQUEST['PARENT_ID'])) {
            $filterParentId = intval($_REQUEST['PARENT_ID']);
        } else {
            $gridOpts = new CCrmGridOptions('CRM_LOC_LIST');
            $filter = $gridOpts->GetFilter(array());
            if (isset($filter['PARENT_ID'])) {
                $filterParentId = intval($filter['PARENT_ID']);
            }
        }
        if ($filterParentId !== false) {
            $res = Location\LocationTable::getByID($filterParentId)->fetch();
            if (!!$res['ID']) {
                $parentId = intval($res['PARENT_ID']);
                $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_LOC_STEP_UP'), 'TITLE' => GetMessage('CRM_LOC_STEP_UP_TITLE'), 'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_LIST'], array()) . '?PARENT_ID=' . $parentId, 'ICON' => 'btn-list');
            }
        }
    }
    // ADD IN LIST
    if ($locAdd) {
Exemple #9
0
             if (strpos($k, '~') === 0) {
                 continue;
             }
             $arField[$k] = $v;
         }
         if (empty($arField)) {
             continue;
         }
         if (!$CCrmFields->UpdateField($ID, $arField)) {
             continue;
         }
         if (isset($arField['SHOW_IN_LIST']) && $arField['SHOW_IN_LIST'] !== $arPresetField['SHOW_IN_LIST']) {
             if ($arField['SHOW_IN_LIST'] === 'Y') {
                 CCrmGridOptions::AddVisibleColumn($gridID, $arPresetField['FIELD_NAME']);
             } else {
                 CCrmGridOptions::RemoveVisibleColumn($gridID, $arPresetField['FIELD_NAME']);
             }
         }
     }
     unset($arPostField);
     //Clear components cache
     $CACHE_MANAGER->ClearByTag('crm_fields_list_' . $arResult['ENTITY_ID']);
 }
 if ($_POST['action_all_rows_' . $arResult['GRID_ID']] == 'Y' && $_POST['action_button_' . $arResult['GRID_ID']] == 'delete') {
     $arFields = $CCrmFields->GetFields();
     foreach ($arFields as $ID => $arField) {
         $CCrmFields->DeleteField($arField['ID']);
     }
     //Clear components cache
     $CACHE_MANAGER->ClearByTag('crm_fields_list_' . $arResult['ENTITY_ID']);
 }
Exemple #10
0
$arParams['PATH_TO_PRODUCTPROPS_LIST'] = CrmCheckPath('PATH_TO_PRODUCTPROPS_LIST', $arParams['PATH_TO_PRODUCTPROPS_LIST'], '');
$arParams['PATH_TO_PRODUCTPROPS_ADD'] = CrmCheckPath('PATH_TO_PRODUCTPROPS_ADD', $arParams['PATH_TO_PRODUCTPROPS_ADD'], '?add');
$arParams['PATH_TO_PRODUCTPROPS_EDIT'] = CrmCheckPath('PATH_TO_PRODUCTPROPS_EDIT', $arParams['PATH_TO_PRODUCTPROPS_EDIT'], '?prop_id=#prop_id#&edit');
$arResult['GRID_ID'] = 'CRM_PRODUCTPROPS_LIST';
$arResult['FORM_ID'] = isset($arParams['FORM_ID']) ? $arParams['FORM_ID'] : '';
$arResult['TAB_ID'] = isset($arParams['TAB_ID']) ? $arParams['TAB_ID'] : '';
$arPropType = array('' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_ALL'), 'S' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_S'), 'N' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_N'), 'L' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_L'), 'F' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_F'), 'E' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_E'));
$arUserTypeList = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'edit');
\Bitrix\Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
foreach ($arUserTypeList as $arUserType) {
    $arPropType[$arUserType['PROPERTY_TYPE'] . ':' . $arUserType['USER_TYPE']] = $arUserType['DESCRIPTION'];
}
$arResult['HEADERS'] = array(array('id' => 'ID', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_ID'), 'sort' => 'id', 'align' => 'right', 'default' => true, 'editable' => false), array('id' => 'NAME', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_NAME'), 'sort' => 'name', 'default' => true, 'editable' => true), array('id' => 'PROPERTY_TYPE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_PROPERTY_TYPE'), 'default' => true, 'editable' => false, 'type' => 'list'), array('id' => 'SORT', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_SORT'), 'sort' => 'sort', 'align' => 'right', 'default' => true, 'editable' => true), array('id' => 'ACTIVE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_ACTIVE'), 'sort' => 'active', 'align' => 'center', 'default' => true, 'editable' => true, 'type' => 'checkbox'), array('id' => 'IS_REQUIRED', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_IS_REQUIRED'), 'align' => 'center', 'default' => true, 'editable' => true, 'type' => 'checkbox'), array('id' => 'MULTIPLE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_MULTIPLE'), 'align' => 'center', 'default' => true, 'editable' => true, 'type' => 'checkbox'), array('id' => 'XML_ID', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_XML_ID'), 'editable' => true));
$arResult['FILTER_PRESETS'] = array();
$arResult['FILTER'] = array(array('id' => 'NAME', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_NAME'), 'default' => true), array('id' => 'ACTIVE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_ACTIVE'), 'type' => 'list', 'items' => array('' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_ALL'), 'Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'))), array('id' => 'IS_REQUIRED', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_IS_REQUIRED'), 'type' => 'list', 'items' => array('' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_ALL'), 'Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'))), array('id' => 'MULTIPLE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_MULTIPLE'), 'type' => 'list', 'items' => array('' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_ALL'), 'Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'))), array('id' => 'XML_ID', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_XML_ID')), array('id' => 'PROPERTY_TYPE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_PROPERTY_TYPE'), 'type' => 'list', 'items' => $arPropType));
$CGridOptions = new CCrmGridOptions($arResult['GRID_ID']);
$arFilter = $CGridOptions->GetFilter($arResult['FILTER']);
$arStrFilters = array('NAME', 'CODE');
foreach ($arFilter as $k => $v) {
    if (in_array($k, $arStrFilters, true)) {
        $arFilter['?' . $k] = $v;
        unset($arFilter[$k]);
    }
}
$arSort = array();
$by = isset($_GET['by']) ? trim($_GET['by']) : 'ID';
$sort = isset($_GET['order']) ? trim($_GET['order']) : 'asc';
if (isset($_GET['by']) && isset($_GET['order'])) {
    $arSort = array($by => $sort);
}
$gridSorting = $CGridOptions->GetSorting(array('sort' => array('sort' => 'asc'), 'vars' => array('by' => 'by', 'order' => 'order')));
Exemple #11
0
    $arResult['FILTER_PRESETS'] = array('filter_change_today' => array('name' => GetMessage('CRM_PRESET_CREATE_TODAY'), 'fields' => array('DATE_CREATE_datesel' => 'today')), 'filter_change_yesterday' => array('name' => GetMessage('CRM_PRESET_CREATE_YESTERDAY'), 'fields' => array('DATE_CREATE_datesel' => 'yesterday')), 'filter_change_my' => array('name' => GetMessage('CRM_PRESET_CREATE_MY'), 'fields' => array('CREATED_BY_ID' => $currentUserID, 'CREATED_BY_ID_name' => $currentUserName)));
} elseif (isset($arParams['SHOW_INTERNAL_FILTER']) && strtoupper(strval($arParams['SHOW_INTERNAL_FILTER'])) === 'Y') {
    $arResult['FILTER'] = array(array('id' => "{$filterFieldPrefix}ID", 'name' => 'ID', 'default' => false), array('id' => "{$filterFieldPrefix}EVENT_TYPE", 'name' => GetMessage('CRM_COLUMN_EVENT_TYPE'), 'default' => true, 'type' => 'list', 'items' => array('' => '', '0' => GetMessage('CRM_EVENT_TYPE_USER'), '1' => GetMessage('CRM_EVENT_TYPE_CHANGE'), '2' => GetMessage('CRM_EVENT_TYPE_SNS'))), array('id' => "{$filterFieldPrefix}EVENT_ID", 'name' => GetMessage('CRM_COLUMN_EVENT_NAME'), 'default' => true, 'type' => 'list', 'items' => array('' => '') + CCrmStatus::GetStatusList('EVENT_TYPE')), array('id' => "{$filterFieldPrefix}EVENT_DESC", 'name' => GetMessage('CRM_COLUMN_EVENT_DESC')), array('id' => "{$filterFieldPrefix}CREATED_BY_ID", 'name' => GetMessage('CRM_COLUMN_CREATED_BY_ID'), 'default' => true, 'enable_settings' => false, 'type' => 'user'), array('id' => "{$filterFieldPrefix}DATE_CREATE", 'name' => GetMessage('CRM_COLUMN_DATE_CREATE'), 'default' => true, 'type' => 'date'));
}
$arResult['HEADERS'] = array();
$arResult['HEADERS'][] = array('id' => 'ID', 'name' => 'ID', 'sort' => 'id', 'default' => false, 'editable' => false);
$arResult['HEADERS'][] = array('id' => 'DATE_CREATE', 'name' => GetMessage('CRM_COLUMN_DATE_CREATE'), 'sort' => false, 'default' => true, 'editable' => false, 'width' => '140px');
if ($arResult['EVENT_ENTITY_LINK'] == 'Y') {
    $arResult['HEADERS'][] = array('id' => 'ENTITY_TYPE', 'name' => GetMessage('CRM_COLUMN_ENTITY_TYPE'), 'sort' => false, 'default' => true, 'editable' => false);
    $arResult['HEADERS'][] = array('id' => 'ENTITY_TITLE', 'name' => GetMessage('CRM_COLUMN_ENTITY_TITLE'), 'sort' => false, 'default' => true, 'editable' => false);
}
$arResult['HEADERS'][] = array('id' => 'CREATED_BY_FULL_NAME', 'name' => GetMessage('CRM_COLUMN_CREATED_BY'), 'sort' => false, 'default' => true, 'editable' => false);
$arResult['HEADERS'][] = array('id' => 'EVENT_NAME', 'name' => GetMessage('CRM_COLUMN_EVENT_NAME'), 'sort' => false, 'default' => true, 'editable' => false);
$arResult['HEADERS'][] = array('id' => 'EVENT_DESC', 'name' => GetMessage('CRM_COLUMN_EVENT_DESC'), 'sort' => false, 'default' => true, 'editable' => false);
$arNavParams = array('nPageSize' => $arResult['EVENT_COUNT']);
$CGridOptions = new CCrmGridOptions($arResult['GRID_ID']);
if (($arResult['TAB_ID'] === '' || $arResult['TAB_ID'] === $activeTabID) && isset($_REQUEST['clear_filter']) && $_REQUEST['clear_filter'] == 'Y') {
    $urlParams = array();
    foreach ($arResult['FILTER'] as $arFilterField) {
        $filterFieldID = $arFilterField['id'];
        if ($arFilterField['type'] == 'user') {
            $urlParams[] = $filterFieldID . '_name';
        }
        if ($arFilterField['type'] == 'date') {
            $urlParams[] = $filterFieldID . '_datesel';
            $urlParams[] = $filterFieldID . '_days';
            $urlParams[] = $filterFieldID . '_from';
            $urlParams[] = $filterFieldID . '_to';
        }
        $urlParams[] = $filterFieldID;
    }
Exemple #12
0
                $actionData['ID'] = $_GET['ID'];
                unset($_GET['ID'], $_REQUEST['ID']);
            }
            $actionData['AJAX_CALL'] = false;
            if (isset($_GET['AJAX_CALL'])) {
                $actionData['AJAX_CALL'] = true;
                // Must be transfered to main.interface.grid
                //unset($_GET['AJAX_CALL'], $_REQUEST['AJAX_CALL']);
            }
        }
    }
}
// <-- Try to extract user action data
$arNavParams = array('nPageSize' => $arParams['PRODUCT_COUNT']);
$arNavigation = CDBResult::GetNavParams($arParams['PRODUCT_COUNT']);
$CGridOptions = new CCrmGridOptions($arResult['GRID_ID']);
$arNavParams = $CGridOptions->GetNavParams($arNavParams);
$arNavParams['bShowAll'] = false;
$arFilter = $gridFilter = $CGridOptions->GetFilter($arResult['FILTER']);
$arFilter['CATALOG_ID'] = $catalogID;
$sectionID = isset($arParams['~SECTION_ID']) ? intval($arParams['~SECTION_ID']) : 0;
$bFilterSection = $bTree || !isset($arFilter['GRID_FILTER_APPLIED']) || !$arFilter['GRID_FILTER_APPLIED'] || isset($arFilter['LIST_SECTION_ID']) && $arFilter['LIST_SECTION_ID'] !== '';
if ($bFilterSection) {
    if (!$bTree && isset($arFilter['GRID_FILTER_APPLIED']) && $arFilter['GRID_FILTER_APPLIED'] && isset($arFilter['LIST_SECTION_ID'])) {
        $sectionID = intval($arFilter['LIST_SECTION_ID']);
    }
    $arFilter['SECTION_ID'] = $sectionID;
}
// reset section filter HACK
if (!is_array($_SESSION['main.interface.grid'])) {
    $_SESSION['main.interface.grid'] = array();
Exemple #13
0
//<-- CONTACT
// COMPANY -->
if (!in_array(CCrmOwnerType::CompanyName, $effectiveEntityTypes, true)) {
    //HACK: For $dbRes->NavNum correction
    $dbRes = new CDBResult();
    $dbRes->InitNavStartVars();
} else {
    $dataUid = $uid . '_' . strtolower(CCrmOwnerType::CompanyName);
    $arResult['ENTITY_DATA'][CCrmOwnerType::CompanyName] = array('UID' => $dataUid, 'ITEMS' => array());
    $sort = $companySort;
    $select = $companySelect;
    $filter = array();
    $filterFields = array(array('id' => 'ID'), array('id' => 'TITLE'), array('id' => 'CONTACT_ID'));
    $navParams = array('nPageSize' => $itemPerPage, 'iNumPage' => $enablePaging ? false : 1, 'bShowAll' => false);
    $navigation = CDBResult::GetNavParams($navParams);
    $CGridOptions = new CCrmGridOptions($dataUid);
    $navParams = $CGridOptions->GetNavParams($navParams);
    $navParams['bShowAll'] = false;
    if ($enableSearch) {
        $filter += $CGridOptions->GetFilter($filterFields);
        if (!empty($filter)) {
            if (isset($filter['CONTACT_ID'])) {
                //HACK: Geting contact company.
                $dbRes = CCrmContact::GetListEx($contactSort, array('=ID' => $filter['CONTACT_ID']), false, false, array('COMPANY_ID'));
                $contact = $item = $dbRes->Fetch();
                if (is_array($contact)) {
                    $filter['=ID'] = $contact['COMPANY_ID'];
                }
                unset($filter['CONTACT_ID']);
            }
            if (isset($filter['TITLE'])) {
Exemple #14
0
                if ($ex = $APPLICATION->GetException()) {
                    $error = $ex->GetString();
                } else {
                    $error = GetMessage('CRM_TAX_DELETION_GENERAL_ERROR');
                }
                ShowError($error);
            }
        }
        unset($_GET['ID'], $_REQUEST['ID']);
        // otherwise the filter will work
    }
    if (!isset($_GET['AJAX_CALL'])) {
        LocalRedirect($bInternal ? '?' . $arParams['FORM_ID'] . '_active_tab=tab_product' : '');
    }
}
$gridOptions = new CCrmGridOptions($arResult['GRID_ID']);
$gridSorting = $gridOptions->GetSorting(array('sort' => array('NAME' => 'asc'), 'vars' => array('by' => 'by', 'order' => 'order')));
$sort = $arResult['SORT'] = $gridSorting['sort'];
$arResult['SORT_VARS'] = $gridSorting['vars'];
$arLangs = array();
$dbLangsList = CSite::GetList($b = "sort", $o = "asc");
while ($arLang = $dbLangsList->Fetch()) {
    $arLangs[$arLang["LID"]] = "[" . $arLang["LID"] . "]&nbsp;" . $arLang["NAME"];
}
$taxies = array();
$allTaxies = CCrmTax::GetAll();
foreach ($allTaxies as $k => $v) {
    $tax = array();
    $tax['ID'] = $tax['~ID'] = $k;
    // Key is Currency ID
    $tax['TIMESTAMP_X'] = $tax['~TIMESTAMP_X'] = CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', MakeTimeStamp($v['TIMESTAMP_X'])));
Exemple #15
0
 if ($res) {
     //Save default value for 'SHOW_IN_LIST'
     if ($arResult['NEW_FIELD']) {
         $defaultShowInList = CUserOptions::GetOption('crm', 'uf_show_in_list', 'N');
         if ($arField['SHOW_IN_LIST'] === 'N' && $defaultShowInList !== 'N') {
             CUserOptions::DeleteOption('crm', 'uf_show_in_list');
         } elseif ($arField['SHOW_IN_LIST'] === 'Y' && $defaultShowInList !== 'Y') {
             CUserOptions::SetOption('crm', 'uf_show_in_list', 'Y');
         }
     }
     //Register/Unregister fild in entity list -->
     $gridID = CCrmGridOptions::GetDefaultGrigID(CCrmOwnerType::ResolveIDByUFEntityID($arResult['ENTITY_ID']));
     if ($arField['SHOW_IN_LIST'] === 'Y') {
         CCrmGridOptions::AddVisibleColumn($gridID, $arResult['FIELD_ID']);
     } else {
         CCrmGridOptions::RemoveVisibleColumn($gridID, $arResult['FIELD_ID']);
     }
     //<-- Register/Unregister fild in entity list
     //Clear components cache
     $GLOBALS['CACHE_MANAGER']->ClearByTag('crm_fields_list_' . $arResult['ENTITY_ID']);
     //And go to proper page
     if (isset($_POST['save'])) {
         LocalRedirect($arResult['~FIELDS_LIST_URL']);
     } elseif (isset($_POST['apply'])) {
         LocalRedirect(str_replace(array('#entity_id#', '#field_id#'), array($arResult['ENTITY_ID'], $arResult['FIELD_ID']), $arParams['~FIELD_EDIT_URL']));
     } else {
         LocalRedirect($arResult['~FIELDS_LIST_URL']);
     }
 } else {
     $ex = $APPLICATION->GetException();
     ShowError($ex->GetString());
Exemple #16
0
    ob_end_clean();
    $arResult['FILTER'] = array(array('id' => 'OPPORTUNITY', 'name' => GetMessage('CRM_COLUMN_OPPORTUNITY'), 'type' => 'number'), array('id' => 'CURRENCY_ID', 'name' => GetMessage('CRM_COLUMN_CURRENCY_ID'), 'type' => 'list', 'items' => array('' => '') + CCrmCurrencyHelper::PrepareListItems()), array('id' => 'PROBABILITY', 'name' => GetMessage('CRM_COLUMN_PROBABILITY'), 'type' => 'number'), array('id' => 'CLOSED', 'name' => GetMessage('CRM_COLUMN_CLOSED'), 'type' => 'list', 'items' => array('' => '', 'Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'))), array('id' => 'TYPE_ID', 'name' => GetMessage('CRM_COLUMN_TYPE_ID'), 'default' => 'Y', 'type' => 'list', 'items' => array('' => '') + CCrmStatus::GetStatusList('DEAL_TYPE')), array('id' => 'BEGINDATE', 'name' => GetMessage('CRM_COLUMN_BEGINDATE'), 'type' => 'date'), array('id' => 'CLOSEDATE', 'name' => GetMessage('CRM_COLUMN_CLOSEDATE'), 'type' => 'date'), array('id' => 'DATE_CREATE', 'name' => GetMessage('CRM_COLUMN_DATE_CREATE'), 'default' => 'Y', 'type' => 'date'), array('id' => 'DATE_MODIFY', 'name' => GetMessage('CRM_COLUMN_DATE_MODIFY'), 'default' => 'Y', 'type' => 'date'), array('id' => 'MODIFY_BY_ID', 'name' => GetMessage('CRM_COLUMN_MODIFY_BY'), 'enable_settings' => false, 'type' => 'user'), array('id' => 'ASSIGNED_BY_ID', 'name' => GetMessage('CRM_COLUMN_ASSIGNED_BY'), 'default' => 'Y', 'enable_settings' => false, 'type' => 'user'), array('id' => 'CONTACT_ID', 'name' => GetMessage('CRM_COLUMN_CONTACT_LIST'), 'type' => 'custom', 'value' => $sValContact), array('id' => 'COMPANY_ID', 'name' => GetMessage('CRM_COLUMN_COMPANY_LIST'), 'type' => 'custom', 'value' => $sValCompany));
    $CCrmUserType->ListAddFilterFields($arResult['FILTER'], $arResult['FILTER2LOGIC'], $arResult['GRID_ID']);
    $arResult['FILTER_PRESETS'] = array('filter_week' => array('name' => GetMessage('CRM_PRESET_WEEK'), 'fields' => array('DATE_MODIFY_datesel' => 'week')), 'filter_week_prev' => array('name' => GetMessage('CRM_PRESET_WEEK_PREV'), 'fields' => array('DATE_MODIFY_datesel' => 'week_ago')), 'filter_month' => array('name' => GetMessage('CRM_PRESET_MONTH'), 'fields' => array('DATE_MODIFY_datesel' => 'month')), 'filter_month_prev' => array('name' => GetMessage('CRM_PRESET_MONTH_PREV'), 'fields' => array('DATE_MODIFY_datesel' => 'month_ago')), 'filter_my_week' => array('name' => GetMessage('CRM_PRESET_MY_WEEK'), 'fields' => array('DATE_MODIFY_datesel' => 'week', "ASSIGNED_BY_ID" => __format_user4search(), "ASSIGNED_BY_ID[]" => $GLOBALS['USER']->GetID())), 'filter_my_week_ago' => array('name' => GetMessage('CRM_PRESET_MY_WEEK_AGO'), 'fields' => array('DATE_MODIFY_datesel' => 'week_ago', "ASSIGNED_BY_ID" => __format_user4search(), "ASSIGNED_BY_ID[]" => $GLOBALS['USER']->GetID())));
}
if ($arParams['USE_AMCHARTS']) {
    $arResult['HEADERS'] = array(array('id' => 'TITLE', 'name' => GetMessage('CRM_COLUMN_TITLE'), 'sort' => false, 'default' => true, 'editable' => false), array('id' => 'PROCENT', 'name' => GetMessage('CRM_COLUMN_PROCENT'), 'sort' => false, 'default' => true, 'editable' => false, 'align' => 'right'), array('id' => 'COUNT_FUNNEL', 'name' => GetMessage('CRM_COLUMN_COUNT'), 'sort' => false, 'default' => true, 'editable' => false, 'align' => 'right'));
} else {
    $arResult['HEADERS'] = array(array('id' => 'FUNNEL', 'name' => GetMessage('CRM_COLUMN_FUNNEL'), 'sort' => false, 'default' => false, 'editable' => false, 'align' => 'center'), array('id' => 'TITLE', 'name' => GetMessage('CRM_COLUMN_TITLE'), 'sort' => false, 'default' => true, 'editable' => false), array('id' => 'PROCENT', 'name' => GetMessage('CRM_COLUMN_PROCENT'), 'sort' => false, 'default' => true, 'editable' => false, 'align' => 'right'), array('id' => 'COUNT_FUNNEL', 'name' => GetMessage('CRM_COLUMN_COUNT'), 'sort' => false, 'default' => true, 'editable' => false, 'align' => 'right'));
}
$i = 0;
foreach ($arResult['CURRENCY_LIST'] as $k => $v) {
    $arResult['HEADERS'][] = array('id' => $k, 'name' => GetMessage('CRM_COLUMN_SUMM', array('#CURRENCY#' => htmlspecialcharsbx($v))), 'sort' => false, 'default' => $i == 0, 'editable' => false, 'align' => 'right');
    $i++;
}
$CGridOptions = new CCrmGridOptions($arResult['GRID_ID']);
if (isset($_REQUEST['clear_filter']) && $_REQUEST['clear_filter'] == 'Y') {
    $urlParams = array();
    foreach ($arResult['FILTER'] as $id => $arFilter) {
        if ($arFilter['type'] == 'user') {
            $urlParams[] = $arFilter['id'];
            $urlParams[] = $arFilter['id'] . '_name';
        } else {
            $urlParams[] = $arFilter['id'];
        }
    }
    $urlParams[] = 'clear_filter';
    $CGridOptions->GetFilter(array());
    LocalRedirect($APPLICATION->GetCurPageParam('', $urlParams));
}
$arFilter += $CGridOptions->GetFilter($arResult['FILTER']);
Exemple #17
0
 } else {
     foreach ($arEntityID as $entityID) {
         $isPermitted = CCrmActivity::CheckReadPermission(CCrmOwnerType::ResolveID($entityType), $entityID, $userPermissions);
         if (!$isPermitted) {
             break;
         }
     }
 }
 if (!$isPermitted) {
     echo CUtil::PhpToJSObject(array('ERROR' => GetMessage('CRM_PERMISSION_DENIED')));
     die;
 }
 // <--PERMISSIONS CHECK
 if (empty($arEntityID) && $gridID !== '') {
     //Apply grid filter if ids is not defined
     $gridOptions = new CCrmGridOptions($gridID);
     $gridFilter = $gridOptions->GetFilter(array());
     //Clear service fields
     if (isset($gridFilter['GRID_FILTER_APPLIED'])) {
         unset($gridFilter['GRID_FILTER_APPLIED']);
     }
     if (isset($gridFilter['GRID_FILTER_ID'])) {
         unset($gridFilter['GRID_FILTER_ID']);
     }
     if (is_array($gridFilter) && !empty($gridFilter)) {
         $dbEntities = null;
         if ($entityType === 'LEAD') {
             CCrmLead::PrepareFilter($gridFilter);
             $dbEntities = CCrmLead::GetListEx(array(), $gridFilter, false, false, array('ID'));
         } elseif ($entityType === 'DEAL') {
             CCrmDeal::PrepareFilter($gridFilter);
Exemple #18
0
$arParams['PULL_UPDATE_CMD'] = $arResult['PULL_UPDATE_CMD'] = isset($arParams['PULL_UPDATE_CMD']) ? $arParams['PULL_UPDATE_CMD'] : 'crm_contact_update';
$arParams['PULL_DELETE_CMD'] = $arResult['PULL_DELETE_CMD'] = isset($arParams['PULL_DELETE_CMD']) ? $arParams['PULL_DELETE_CMD'] : 'crm_contact_delete';
*/
$arResult['FILTER'] = array(array('id' => 'NAME'), array('id' => 'LAST_NAME'), array('id' => 'FULL_NAME'), array('id' => 'MODIFY_BY_ID'), array('id' => 'ASSIGNED_BY_ID'));
$arResult['FILTER_PRESETS'] = array('filter_my' => array('name' => GetMessage('M_CRM_CONTACT_LIST_PRESET_MY'), 'fields' => array('ASSIGNED_BY_ID' => $currentUserID)), 'filter_change_my' => array('name' => GetMessage('M_CRM_CONTACT_LIST_PRESET_CHANGE_MY'), 'fields' => array('MODIFY_BY_ID' => $currentUserID)));
$itemPerPage = isset($arParams['ITEM_PER_PAGE']) ? intval($arParams['ITEM_PER_PAGE']) : 0;
if ($itemPerPage <= 0) {
    $itemPerPage = 20;
}
$arParams['ITEM_PER_PAGE'] = $itemPerPage;
$sort = array('LAST_NAME' => 'ASC', 'NAME' => 'ASC');
$filter = array();
$navParams = array('nPageSize' => $itemPerPage, 'iNumPage' => $enablePaging ? false : 1, 'bShowAll' => false);
$select = array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'POST', 'PHOTO', 'ASSIGNED_BY_ID', 'ASSIGNED_BY_LOGIN', 'ASSIGNED_BY_NAME', 'ASSIGNED_BY_SECOND_NAME', 'ASSIGNED_BY_LAST_NAME', 'COMPANY_ID', 'COMPANY_TITLE', 'COMMENTS');
$navigation = CDBResult::GetNavParams($navParams);
$CGridOptions = new CCrmGridOptions($arResult['UID']);
$navParams = $CGridOptions->GetNavParams($navParams);
$navParams['bShowAll'] = false;
$arResult['GRID_FILTER_ID'] = '';
$arResult['GRID_FILTER_NAME'] = '';
if ($enableSearch) {
    $filter += $CGridOptions->GetFilter($arResult['FILTER']);
    if (empty($filter)) {
        $enableSearch = $arResult['ENABLE_SEARCH'] = false;
        $arResult['GRID_FILTER_NAME'] = GetMessage('M_CRM_DEAL_LIST_FILTER_NONE');
    } else {
        if (isset($filter['GRID_FILTER_APPLIED']) && $filter['GRID_FILTER_APPLIED'] && isset($filter['GRID_FILTER_ID'])) {
            $filterID = $filter['GRID_FILTER_ID'];
            $arResult['GRID_FILTER_ID'] = $filterID;
            $arResult['GRID_FILTER_NAME'] = isset($arResult['FILTER_PRESETS'][$filterID]) ? $arResult['FILTER_PRESETS'][$filterID]['name'] : GetMessage('M_CRM_CONTACT_LIST_FILTER_CUSTOM');
        } else {
Exemple #19
0
    $arParams['UID'] = 'mobile_crm_invoice_event_list';
}
$arResult['UID'] = $arParams['UID'];
$arResult['FILTER'] = array(array('id' => 'ORDER_ID'));
$itemPerPage = isset($arParams['ITEM_PER_PAGE']) ? intval($arParams['ITEM_PER_PAGE']) : 0;
if ($itemPerPage <= 0) {
    $itemPerPage = 20;
}
$arParams['ITEM_PER_PAGE'] = $itemPerPage;
$arResult['EVENT_TYPES'] = CCrmInvoiceEvent::getTypes();
$sort = array('ID' => 'DESC');
$filter = array('ORDER_ID' => $entityID, 'TYPE' => array_keys($arResult['EVENT_TYPES']));
$navParams = array('nPageSize' => $itemPerPage, 'iNumPage' => $enablePaging ? false : 1, 'bShowAll' => false);
$select = array('ID', 'TYPE', 'DATA', 'DATE_CREATE', 'USER_ID');
$navigation = CDBResult::GetNavParams($navParams);
$CGridOptions = new CCrmGridOptions($arResult['UID']);
$navParams = $CGridOptions->GetNavParams($navParams);
$navParams['bShowAll'] = false;
$arResult['ITEMS'] = array();
$event = new CCrmInvoiceEvent();
$dbRes = $event->GetList($sort, $filter, false, $navParams, $select);
$dbRes->NavStart($navParams['nPageSize'], false);
$arResult['PAGE_NAVNUM'] = intval($dbRes->NavNum);
// pager index
$arResult['PAGE_NUMBER'] = intval($dbRes->NavPageNomer);
// current page index
$arResult['PAGE_NAVCOUNT'] = intval($dbRes->NavPageCount);
// page count
$arResult['PAGER_PARAM'] = "PAGEN_{$arResult['PAGE_NAVNUM']}";
$arResult['PAGE_NEXT_NUMBER'] = $arResult['PAGE_NUMBER'] + 1;
$items = array();
Exemple #20
0
<?php

if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) {
    die;
}
global $APPLICATION;
$arTabs = array();
$arTabs[] = array('id' => 'tab_1', 'name' => GetMessage('CRM_TAB_1'), 'title' => GetMessage('CRM_TAB_1_TITLE'), 'icon' => '', 'fields' => $arResult['FIELDS']['tab_1']);
CCrmGridOptions::SetTabNames($arResult['FORM_ID'], $arTabs);
$formCustomHtml = '<input type="hidden" name="vat_id" value="' . $arResult['VAT_ID'] . '"/>';
$APPLICATION->IncludeComponent('bitrix:main.interface.form', '', array('FORM_ID' => $arResult['FORM_ID'], 'TABS' => $arTabs, 'BUTTONS' => array('standard_buttons' => true, 'back_url' => $arResult['BACK_URL'], 'custom_html' => $formCustomHtml), 'DATA' => $arResult['VAT'], 'SHOW_SETTINGS' => 'Y', 'THEME_GRID_ID' => $arResult['GRID_ID'], 'SHOW_FORM_TAG' => 'Y'), $component, array('HIDE_ICONS' => 'Y'));
Exemple #21
0
    } else {
        if ($actionData['NAME'] === 'delete' && isset($actionData['ID'])) {
            CCatalogMeasure::delete($actionData['ID']);
        }
        if (!$actionData['AJAX_CALL']) {
            LocalRedirect($arParams['PATH_TO_MEASURE_LIST']);
        }
    }
}
// <-- POST & GET actions processing
if (intval($arParams['MEASURE_COUNT']) <= 0) {
    $arParams['MEASURE_COUNT'] = 20;
}
$arNavParams = array('nPageSize' => $arParams['MEASURE_COUNT']);
$arNavigation = CDBResult::GetNavParams($arNavParams);
$gridOptions = new CCrmGridOptions($arResult['GRID_ID']);
$gridSorting = $gridOptions->GetSorting(array('sort' => array('CODE' => 'asc'), 'vars' => array('by' => 'by', 'order' => 'order')));
$arResult['SORT'] = $gridSorting['sort'];
$arResult['SORT_VARS'] = $gridSorting['vars'];
$arNavParams = $gridOptions->GetNavParams($arNavParams);
$arNavParams['bShowAll'] = false;
$sortField = isset($_REQUEST['by']) ? $_REQUEST['by'] : 'ID';
$sortDirection = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC';
$select = array('ID', 'CODE', 'MEASURE_TITLE', 'SYMBOL_RUS', 'SYMBOL_INTL', 'SYMBOL_LETTER_INTL', 'IS_DEFAULT');
$dbResult = CCatalogMeasure::getList($arResult['SORT'], array(), false, $arNavParams, $select);
$dbResult->NavStart($arNavParams['nPageSize'], false);
$arResult['MEASURES'] = array();
while ($measure = $dbResult->GetNext()) {
    $ID = intval($measure['~ID']);
    $measure['PATH_TO_MEASURE_EDIT'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_MEASURE_EDIT'], array('measure_id' => $ID));
    $measure['PATH_TO_DELETE'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_MEASURE_LIST']), array('action_' . $arResult['GRID_ID'] => 'delete', 'ID' => $ID, 'sessid' => bitrix_sessid()));