I've been fighting with sugar to be able to show information that is not managed with sugar but is relative to a contact.
The idea is that when a contact calls, I'd like to be able to see all the information of the contact, also the info that is not inside sugar.
based on the Cookbook from Josh Sweeney, I got it.
Here is how.
- In Studio -> Contacts add a link box called accountlink with a label of Account Link.
- Add the Account Link field to the Detail View then Save and Deploy
- Create a folder <install dir>/myscripts
- Create a file in <install dir>/myscripts/contact_info.php
- In that file add the following code:
Code:
<?php
$contact_id = $_GET['contact_id'];
$account_id = $_GET['account_id'];
echo "<br/><br/><br/><br/>";
echo "Contact ID:" . $contact_id."</br>";
echo "Account ID:" . $account_id."</br>";
echo "aqui posarem tot el que ha comprat el contacte / client";
echo '</br></br><div style="padding:3px;"><a href="#" class="lbAction" rel="deactivate">Close Lightbox</a></div>';
?>
- Open <install dir>/custom/modules/Contacts and copy the scripts and css folders from the lightbox.zip file into the contacts directory.
- Edit <install dir>/custom/modules/Contacts/metadata/editdetailviewdefs.php
- Find the array where accountlink_c is declared and add the line highlighted in blue
Code:
'name' => 'accountlink_c',
'customCode' => '<a href="/myscripts/contact_info.php?contact_id={$fields.id.value}&account_id={$fields.account_id.value}" class="lbOn">Show related information</a>',
'label' => 'LBL_ACCOUNTLINK', - Next we have add a new detail view to override the base detail view.
- Open <install dir>/custom/modules/Contacts and create a new folder named views]
- In view create a file called view.detail.php
- Add the following code:
Code:
<?php
require_once('include/MVC/View/views/view.detail.php');
class ContactsViewDetail extends ViewDetail
{
function ContactsViewDetail()
{
parent::ViewDetail();
}
function display()
{
echo '<link rel="stylesheet" href="/myscripts/lightbox/css/lightbox.css" type="text/css" media="screen" />';
echo '<script type="text/javascript" src="/myscripts/lightbox/scripts/prototype.js"></script>';
echo '<script type="text/javascript" src="/myscripts/lightbox/scripts/lightbox.js"></script>';
parent::display();
}
}
?> - Save and go to a contact record in Sugar.
- Click the link and view the lightbox action.
remember to change script's ownership if needed.
Code:
chown -R www-data:www-data <install dir>/myscripts
attached zip file with lightbox,prototype and contact_info.php
P.D: I'm pretty new on sugar, is this the cleanest way of doing it?
I'd rather put the info in a new tab instead of using a lightbox, anyone has a clue, how to do this?
Bookmarks