I have create calculated field on custom module. So basically, this module sum all invoice totals made by each sales. Calculated field is sum of all invoice assigned to user. I have already made the calculated field on detail view and its work. Now, I want to show the calculated field on dashlet. Here is my screenshot :
As you can see, the current sales column is blank. It should be filled with integer value showing sum of invoice total made by sales name. I've created the module, field, and layout using suitecrm studio & module builder. How can I show calculated field on dashlet ?
Here is the function to show calculated field on detail page and its already work, however it doesnt work on dashlet or listview:
public function preDisplay(){
//$this->bean contains all the information on the Case
//use that information to grab the related account bean, something like:
//date format still error here
$a = new AOS_Invoices();
$validFromFormatted = date_create_from_format('m/d/Y', $this->bean->valid_from);
$validToFormatted = date_create_from_format('m/d/Y', $this->bean->valid_through);
$arr = $a->get_full_list(null,'(aos_invoices.assigned_user_id = \''.$this->bean->user_id_c.'\' and invoice_date between \''.date_format($validFromFormatted,'Y-m-d').'\' and \''.date_format($validToFormatted,'Y-m-d').'\')');
$sum = 0;
foreach($arr as $key=>$value){
if(isset($value->total_amount))
$sum += $value->total_amount;
}
$this->bean->current_sales = $sum;
parent::preDisplay();
}
Instead of creating a custom dashlet. You could create a report instead. Add the field you want to be displayed. Add the total amount
field and then set the total function. You could group by the sales name.
On your home screen, add the reports dashlet, select the edit button, and select the report you just created.