Skip to main content

How to Create a sub-panel and build relationships

How to Create a sub-panel and build relationships on the
modules Oqc-Contract, oqc-Offering, oqc_products.

Attention: Every time you need to make a change like this it's smart to backup the files to be
modified and a backup the database. It must not be done when there are users on-line on the
system.
The module of OpenQuotesandContracts, can be downloaded at the site of sugarforge
in projects, the modules were developed to work with mozzila. This manual will explainain
how to create relationship with other modules, also create the sub-panels of these
relationships. All customizations are not Upgrade-SAFE, or if made some customization the
set up files, should be kept to verify the possibility of having integration with other future
versions of sugarCRM.
Many to many relationships on sugar CRM are made with some steps.
- Define the link of relationship on the vardefs of both modules on the relationship
- Create a metadata file with the fields of DB and definition of the relationship
- Set up the database table
- Create Subpanels
VARDEFS
On vardefs file of the modules is necessary to create some lines to define the link field of
the relationship many-to-many. In oqc_X modules is used in the file
OpenQuotesandContracts.php on the path:
/sugarcrm/custom/Extension/modules/oqc_Contract/Ext/Vardefs/
On this file is necessary to specify the field of their relationship, by adding the following
lines. For example with the Project s module:
//Contracts and Project's relationship test
'project',
'type' => 'link',
'relationship' => 'oqc_Contract_project',
'source' => 'non-db',
);
?>
//Contracts and Project's relationship test
In the original modules of sugarCRM this file doesn't exists, so it is necessary to create a
file with same name: OpenQuotesandContracts.php on the path:
/sugarcrm/custom/Extension/modules/Project/Ext/Vardefs/ (if doesn't exist this path you
need to create it)
In the file it must be specified the link field of the relationship with the contracts. Example
With module projects:
//Relationship test
'oqc_contract',
'type' => 'link',
'relationship' => 'oqc_Contract_project',
'source' => 'non-db',
);
?>
//Relationship test
METADATA
In the metadata file must be defined the relationship between the modules, Fields of the
database are also defined in this file. There is a file for each relationship, since it is a Manyto-
Many relationship. You must creathe the file oqc_ _
MetaData.php on the path:
/sugarcrm/metadata/
It is recommended to copy a file that already exists in that model with similar relationship.
Example with Project's module:
file: /sugarcrm/metadata/oqc_Contract_projectMetaData.php:
( note that the project module is in lower case)
$dictionary["oqc_Contract_project"] = array (
'table' => 'oqc_contract_project',
'fields' =>
array (
0 =>
array (
'name' => 'id',
'type' => 'varchar',
'len' => 36,
),
1 =>
array (
'name' => 'date_modified',
'type' => 'datetime',
),
2 =>
array (
'name' => 'deleted',
'type' => 'bool',
'len' => '1',
'default' => '0',
'required' => true,
),
3 =>
array (
'name' => 'oqc_contract_ida',
'type' => 'varchar',
'len' => 36,
),
4 =>
array (
'name' => 'project_idb',
'type' => 'varchar',
'len' => 36,
),
),
'indices' =>
array (
0 =>
array (
'name' => 'oqc_contract_projectpk',
'type' => 'primary',
'fields' =>
array (
0 => 'id',
),
),
1 =>
array (
'name' => 'oqc_contract_project_ida1',
'type' => 'index',
'fields' =>
array (
0 => 'oqc_contract_ida',
),
),
2 =>
array (
'name' => 'oqc_contract_project_idb2',
'type' => 'index',
'fields' =>
array (
0 => 'project_idb',
),
),
3 =>
array (
'name' => 'oqc_contract_project_idc3',
'type' => 'index',
'fields' =>
array (
0 => 'oqc_contract_ida',
1 => 'project_idb',
),
),
),
'relationships' =>
array (
'oqc_Contract_project' =>
array (
'lhs_module' => 'oqc_Contract',
'lhs_table' => 'oqc_contract',
'lhs_key' => 'id',
'rhs_module' => 'Project',
'rhs_table' => 'project',
'rhs_key' => 'id',
'relationship_type' => 'many-to-many',
'join_table' => 'oqc_contract_project',
'join_key_lhs' => 'oqc_contract_ida',
'join_key_rhs' => 'project_idb',
),
),
);
?>
Table files
So that sugar can repair and build the table you must create a line to refer the metadata file.
On the files: OpenQuotesandContracts.php and tabledictionary.ext.php, respectively, on the
paths:
/sugarcrm/custom/Extension/application/Ext/TableDictionary/
/sugarcrm/custom/application/Ext/TableDictionary/
you must insert a line before ?>. Example with Project's module:
include('metadata/oqc_Contract_projectMetaData.php');
REBUILDING TABLES AND RELATIONSHIPS
After modifing and creating all these files is necessary to enter in sugarcrm on the browser,
go into admin> repair and repair relationships,quick repair and repair DB (database). When
repaired the database is repared sugar will create the table with the fields defined in your
metadata file.
Creating a Sub-panel
In order to create a subpanel on the oqc_something modules it must be created some
definitions on the file: OpenQuotesandContracts.php on the path:
/sugarcrm/custom/Extension/modules/oqc_Contract/Ext/Layoutdefs/
On this file must be created lines to define the sub-panel of the original sugarCRM module,
in my case, project. Example with Project's module.
//Teste subpainel de projetos em contratos
100,
'module' => 'Project',
'subpanel_name' => 'default',
'get_subpanel_data' => 'project',
'add_subpanel_data' => 'project_idb',
'title_key' => 'lbl_project', //this key must be translated on the en_us.lang file
);
?>
//teste subpainel de projetos em contratos
To set up the title of the sub-panel is necessary to put a line on the language file, in my case
was made with Portuguese pt_br.lang.php for English must be done to file en_us.lang.php
on the path:
/sugarcrm/modules/oqc_Contract/language/
This must be done on the language cache file( pt_br.lang.php) as well, on the path:
sugarcrm/cache/modules/oqc_Contract/language/pt_br.lang.php
The key on the previous step must be used: Example with lbl_project:
$mod_strings = array (
'lbl_project'=> 'Projetos',
than Repair extensions and Quick repair.
To set up a oqc Sub-panel on the Original Module (in my case Project), since the
relationship and table are already defined, you just need to define the sub-panel on the
original module on the path: (is it doesn't exists than create it, create the file as well)
sugarcrm/custom/Extension/modules/Project/Ext/Layoutdefs/OpenQuotesAndContracts.php
Example with projectsXoqc_contract:
note oqc_contract
in lower case
'order' => 100,
'module' => 'oqc_Contract',
'subpanel_name' => 'default',
'get_subpanel_data' => 'oqc_contract',
'add_subpanel_data' => 'oqc_Contract_ida',
'title_key' => 'LBL_OQC_CONTRACT_SUBPANEL_TITLE',
);
?>
Quick repair it, and it should be ready to use!

Comments

Popular posts from this blog

Install SugarCRM - Step by Step Guide

SugarCRM is the market-leading, commercial Open Source customer relationship management (CRM) application. SugarCRM’s Open Source architecture easily adapts to any business environment by offering a more flexible, cost-effective alternative than proprietary applications. It offers a complete CRM system for businesses of all sizes. For a small business SugarCRM can be a huge time and expense saver. It requires minimal technical knowledge to get it installed and the built in web administration console and backup system allow you to feel comfortable that it’s going to keep running. Core SugarCRM functionality includes sales automation, marketing campaigns, support cases, project mgmt, calendaring and more. Built in PHP, supports MySQL and SQL Server allows it that cool functionality LAMP system. We have tested it Windows XP/Vista/2k3 . Step 1: Installing XAMPP on Windows 1. Go to http://www.apachefriends.org/en/xampp-windows.html#641 and click "XAMPP Windows 1.7.1". Download...

STRESS MANAGEMENT

STRESS Stress is an unpleasant fact of life.  We all experience it for various reasons,  and we all try to come up with ways of  coping with it—some with more success  than others. So what exactly is stress  doing to your mind (and body)  when you're staring down a deadline?  And what can you do to power through it? What Stress Actually Does  to You and What You Can  Do About It The real problem with stress is that, for such a well  understood and universally experienced condition,  as a society we deal with it so poorly that it leads  to many of our most lethal illnesses and  long-term health problems. High blood  pressure, heart disease, cancer, stroke,  obesity, and insomnia are all medical  conditions across the spectrum that  can be related to or directly influenced  by high stress as an environmental conditio...

Jquery Carousels

Jquery Carousels we all love carousels they are a fantastic way to give the effects we want our visitors to have, more than that we have multiple components to show like images, links, text etc. There are lot many ways to achieve it, Jquery is ofcourse the best possible option available outside. We all search for lot of ems it can be Jquery Flexslider  or Jcarousel Lite  whatever you choose, customization is required, in this tutorial I am not going to focus on how to install these libraries rather one step ahead, to let you know how these carousels can be called multiple times in the same page having their controls working respectively for each carousel instance. So, lets get started with the HTML <div id="sideRight"> <div id="first">       <!-- Do not change the class and tag type, as this will remain as it is for all the following divisions-->       <p class="containheader">Plans for you <a ...