Если вы владеете языком PHP, то можете менять интерфейс Дизайнера Бизнес-Процессов.
Такие изменения интерфейса доступны начиная с 6 версии CRM, поэтому, если вы все еще используете версию 5.4, то ничего не выйдет, так как в ней отсутствуют необходимые директории для создания файлов в рамках данной задачи.
Важный момент: НЕ изменяйте никаких файлов, созданных ядром Дизайнера Бизнес-Процессов, так как при каждом обновлении они будут автоматически переписываться и, таким образом, вы потеряете все свои изменения.
Файлы ядра написаны на PHP и не шифруются.
This is the only interface existing also in the 5.4.0 version.
Если вы хотите интегрировать в vTiger функцию, а ее размеры слишком велики для простого текстового поля, то вы можете ее отдельно.
В VtigerCRM 5.4: Создайте новый файл в modules/Workflow2/functions/ с названием <individual>.inc.php
В VtigerCRM 6.x: Создайте новый файл в modules/Workflow2/extends/functions/ с названием <individual>.inc.php
Все функции с префиксом fix wf_ , которые вы напишите/определите в этом файле, будут доступны для пользовательских выражений.
Не вносите изменений в файл core.inc.php , так как функции, описанные в этом файле, запускаются с Дизайнером Бизнес-Процессов.
Но вы можете использовать этот файл как пример того, как должен выглядеть файл, созданный вами.
Если вы нарушите синтаксис PHP и интегрируете его с ошибкой, то Бизнес-Процесс не выполнится, потому что эти файлы включены в работу множества Задач!
Пример функции, которая интегрирована в ядро:
if(!function_exists("wf_date")) {
function wf_date($value, $interval, $format = "Y-m-d") {
if(empty($interval)) {
$dateValue = strtotime($value);
} else {
$dateValue = strtotime($interval, strtotime($value));
}
return date($format, $dateValue);
}
}
Доступно только в версии VtigerCRM 6.x
PDFMaker и SQL-отчеты реализуются следующим образом:
Если вы создадите похожий модуль, то сможете создать другой interfacefile, который сможет прикреплять файлы к электронным письмам, хранить их как документы или просто использовать в любой Задаче, которая может так или иначе обрабатывать файлы.
Файлы создаются в папке modules/Workflow2/extends/interfaceFiles/ с названиями <individual>.inc.php.
Этот файл должен включать в себя класс (Class), который находится по такому пути \Workflow\InterfaceFiles.
Для того, чтобы Дизайнер Бизнес-Процессов распознал ваш файл, он должен иметь такую структуру:
<?php
namespace Workflow\Plugins\InterfaceFiles;
class [ModuleName] extends \Workflow\InterfaceFiles {
protected $title = '[ModuleName]';
protected $key = '[SanitizedModuleName]';
public function __construct() {
if(!$this->isModuleActive()) {
return;
}
}
/**
* @var String $moduleName The module of the current Workflow
* @return array - array(
* 'filekeyA' => 'File title of the first file from this module',
* ...
* )
*
* The file title will be shown in the task configurations.
* The filekey will be given to your _getFile and should uniquely identify the file you should generate
*/
protected function _getAvailableFiles($moduleName) {
$return = array();
if(!$this->isModuleActive()) {
return $return;
}
/*
This function must simple return an array, like this:
array(
'filekeyA' => 'File title of this file'
)
*/
return $return;
}
/**
* @var String $key - The fileKey you set in the _getAvailableFiles function
* @var String $moduleName - The module from the given RecordID, which should be used to generate the file
* @var Int $crmid - The ID of the Record, which should be used to generate the file
* @return array - An Array with the following Structure
* array(
* 'path' => "<temporarily path to the generated file>",
* 'type' => "<mime type of the generated file>",
* 'name' => "<filename of the generated file>"
* );
* The filename will probably overwritten by some tasks,
* but if not, it will be used to give this file to the user.
*/
protected function _getFile($key, $moduleName, $crmid) {
if(!$this->isModuleActive()) {
return false;
}
return array(
'path' => "<temporarily path to the generated file>",
'type' => "<mime type of the generated file>",
'name' => "<filename of the generated file>"
);
}
public function isModuleActive() {
return getTabid('[moduleName]') && vtlib_isModuleActive('[moduleName]');
}
}
// This will register this class in the Interface Registry
\Workflow\InterfaceFiles::register('[SanitizedModuleName]', '\Workflow\Plugins\InterfaceFiles\[ModuleName]');
После версий 600.0801 эта Задача будет интегрирована в каждую версию vTiger.
В данный момент функция присутствует только в блоке «Интеграция PDFMaker».
Добавьте файл с название <individual>.inc.php в папку /modules/Workflow2/extends/fileactions/.
Этот файл должен содержать класс (class), который извлекается из \Workflow\FileAction. Этот класс должен содержать следующую структуру:
<?php
namespace Workflow\Plugins\FileActions;
class [IndividualNameA] extends \Workflow\FileAction {
/**
* @param String $moduleName - The module from the workflow, this action will be used
* @return array - Returns an array with the Option, this file could provide:
* array(
'title' => '<title of this FileAction (could be translated in lang Files)>',
'options' => $options
)
$options is also an array with configuration options,
the User should input, if he choose this action
$options = array(
'<configKeyA>' => array(
'type' => '<templatefield|templatearea|picklist|checkbox>',
'label' => '<label show before this configuration option (could be translated)',
'placeholder' => '<placeholder of input field>,
// if type = checkbox
// 'value' => 1
// if type = picklist
// 'options' => array('ID1' => 'value1', 'ID2' => 'value2', ...)
),
...
)
*/
public function getActions($moduleName) {
$return = array();
return $return;
}
/**
* @param array $configuration - Array with all configuration options, the user configure
* @param string $filepath - The temporarily filepath of the file, which should be transformed
* @param string $filename - The filename of this file
* @param \Workflow\VTEntity $context - The Context of the Workflow
* @param array $targetRecordIds
* @return void
*/
public function doAction($configuration, $filepath, $filename, $context, $targetRecordIds = array()) {
}
}
\Workflow\FileAction::register('[SanitizedIndividualNameA]', '\Workflow\Plugins\FileActions\[IndividualNameA]');
Вам необходимы поля, которые отсутствуют в стандартном наборе полей?
Вы можете интегрировать свои собственные типы полей!
Добавьте файл с именем <individual>.inc.php в папку /modules/Workflow2/extends/fieldtypes/.
Файл должен содержать класс (class ), который извлекается из \Workflow\Fieldtype. Класс должен содержать следующую структуру:
<?php
namespace Workflow\Plugins\Fieldtypes;
class [IndividualNameA] extends \Workflow\Fieldtype
{
/**
* Должен вернуть каждое текстовое поле, которому присвоен этот класс
*
* @param $moduleName - Название модуля Бизнес-Процесса, где будет выводиться поле
* @return array - Массив со следующей структурой
* array(
* array(
'id' => '<uniqueFieldTypeID>',
'title' => '<NameOfFieldType>',
'config' => $config
* ), ...
* )
$config - массив полей конфигурации, которые необходимо настроить из бэкэнда
* Структура следующая:
* array(
* '<configKey>' => array(
'type' => '[templatefield,templatearea,picklist,checkbox]',
* 'label' => '<label Of Configuration Input>',
// if type = checkbox
// 'value' => 1
// if type = picklist
// 'options' => array('ID1' => 'value1', 'ID2' => 'value2', ...)
* ), ...
* )
*
*/
public function getFieldTypes($moduleName) {
$fields = array();
/*
Example:
$fields[] = array(
'id' => 'reference',
'title' => 'Referenz',
'config' => array(
'reference' => array(
'type' => 'picklist',
'label' => 'Referenz',
'options' => $relmodules,
)
)
);
*/
return $fields;
}
/**
* @param $data - Config Array of this Input with the following Structure
* array(
* 'label' => 'Label the Function should use',
* 'name' => 'The Fieldname, which should used as name attribute',
* 'config' => Key-Value Array with all configurations, done by admin
* )
* @param \Workflow\VTEntity $context - Current Record, which is assigned to the Workflow
* @return array - The rendered content, shown to the user with the following structure
* array(
* 'html' => '<htmlContentOfThisInputField>',
* 'javascript' => 'A Javascript executed after html is shown'
* )
*
*/
public function renderFrontend($data, $context) {
$html = '';
$script = '';
return array('html' => $html, 'javascript' => $script);
}
}
// Класс необходимо зарегистрировать
\Workflow\Fieldtype::register('[IndividualNameA]', '\Workflow\Plugins\Fieldtypes\[IndividualNameA]');
Если вы используете настраиваемые поля в Задаче Inventory, такие как Счет, Коммерческое предложение, то значения этих полей будут очищены при выполнении любого другого Бизнес-Процесса и вы не сможете взаимодействовать с ними из Дизайнера Бизнес-Процессов, если версия вашего vTiger ниже 600.0825.
С этой версией вы сможете создавать файлы с именем “InventoryFields.inc.php” прямо в директории “extends”.
Эти файлы не будут переписаны во время обновления.
В этом файле вы можете настраивать создаваемые вами поля и сохранять их при выполнении Бизнес-Процессов.
Этот файл ОБЯЗАТЕЛЬНО ДОЛЖЕН иметь следующую структуру:
По той причине, что этот файл будет включен в каждое выполнение Бизнес-Процесса во всех модулях Inventory, вы должны вносить изменения осторожно.
Любая ошибка в этом файле сделает выполнение любого Бизнес-Процесса невозможным.
<?php
/**
* You need to enter the following php structure
*
* return array(
* 'tableCol' => array('inventoryField' => 'FieldNameWithoutProductIndex', 'label' => 'Label of this field'),
* );
*/
// Example:
return array(
'test' => array('inventoryField' => 'testCol', 'label' => 'Testvalue'),
);
| tableCol | Это имя колонки в таблице vtiger_inventoryproductrel. Не используется для чтения из БД, но подходит для использования как уникальное имя |
| FieldNameWithoutProductIndex | Это код значения в ProductsArray. Вы используете это значение в функции “getAssociatedProducts” |
| Testvalue | Является названием этого поля, которое будет показано в настройках Задачи |