Question

I added a custom module in vtigercrm 5.4 using vtlib/moduledir/5.4 by copying this folder.

Everything works fine except one thing, I added hard coded data in database (I create table for my custom module and link this to vtiger_field, vtiger_blocks, vtiger_crmentity, etc...), but this data is not showing when I open my module. I changed table name and columns name in module.php, but everything fails. Can anyone tell me how I show my data in to this list.

image

got something. I add get_related_list function in vtiger_relatedlists table. and create this function in module.php. and in function I add this code:


global $adb; 
$header = array("RabateName");
$data = "SELECT  RabateName FROM vtiger_OrganisationRabate where vtiger_OrganisationRabate.OrganisationRabate_id = ?";
$result = $adb->pquery($data,array(495));
$accountname = array(array());
while($resultrow = $adb->fetchByAssoc($result)) 
{
    $accountname[]=$resultrow;
}
$return_value = array('header'=>$header,'entries'=>$accountname);
return $return_value;

but again fails,still not showing.

Was it helpful?

Solution

You are adding module hard coded in database details. you are missing some of thew table. So my suggestion is to add module by using script.

Here is the script.

<?php 

// Turn on debugging level
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');

$module = new Vtiger_Module();
$module->name = 'Store';
$module->save();

$module->initTables();
$module->initWebservice();

$menu = Vtiger_Menu::getInstance('Support');
$menu->addModule($module);

$block1 = new Vtiger_Block();
$block1->label = 'Organization Information';
$module->addBlock($block1); //to create a new block

$field0 = new Vtiger_Field();
$field0->name = 'organization_name';
$field0->label = 'Organization Name';
$field0->table = $module->basetable; 
$field0->column = 'organization_name';
$field0->columntype = 'VARCHAR(100)';
$field0->uitype = 2;
$field0->typeofdata = 'V~M';
$module->setEntityIdentifier($field0); //to insert values in entity folder
$block1->addField($field0); //to add field in block


$field1 = new Vtiger_Field();
$field1->name = 'store_id_auto';
$field1->label = 'Store ID';
$field1->table = $module->basetable; 
$field1->column = 'store_id_auto';
$field1->columntype = 'VARCHAR(100)';
$field1->uitype = 4;
$field1->typeofdata = 'V~O';
$block1->addField($field1);

//Do not change any value for filed2.
$field2 = new Vtiger_Field();
$field2->name = 'assigned_user_id';
$field2->label = 'Assigned To';
$field2->table = 'vtiger_crmentity'; 
$field2->column = 'smownerid';
$field2->columntype = 'int(19)';
$field2->uitype = 53;
$field2->typeofdata = 'V~M';
$block1->addField($field2);

$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
$module->addFilter($filter1);

// Add fields to the filter created
$filter1->addField($field0, 1);
$filter1->addField($field1, 2);
$filter1->addField($field2, 3);


/** Set sharing access of this module */
$module->setDefaultSharing('Private'); 
/** Enable and Disable available tools */
$module->enableTools(Array('Import', 'Export'));
$module->disableTools('Merge');

 ?>

First create a module folder in modules and copy files from vtlib/ModuleDir/5.4.0 file to the folder created in modules/newmodule

Change name of ModuleFile.js, ModuleFile.php, ModuleFileAjax.php with your module name(with no space).

Keep in mind, During changing name of ModuleFileAjax.php just Replace ModuleFile with name of Module.

Go to modulename.php to change the class name, $table_name (6values change), $table_index (4values change).

Table index is nothing but the moduleid(ex. taskid) which is auto generated after modulecreated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top