Since you're running the OS version, I can't just say "Use workflow!"
The code you're looking to customize will be found in ./modules/Cases/Save.php
Basically, you feel for the "Closed" flag, and then do some stuff, a la:
PHP Code:
if($focus->status == 'Closed') {
// do some stuff here
}
The "stuff" part is up to you, but a simple email alert, for cases in particular would be like:
PHP Code:
$email = new Email();
$email->type = 'out';
$email->name = "The Subject";
$email->description = "The body text goes here.";
$email->to_addrs_arr = $email->parse_addrs("", $focus->id, $focus->first_name." ".$focus->last_name, $focus->email1);
$email->from_addr = $current_user->email1;
// link to case
$email->load_relationship("cases");
$email->add($focus->id);
// make it the primary link
$email->parent_type = 'aCase';
$email->parent_id = $focus->id;
// link the CSR
$email->load_relationship("users");
$email->users->add($current_user->id);
// save & send
$email->save();
$email->send();
Notice I said "Like" - you'll have to do the footwork to get the contact from the case, but it's fairly straightforward; just follow the above examples.
The second question is difficult to answer. It requires a pretty deep understanding of Sugar's class system. If you want to attempt this customization, you'll be spending a lot of time in the modules/EmailTemplates module.
The rule of thumb is to do exactly what is being done for Contacts/Leads and just substitute "Cases" in.
If you do get it working, you should start a SugarForge project for this - it's not the first time I've heard this asked for as a feature.
Bookmarks