Thursday, October 8, 2009

Fix "Related To" problem in Sugar Notes module

We have a customized module "Installation" in Sugar. It related to Notes module. For some reason, when user create a note from Installation module, it doesn't automatically pull out the related Installation record. As a matter of fact, in "related to" field, "Installation" is not even an option.

I know a Dropdown named "parent_type_display", I add Installation into there, but it works for any other activities, such as Call, Meeting.. except Notes.

Then I decided to trace it from the code. I started from index.php, then I found out it is a long trip to reach the problem. I only care about final display, so if the dropdown options is not from "parent_type_display", then it must be somewhere to generate the select options. I need to find how the final html is generated. Then I find file include/EditView/EditView2.php, and it has a method display(). I believe this should be the last method to generate the html stream. I put a log right before the statement
$str .= $this->th->displayTemplate($this->module, $this->view, $this->tpl, $ajaxSave, $this->defs);

Then assumption is approved. This string is the final html. Then I went a step further, dig into method displayTemplate() in file include/TemplateHandler/TemplateHandler.php.

Hmm, it's the place to find what is the final template file. I put a log statement right after :
$file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl';
$GLOBAL['log']->debug("template file name : ".$file);

I found out the template file is catch/modules/Notes/editview.tpl. Then I open this file, search for "select". found this:
{html_options options=$fields.parent_name.options selected=$fields.parent_type.value}

I know fields is an array defined in modules/Notes/vardefs.php, open that file, I see this:
 'parent_name'={
     array(
        'name'=> 'parent_name',
        'parent_type'=>'record_type_display' ,
        'type_name'=>'parent_type',
        'id_name'=>'parent_id', 'vname'=>'LBL_RELATED_TO',
        'type'=>'parent',
        'source'=>'non-db',
        'options'=> 'record_type_display_notes',
        ),

Here it is, the dropdown is not "parent_type_display", I check other module's definition, such as "meetings, calls", they all use "parent_type_display". That's why change this dropdown values, "related to" can be changed for other module except Notes.

Then I goto Dropdown Editor, add my customized module name into "record_type_display_notes". Problem solved.


Tuesday, October 6, 2009

The worst home inspector(1)

I have hired Maureen Wood of Town & Country Home Inspections to inspector my semi-detached house this summer. I interviewed her over the phone, and specially asked if she climbs up to the roof to check roofing. She answered positively.


But she just looked the roof from ground level, and she didn’t discover a hole on the side of the chimney which is a hole torn by raccoon. In the first day I moved in to that house, I discovered a family of raccoon lived in the attic.


If she looked the roof from eaves, she should be able to discover that hole. Or if she was a person who is attention to detail, she should be able to find the mess left by raccoon.   She didn’t enter the attic, just raised her hand into the attic and took a couple of pictures from the attic entrance hole. Even that, she refused to admit she did a poor job and refuse to admit any liability.


If a home inspector didn’t have home construction experience, he or she should at least very handy. After I read the home inspection report thoroughly, I realize this home inspector did nothing for me.


Anything is not visible to me; she has no idea as well. She doesn’t have any device can detect the hazard material, such as asbestos, radon, lead and UFFI.


Something like faucet drips, sink drain clogged… oh, come on, I can see it myself. And home inspector is supposed to give home buyer some advices to fix those problems. Those are all minor problems; anybody who is a little bit handy can fix those themselves.


For example, the clogged drain, there’s a cap on the drain pipe under the sink, if you remove that cap, you can take out the drainage blocker, and clean it regularly. But I believe not everyone knows that, at least the former home owner didn’t know that. And my home inspector probably didn’t know that as well. Because she just told me the drain is clogged, didn’t say anything that is an easy fix.


I have owned my first house for a month. One advice to new home owner is that never hire a home inspector who doesn’t have home construction experience and not able to check roof and attic.
Google+