My goal is to send every day at 6 pm a report of all the notes made every day by an specific person, So they way this can be done is by going through the targets and getting the notes of each target by loading right relationship .
function sendSuiteMail($from,$fromName,$body,$subject){
global $current_user;
console.log($current_user->name);
require_once $_SERVER[DOCUMENT_ROOT].'/include/SugarPHPMailer.php';
$mailer=new SugarPHPMailer();
$mailer->prepForOutbound();
$mailer->setMailerForSystem();
$message = "<html>$current_user->name<br>You logged into ECS CRM today</html>";
$mailer->From = "$from";
$mailer->FromName = "$fromName";
$mailer->IsHTML(true);
$mailer->Subject = $subject;
$mailer->Body = "$body";
//$mailer->AddAddress("$current_user->email1");
$mailer->AddAddress("dsanchez@ecs-support.com");
$mailer->Send();
}
class reportSend{
function after_login_methodReport($bean ,$event, $arguments){
$fromName = "ECS CRM";
$from= "crm@ecs-support.com";
$subject = "New Alert for $bean->name";
$accBean = BeanFactory::getBean('Prospects');
$accBeans = $accBean->get_full_list('name');
$body = "<html>";
foreach($accBeans as $curBean){
$body.=$curBean->name." <br>";
}
$body.=count($accBeans);
$body.="</html>";
sendSuiteMail($from,$fromName,$body,$subject);
}
}
I tried to load a relationship ($accBean->load_relationship(‘prospect_notes’) but its not working , any ideas?