Admin email on manual credit update
If you wish to have admin receive an email notification when another admin updates a user's credit you can add the following to the Model file.
File:
\administrator\components\com_rsappt_pro2\models\user_credit_detail.php
Around line 256 look for:
} else {
// admin edit
$sql = 'INSERT INTO #__sv_apptpro2_user_credit_activity (user_id, comment, operator_id, balance) '.
"VALUES (".JRequest::getVar('user_id').",".
"'".JText::_('RS1_ADMIN_CREDIT_ACTIVITY_EDIT')." ".JRequest::getVar('balance')."',".
$user->id.",".
"(SELECT balance from #__sv_apptpro2_user_credit WHERE user_id = ".JRequest::getVar('user_id')."))";
$this->_db->setQuery($sql);
$this->_db->query();
if ($this->_db->getErrorNum()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
return true;
}
Add the red code..
} else {
// admin edit
$sql = 'INSERT INTO #__sv_apptpro2_user_credit_activity (user_id, comment, operator_id, balance) '.
"VALUES (".JRequest::getVar('user_id').",".
"'".JText::_('RS1_ADMIN_CREDIT_ACTIVITY_EDIT')." ".JRequest::getVar('balance')."',".
$user->id.",".
"(SELECT balance from #__sv_apptpro2_user_credit WHERE user_id = ".JRequest::getVar('user_id')."))";
$this->_db->setQuery($sql);
$this->_db->query();
if ($this->_db->getErrorNum()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
$sql = 'SELECT * FROM #__sv_apptpro2_config';
$this->_db->setQuery($sql);
$apptpro_config = NULL;
$apptpro_config = $this->_db->loadObject();
if($apptpro_config->mailTO != "") {
$mailer = JFactory::getMailer();
$mailer->addRecipient($apptpro_config->mailFROM); // <-- optionally you could hard code an email address here.
$mailer->setSubject("User Credit Update");
$mailer->setBody("User Credit Update on user: ".JRequest::getVar('user_id').", by operator:".$user->id);
if($mailer->send() != true){
logIt("Error sending email: ".$mailer->ErrorInfo);
}
}
return true;
}
The above will send an email to the address in the Config screen, Basic Setup tab, Send email notifications TO box. You can hard code a specific email address if required above where indicated.
Change the subject and/or message text, shown in black, as desired.