Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:extensions:workflowdesigner:developers [2014/12/09 13:01]
swarnat
en:extensions:workflowdesigner:developers [2016/07/22 12:38] (current)
swarnat
Line 8: Line 8:
 This files will be overwritten with every update and your modifications are lost. This files will be overwritten with every update and your modifications are lost.
 </​WRAP>​ </​WRAP>​
 +
 +All already existing core extension files, are installed in plain PHP code and not be encrypted!
  
 ==== Add functions you could use in custom expressions ==== ==== Add functions you could use in custom expressions ====
Line 71: Line 73:
     /**     /**
      * @var String $moduleName The module of the current Workflow      * @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) {     protected function _getAvailableFiles($moduleName) {
Line 83: Line 92:
                 '​filekeyA'​ => 'File title of this file'                 '​filekeyA'​ => 'File title of this file'
              )              )
-              +
-           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+
         */         */
  
Line 101: Line 108:
      ​* ​                     '​name'​ => "<​filename 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.+     * 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) {     protected function _getFile($key,​ $moduleName,​ $crmid) {
Line 120: Line 128:
 } }
  
 +// This will register this class in the Interface Registry
 \Workflow\InterfaceFiles::​register('​[SanitizedModuleName]',​ '​\Workflow\Plugins\InterfaceFiles\[ModuleName]'​);​ \Workflow\InterfaceFiles::​register('​[SanitizedModuleName]',​ '​\Workflow\Plugins\InterfaceFiles\[ModuleName]'​);​
 </​code>​ </​code>​
 +
 +==== Add new Options what to do with Files generated by Workflows ====
 +
 +With 600.0801 in added this interface. It will be integrated in every tasks in the next versions.
 +At this moment it is only integrated into the new PDFMaker Integration block.
 +
 +Add a file in **/​modules/​Workflow2/​extends/​fileactions/​** with the filename "<​individual>​.inc.php"​
 +
 +This file must contain a class which extends from **\Workflow\FileAction**.
 +This class must have the following structure:
 +
 +<code php>
 +<?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]'​);​
 +</​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.