How to create a logic hook in SuiteCRM based a custom module 'ProductInvestigation' subpanel of Cases

I’m using a custom module called ProductInvestigation and Cases module; when the user adds/deletes a case from the subpanel; I would like to send an email. It has a one to many relationship. The logic I’m thinking of is that if the cases status is new and ProductInvestigation status is InvestigationClosed then it should send out an email. Function createPIEmailwithCases is what I would like to use to send the email. But how do I get the data from the relationship to be send in the email. Is it that function before_add and after_add should be in this function createPIEmailwithCases? This is what I have so far.

function before_add($bean, $event, $arguments)
    {
		 if ($arguments['related_module'] =='Cases')
		 {
			$bean->new_case_c =$arguments['related_id'];
		  
			
			
			$case_bean = BeanFactory::getBean('Cases', $arguments['related_id']);
			
			/* Get PI Status */
			$pi_status=trim($bean->getFieldValue('status_c'));
			
		
			if ($case_bean->status_c = "New" && $pi_status='Investigation_Closed' ) 
			{
				   
			}
		}
	}
	
	function after_add($bean, $event, $arguments)
    {
	 if ($arguments['related_module'] =='Cases'){
		$bean->new_case_c =$arguments['related_id'];
      
		$bean->save();

	 }
    } 


*function createPIEmailwithCases(&$email,$action_array,$bean,$xtpl){
	
	/* Get PI Number */

	$xtpl->assign('PI_Number', $bean->pinum_c);
	
	/* Get PI Subject */
	$xtpl->assign('PI_Subject', $bean->name);
	
	/* Get Product Name */
	$xtpl->assign('Product_Name', $bean->product_name_c);
	
	/* Get Product Type */
	$xtpl->assign('Product_Type', $bean->type_of_product_c);
	
	/* Get Batch # */
	$xtpl->assign('Batch_Number', $bean->batch_c);
	
	/* Get Size(s) */
	$xtpl->assign('Size', $bean->size_c);
	
	/* Get Fill Date */
	$xtpl->assign('Fill_Date', $bean->filldate_c);
	
	/* Get Batch # */
	$xtpl->assign('BestBefore', $bean->bestbefore_c);

	/* Get PI Description */
	$xtpl->assign('PI_Desc', $bean->description);
	
			
	/* Get Reviewer Name */
	$xtpl->assign('Reviewed_By',$bean->reviewer_c);
	
	$xtpl->assign('Review_Date',$bean->reviewdate_c);

	
	
	/* Create email message using email template and data above */
	$xtpl->parse('block');
	$email->Body = from_html($xtpl->text('block'));
	
	return $email;
}