Friday, September 20, 2013

SugarCRM Quote PDF customization


1) Customize Fonts in default PDF of SugarCRM

  • copy and Edit  custom/modules/Quotes/sugarpdf/sugarpdf.quotes.php
  • add html tag for font.
  • like '<b>'.value.'</b>' for bold
  • '<u>'.value.'</u>' for underline
  • '<i>'.value.'</i>'
  • For Example you want to change for quote number :
 Code:  1.(For Label) : $quote[0]['TITLE'] = '<u><b><i>'.$mod_strings['LBL_PDF_QUOTE_NUMBER'].'</i></b></u>';

                 2.(For Value)     :   $quote[0]['VALUE']['value'] = '<u><b><i>'.format_number_display($this->bean->quote_num,$this->bean->system_id).'</i></b></u>';

Output :     





2) Customize Layout Using TcPDF :
 
   Code  :  coming  soon

Wednesday, August 7, 2013

Duplicate Finder

This is what i have find during surfing on internet,

Give an indication next to phone number if it is found to be repeated over various Contacts :

1.Create a process_record logic hook in custom/modules/Contacts/logic_hooks.php



<?php
$hook_array['process_record'][] = Array(1, 'Check Dup', 'custom/modules/Contacts/checkDup.php','checkDupC', 'checkDupF');

2. Create a file checkDup.php in SugarCRM/custom/modules/Contacts/








<?php
class checkDupC{
function checkDupF($bean){
$sContacts = $bean->db->query('SELECT contacts.id FROM contacts WHERE contacts.phone_work = "'.$bean->phone_work.'" AND contacts.id <> "'.$bean->id.'" AND contacts.phone_work IS NOT NULL', true);
$bFound = false;
while($aContacts = $bean->db->fetchByAssoc($sContacts)){
if(!empty($aContacts['id']))
$bFound = true;
}

if($bFound){
$bean->phone_work = $bean->phone_work."&nbsp;".SugarThemeRegistry::current()->getImage('no');
}
}
}

Now, refresh the list view and you should have (X) mark after phone number.









Wednesday, June 26, 2013

Dependable Required Field




e.g.: 
       My Module Name : Desner
       Field                   : desnerStatus_c ( DropDown ) (Values :  nitin, blog, spot, nrsd)



Condition : if i select nrsd from desnerStatus_c dropdown want description required else remove validation.


Step1: Copy or make path like Sugarcrm/custom/modules/Desner/views/view.edit.php

Step2: copy below code in view.edit.php

<?php
require_once('include/MVC/View/views/view.edit.php');
class DesnerViewEdit extends ViewEdit {
    public function __construct() {
        parent::ViewEdit();
        $this->useForSubpanel = true; 
        $this->useModuleQuickCreateTemplate = true; 
    }
    function display() {
        global $mod_strings;
        $jsscript = <<<EOQ

                   <script>
                      
       $('#desnerStatus_c').change(function() {
            makerequired(); 
                       });
 function makerequired()
  {
        var status = $('#desnerStatus_c').val(); 
       if(status == 'nrsd'){                     addToValidate('EditView','description','varchar',true,'{$mod_strings['LBL_DESCRIPTION']}');                           $('#description_label').html('{$mod_strings['LBL_DESCRIPTION']}: <font color="red">*</font>'); 
                            }
       else{
          removeFromValidate('EditView','description');                       
                        $('#description_label').html('{$mod_strings['LBL_DESCRIPTION']}: '); 
                            }
         }
     makerequired(); 
    </script>
EOQ;
        parent::display();
        echo $jsscript;     
    }

}



Note:

  •         It is tested on SugarCRM 6.5 and above
  •         For another version that not supported JQuery add one line after <<<EOQ
         <script src="http://code.jquery.com/jquery-1.9.1.js"></script>




Step 3 : Any Query Please Make comment




                                                       



Thursday, May 30, 2013

Hide Subpanel from Module



Want to Hide Subpanel from Module Permanently ?

Goto : sugarcrm/custom/Extension/modules/Leads/Ext//Layoutdefs/

see for the  layoutdefs.ext.php


if not than create.

( e.g. hide champaign subpanel )

edit that file and add line:

unset($layout_defs['Leads']['subpanel_setup']['campaigns']); 

Than repair and rebult.

Note: You need to create the folders and files if they doesn´t exist.
             If you want that panel than do vice-versa


For Sugarcrm 6.4.X or 6.5.X TRY THIS

Goto : sugarcrm/custom/Extension/modules/Leads/Ext//Layoutdefs/

hide_campaigns_subpanel.php

edit that file and add line:

<?php unset($layout_defs['Leads']['subpanel_setup']['campaigns']);

If file already there than

make file like              _override_hide_campaigns_subpanel.php

Tuesday, April 2, 2013

Copy Field into Related SubPanel




Copy Fields from parent module to related module at real time,

e.g : Need to create case from contacts and want contact field fill in new created case.

Steps => 1

Go to studio and create related field of Contacts in Case module.

Make this field in Edit View, Detail View and Quick Create view.

Steps =>2

Go to SugarCRM/include/generic/SugarWidgets/SugarWidgetSubPanelTopButtonQuickCreate.php

At line 128, place below code:


 if(strtolower($defines['child_module_name']) =='cases') {
            if(strtolower($defines['parent_bean_name']) == 'contact' ){            
                if(isset($defines['focus']->id))$additionalFormFields['contact_id_c'] = $defines['focus']->id;
                if(isset($defines['focus']->name))$additionalFormFields['contact_person_c'] = $defines['focus']->name;
            }            
        }

where contact_id_c and contact_person_c is the my new field id and name


Tuesday, March 19, 2013

Add Field in Address

1) make fields name area_c by studio in contacts and accounts and leads

2) change in /include/SugarFields/Fields/Address/EditView.tpl

add line one line after country
{{assign var="area" value=$displayParams.key|cat:'_address_area_c'}} 


after that add one TR :



<tr>

<td id="{{$area}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >

{sugar_translate label='LBL_AREA' module='{{$module}}'}:
{if $fields.{{$area}}.required || {{if $area|lower|in_array:$displayParams.required}}true{{else}}false{{/if}}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<input type="text" name="{{$area}}" id="{{$area}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$area}}.value}' tabindex="{{$tabindex}}">
</td>
</tr>



add one line like,

address_postalcode.value|escape:'htmlentitydecode'|strip_tags|url2html|nl2br}<br>

{$fields.{{$displayParams.key}}_address_area_c.value}|escape:'htmlentitydecode'|strip_tags|url2html|nl2br}

{$fields.{{$displayParams.key}}_address_country.value|escape:'htmlentitydecode'|strip_tags|url2html|nl2br}
</td>


_address_postalcode.value|escape:'htmlentitydecode'|strip_tags|url2html|nl2br}<br>

{$fields.{{$displayParams.key}}_address_area_c.value|escape:'htmlentitydecode'|strip_tags|url2html|nl2br}
<br>

{$fields.{{$displayParams.key}}_address_country.value|escape:'htmlentitydecode'|strip_tags|url2html|nl2br}
</td>


<td>
<input type="text" name="{{$postalcode}}" id="{{$postalcode}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$postalcode}}.value}' tabindex="{{$tabindex}}">
</td>
</tr>

<!--tr>

<tr>
<td id="{{$area}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' class="dataLabel" >
{sugar_translate label='Area' module='{{$module}}'}:
{{if $area|lower|in_array:$displayParams.required}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{{/if}}
</td>
<td width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].field}}%' class='tabEditViewDF' >
<input type="text" name="{{$area}}" id="{{$area}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$area}}.value}' tabindex="{{$tabindex}}">
</td>
</tr-->
<tr>

<td id="{{$area}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >

{sugar_translate label='Area' module='{{$module}}'}:
{if $fields.{{$area}}.required || {{if $area|lower|in_array:$displayParams.required}}true{{else}}false{{/if}}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<input type="text" name="{{$area}}" id="{{$area}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$area}}.value}' tabindex="{{$tabindex}}">
</td>
</tr>


<tr>
<td id="{{$country}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >



Sunday, March 10, 2013

Show and hide Panel on load and click on checkbox





Step1: Create one .js file in root /var/www/crm/*.js
function display()
{document.getElementById(‘LBL_PANEL5′).style.display = ‘none’;}



Step2: include file in editview.php
‘includes’ =>
array (
0 =>
array (
‘file’ => *.js’,
),
),

step3: onload run file:
),
‘javascript’ => ‘<script type=”text/javascript” language=”Javascript”> onload=display(); </script>’,
),
‘panels’ =>
step4: call function on checkbox event:

‘label’ => ‘LBL_FEEDBACK_TEST_DRIVE’,
’displayParams’ =>
array (
‘field’ =>
array (
‘onChange’ => ‘display();’,
),
),

Sunday, January 27, 2013

Disable Last view in SugarCRM


There is two way to disable lastview.

1) you can write logic hook in custom/modules/Users/logic_hook.php
after_retrive
AND delete all data write in tracker table.
2) if You want to disable for perticular Module,
for e.g. Disable for Account module
go to modules/Accounts/account.php
find get_summary_text() function
comment (//) return value.
Best of Luck…


Tuesday, January 1, 2013

Remove Navigation Warning MSG from Every Page

Steps =>

1=> Just goto sugarcrm/includes/javascript/Sugar_grp1.js

2=> find WARN_UNSAVED_CHANGES

3=> after change code will look like,



if(dataHasChanged==true){

//return SUGAR.language.get('app_strings','WARN_UNSAVED_CHANGES');


}else{return;}}

Ad