Install Signature Field
During the steps you can replace the names of the classes and the names of the files and/or the relative paths
If during the steps you change the names of the files, classes andor /the names of the files and/or the relative paths remember to change them also in the scripts that we are going to create and in the installation script (InstallSignatureField.phpphp )(last step)
- Create new file
TouchCustom.php
in(or whatever you want)modules/SDK/src/MyCustomizations/modules/Touch
folder (or whatever you want).folder. Put the following piece of code in the file:
<?php
require_once('modules/Touch/Touch.php');
class TouchCustom extends Touch { // You can replace "Custom" with whatever you want
public function __construct() {
parent::__construct();
$this->webservices['GetRecord'] = array('file' => 'overrides/TouchGetRecord2.TouchGetRecordCustom.php', 'class' => 'TouchGetRecord2'TouchGetRecordCustom'); // You can replace "Custom" with whatever you want
$this->webservices['SaveRecord'] = array('file' => 'overrides/TouchSaveRecord2.TouchSaveRecordCustom.php', 'class' => 'TouchSaveRecord2'TouchSaveRecordCustom'); // You can replace "Custom" with whatever you want
}
}
TouchGetRecordCustom.php
inmodules/Touch/vtws2/overrides
folder. Put the following piece of code in the file:
<?php
include('modules/Touch/vtws2/TouchGetRecord.php');
class TouchGetRecordCustom extends TouchGetRecord {
function process(&$request) {
$module = $request['module'];
$record = parent::process($request);
if ($record && $record['success'] && $recordid == 0) {
if (in_array($module, array('ModuleCustom1', 'ModuleCustom2', 'ModuleCustomN'))) {
$no_image_lbl = getTranslatedString('NO_SIGNATURE_IMAGE', $module);
if (isset($record['signature']) && $record['signature'] == $no_image_lbl) {
$record['signature'] = '';
}
}
}
$record['success'] = true;
return $record;
}
function retrieveRecord($module, $recordid, $prodblock = 0) {
$record = parent::retrieveRecord($module, $recordid, $prodblock);
if ($recordid > 0) {
if (in_array($module, array('ModuleCustom1', 'ModuleCustom2', 'ModuleCustomN'))) {
$no_image_lbl = getTranslatedString('NO_SIGNATURE_IMAGE', $module);
if (!empty($record['signature']) && $record['signature'] != $no_image_lbl) {
$img_path = $record['signature'];
$type = pathinfo($img_path, PATHINFO_EXTENSION);
$data = file_get_contents($img_path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
$record['signature'] = $base64;
} else {
$record['signature'] = '';
}
}
}
return $record;
}
}
- Create new file Custom.js
(or whatever you want)in modules/Touch/overrides. The app will automatically download it to extend/overwrite the default behavior. Put the following piece of code in the file:
(function() {
if (Vtecrm && Vtecrm.app) {
Ext.define("Vtecrm.view.ShowRecordCustom", { // You can replace "Custom" with whatever you want
override: "Vtecrm.view.ShowRecord",
signatureModules: ["HelpDesk", "ModuleCustom1", "ModuleCustom2", "ModuleCustomN"], // ModuleCustom* are the modules where you want to enable the signature
});
}
})();
If you already have app customizations in thea file, you just need to add the class definition (Vtecrm.view.ShowRecordCustom
).
If you have already extended/overwritten the class Vtecrm.view.ShowRecord
you just need to overwrite the variable signatureModules
adding the modules where you want to enable the signature
- Create new file InstallSignatureField.php (or whatever you want) in plugins/script folder and copy&paste the following code:
<?php
die(); // Uncomment this to run the script
require('../../config.inc.php');
chdir($root_directory);
require_once('include/utils/utils.php');
require_once('vtlib/Vtecrm/Module.php');
$Vtiger_Utils_Log = true;
global $adb, $table_prefix;
VteSession::start(); // crmv@128133
SDK::setClass('Touch', 'TouchCustom', 'modules/SDK/src/MyCustomizations/modules/Touch/TouchCustom.php'); // You can replace "Custom" with whatever you
$moduleName = 'ModuleCustom'; // ModuleCustom is the module where you want to enable the signature
$signatureBlock = new Vtiger_Block();
$signatureBlock->label = 'LBL_SIGNATURE_BLOCK';
$moduleInstance = Vtiger_Module::getInstance($moduleName);
$moduleInstance->addBlock($signatureBlock);
$fields = array();
$fields[] = array(
'module' => $moduleName,
'block' => 'LBL_SIGNATURE_BLOCK',
'name' => 'signature',
'label' => 'signature',
'uitype' => '1016',
'columntype' => 'VARCHAR(255)',
'typeofdata' => 'V~O'
);
include('modules/SDK/examples/fieldCreate.php');
SDK::setLanguageEntries($moduleName, 'LBL_SIGNATURE_BLOCK', array('it_it' => 'Signature Information', 'en_us' => 'Signature Information'));
SDK::setLanguageEntries($moduleName, 'signature', array('it_it' => 'Firma', 'en_us' => 'Signature'));
SDK::setLanguageEntries($moduleName, 'NO_SIGNATURE_IMAGE', array('it_it' => 'Nessuna Firma', 'en_us' => 'No Signature'));
- Execute the file InstallSignatureField.php and logout/login from VTENEXT on both the web and app side
You can run the script in the browser or through the CLI
cd plugins/script && php -f InstallSignatureField.php > InstallSignatureField.log