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.
detailperto gestiremanage lathe visualizzazionedisplay delof campothe field in DetailView
INPUT
$module : modulothe correntecurrent module name
$fieldlabel: etichettathe dellabel campoof the field
$fieldname : nomethe delname campoof the field
$col_fields: (array) valorithe deivalues campiof the fields
OUTPUT
$label_fld[] : etichettathe tradottatranslated label
$label_fld[] : valorethe davalue visualizzareto be displayed
editperto gestiremanage lathe visualizzazionedisplay delof campothe field in EditView
INPUT
$module_name : modulothe correntecurrent module name
$fieldlabel : etichettathe dellabel campoof the field
$value : valorethe delvalue campoof the field
OUTPUT
$editview_label[] : etichettathe tradottatranslated label
$fieldvalue[] : valorethe davalue visualizzareto be displayed
reportperto gestiremanage lathe visualizzazionedisplay delof campothe neifield in Report
INPUT
$sdk_value : valorethe delvalue campoof the field
OUTPUT
$fieldvalue : valorethe davalue visualizzareto be displayed
SeIf ilthe valorevalue salvatoto nelbe displayed from the interface is formatted differently than the value saved in the database è(e.g. diverso da quello mostrato da interfaccia (es. numeronumber 1.000,25 chewhich devemust esserebe salvatosaved comeas 1000.25) allorathen vannothe gestitefollowing anchemethods lemust seguentialso modalitàbe permanaged salvareto ilsave valorethe nelvalue formatoin correttothe ecorrect ricercarlo.format and search for it.
insertperto convertireconvert ilthe valorevalue nelto formatothe daformat salvareto nelbe saved in the database
INPUT
$this->column_fields : (array) valorithe deivalues campiof the fields
$fieldname : nomethe delname campoof the field
OUTPUT
$fldvalue : valorethe davalue salvareto nelsave in the database
formatvalueperto convertireconvert ilthe valorevalue checoming arrivafrom dallathe $_REQUEST nelinto formatothe salvatoformat nelsaved in the database (usatoused nellain nuovathe gestionenew deimanagement Campiof Condizionali)Conditional Fields)
INPUT
$value : valorethe delvalue campoof the field
OUTPUT
$value : valorethe convertitovalue nelconverted formatoto database format
querygeneratorsearch
per convertire il valore cercato dall’utente in lista e filtri
INPUT E OUTPUT
$fieldname : nome del campo
$operator : operatore di confronto
$value : valore cercato
customviewsearch
per gestire la conversione del valore nei filtri dei popup per i campi reference
INPUT E OUTPUT
$tablename : tabella del campo
$fieldname : nome del campo
$comparator : operatore di confronto
$value : valore cercato
popupbasicsearch
per gestire la conversione del valore nella ricerca dei popup per i campi reference
INPUT
$table_name : the table name
$column_name : the column name
$search_string : valore cercato
OUTPUT
$where : condizione della query
es. $where = "$table_name.$column_name = '".convertToDBFunction($search_string)."'";
popupadvancedsearch
per gestire la conversione del valore nella ricerca avanzata dei popup per i campi reference
INPUT E OUTPUT
$tab_col : the table and the column of the field
$srch_cond : operatore di confronto
$srch_val : valore cercato
reportsearch
per convertire il valore cercato dall’utente nei report
INPUT E OUTPUT
$table : the table of the field
$column : the column of the field
$fieldname : the field name
$comparator : operatore di confronto
$value : valore cercato
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