One of my clients had me setup SugarCRM Community Edition for him. SugarCRM Community Edition is quite nice, it’s open source and free it helps my client to save quite some moeny. However it lacks some advance features such as generating reports. ZuckerReports fills that hole by providing user a way to create multiple types of reports, kudos to the developers behind it.
But after installing it, I noticed there is a bug while creating a Listing Template, whenever there is a custom field (user-defined field) involved in filtering, the returning result is empty. So I dug into the code and found out that the bugs were simple to fix. Just modify one function in each of these two files:
modules/ZuckerListingTemplateOrder/ListingTemplateFilter.php
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | function create_where_clause($parameter_values = array()) { global $beanList, $beanFiles; $result = ""; $beanName = $beanList[$this->module_name]; $beanFile = $beanFiles[$beanName]; if (!empty($beanName) && !empty($beanFile)) { require_once($beanFile); $seed = new $beanName; $field_def = $seed->field_defs[$this->field_name]; if ($field_def["type"] == "relate" && $field_def["source"] == "non-db") { $result .= $field_def["table"].".".$field_def["rname"]; } else { if(substr($this->field_name, -2) == "_c"){ $result .= $seed->table_name."_cstm.".$this->field_name; } else{ $result .= $seed->table_name.".".$this->field_name; } } $result .= " ".$this->comparator." "; if ($this->value_type == "parameter") { $rpl = new ReportParameterLink(); $rpl->retrieve($this->value); $result .= "'".$parameter_values[$rpl->name]."'"; } else { $result .= "'".$this->value."'"; } } return $result; } |
modules/ZuckerListingTemplateOrder/ListingTemplateOrder.php
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | function create_order_clause($parameter_values = array()) { global $beanList, $beanFiles; $result = ""; $beanName = $beanList[$this->module_name]; $beanFile = $beanFiles[$beanName]; if (!empty($beanName) && !empty($beanFile)) { require_once($beanFile); $seed = new $beanName; $field_def = $seed->field_defs[$this->field_name]; if ($field_def["type"] == "relate" && $field_def["source"] == "non-db") { $result .= $field_def["table"].".".$field_def["rname"]; } else { if(substr($this->field_name, -2) == "_c"){ $result .= $seed->table_name."_cstm.".$this->field_name; } else{ $result .= $seed->table_name.".".$this->field_name; } } if ($this->order_type == "asc") { $result .= " asc "; } else { $result .= " desc "; } } return $result; } |
Basically what it does is checking if a field ends with “_c”, if so meaning it’s a custom field so loads it from the correct custom table. Hope this helps with those who have problem listing custom fields from ZuckerReports.
2 Responses to “Fix ZuckerReport Not Reporting Custom Fields”
February 18th, 2010 at 8:46 PM
It might be a bit of a hack but .. thank you!
February 18th, 2010 at 11:12 PM
Until they have an official fix, we can only hack it =)