@@ -80,16 +80,25 @@ class Pmgmail {
|
||||
* return uid
|
||||
*
|
||||
*/
|
||||
public function sendEmail($app_uid, $mail, $index)
|
||||
public function sendEmail($app_uid, $mailToAddresses, $index, $arrayTask = null, $arrayData = null)
|
||||
{
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Application.php");
|
||||
//getting the default email server
|
||||
$defaultEmail = $this->emailAccount();
|
||||
|
||||
if ($defaultEmail === null) {
|
||||
error_log(G::LoadTranslation('ID_EMAIL_ENGINE_IS_NOT_ENABLED'));
|
||||
return false;
|
||||
}
|
||||
$mailCcAddresses = "";
|
||||
$oApplication = new \Application();
|
||||
$formData = $oApplication->Load($app_uid);
|
||||
|
||||
$frmData = unserialize($formData['APP_DATA']);
|
||||
$dataFormToShowString = "";
|
||||
foreach ($frmData as $field=>$value){
|
||||
if( ($field != 'SYS_LANG') &&
|
||||
|
||||
foreach ($frmData as $field => $value) {
|
||||
if (($field != 'SYS_LANG') &&
|
||||
($field != 'SYS_SKIN') &&
|
||||
($field != 'SYS_SYS') &&
|
||||
($field != 'APPLICATION') &&
|
||||
@@ -99,13 +108,15 @@ class Pmgmail {
|
||||
($field != 'USER_LOGGED') &&
|
||||
($field != 'USR_USERNAME') &&
|
||||
($field != 'DYN_CONTENT_HISTORY') &&
|
||||
($field != 'PIN') ){
|
||||
($field != 'PIN') &&
|
||||
(!is_array($value))
|
||||
) {
|
||||
$dataFormToShowString .= " " . $field . " " . $value;
|
||||
}
|
||||
}
|
||||
$appData = $this->getDraftApp($app_uid, $index);
|
||||
|
||||
foreach ($appData as $application){
|
||||
foreach ($appData as $application) {
|
||||
$appNumber = $application['APP_NUMBER'];
|
||||
$appStatus = $application['APP_STATUS'];
|
||||
$index = $application['DEL_INDEX'];
|
||||
@@ -119,39 +130,69 @@ class Pmgmail {
|
||||
$tasUid = $application['TAS_UID'];
|
||||
$lastIndex = $application['DEL_LAST_INDEX'];
|
||||
|
||||
if($appStatus == "DRAFT"){
|
||||
if ($appStatus == "DRAFT") {
|
||||
$labelID = "PMDRFT";
|
||||
} else {
|
||||
$labelID = "PMIBX";
|
||||
}
|
||||
}
|
||||
|
||||
if (( string ) $mailToAddresses === "") {
|
||||
if ($arrayTask) {
|
||||
$oCases = new \Cases ();
|
||||
|
||||
foreach ( $arrayTask as $aTask ) {
|
||||
if (! isset ( $aTask ["USR_UID"] )) {
|
||||
$aTask ["USR_UID"] = "";
|
||||
}
|
||||
$respTo = $oCases->getTo ( $aTask ["TAS_ASSIGN_TYPE"], $aTask ["TAS_UID"], $aTask ["USR_UID"], $arrayData );
|
||||
$mailToAddresses = $respTo ['to'];
|
||||
$mailCcAddresses = $respTo ['cc'];
|
||||
|
||||
if ($aTask ["TAS_ASSIGN_TYPE"] === "SELF_SERVICE") {
|
||||
$labelID = "PMUASS";
|
||||
if (( string ) $mailToAddresses === "") { // Self Service Value Based
|
||||
$criteria = new \Criteria ( "workflow" );
|
||||
$criteria->addSelectColumn ( \AppAssignSelfServiceValuePeer::GRP_UID );
|
||||
$criteria->add ( \AppAssignSelfServiceValuePeer::APP_UID, $app_uid );
|
||||
|
||||
$rsCriteria = \AppAssignSelfServiceValuePeer::doSelectRs ( $criteria );
|
||||
$rsCriteria->setFetchmode ( \ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
while ( $rsCriteria->next () ) {
|
||||
$row = $rsCriteria->getRow ();
|
||||
}
|
||||
$targetIds = unserialize ( $row ['GRP_UID'] );
|
||||
$oUsers = new \Users ();
|
||||
|
||||
if($mail == ""){
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
|
||||
$oUsers = new \Users();
|
||||
|
||||
if($nextUsr == ""){
|
||||
//Unassigned:
|
||||
$mail = "";
|
||||
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php");
|
||||
$oTaskUsers = new \TaskUser();
|
||||
|
||||
$taskUsers = $oTaskUsers->getAllUsersTask($tasUid);
|
||||
foreach ($taskUsers as $user){
|
||||
$usrData = $oUsers->loadDetails($user['USR_UID']);
|
||||
$nextMail = $usrData['USR_EMAIL'];
|
||||
$mail .= ($mail == '') ? $nextMail : ','. $nextMail;
|
||||
}
|
||||
$labelID = "PMUASS";
|
||||
}else {
|
||||
$usrData = $oUsers->loadDetails($nextUsr);
|
||||
$mail = $usrData['USR_EMAIL'];
|
||||
}
|
||||
if (is_array($targetIds)) {
|
||||
foreach ( $targetIds as $user ) {
|
||||
$usrData = $oUsers->loadDetails ( $user );
|
||||
$nextMail = $usrData ['USR_EMAIL'];
|
||||
$mailToAddresses .= ($mailToAddresses == '') ? $nextMail : ',' . $nextMail;
|
||||
}
|
||||
} else {
|
||||
$group = new \Groups();
|
||||
$users = $group->getUsersOfGroup($targetIds);
|
||||
foreach ($users as $user) {
|
||||
$nextMail = $user['USR_EMAIL'];
|
||||
$mailToAddresses .= ($mailToAddresses == '') ? $nextMail : ',' . $nextMail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$oUsers = new \Users ();
|
||||
|
||||
$usrData = $oUsers->loadDetails ( $nextUsr );
|
||||
$mailToAddresses = $usrData ['USR_EMAIL'];
|
||||
}
|
||||
}
|
||||
|
||||
//first template
|
||||
$pathTemplate = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . "pmGmail.html";
|
||||
if (!file_exists($pathTemplate)){
|
||||
if (!file_exists($pathTemplate)) {
|
||||
$file = @fopen($pathTemplate, "w");
|
||||
fwrite($file, '<div>');
|
||||
fwrite($file, '<span style="display: none !important;">');
|
||||
@@ -173,7 +214,8 @@ class Pmgmail {
|
||||
|
||||
$change = array('[', ']', '"');
|
||||
$fdata = str_replace($change, ' ', $dataFormToShowString);
|
||||
$aFields = array('proName' => $proName,
|
||||
$aFields = array(
|
||||
'proName' => $proName,
|
||||
'appNumber' => $appNumber,
|
||||
'caseUid' => $app_uid,
|
||||
'taskName' => $tasName,
|
||||
@@ -186,18 +228,15 @@ class Pmgmail {
|
||||
'oform' => $fdata
|
||||
);
|
||||
|
||||
$subject = "[PM] " .$proName. " (" . $index . ") Case: ". $appNumber;
|
||||
$subject = "[PM] " . $proName . " (" . $index . ") Case: " . $appNumber;
|
||||
|
||||
//getting the default email server
|
||||
$defaultEmail = $this->emailAccount();
|
||||
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.wsBase.php");
|
||||
$ws = new \wsBase();
|
||||
|
||||
$resultMail = $ws->sendMessage(
|
||||
$app_uid,
|
||||
$defaultEmail, //From,
|
||||
$mail,//To,
|
||||
'',
|
||||
$mailToAddresses,//$To,
|
||||
$mailCcAddresses,//$Cc
|
||||
'',
|
||||
$subject,
|
||||
'pmGmail.html',//template
|
||||
@@ -279,5 +318,3 @@ class Pmgmail {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user