How to add custom subpanel on detail view page without relationship - sugarcrm

How to add custom subpanel on detail view page without relationship
Eg.: I want to add Accounts subpanel on Leads Detail View Page.

This might give you an edge towards the correct answer but you should be aware that it is fairly involved.
You can create a custom dashlet by adding a file to the director custom/Extension/modules/Leads/Ext/Layout/name_this_file_anything.php
The content of the file should be something add a new element to the array $layout_defs['Leads']['subpanel_setup']. You can probably find what to add from the layout defs files in the existing modules directory.
If you need to create a custom subpanel that is quite a bit more work and involves creating a function called "getSubpanelQueryParts($params)" which queries the required records and returns an array of query parts and adds an element to the subpanel_setup/custom_dashlet array which reads something like this:
'collection_list' => array(
'calls_opportunities' => array(
'subpanel_name' => 'ForAccounts',
'module' => 'Calls',
'get_subpanel_data' => 'function:getSubpanelQueryParts', // here custom method defined
'generate_select' => true, // to build custom SQL query
'function_parameters' => array(
'import_function_file' => 'custom/application/Ext/Utils/custom_calls_opportunities.php',
'return_as_array' => 'true'
), // to get data for subpanel collection item
),
),

Related

How to use/link sys_category field in custom model in TYPO3

I am developing an extension in which I am uploading files and for each file upload I need to have one or more categories associated with it.
I have built a custom category model and it shows fine at the backend when creating a record, but I want to show/link the sys_category records instead of my own custom categories.
How do I link that field in my custom model?
If anyone else stumbles upon this, I found the solution from the documentation thanks to #larry-pete.
Simply add these lines to your ext_tables.php file in your extension folder.
// Add an extra categories selection field to the pages table
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(
'ext_key',
'your_table_name',
'categories',
array(
// Set a custom label
'label' => 'LLL:EXT:ext_key/Resources/Private/Language/locallang.xlf:additional_categories',
// This field should not be an exclude-field
'exclude' => FALSE,
// Override generic configuration, e.g. sort by title rather than by sorting
'fieldConfiguration' => array(
'foreign_table_where' => ' AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC',
),
// string (keyword), see TCA reference for details
'l10n_mode' => 'exclude',
// list of keywords, see TCA reference for details
'l10n_display' => 'hideDiff',
)
);
Hope it helps someone.

How to perform add action in a form only one time, after update the record everytime

I have a form element. When I click the submit button it will add the data to the table.
that is working fine. But my need is to add data to the table only the first time, after each submission data should updated.how we can do this?
function add(){
if(!empty($this->data)){
$this->loadModel('Defineroute');
$this->Defineroute->create();
$this->Defineroute->save($route_data); //route_data is data from the form
}
}
I have one more doubts, I have a view.ctp in the controller I have a view() function for that. But in the view.ctp I use one form element.
How we can write function for that element in the controller? When I try to write function, it shows the error missing view..
CakePhp determines if it should update an existing record or insert a new record based on the presence of the primary key ('id') inside the data you're saving;
This will insert a new record:
$route_data = array(
'Defineroute' => array(
'name' => 'I am a new record'
)
);
$this->Defineroute->save($route_data);
And this will update an existing record;
$route_data = array(
'Defineroute' => array(
'id' => 123,
'name' => 'I will update record with ID 123'
)
);
$this->Defineroute->save($route_data);
To accommodate this in a single form, create the form inside your view/element and only add an input for the id field if you're editing an existing record
Also see Saving your data

SugarCRM restriction on custom field

i'm totally new to SugarCRM module development, however i have very good knowledge of PHP, ajax and database programming.
Here is my task:I have been asked to create a restriction on a custom field from the clients module.
There is a custom field called identification number, what i need to do is avoid a new client to be saved into the database based on that field, in other words the client has to be unique. It has to display a pop up window saying "that client already exists"
Copy editviewdefs.php of Accounts to the custom folder and change the custom field definition for id_number to this
array(
'name' => 'id_number',
'displayParams' =>
array (
'field' =>
array (
'onChange' => 'check_is_duplicate(this);',
),
),
),
Create a javascript function check_is_duplicate
function check_is_duplicate(obj) {
// Call a script via Ajax. Pass values for id and id_number with the request.
if (o.responseText > 0) {
alert('duplicate');
document.getElementById('SAVE').disabled = true;
} else {
document.getElementById('SAVE').disabled = false;
}
}
You would have to create the script which would be called via ajax request.
In that script you would have to run a query like -
SELECT COUNT(*) AS count FROM accounts
WHERE deleted = 0 AND id != {$record} AND id_number = {$id_number}
Execute the query and return the count.
Afterwards on saving check for duplicates from server side using the beforeSave logic hook.
You can create a custom duplicate check by the following code:
$dictionary['Account']['duplicate_check']['FilterDuplicateCheck']['filter_template'] = array(
array(
'$and' => array(
array('identification_number' => array('$equals' => '$identification_number')),
),
),
);
Add this code in the file: /custom/Extension/modules/Accounts/Ext/Vardefs/duplicate_check.php.
Then, perform a quick repair/rebuild.
How it works:
When you enter the identification number and press save, SugarCRM will perform a duplicate check. If duplicates are found, SugarCRM will list the duplicates and you can choose to use the duplicate or ignore.

Symfony2 entityaudit: Add field on revision table

I have 2 entities in my bundle that are audited via simplethings/entity-audit.
I would like to add a field to REVISIONS table call "reason". Every time a user updates or delete an entity, he/she needs to especicify an reason for doing that (why updating/deleting) via form, and this reason should be associated to the entity revision.
How would you guys do it? I dont have much experience in OOP.
Thank you very much in advance.
for adding field you need to add field in your database like 'ip' next you change your bundle in file "logRevisionsListener.php"
private function getRevisionId()
{
if ($this->revisionId === null) {
$this->conn->insert($this->config->getRevisionTableName(), array(
'timestamp' => date_create('now'),
'username' => $this->config->getCurrentUsername(),
'ip' => $this->config->getCurrentUsername(),(not correct just for test it give me the user name)
), array(
Type::DATETIME,
Type::STRING,
Type::STRING
));
.
.
}
I added here the ip field and change your Revision.php file by adding your field with the getter method

How to get the value of the form field in drupal 7?

I have added a field on the page_node_form with the following code.
switch($form_id){
case 'page_node_form':
$form['comment_popup'] = array(
'#type' => 'select',
'#title' => t('Comments popup'),
'#options' => array('On' => 'On', 'Off' => 'Off'),
);
}
As the comment form appears on the node so I want when the comment_popup field has the value Off then the subject field should not be displayed in the comment form and when the comment_popup field has the value 'On' then the subject field should be displayed.
I have tried the following code but it did not work.
case 'comment_node_page_form':
if($form_state['comment_popup']['#value'] == 'Off') {
$form['subject']['#access']=FALSE;
}
Any one who can help me?
What you're doing can't work I'm afraid, you're setting an element in one form and then trying to read it from another form which doesn't make sense.
What you need to do is add a submit handler to the page_node_form function which saves the comment_popup value for that node to a custom table. Then in the form alter for `comment_node_page_form' you need to read in the comment_popup data for that particular node, and make the access decisions to the form elements based on that.
Hope that helps