[SOLVED][Need CONFIRM] Relate Activities to Custom Module

edited September 2012 in vtlib Vote Up0Vote Down
I needed to relate Activities to my Custom Module. Using vtlib its not working because Calendar module is not fully supported by vtlib. So i made a little workaround for this issue. BUT it would be really, really nice if this or similar solution(one that works with vtlib) would be in next stable version of vtiger.
I am writing this here because i dont know to use wiki (me n00b) or i have no permissions to post new article. How to post this on wiki?

To be clear, what i wanted to achieve is attached as pic.

Step 1:
Follow my instructions here how to get Activities in your Custom Module More Information tab.

Step 2:
insert into file modules/Custom-Module/Custom-Module.js
 document.write("<script type='text/javascript' src='include/js/Merge.js'></"+"script>");
 function verify_data(form) {
       if(! form.createpotential.checked == true)
       {
               if (form.potential_name.value == "")
               {
                       alert(alert_arr.OPPORTUNITYNAME_CANNOT_BE_EMPTY);
                       return false;   
               }
               if (form.closedate.value == "")
               {
                       alert(alert_arr.CLOSEDATE_CANNOT_BE_EMPTY);
                       return false;   
               }
               return dateValidate('closedate','Potential Close Date','GECD');
                       
               
         }
         return true;
 }
 
 function togglePotFields(form)
 {
       if (form.createpotential.checked == true)
       {
               form.potential_name.disabled = true;
               form.closedate.disabled = true;
               
       }
       else
       {
               form.potential_name.disabled = false;
               form.closedate.disabled = false;
       }       
 
 }

 function toggleAssignType(currType)
 {
         if (currType=="U")
         {
                 getObj("assign_user").style.display="block"
                 getObj("assign_team").style.display="none"
         }
         else
         {
                 getObj("assign_user").style.display="none"
                 getObj("assign_team").style.display="block"
         }
 }
 
 function set_return(product_id, product_name) {
       if(document.getElementById('from_link').value != '') {
         window.opener.document.QcEditView.parent_name.value = product_name;
         window.opener.document.QcEditView.parent_id.value = product_id;
       } else {
         window.opener.document.EditView.parent_name.value = product_name;
         window.opener.document.EditView.parent_id.value = product_id;
 }
 }
 
 function set_return_todo(product_id, product_name) {
	if(document.getElementById('from_link').value != '') {
          window.opener.document.QcEditView.task_parent_name.value = product_name;
          window.opener.document.QcEditView.task_parent_id.value = product_id;
        } else {
          window.opener.document.createTodo.task_parent_name.value = product_name;
          window.opener.document.createTodo.task_parent_id.value = product_id;
 	}
 }

Step 3:
at the end of a file modules/Custom-Module/Custom-Module.php insert following function (copied from Leads.php).
         /** Returns a list of the associated emails
          * @param  integer   $id      - leadid
          * returns related emails record in array format
          */
         function get_emails($id, $cur_tab_id, $rel_tab_id, $actions=false) {
                 global $log, $singlepane_view,$currentModule,$current_user;
                 $log->debug("Entering get_emails(".$id.") method ...");
                 $this_module = $currentModule;
 
               $related_module = vtlib_getModuleNameById($rel_tab_id);
                 require_once("modules/$related_module/$related_module.php");
                 $other = new $related_module();
               vtlib_setup_modulevars($related_module, $other);                
                 $singular_modname = vtlib_toSingular($related_module);
                 
                 $parenttab = getParentTab();
                 
                 if($singlepane_view == 'true')
                         $returnset = '&return_module='.$this_module.'&return_action=DetailView&return_id='.$id;
                 else
                         $returnset = '&return_module='.$this_module.'&return_action=CallRelatedList&return_id='.$id;
                 
                 $button = '';
                 
                 $button .= '<input type="hidden" name="email_directing_module"><input type="hidden" name="record">';    
                     
                 if($actions) {
                         if(is_string($actions)) $actions = explode(',', strtoupper($actions));
                         if(in_array('SELECT', $actions) && isPermitted($related_module,4, '') == 'yes') {
                                 $button .= "<input title='".getTranslatedString('LBL_SELECT')." ". getTranslatedString($related_module). "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id&parenttab=$parenttab','test','width=640,height=602,resizable=0,scrollbars=0');\" value='". getTranslatedString('LBL_SELECT'). " " . getTranslatedString($related_module) ."'> ";
                       }

                         if(in_array('ADD', $actions) && isPermitted($related_module,1, '') == 'yes') {
                                 $button .= "<input title='". getTranslatedString('LBL_ADD_NEW')." ". getTranslatedString($singular_modname)."' accessyKey='F' class='crmbutton small create' onclick='fnvshobj(this,\"sendmail_cont\");sendmail(\"$this_module\",$id);' type='button' name='button' value='". getTranslatedString('LBL_ADD_NEW')." ". getTranslatedString($singular_modname)."'></td>";
                         }
                 } 
 
                 $query ="select case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name," .
                                 " vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.semodule, vtiger_activity.activitytype," .
                                 " vtiger_activity.date_start, vtiger_activity.status, vtiger_activity.priority, vtiger_crmentity.crmid," .
                                 " vtiger_crmentity.smownerid,vtiger_crmentity.modifiedtime, vtiger_users.user_name, vtiger_seactivityrel.crmid as parent_id " .
                                 " from vtiger_activity" .
                                 " inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid" .
                                 " inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid" .
                                 " left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid" .
                                 " inner join vtiger_users on  vtiger_users.id=vtiger_crmentity.smownerid" .
                                 " where vtiger_activity.activitytype='Emails' and vtiger_crmentity.deleted=0 and vtiger_seactivityrel.crmid=".$id;      
                                         
                 $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); 
                 
                 if($return_value == null) $return_value = Array();
                 $return_value['CUSTOM_BUTTON'] = $button;
                 
                 $log->debug("Exiting get_emails method ...");           
                 return $return_value;
         }

Step 4:
for $app_strings array (labels) insert into file include/language/en_us.lang.php
 'CUSTOM-MODULE'=>'Custom-Module',
 'COMBO_CUSTOM-MODULE'=>'Custom-Module',
 'LBL_CUSTOM-MODULE_NAME' => 'Custom-Module',

Step 5:
insert getCustom-ModuleName function in file include/utils/CommonUtils.php
 /**  
  * Function to get the Custom-Module Name when a contact id is given
  * Takes the input as $custom-moduleid - Custom-Module id
  * returns the Custom-Module Name in string format.
  */
 function getCustom-ModuleName($custom-module_id)
 {
         global $log;
         $log->debug("Entering getCustom-ModuleName(".$Custom-Module_id.") method ...");
         $log->info("in getCustom-ModuleName ".$custom-module_id);
 
         global $adb, $current_user;
         $custom-module_name = '';
         if($custom-module_id != '')
         {
                 $sql = "select * from vtiger_custom-module where custom-moduleid=?";
                 $result = $adb->pquery($sql, array($custom-module_id));
                 $custom-module_name = $adb->query_result($result,0,"custom-modulename");
         }
         $log->debug("Exiting getCustom-ModuleName method ...returning $custom-module_name");
         return $custom-module_name;
 }
Step 6:
for uitype 66 (this is for DetailView) other uitypes still in question.
in file include/utils/DetailViewUtils.php insert following around line 923
                       elseif($parent_module == "Custom-Module")
                       {
                               $label_fld[] = $app_strings['LBL_CUSTOM-MODULE_NAME'];
                               $custom-module_name = getCustom-ModuleName($value);
                               $label_fld[] = '<a href="index.php?module='.$parent_module.'&action=DetailView&record='.$value.'">'.$custom-module_name.'</a>';
                       }

Step 7:
in file include/utils/EditViewUtils.php around line 758 insert following
                       elseif($parent_module == "Custom-Module")
                       {
                               $parent_name = getCustom-ModuleName($value);
                               $custom-module_selected = "selected";
                       }
and around line 830 you should have this
                $editview_label[0] = array(
                        $app_strings['COMBO_CUSTOM-MODULE'],
                        $app_strings['COMBO_LEADS'],
                        $app_strings['COMBO_ACCOUNTS'],
                        $app_strings['COMBO_POTENTIALS'],
                );
                $editview_label[1] = array(
                        $custom-module_selected,
                        $lead_selected,
                        $account_selected,
                        $potential_selected
                );
                $editview_label[2] = array(
                        "Custom-Module&action=Popup",
                        "Leads&action=Popup",
                        "Accounts&action=Popup",
                        "Potentials&action=Popup"
                );
Step 8:
for listview Related To field insert in file include/utils/ListViewUtils.php arround line 3346 following
       if($parent_module == 'Custom-Module')
       {
               $parent_query = "SELECT custom-modulename FROM vtiger_custom-module WHERE custom-moduleid=?";
               $parent_result = $adb->pquery($parent_query, array($parent_id));
               $parent_name = textlength_check($adb->query_result($parent_result,0,"custom-modulename"));
       }

Step 9:
for picklist values insert following in modules/Calendar/addEventUI.php
around line 645
                                                                       <option value="Custom-Module"><?php echo $app_strings['LBL_CUSTOM-MODULE_NAME']?></option>
and around line 959
                                               <option value="Custom-Module"><?php echo $app_strings['LBL_CUSTOM-MODULE_NAME']?></option>

Step 10:
Test and give me feedback! I would be glad to fix issues with this workaround!

NOTE
When using code i posted here... please be advised to change every occurrences of Custom-Module, CUSTOM-MODULE and custom-module with your module and watch out for big letters because they MATTER!

Great thing about this is that when you create a task or event from your custom module more info page you get your module record already related to that activity. All you need to do, in example of a todo, is write name and time. Click save and its related. You dont need to relate it by yourself.

Enjoy! <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>; <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>;
«1

Comments

  • 15 Comments sorted by Votes Date Added
  • does this work with your custom module?
  • this sounds just what i'm looking for as i wish to link activities to service contracts.

    i don't understand step 3 - what is the relevenace of the get_emails function that is added, i would have expeced the get_activities function (or similar) instead.
  • please restate what the purpose of what the custom mod is and the result desired
  • @rogersibley
    yes you are right. get_activities function should be copied instead of get_emails.

    @hassansr
    i have made a custome module. module that has purpose in our company and vtiger installation. we wanted to link that module to activities in calendar. that is not possible using only vtlib. so if someone needs that his or hers module is related to calendar/activities he or her must take these steps.

    what is accomplished with this?
    1. creating a meeting/call/task could be related to record of a custom module.
    2. on custom module detailview you have activities and activity history and you can see what appointments are and were related to this custom module record.
  • thanks for the information provided here, it's helped me with a solution for my client.

    my client is now using this function to allow him to create events from the service contract module. service calls are tracked through trouble tickets, however there are also regular inspection visits built into the contract and this function allows him to keep those separate from the trouble ticketed visits.
  • great job!
    i wanted to apply this feature to my project module (vtiger v5.2.1), but i did something wrong, it didn't work out for me.

    so, let me show you my steps:

    1) i have read the manual

    2) i opened project.js (it contained nothing but a comment) in www\vtigercrm\modules\project and pasted the code, given in the manual (2nd step)

    3) opened project.php in www\vtigercrm\modules\project and pasted the code, given in the manual (3d step), inserted the code, and changed the get_emails to get_activities (you can find two get_emails in the given code).
    but didn't change anything in
    $return_value&#91;'custom_button'&#93; = $button;
    

    4) inserted the following into file include/language/en_us.lang.php
    'project'=&gt;'project', 
     'combo_project'=&gt;'project', 
     'lbl_project_name' =&gt; 'project',
    

    5) inserted the code from step5 in file include/utils/commonutils.php (in the given code nothing was changed)

    6) in file include/utils/detailviewutils.php inserted the following around line 923
    elseif&#40;$parent_module == &quot;project&quot;&#41; 
                           &#123; 
                                   $label_fld&#91;&#93; = $app_strings&#91;'lbl_project_name'&#93;; 
                                   $custom-module_name = getcustom-modulename&#40;$value&#41;; 
                                   $label_fld&#91;&#93; = '&lt;a href=&quot;index&#46;php?module='&#46;$parent_module&#46;'&amp;action=detailview&amp;record='&#46;$value&#46;'&quot;&gt;'&#46;$custom-module_name&#46;'&lt;/a&gt;'; 
                           &#125;
    
    7) in file include/utils/editviewutils.php around line 758 inserted following
    elseif&#40;$parent_module == &quot;project&quot;&#41; 
                           &#123; 
                                   $parent_name = getcustom-modulename&#40;$value&#41;; 
                                   $custom-module_selected = &quot;selected&quot;; 
                           &#125;
    

    and around line 830 i replaced existing (similar) strings by the following
    $editview_label&#91;0&#93; = array&#40; 
                            $app_strings&#91;'combo_project'&#93;, 
                            $app_strings&#91;'combo_leads'&#93;, 
                            $app_strings&#91;'combo_accounts'&#93;, 
                            $app_strings&#91;'combo_potentials'&#93;, 
                    &#41;; 
                    $editview_label&#91;1&#93; = array&#40; 
                            $project_selected, 
                            $lead_selected, 
                            $account_selected, 
                            $potential_selected 
                    &#41;; 
                    $editview_label&#91;2&#93; = array&#40; 
                            &quot;project&amp;action=popup&quot;, 
                            &quot;leads&amp;action=popup&quot;, 
                            &quot;accounts&amp;action=popup&quot;, 
                            &quot;potentials&amp;action=popup&quot; 
                    &#41;;
    

    <!-- s8) --><img src="{smilies_path}/icon_cool.gif" alt="8)" title="cool" /><!-- s8) --> inserted in file include/utils/listviewutils.php arround line 3346 following
    if&#40;$parent_module == 'project'&#41; 
           &#123; 
                   $parent_query = &quot;select custom-modulename from vtiger_custom-module where custom-moduleid=?&quot;; 
                   $parent_result = $adb-&gt;pquery&#40;$parent_query, array&#40;$parent_id&#41;&#41;; 
                   $parent_name = textlength_check&#40;$adb-&gt;query_result&#40;$parent_result,0,&quot;custom-modulename&quot;&#41;&#41;; 
           &#125;
    

    9) inserted following in modules/calendar/addeventui.php
    around line 645
    &lt;option value=&quot;project&quot;&gt;&lt;?php echo $app_strings&#91;'lbl_project_name'&#93;?&gt;&lt;/option&gt;
    

    and around line 959
    &lt;option value=&quot;project&quot;&gt;&lt;?php echo $app_strings&#91;'lbl_project_name'&#93;?&gt;&lt;/option&gt;
    

    can somebody kindly point to my mistakes (unfortunately, i am not a programmer, started learning php only yesterday).
    i think, every vtigercrm user want to relate their project activities to calendar.

    thank you!
  • anyone figure this out with the projects module???
    i need this as well and also tried the steps listed.
    help would be appreciated!

    robert
  • hey guys,

    here is what i did with projects - similar but a few changes to the previous try in this post.
    error message when i go to projects

    i can select projects and relate to projects in the activities mask though.
    the error i get is
    fatal error: call to undefined method project::get_activities() in /home/ostina5/public_html/db/include/utils/detailviewutils.php on line 1740


    any suggestions???

    step 1

    set relation in vtiger database
    vtiger_relatedlist
    135 44 9 get_activities 6 activity 0 add,select
    (projects is 44 for me and activities is 9)
    /** returns a list of the associated tasks
     	 * @param  integer   $id      - leadid
     	 * returns related task or event record in array format
    	*/
    	function get_activities($id, $cur_tab_id, $rel_tab_id, $actions=false) {
    		global $log, $singlepane_view,$currentmodule,$current_user;
    		$log-&gt;debug(&quot;entering get_activities(&quot;&#46;$id&#46;&quot;) method &#46;&#46;&#46;&quot;);
    		$this_module = $currentmodule;
    
            $related_module = vtlib_getmodulenamebyid($rel_tab_id);
    		require_once(&quot;modules/$related_module/activity&#46;php&quot;);
    		$other = new activity();
            vtlib_setup_modulevars($related_module, $other);		
    		$singular_modname = vtlib_tosingular($related_module);
    		
    		$parenttab = getparenttab();
    		
    		if($singlepane_view == 'true')
    			$returnset = '&amp;return_module='&#46;$this_module&#46;'&amp;return_action=detailview&amp;return_id='&#46;$id;
    		else
    			$returnset = '&amp;return_module='&#46;$this_module&#46;'&amp;return_action=callrelatedlist&amp;return_id='&#46;$id;
    		
    		$button = '';
    				
    		$button &#46;= '&lt;input type=&quot;hidden&quot; name=&quot;activity_mode&quot;&gt;';
    		
    		if($actions) {
    			if(is_string($actions)) $actions = explode(',', strtoupper($actions));
    			if(in_array('add', $actions) &amp;&amp; ispermitted($related_module,1, '') == 'yes') {
    				$button &#46;= &quot;&lt;input title='&quot;&#46;gettranslatedstring('lbl_new')&#46; &quot; &quot;&#46; gettranslatedstring('lbl_todo', $related_module) &#46;&quot;' class='crmbutton small create'&quot; &#46;
    					&quot; onclick='this&#46;form&#46;action&#46;value=\&quot;editview\&quot;;this&#46;form&#46;module&#46;value=\&quot;$related_module\&quot;;this&#46;form&#46;return_module&#46;value=\&quot;$this_module\&quot;;this&#46;form&#46;activity_mode&#46;value=\&quot;task\&quot;;' type='submit' name='button'&quot; &#46;
    					&quot; value='&quot;&#46; gettranslatedstring('lbl_add_new')&#46; &quot; &quot; &#46; gettranslatedstring('lbl_todo', $related_module) &#46;&quot;'&gt;&amp;nbsp;&quot;;
    				$button &#46;= &quot;&lt;input title='&quot;&#46;gettranslatedstring('lbl_new')&#46; &quot; &quot;&#46; gettranslatedstring('lbl_todo', $related_module) &#46;&quot;' class='crmbutton small create'&quot; &#46;
    					&quot; onclick='this&#46;form&#46;action&#46;value=\&quot;editview\&quot;;this&#46;form&#46;module&#46;value=\&quot;$related_module\&quot;;this&#46;form&#46;return_module&#46;value=\&quot;$this_module\&quot;;this&#46;form&#46;activity_mode&#46;value=\&quot;events\&quot;;' type='submit' name='button'&quot; &#46;
    					&quot; value='&quot;&#46; gettranslatedstring('lbl_add_new')&#46; &quot; &quot; &#46; gettranslatedstring('lbl_event', $related_module) &#46;&quot;'&gt;&quot;;
    			}
    		}
    
    		$query = &quot;select vtiger_activity&#46;*,vtiger_seactivityrel&#46;*, vtiger_contactdetails&#46;lastname, vtiger_contactdetails&#46;contactid, vtiger_crmentity&#46;crmid, vtiger_crmentity&#46;smownerid, vtiger_crmentity&#46;modifiedtime,case when (vtiger_users&#46;user_name not like '') then vtiger_users&#46;user_name else vtiger_groups&#46;groupname end as user_name,vtiger_recurringevents&#46;recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel&#46;activityid=vtiger_activity&#46;activityid inner join vtiger_crmentity on vtiger_crmentity&#46;crmid=vtiger_activity&#46;activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel&#46;activityid = vtiger_activity&#46;activityid left join vtiger_contactdetails on vtiger_contactdetails&#46;contactid = vtiger_cntactivityrel&#46;contactid left join vtiger_users on vtiger_users&#46;id=vtiger_crmentity&#46;smownerid left outer join vtiger_recurringevents on vtiger_recurringevents&#46;activityid=vtiger_activity&#46;activityid left join vtiger_groups on vtiger_groups&#46;groupid=vtiger_crmentity&#46;smownerid where vtiger_seactivityrel&#46;crmid=&quot;&#46;$id&#46;&quot; and vtiger_crmentity&#46;deleted = 0 and ((vtiger_activity&#46;activitytype='task' and vtiger_activity&#46;status not in ('completed','deferred')) or (vtiger_activity&#46;activitytype not in ('emails','task') and  vtiger_activity&#46;eventstatus not in ('','held'))) &quot;;
    					
    		$return_value = getrelatedlist($this_module, $related_module, $other, $query, $button, $returnset); 
    		
    		if($return_value == null) $return_value = array();
    		$return_value&#91;'custom_button'&#93; = $button;
    		
    		$log-&gt;debug(&quot;exiting get_activities method &#46;&#46;&#46;&quot;);		
    		return $return_value;
    	}
    


    step 2

    added to modules/project/project.js
    /*+**********************************************************************************
     * the contents of this file are subject to the vtiger crm public license version 1&#46;0
     * (&quot;license&quot;); you may not use this file except in compliance with the license
     * the original code is&#58;  vtiger crm open source
     * the initial developer of the original code is vtiger&#46;
     * portions created by vtiger are copyright (c) vtiger&#46;
     * all rights reserved&#46;
     ************************************************************************************/
        document&#46;write(&quot;&lt;script type='text/javascript' src='include/js/merge&#46;js'&gt;&lt;/&quot;+&quot;script&gt;&quot;);
        function verify_data(form) {
               if(! form&#46;createpotential&#46;checked == true)
               {
                       if (form&#46;potential_name&#46;value == &quot;&quot;)
                       {
                               alert(alert_arr&#46;opportunityname_cannot_be_empty);
                               return false;   
                       }
                       if (form&#46;closedate&#46;value == &quot;&quot;)
                       {
                               alert(alert_arr&#46;closedate_cannot_be_empty);
                               return false;   
                       }
                       return datevalidate('closedate','potential close date','gecd');
                               
                       
                 }
                 return true;
        }
    
        function togglepotfields(form)
        {
               if (form&#46;createpotential&#46;checked == true)
               {
                       form&#46;potential_name&#46;disabled = true;
                       form&#46;closedate&#46;disabled = true;
                       
               }
               else
               {
                       form&#46;potential_name&#46;disabled = false;
                       form&#46;closedate&#46;disabled = false;
               }       
    
        }
    
        function toggleassigntype(currtype)
        {
                 if (currtype==&quot;u&quot;)
                 {
                         getobj(&quot;assign_user&quot;)&#46;style&#46;display=&quot;block&quot;
                         getobj(&quot;assign_team&quot;)&#46;style&#46;display=&quot;none&quot;
                 }
                 else
                 {
                         getobj(&quot;assign_user&quot;)&#46;style&#46;display=&quot;none&quot;
                         getobj(&quot;assign_team&quot;)&#46;style&#46;display=&quot;block&quot;
                 }
        }
    
        function set_return(product_id, product_name) {
               if(document&#46;getelementbyid('from_link')&#46;value != '') {
                 window&#46;opener&#46;document&#46;qceditview&#46;parent_name&#46;value = product_name;
                 window&#46;opener&#46;document&#46;qceditview&#46;parent_id&#46;value = product_id;
               } else {
                 window&#46;opener&#46;document&#46;editview&#46;parent_name&#46;value = product_name;
                 window&#46;opener&#46;document&#46;editview&#46;parent_id&#46;value = product_id;
        }
        }
    
        function set_return_todo(product_id, product_name) {
           if(document&#46;getelementbyid('from_link')&#46;value != '') {
                  window&#46;opener&#46;document&#46;qceditview&#46;task_parent_name&#46;value = product_name;
                  window&#46;opener&#46;document&#46;qceditview&#46;task_parent_id&#46;value = product_id;
                } else {
                  window&#46;opener&#46;document&#46;createtodo&#46;task_parent_name&#46;value = product_name;
                  window&#46;opener&#46;document&#46;createtodo&#46;task_parent_id&#46;value = product_id;
           }
        }
    

    step 3

    added to modules/project/project.php
    /** returns a list of the associated tasks
     	 * @param  integer   $id      - leadid
     	 * returns related task or event record in array format
    	*/
    	function get_activities($id, $cur_tab_id, $rel_tab_id, $actions=false) {
    		global $log, $singlepane_view,$currentmodule,$current_user;
    		$log-&gt;debug(&quot;entering get_activities(&quot;&#46;$id&#46;&quot;) method &#46;&#46;&#46;&quot;);
    		$this_module = $currentmodule;
    
            $related_module = vtlib_getmodulenamebyid($rel_tab_id);
    		require_once(&quot;modules/$related_module/activity&#46;php&quot;);
    		$other = new activity();
            vtlib_setup_modulevars($related_module, $other);		
    		$singular_modname = vtlib_tosingular($related_module);
    		
    		$parenttab = getparenttab();
    		
    		if($singlepane_view == 'true')
    			$returnset = '&amp;return_module='&#46;$this_module&#46;'&amp;return_action=detailview&amp;return_id='&#46;$id;
    		else
    			$returnset = '&amp;return_module='&#46;$this_module&#46;'&amp;return_action=callrelatedlist&amp;return_id='&#46;$id;
    		
    		$button = '';
    				
    		$button &#46;= '&lt;input type=&quot;hidden&quot; name=&quot;activity_mode&quot;&gt;';
    		
    		if($actions) {
    			if(is_string($actions)) $actions = explode(',', strtoupper($actions));
    			if(in_array('add', $actions) &amp;&amp; ispermitted($related_module,1, '') == 'yes') {
    				$button &#46;= &quot;&lt;input title='&quot;&#46;gettranslatedstring('lbl_new')&#46; &quot; &quot;&#46; gettranslatedstring('lbl_todo', $related_module) &#46;&quot;' class='crmbutton small create'&quot; &#46;
    					&quot; onclick='this&#46;form&#46;action&#46;value=\&quot;editview\&quot;;this&#46;form&#46;module&#46;value=\&quot;$related_module\&quot;;this&#46;form&#46;return_module&#46;value=\&quot;$this_module\&quot;;this&#46;form&#46;activity_mode&#46;value=\&quot;task\&quot;;' type='submit' name='button'&quot; &#46;
    					&quot; value='&quot;&#46; gettranslatedstring('lbl_add_new')&#46; &quot; &quot; &#46; gettranslatedstring('lbl_todo', $related_module) &#46;&quot;'&gt;&amp;nbsp;&quot;;
    				$button &#46;= &quot;&lt;input title='&quot;&#46;gettranslatedstring('lbl_new')&#46; &quot; &quot;&#46; gettranslatedstring('lbl_todo', $related_module) &#46;&quot;' class='crmbutton small create'&quot; &#46;
    					&quot; onclick='this&#46;form&#46;action&#46;value=\&quot;editview\&quot;;this&#46;form&#46;module&#46;value=\&quot;$related_module\&quot;;this&#46;form&#46;return_module&#46;value=\&quot;$this_module\&quot;;this&#46;form&#46;activity_mode&#46;value=\&quot;events\&quot;;' type='submit' name='button'&quot; &#46;
    					&quot; value='&quot;&#46; gettranslatedstring('lbl_add_new')&#46; &quot; &quot; &#46; gettranslatedstring('lbl_event', $related_module) &#46;&quot;'&gt;&quot;;
    			}
    		}
    
    		$query = &quot;select vtiger_activity&#46;*,vtiger_seactivityrel&#46;*, vtiger_contactdetails&#46;lastname, vtiger_contactdetails&#46;contactid, vtiger_crmentity&#46;crmid, vtiger_crmentity&#46;smownerid, vtiger_crmentity&#46;modifiedtime,case when (vtiger_users&#46;user_name not like '') then vtiger_users&#46;user_name else vtiger_groups&#46;groupname end as user_name,vtiger_recurringevents&#46;recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel&#46;activityid=vtiger_activity&#46;activityid inner join vtiger_crmentity on vtiger_crmentity&#46;crmid=vtiger_activity&#46;activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel&#46;activityid = vtiger_activity&#46;activityid left join vtiger_contactdetails on vtiger_contactdetails&#46;contactid = vtiger_cntactivityrel&#46;contactid left join vtiger_users on vtiger_users&#46;id=vtiger_crmentity&#46;smownerid left outer join vtiger_recurringevents on vtiger_recurringevents&#46;activityid=vtiger_activity&#46;activityid left join vtiger_groups on vtiger_groups&#46;groupid=vtiger_crmentity&#46;smownerid where vtiger_seactivityrel&#46;crmid=&quot;&#46;$id&#46;&quot; and vtiger_crmentity&#46;deleted = 0 and ((vtiger_activity&#46;activitytype='task' and vtiger_activity&#46;status not in ('completed','deferred')) or (vtiger_activity&#46;activitytype not in ('emails','task') and  vtiger_activity&#46;eventstatus not in ('','held'))) &quot;;
    					
    		$return_value = getrelatedlist($this_module, $related_module, $other, $query, $button, $returnset); 
    		
    		if($return_value == null) $return_value = array();
    		$return_value&#91;'custom_button'&#93; = $button;
    		
    		$log-&gt;debug(&quot;exiting get_activities method &#46;&#46;&#46;&quot;);		
    		return $return_value;
    	}
    
    

    step 4

    added to include/language/en_us.lang.php
    
    'project' =&gt; 'projects',
    'combo_project'=&gt;'projects',
    'lbl_project_name' =&gt; 'projects',
    
    
    step 5
    
    added to include/utils/commonutils&#46;php
    
       /** 
          * function to get the custom-module name when a contact id is given
          * takes the input as $custom-moduleid - custom-module id
          * returns the custom-module name in string format&#46;
          */
        function getprojectname($projectid)
        {
                 global $log;
                 $log-&gt;debug(&quot;entering getprojectname(&quot;&#46;$projectid&#46;&quot;) method &#46;&#46;&#46;&quot;);
                 $log-&gt;info(&quot;in getprojectname &quot;&#46;$projectid);
    
                 global $adb, $current_user;
                 $projectname = '';
                 if($projectid != '')
                 {
                         $sql = &quot;select * from vtiger_project where projectid=?&quot;;
                         $result = $adb-&gt;pquery($sql, array($projectid));
                         $projectname = $adb-&gt;query_result($result,0,&quot;projectname&quot;);
                 }
                 $log-&gt;debug(&quot;exiting getprojectname method &#46;&#46;&#46;returning $projectname&quot;);
                 return $projectname;
        }
    
    
    step 6

    added to include/utils/detailview.php
    line 923
    
    	elseif($parent_module == &quot;project&quot;)
                           {
                                   $label_fld&#91;&#93; = $app_strings&#91;'lbl_project_name'&#93;;
                                   $projectname = getprojectname($value);
                                   $label_fld&#91;&#93; = '&lt;a href=&quot;index&#46;php?module='&#46;$parent_module&#46;'&amp;action=detailview&amp;record='&#46;$value&#46;'&quot;&gt;'&#46;$projectname&#46;'&lt;/a&gt;';
                           }
    

    step 7

    include/utils/editviewutils.php
    line 758
    	 elseif($parent_module == &quot;project&quot;)
                           {
                                   $parent_name = getprojectname($value);
                                   $project_selected = &quot;selected&quot;;
                           }
    

    line 830
    $editview_label&#91;0&#93; = array(
    			$app_strings&#91;'combo_leads'&#93;,
    			$app_strings&#91;'combo_accounts'&#93;,
    			$app_strings&#91;'combo_potentials'&#93;,
    			$app_strings&#91;'combo_project'&#93;,
    		);
    		$editview_label&#91;1&#93; = array(
    			$lead_selected,
    			$account_selected,
    			$potential_selected,
    			$potential_selected
    		);
    		$editview_label&#91;2&#93; = array(
    			&quot;leads&amp;action=popup&quot;,
    			&quot;accounts&amp;action=popup&quot;,
    			&quot;potentials&amp;action=popup&quot;,
    			&quot;project&amp;action=popup&quot;
    		);
    

    step 8

    include/utils/listviewutils.php
    if($parent_module == 'project')
           {
                   $parent_query = &quot;select projectname from vtiger_project where projectid=?&quot;;
                   $parent_result = $adb-&gt;pquery($parent_query, array($parent_id));
                   $parent_name = textlength_check($adb-&gt;query_result($parent_result,0,&quot;projectname&quot;));
           }
    
    step 9

    modules/calendar/addeventui.php
    line 645
    &lt;option value=&quot;project&quot;&gt;&lt;?php echo $app_strings&#91;'lbl_project_name'&#93;?&gt;&lt;/option&gt;
    

    line 959
    &lt;option value=&quot;project&quot;&gt;&lt;?php echo $app_strings&#91;'lbl_project_name'&#93;?&gt;&lt;/option&gt;
    

    step 10
    error message when i go to projects

    i can select projects and relate to projects in the activities mask


    any suggestions???
  • i had exams and didn't follow forum and mail notifications are not sent to my email. have to check forum notification settings.

    whats on that 1740 line? i checked it in my vtiger and it appears nothing relevant to that error you get. you probably changed something before that line and there is mismatch between our codes.

    and important question, what vtiger version are you using? i tried and been using this only on 510.
  • hi kefalo

    i tested your guide in <!-- l --><a class="postlink-local" href="http://forums.vtiger.com/viewtopic.php?f=95&t=33599">viewtopic.php?f=95&t=33599</a><!-- l --> with my custom module.
    everything was ok, but texbox control can not get value when popup mymodule closed !

    what more should i do ?


    i have a similar problem (i think so ) <!-- l --><a class="postlink-local" href="http://forums.vtiger.com/viewtopic.php?f=95&t=43380">viewtopic.php?f=95&t=43380</a><!-- l -->


    can you help me ?
Sign In or Register to comment.