function generateMsgAndSendUsMail($pjnames, $userid, $projUniqId, $comp) { $User_id = $this->Auth->user('id'); $this->loadModel('User'); $rec = $this->User->findById($User_id); $from_name = $rec['User']['name'] . ' ' . $rec['User']['last_name']; App::import('helper', 'Casequery'); $csQuery = new CasequeryHelper(new View(null)); App::import('helper', 'Format'); $frmtHlpr = new FormatHelper(new View(null)); ##### get User Details $toUsrArr = $csQuery->getUserDtls($userid); $to = ""; $to_name = ""; if (count($toUsrArr)) { $to = $toUsrArr['User']['email']; $to_name = $frmtHlpr->formatText($toUsrArr['User']['name']); } $multiple = 0; if (stristr($pjnames, ",")) { $multiple = 1; $subject = "You have been added to multiple projects on Orangescrum"; } else { $subject = "You have been added to " . $pjnames . " on Orangescrum"; } $this->Email->delivery = EMAIL_DELIVERY; $this->Email->to = $to; $this->Email->subject = $subject; $this->Email->from = FROM_EMAIL_NOTIFY; $this->Email->template = 'project_add'; $this->Email->sendAs = 'html'; $this->set('to_name', $to_name); $this->set('projName', $pjnames); $this->set('projUniqId', $projUniqId); $this->set('multiple', $multiple); $this->set('company_name', $comp['Company']['name']); $this->set('from_name', $from_name); return $this->Sendgrid->sendgridsmtp($this->Email); }
function generateMsgAndSendMail($uid, $allfiles, $hid_caseno, $case_title, $respond, $hid_proj, $hid_priority, $hid_type, $msg, $emailbody, $assignTo, $name_email, $case_uniq_id, $type, $toEmail = NULL, $toName = NULL, $domain = HTTP_ROOT) { App::import('helper', 'Casequery'); $csQuery = new CasequeryHelper(new View(null)); App::import('helper', 'Format'); $frmtHlpr = new FormatHelper(new View(null)); ##### get User Details $to = ""; $to_name = ""; if (!$toEmail) { $toUsrArr = $csQuery->getUserDtls($uid); if (count($toUsrArr)) { $to = $toUsrArr['User']['email']; $to_name = $frmtHlpr->formatText($toUsrArr['User']['name']); } } else { $to = $toEmail; $to_name = $toName; } ##### get Sender Details $senderUsrArr = $csQuery->getUserDtls(SES_ID); $by_name = ""; $by_name = ""; if (count($senderUsrArr)) { $by_email = $senderUsrArr['User']['email']; $by_name = $frmtHlpr->formatText($senderUsrArr['User']['name']); } //$from_name = preg_replace("/[^a-zA-Z0-9]+/", "", $by_name); $fromname = $frmtHlpr->formatText(trim($senderUsrArr['User']['name'] . " " . $senderUsrArr['User']['last_name'])); ##### get Project Details $Project = ClassRegistry::init('Project'); $Project->recursive = -1; $prjArr = $Project->find('first', array('conditions' => array('Project.id' => $hid_proj), 'fields' => array('Project.name', 'Project.short_name', 'Project.uniq_id'))); $projName = ""; $case_no = ""; $projUniqId = ""; if (count($prjArr)) { $projName = $frmtHlpr->formatText($prjArr['Project']['name']); $case_no = $frmtHlpr->formatText($prjArr['Project']['short_name']) . "-" . $hid_caseno; $projUniqId = $prjArr['Project']['uniq_id']; } ##### get Case Type $cseTyp = ""; $csTypArr = $csQuery->getType($hid_type); if (count($csTypArr)) { $cseTyp = $csTypArr['Type']['name']; } if ($hid_type != 10) { $pri = ""; if ($hid_priority == "NULL" || $hid_priority == "") { $pri = "<font style='color:#AD9227;padding:0;margin:0;height:16px;'>LOW</font>"; } else { if ($hid_priority == 0) { $pri = "<font style='color:#AE432E;padding:0;margin:0;height:16px;'>HIGH</font>"; } else { if ($hid_priority == 1) { $pri = "<font style='color:#28AF51;padding:0;margin:0;height:16px;'>MEDIUM</font>"; } else { if ($hid_priority >= 2) { $pri = "<font style='color:#AD9227;padding:0;margin:0;height:16px;'>LOW</font>"; } } } } $priRity = "<font color='#737373'><b>Priority:</b></font> " . $pri; } else { $priRity = ""; } $postingName = ""; if (SES_ID == $uid) { $postingName = "You have"; } elseif ($by_name) { $postingName = $by_name . " has"; } $from = FROM_EMAIL_NOTIFY; if ($type == "Resolved") { $typ = "-" . strtoupper($type); } else { if ($type == "Closed") { $typ = "-" . strtoupper($type); } else { if ($type == "Started") { $typ = "-" . strtoupper($type); } else { $typ = ""; } } } $projNameInSh = $projName; if (strlen($projNameInSh) > 10) { //$projNameInSh = substr($projNameInSh,0,9).'...'; $projNameInSh = $projNameInSh; } $shrt = $frmtHlpr->formatText($prjArr['Project']['short_name']); if ($shrt) { $projShortNcaseNumber = $hid_caseno . "(" . $shrt . ")"; } else { $projShortNcaseNumber = $hid_caseno; } $subject = EMAIL_SUBJ . ":" . $projNameInSh . ":#" . $projShortNcaseNumber . "-" . stripslashes(html_entity_decode($case_title, ENT_QUOTES)); $message = EMAIL_REPLY . "<body style='width:100%; margin:0; padding:0; -webkit-text-size-adjust:none; -ms-text-size-adjust:none; background-color:#ffffff;'>\n <table cellpadding='0' cellspacing='0' border='0' id='backgroundTable' style='height:auto !important; margin:0; padding:0; width:100% !important; background-color:#F0F0F0;color:#222222; font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:19px; margin-top:0; padding:0; font-weight:normal;'>\n <tr>\n <td>\n <div id='tablewrap' style='width:100% !important; max-width:600px !important; text-align:center; margin:0 auto;'>\n <table id='contenttable' width='600' align='center' cellpadding='0' cellspacing='0' border='0' style='background-color:#FFFFFF; margin:0 auto; text-align:center; border:none; width: 100% !important; max-width:600px !important;border-top:8px solid #5191BD'>\n <tr>\n <td width='100%'>\n <table bgcolor='#FFF' border='0' cellspacing='10' cellpadding='0' width='100%'>\n <tr>\n <td align='left' valign='top' style='line-height:22px;font:14px Arial;'>\n <font color='#737373'><b>Title: </b></font> <a href='" . $domain . "users/login/?dashboard#details/" . $case_uniq_id . "' target='_blank' style='text-decoration:underline;color:#F86A0C;'>" . stripslashes($case_title) . "</a>\n <br/><br/>\n <font color='#737373'><b>Project:</b></font> " . $projName . "\n </td>\n </tr>\n <tr>\n <td>\n <table bgcolor='#FFF' border='0' cellspacing='0' cellpadding='0'>\n <tr>\n <td align='left' style='line-height:22px;font:14px Arial'>\n <font color='#737373'><b>Task#:</b></font> " . $case_no . "\n </td>\n <td style='padding-left:10px;line-height:22px;font:14px Arial'>\n <font color='#737373'><b>Type:</b></font> " . $cseTyp . "\n </td>\n </tr>\n <tr style='height:10px;'><td colspan='2'> </td></tr>\n <tr>\n <td align='left' style='line-height:22px;font:14px Arial'>" . $priRity . "</td>\n <td style='padding-left:10px;line-height:22px;font:14px Arial'>" . $msg . "</td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n <table bgcolor='#F0F0F0' border='0' cellspacing='0' cellpadding='10' width='100%' style='border-top:2px solid #F0F0F0;margin-top:5px;text-align:left;'>\n <tr>\n <td width='100%' bgcolor='#ffffff' style='text-align:left;font:14px Arial'>\n <p>\n <font color='#737373'><b>" . $postingName . " " . $emailbody . "</b></font>\n </p>\n <p>\n " . stripslashes($respond) . "\n </p>\n <p>\n " . $allfiles . "\n </p>\n </td>\t \n </tr>\n " . $assignTo . "\n </table>\n <table bgcolor='#F0F0F0' border='0' cellspacing='0' cellpadding='10' width='100%' style='border-top:2px solid #F0F0F0;margin-top:10px;text-align:left;'>\n <tr>\n <td width='100%' bgcolor='#ffffff' style='text-align:left;font:14px Arial'>\n <p style='color:#676767; line-height:20px;'>\n To read the original message, view comments, reply & download attachment: <br/> Link: <a href='" . $domain . "users/login/dashboard#details/" . $case_uniq_id . "' target='_blank'>" . $domain . "users/login/dashboard#details/" . $case_uniq_id . "</a>\n </p>\n <p style='color:#676767; padding-top:2px;'>\n This email notification is sent by " . $by_name . " to " . $name_email . "\n </p>\n\n </td>\t \n </tr>\n </table>\n <table bgcolor='#F0F0F0' border='0' cellspacing='0' cellpadding='10' width='100%' style='border-top:2px solid #F0F0F0;margin-top:5px;border-bottom:3px solid #2489B3'>\n <tr>\n <td width='100%' bgcolor='#ffffff' style='text-align:center;'>\n <p style='color:#222222; font-family:Arial, Helvetica, sans-serif; font-size:11px; line-height:14px; margin-top:0; padding:0; font-weight:normal;padding-top:5px;'>\n You are receiving this email notification because you have subscribed to Orangescrum, to unsubscribe, please email with subject 'Unsubscribe' to <a href='mailto:" . SUPPORT_EMAIL . "'>" . SUPPORT_EMAIL . "</a>\n\n </p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </div>\n </td>\n </tr>\n </table> \n </body>"; //return $this->Sendgrid->sendEmail($from,$to,$subject,$message,$type); return $this->Sendgrid->sendGridEmail($from, $to, $subject, $message, $type, $fromname); }