Creating a New Popup UItype in VtigerCRM5.1.0 for a Newly Created Module.
Here things are explained using Locations Module. Locations is a new module that we have already created and is functioning well.
I assume that the newly created UItype is 1001 for Locations popup selector.
1. First I added a method to: include/utils/CommonUtils.php
function getLocationName($location_id)
{
global $log;
 $log->debug("Entering getLocationName(".$location_id.") method ...");
 $log->info("in getlocationname ".$location_id);
 global $adb;
 $sql = "select locationname from vtiger_locations where locationsid=?";
     $result = $adb->pquery($sql, array($location_id));
 $locationname = $adb->query_result($result,0,"locationname");
 $log->debug("Exiting getLocationName method ...");
 return $locationname;
}
2.Added an elseif condition in else if ladder of file:  include/utils/EditViewUtils.php
elseif($uitype == 1001)
{
 if($value != '')
 {
  $location_name = getLocationName($value);
 }
 elseif(isset($_REQUEST['location_id']) && $_REQUEST['location_id'] != '')
 {
  $value = $_REQUEST['location_id'];
  $location_name = getLocationName($value);
 }    
 $pop_type = 'specific';  
 $editview_label[]=getTranslatedString($fieldlabel, $module_name);
 $fieldvalue[] = $location_name;
 $fieldvalue[] = $value;
}
3.Added an elseif condition in else if ladder of file::  include/utils/EditViewUtils.php
elseif($uitype == 1001)
    {
 $label_fld[] =getTranslatedString($fieldlabel, $module);
            $location_id = $col_fields[$fieldname];
            if($location_id != '')
            {
                   $location_name = getLocationName($location_id);
            }
           $label_fld[] = $location_name;
 $label_fld["secid"] = $location_id;
 $label_fld["link"] = "index.php?module=Locations&action=DetailView&record=".$location_id; 
    }
Edited Smarty (.tpl) files.
1.Smarty/templates/DetailViewFields.tpl
Replaced following else if 
{elseif $keyid eq '50' || $keyid eq '73' || $keyid eq '51' || $keyid eq '57' || $keyid eq '59' || $keyid eq '75' || $keyid eq '81' || $keyid eq '76' || $keyid eq '78' || $keyid eq '80'}
with
{elseif $keyid eq '50' || $keyid eq '73' || $keyid eq '51' || $keyid eq '57' || $keyid eq '59' || $keyid eq '75' || $keyid eq '1001' || $keyid eq '81' || $keyid eq '76' || $keyid eq '78' || $keyid eq '80'}
2.Smarty/templates/EditViewUI.tpl
Added the following in {elseif} ladder 
{elseif $uitype eq 1001}
 <td width="20%" class="dvtCellLabel" align=right>     
 {assign var="pop_type" value="specific"}    
 <font color="red">{$mandatory_field}</font>{$usefldlabel} {if $MASS_EDIT eq '1'}
 <input type="checkbox" name="{$fldname}_mass_edit_check" id="{$fldname}_mass_edit_check"  class="small" >{/if}
 </td>
 <td width="30%" align=left class="dvtCellInfo">   
 <input name="location_name" readonly type="text" style="border:1px solid #bababa;"  value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}"> <img  src="{'select.gif'|@vtiger_imageurl:$THEME}" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}"  LANGUAGE=javascript onclick='return  window.open("index.php?module=Locations&action=Popup&html=Popup_picker&popuptype={$pop_typ e}&form=EditView&fromlink={$fromlink}","test","width=640,height=602,resizable=0,scrollbars=0");'  align="absmiddle" style='cursor:hand;cursor:pointer'>
    <input type="image" tabindex="{$vt_tab}" src="{'clear_field.gif'|@vtiger_imageurl:$THEME}" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.location_id.value='';this.form.location_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
   </td>
3.Smarty/templates/DetailViewUI.tpl
Added the following in {elseif} ladder 
{elseif $keyid eq '1001'} <!--LocationPopup-->
  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}"> <a  href="{$keyseclink}">{$keyval}</a> </td>    
And Finally:
Added the following in {elseif} ladder : include/js/dtlviewajax.js
else if(uitype == '1001') {
 getObj(dtlView).innerHTML = "<a  href=\"index.php?module=Locations&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbs p;</a>";
}
Added a method to: modules/Locations/Locations.js
document.write("<script type='text/javascript' src='include/js/Mail.js'></"+"script>");
document.write("<script type='text/javascript' src='include/js/Merge.js'></"+"script>");
function set_return_specific(location_id, location_name) 
{
        //getOpenerObj used for DetailView 
        var fldName = getOpenerObj("location_name");
        var fldId = getOpenerObj("location_id");
        fldName.value = location_name;
        fldId.value = location_id;
}
I need some on vtiger crm 5.4.0, please contact me....
ReplyDeleteMy email lenamas (@) gmail.com
Delete