Расширенный Поиск имеет два интерфейса, которые можно использовать для реализации пользовательских колонок и условий.
Все необходимое вы найдете в директории extends. Файлы этой директории не зашифрованы.
Этот интерфейс хранится в директории extends/field и позволяет добавлять виртуальные колонки, которые не связаны с полями в vTiger CRM.
Используйте его, чтобы сосчитать значения, суммировать что-либо и т.д.
Как добавить такую виртуальную колонку:
Создайте файл в директории extends / fields со расширением <customname>.inc.php. Use the following class stub for the file:
<?php
namespace SWSearchPlus\Plugin\Field;
class ClassName extends \SWSearchPlus\Customfield
{
public function getFields($moduleName) {
$operators = array();
// Use such condition if your condition only works in special modules
// if($moduleName === 'Accounts') {
$operators = array (
'[columnSlug1]' => array (
'label' => '[Visible Column Label]',
'columnname' => '_[virtualuniquecolumnname]',
'typeofdata' => '[typeofdata of column. Normally: V~O]',
'uitype' => [uitype of column. Normally: 1],
'displaytype' => 3,
),
'[columnSlug2]' => array (
'label' => '[Visible Column Label]',
'columnname' => '_[virtualuniquecolumnname]',
'typeofdata' => '[typeofdata of column. Normally: V~O]',
'uitype' => [uitype of column. Normally: 1],
'displaytype' => 3,
),
);
// }
return $operators;
}
public function execute($key, $moduleName) {
$adb = \PearDatabase::getInstance();
// default calculations
switch($key) {
case 'columnSlug1':
/*
public function addJoinTable($fromTableName, $joinFromColumn, $toTableName, $joinToColumn, $tableDefinition, $tableDefinitionUniqueKey = false) {
$fromTableName = vtiger_crmentity in almost any situation
$joinFromColumn = crmid in almost any situation. These both columns define the SRC ID for JOIN
$toTableName = Result Table Name of $tableDefinition
$joinToColumn = Join Target of $tableDefinition to SRC iD
$tableDefinition = The SQL Query, which generate the result
$tableDefinitionUniqueKey = In some situation it is necessary to manually set a UniqueKey, if more extensions use an equal tableDefinition
This example use the Total SUM Calculation of Account
*/
$tableName = self::$tableHander->addJoinTable('vtiger_crmentity', 'crmid', 'vtiger_invoice', 'accountid', 'SELECT ROUND(SUM(total)) as _totalinvoicesum, accountid FROM vtiger_invoice GROUP BY vtiger_invoice.accountid');
break;
case 'columnSlug2':
....
break;
}
return $tableName;
}
}
\SWSearchPlus\Customfield::register('[uniqueextensionkey]', '\\SWSearchPlus\\Plugin\\Field\\ClassName');
Каждый файл может зарегистрировать множество колонок.
Placeholder description:
| Placeholder | Описание |
| ClassName | Уникальный в рамках директории extends/fields класс |
| uniqueextensionkey | Индивидуальный для вашего расширения ключ |
| columnSlug1,columnSlug2 | Уникальный ключUnique Key of your column. Used internally to call your class |
| Visible Column Label | Заголовок колонки, которую пользователь редактирует в режиме редактора CustomView |
| virtualuniquecolumnname | Вы должны дать полю уникальное имя, используя символ _ |
| typeofdata of column | Тип The type of Data. Necessary for vtiger. Set to V~O works in any case |
| uitype of column | The UIType of this virtual column. Set to 1 works in any case and make this colum handled like text |