Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:extensions:workflowdesigner:developers [2014/12/09 13:43] swarnat [Add new Options what to do with Files generated by Workflows] |
en:extensions:workflowdesigner:developers [2016/07/22 12:38] (current) swarnat |
||
---|---|---|---|
Line 193: | Line 193: | ||
\Workflow\FileAction::register('[SanitizedIndividualNameA]', '\Workflow\Plugins\FileActions\[IndividualNameA]'); | \Workflow\FileAction::register('[SanitizedIndividualNameA]', '\Workflow\Plugins\FileActions\[IndividualNameA]'); | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | ==== Add a FieldType for Request Values from User ==== | ||
+ | |||
+ | You would like to request a very special value from your users and you couldn't do this with the integrated field types? | ||
+ | **You could integrate you own fieldtypes!** | ||
+ | |||
+ | Add a file in **/modules/Workflow2/extends/fieldtypes/** with the filename "<individual>.inc.php" | ||
+ | |||
+ | This file must contain a class which extends from **\Workflow\Fieldtype**. | ||
+ | This class must have the following structure: | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | namespace Workflow\Plugins\Fieldtypes; | ||
+ | |||
+ | class [IndividualNameA] extends \Workflow\Fieldtype | ||
+ | { | ||
+ | /** | ||
+ | * Should return every fieldtype this class will provide | ||
+ | * | ||
+ | * @param $moduleName - The moduleName of the Workflow, which include this field | ||
+ | * @return array - An Array with the following Structure | ||
+ | * array( | ||
+ | * array( | ||
+ | 'id' => '<uniqueFieldTypeID>', | ||
+ | 'title' => '<NameOfFieldType>', | ||
+ | 'config' => $config | ||
+ | * ), ... | ||
+ | * ) | ||
+ | $config is an array of configuration fields, the admin needs to configure in backend | ||
+ | * it must have the following structure | ||
+ | * 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); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // The class neeeds to be registered | ||
+ | \Workflow\Fieldtype::register('[IndividualNameA]', '\Workflow\Plugins\Fieldtypes\[IndividualNameA]'); | ||
+ | </code> | ||
+ | |||
+ | ==== add own shortfunctions ==== | ||
+ | |||
+ | If you want to add a custom "shortfunction" you could use with the syntax $[...], then you must do the following. | ||
+ | Create one file, with filename **<custom>.inc.php** in folder modules/Workflow2/extends/shortfunctions/ | ||
+ | |||
+ | Only required code is: | ||
+ | |||
+ | <code> | ||
+ | \Workflow\Shortfunctions::register('shortfunctionname', <CallAble Object>, $parametersShouldBeParsed); | ||
+ | </code> | ||
+ | |||
+ | The callable object could be any callable element, php could execute. For example an closure, or string with function name. Any possible option you see here: [[http://php.net/manual/de/language.types.callable.php]] | ||
+ | |||
+ | And you must implement this callable object with your PHP code. **That's all!** | ||
+ | |||
+ | ==== use custom Inventory Fields ==== | ||
+ | |||
+ | If you implement custom fields in your Inventory Records, like Invoice, Quotes, the values will be deleted during any workflows and you couldn't interact with this values from Workflow Designer before version 600.0825. | ||
+ | With this version, you could create a file named "InventoryFields.inc.php" directly into the "extends" directory. | ||
+ | This file will not be overwritten during updates of the module. | ||
+ | |||
+ | In this file you could configure the fields you create and want to keep during Workflows. | ||
+ | This file **MUST** have the following structure. | ||
+ | Because this file will be included during every Workflow execution in the Inventory Modules, you should proceed with caution. | ||
+ | Every Error in this file could make it impossible to execute any workflows. | ||
+ | |||
+ | <code php> | ||
+ | <?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'), | ||
+ | ); | ||
+ | </code> | ||
+ | | tableCol | This is the name of the column in the vtiger_inventoryproductrel table. Won't be used to read from database , but will be a good and unique name | | ||
+ | | FieldNameWithoutProductIndex | This is the Key of the value in the ProductsArray. You use this value in the "getAssociatedProducts" function | | ||
+ | | Testvalue | The label of this field, which will be shown on task configurations | | ||
+ | |||
+ | This structure will make it possible to also set this fields if you create an Invoice in an Workflow. |