Custom Uitypes
You can add new types to the existing ones and manage them completely without changing other code. The procedure for creating a new one is:
- Create a new custom field (via Vtlib or VTE web interface)
- Manually change the type of the new field in the database (table vtiger_field, column uitype) with an unused value (nnn) (You can see how to create fields with the desired uitype without manually changing the database in modules/SDK/examples/fieldCreate.php)
- Create the files:
a. nnn.php in modules/SDK/examples
b. nnn.js in modules/SDK/examples
c. nnn.tpl in Smarty/templates/modules/SDK/examples
These files manage the behavior of the new field depending on the context (list, detail, and so on) - Register the new type with the class method SDK::setUitype.
SDK::setUitype($uitype, $src_php, $src_tpl, $src_js, $type='', $params='');
$uitype : the number of the new type; it must be nnn (the name of the files)
$src_php: the path of nnn.php
$src_tpl: the path of nnn.tpl (without Smarty/templates/ at the beginning)
$src_js : the path of nnn.js
$type : the type in webservice format (‘text’, ‘boolean’, and so on)
$params : not used yet
To remove the uitype:
SDK::unsetUitype($uitype);
$uitype : it is the number of the uitype to remove (the files associated with it will not be deleted)
We recommend using uitype with a value greater than 2000, to avoid conflicts with the future releases of vtenext.
The php script has several variables available, the first one is:
$sdk_mode : the views that I can customize for the new uitype (“insert”, “detail”, “edit”, “relatedlist”, “list”, “pdfmaker”, “report”, and so on)
Depending on the type of $sdk_mode, various variables can be read and modified.
detail
to manage the display of the field in DetailView
INPUT
$module : the current module name
$fieldlabel: the label of the field
$fieldname : the name of the field
$col_fields: (array) the values of the fields
OUTPUT
$label_fld[] : the translated label
$label_fld[] : the value to be displayed
edit
to manage the display of the field in EditView
INPUT
$module_name : the current module name
$fieldlabel : the label of the field
$value : the value of the field
OUTPUT
$editview_label[] : the translated label
$fieldvalue[] : the value to be displayed
report
to manage the display of the field in Report
INPUT
$sdk_value : the value of the field
OUTPUT
$fieldvalue : the value to be displayed
If the value to be displayed from the interface is formatted differently than the value saved in the database (e.g. number 1.000,25 which must be saved as 1000.25) then the following methods must also be managed to save the value in the correct format and search for it.
insert
to convert the value to the format to be saved in the database
INPUT
$this->column_fields : (array) the values of the fields
$fieldname : the name of the field
OUTPUT
$fldvalue : the value to save in the database
formatvalue
to convert the value coming from the $_REQUEST into the format saved in the database (used in the new management of Conditional Fields)
INPUT
$value : the value of the field
OUTPUT
$value : the value converted to database format
querygeneratorsearchperto convertireconvert ilthe valorevalue cercatosearched dall’utenteby inthe listauser einto filtrithe list and the filters
INPUT EAND OUTPUT
$fieldname : nomethe delname campoof the field
$operator : operatorethe dicomparison confrontooperator
$value : valorethe cercatovalue searched
customviewsearchperto gestiremanage lathe conversioneconversion delof valorethe neivalue filtriin deithe popup perfilters ifor campithe reference fields
INPUT EAND OUTPUT
$tablename : tabellathe deltable campoof the field
$fieldname : nomethe delname campoof the field
$comparator : operatorethe dicomparison confrontooperator
$value : valorethe cercatovalue searched
popupbasicsearchperto gestiremanage lathe conversioneconversion delof valorethe nellavalue ricercain deithe popup persearch ifor campithe reference fields
INPUT
$table_name : the table name
$column_name : the column name
$search_string : valorethe cercatovalue searched
OUTPUT
$where : condizionethe dellacondition of the queryes.e.g. $where = "$table_name.$column_name = '".convertToDBFunction($search_string)."'";
popupadvancedsearchperto gestiremanage lathe conversioneconversion delof valorethe nellavalue ricercain avanzatathe deiadvanced popup persearch ifor campithe reference fields
INPUT EAND OUTPUT
$tab_col : the table and the column of the field
$srch_cond : operatorethe dicomparison confrontooperator
$srch_val : valorethe cercatovalue searched
reportsearchperto convertireconvert ilthe valorevalue cercatosearched dall’utenteby neithe reportuser in reports
INPUT EAND OUTPUT
$table : the table of the field
$column : the column of the field
$fieldname : the field name
$comparator : operatorethe dicomparison confrontooperator
$value : valorethe cercatovalue searched
Hooks
data/CRMEntity.php
include/ListView/ListViewController.php
include/utils/crmv_utils.php
include/utils/EditViewUtils.php
include/utils/DetailViewUtils.php
include/utils/ListViewUtils.php
include/utils/SearchUtils.php
include/QueryGenerator/QueryGenerator.php
modules/PDFMaker/InventoryPDF.php
modules/Reports/ReportRun.php
modules/Users/Users.php
modules/CustomView/Save.php
modules/CustomView/CustomView.php
Smarty/templates/DisplayFieldsReadonly.tpl
Smarty/templates/DisplayFieldsHidden.tpl
Smarty/templates/DetailViewFields.tpl
Smarty/templates/EditViewUI.tpl
Smarty/templates/DetailViewUI.tpl