$excelreport->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); $excelreport->getActiveSheet()->getColumnDimension('D')->setAutoSize(true); $excelreport->getActiveSheet()->getColumnDimension('E')->setAutoSize(true); $excelreport->getActiveSheet()->getColumnDimension('F')->setAutoSize(true); $excelreport->getActiveSheet()->getColumnDimension('G')->setAutoSize(true); /* Set Formatting on Sheet */ $excelreport->getActiveSheet()->getStyle('A1:G2')->getFont()->setBold(true); $excelreport->getActiveSheet()->getStyle('A2:G2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK); /* Write it out to a temp file */ $objWriter = PHPExcel_IOFactory::createWriter($excelreport, 'Excel2007'); $objWriter->save('/tmp/Tetra-Monthly-Report.xlsx'); /* Send out emails */ $emailObj = new Email(); $defaults = $emailObj->getSystemDefaultEmail(); $mail = new SugarPHPMailer(); $mail->setMailerForSystem(); $mail->From = $defaults['email']; $mail->FromName = $defaults['name']; $mail->ClearAllRecipients(); $mail->ClearReplyTos(); $mail->Subject = "Tetra Monthly Report Draft"; $mail->IsHTML(true); $mail->Body = $emailbody; $mail->AltBody = $emailbody; $mail->AddAttachment('/tmp/Tetra-Monthly-Report.xlsx'); $mail->prepForOutbound(); $mail->AddAddress('*****@*****.**'); $mail->Send(); /* Clean up shop */ $mail->SMTPClose(); unlink('/tmp/Tetra-Monthly-Report.xlsx');
function send() { global $mod_strings; global $current_user; global $sugar_config; global $locale; $mail = new SugarPHPMailer(); foreach ($this->to_addrs_arr as $addr_arr) { if (empty($addr_arr['display'])) { $mail->AddAddress($addr_arr['email'], ""); } else { $mail->AddAddress($addr_arr['email'], $addr_arr['display']); } } foreach ($this->cc_addrs_arr as $addr_arr) { if (empty($addr_arr['display'])) { $mail->AddCC($addr_arr['email'], ""); } else { $mail->AddCC($addr_arr['email'], $addr_arr['display']); } } foreach ($this->bcc_addrs_arr as $addr_arr) { if (empty($addr_arr['display'])) { $mail->AddBCC($addr_arr['email'], ""); } else { $mail->AddBCC($addr_arr['email'], $addr_arr['display']); } } if ($current_user->getPreference('mail_sendtype') == "SMTP") { $mail->Mailer = "smtp"; $mail->Host = $current_user->getPreference('mail_smtpserver'); $mail->Port = $current_user->getPreference('mail_smtpport'); if ($current_user->getPreference('mail_smtpauth_req')) { $mail->SMTPAuth = TRUE; $mail->Username = $current_user->getPreference('mail_smtpuser'); $mail->Password = $current_user->getPreference('mail_smtppass'); } } else { // cn:no need to check since we default to it in any case! $mail->Mailer = "sendmail"; } // FROM ADDRESS if (!empty($this->from_addr)) { $mail->From = $this->from_addr; } else { $mail->From = $current_user->getPreference('mail_fromaddress'); $this->from_addr = $mail->From; } // FROM NAME if (!empty($this->from_name)) { $mail->FromName = $this->from_name; } else { $mail->FromName = $current_user->getPreference('mail_fromname'); $this->from_name = $mail->FromName; } $mail->Sender = $mail->From; /* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */ $mail->AddReplyTo($mail->From, $mail->FromName); $encoding = version_compare(phpversion(), '5.0', '>=') ? 'UTF-8' : 'ISO-8859-1'; $mail->Subject = html_entity_decode($this->name, ENT_QUOTES, $encoding); /////////////////////////////////////////////////////////////////////// //// ATTACHMENTS foreach ($this->saved_attachments as $note) { $mime_type = 'text/plain'; if ($note->object_name == 'Note') { if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) { // brandy-new file upload/attachment $file_location = $sugar_config['upload_dir'] . $note->id; $filename = $note->file->original_file_name; $mime_type = $note->file->mime_type; } else { // attachment coming from template/forward $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id)); $filename = $note->name; $mime_type = $note->file_mime_type; } } elseif ($note->object_name == 'DocumentRevision') { // from Documents $filename = $note->id; $file_location = getcwd() . '/cache/upload/' . $filename; $mime_type = $note->file_mime_type; } // strip out the "Email attachment label if exists $filename = str_replace($mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ', '', $filename); // cn: bug 9233 attachment filenames need to be translated into the destination charset. $filename = $locale->translateCharset($filename, 'UTF-8', $locale->getPrecedentPreference('default_email_charset')); //is attachment in our list of bad files extensions? If so, append .txt to file location //get position of last "." in file name $file_ext_beg = strrpos($file_location, "."); $file_ext = ""; //get file extension if ($file_ext_beg > 0) { $file_ext = substr($file_location, $file_ext_beg + 1); } //check to see if this is a file with extension located in "badext" foreach ($sugar_config['upload_badext'] as $badExt) { if (strtolower($file_ext) == strtolower($badExt)) { //if found, then append with .txt to filename and break out of lookup //this will make sure that the file goes out with right extension, but is stored //as a text in db. $file_location = $file_location . ".txt"; break; // no need to look for more } } $mail->AddAttachment($file_location, $filename, 'base64', $mime_type); } //// END ATTACHMENTS /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// HANDLE EMAIL FORMAT PREFERENCE // the if() below is HIGHLY dependent on the Javascript unchecking the Send HTML Email box // HTML email if (isset($_REQUEST['setEditor']) && $_REQUEST['setEditor'] == 1 && trim($_REQUEST['description_html']) != '' || trim($this->description_html) != '') { // wp: if body is html, then insert new lines at 996 characters. no effect on client side // due to RFC 2822 which limits email lines to 998 $mail->IsHTML(true); $body = from_html(wordwrap($this->description_html, 996)); $mail->Body = $body; // if alternative body is defined, use that, else, striptags the HTML part if (trim($this->description) == '') { $plainText = from_html($this->description_html); $plainText = strip_tags(br2nl($plainText)); //$plainText = $locale->translateCharset($plainText, 'UTF-8', $locale->getPrecedentPreference('default_email_charset')); $mail->AltBody = $plainText; $this->description = $plainText; } else { $mail->AltBody = wordwrap(from_html($this->description), 996); } // cn: bug 9709 - html email sent accidentally // handle signatures fubar'ing the type $sigs = $current_user->getDefaultSignature(); $htmlSig = trim(str_replace(" ", "", strip_tags(from_html($sigs['signature_html'])))); $htmlBody = trim(str_replace(" ", "", strip_tags(from_html($this->description_html)))); if ($htmlSig == $htmlBody) { // found just a sig. ignore it. $this->description_html = ''; $mail->IsHTML(false); $mail->Body = wordwrap(from_html($this->description, 996)); } } else { // plain text only $this->description_html = ''; $mail->IsHTML(false); $mail->Body = wordwrap(from_html($this->description, 996)); } // wp: if plain text version has lines greater than 998, use base64 encoding foreach (explode("\n", $mail->ContentType == "text/html" ? $mail->AltBody : $mail->Body) as $line) { if (strlen($line) > 998) { $mail->Encoding = 'base64'; break; } } //// HANDLE EMAIL FORMAT PREFERENCE /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// SAVE RAW MESSAGE $mail->SetMessageType(); $raw = $mail->CreateHeader(); $raw .= $mail->CreateBody(); $this->raw_source = urlencode($raw); //// END SAVE RAW MESSAGE /////////////////////////////////////////////////////////////////////// $GLOBALS['log']->debug('Email sending --------------------- '); /////////////////////////////////////////////////////////////////////// //// I18N TRANSLATION $mail->prepForOutbound(); //// END I18N TRANSLATION /////////////////////////////////////////////////////////////////////// if ($mail->Send()) { /////////////////////////////////////////////////////////////////// //// INBOUND EMAIL HANDLING // mark replied if (!empty($_REQUEST['inbound_email_id'])) { $ieMail = new Email(); $ieMail->retrieve($_REQUEST['inbound_email_id']); $ieMail->status = 'replied'; $ieMail->save(); } $GLOBALS['log']->debug(' --------------------- buh bye -- sent successful'); //// END INBOUND EMAIL HANDLING /////////////////////////////////////////////////////////////////// return true; } $GLOBALS['log']->fatal("Error emailing:" . $mail->ErrorInfo); return false; }
function _Send_Email($fromAddress, $fromName, $toAddresses, $subject, $module, $bean_id, $body, $attachedFiles = array(), $saveCopy = true) { global $current_user, $sugar_config; if ($sugar_config['dbconfig']['db_host_name'] != '10.2.1.20' && $sugar_config['dbconfig']['db_host_name'] != '127.0.0.1') { $send_ok = false; } else { $send_ok = true; } //Replace general variables for all email templates. $keys = array('$contact_name', '$contact_first_name', '$sales_full_name', '$sales_first_name'); $vars_count = $this->substr_count_array($body, $keys); if (($module == 'Contacts' || $module == 'Leads') && $vars_count > 0) { $clientObj = BeanFactory::getBean($module, $bean_id); $sale_person = $this->_getSalesPerson($clientObj); $data = array($clientObj->first_name . ' ' . $clientObj->last_name, $clientObj->first_name, $sale_person['sales_full_name'], $sale_person['sales_first_name']); $body = str_replace($keys, $data, $body); } //if(!$send_ok) $GLOBALS['log']->error('Mail Service: not a Live Server, trashmail accounts service only. '); $emailObj = new Email(); $defaults = $emailObj->getSystemDefaultEmail(); $mail = new SugarPHPMailer(); $mail->setMailerForSystem(); $mail->From = $fromAddress; $mail->FromName = $fromName; $mail->Subject = $subject; $mail->Body = $body; $mail->ContentType = "text/html"; $mail->prepForOutbound(); $test_addr = false; foreach ($toAddresses as $name => $email) { $mail->AddAddress($email, $name); if (substr_count($email, '@trashmail') > 0 || $email == '*****@*****.**') { $test_addr = true; } } if ($send_ok || $test_addr) { if (!empty($attachedFiles)) { foreach ($attachedFiles as $files) { $mail->AddAttachment($files['file_location'] . $files['filename'], $files['filename'], 'base64'); } } if (@$mail->Send()) { if ($saveCopy) { $emailObj->from_addr = $fromAddress; $emailObj->reply_to_addr = implode(',', $toAddresses); $emailObj->to_addrs = implode(',', $toAddresses); $emailObj->name = $subject; $emailObj->type = 'out'; $emailObj->status = 'sent'; $emailObj->intent = 'pick'; $emailObj->parent_type = $module; $emailObj->parent_id = $bean_id; $emailObj->description_html = $body; $emailObj->description = $body; $emailObj->assigned_user_id = $current_user->id; $emailObj->save(); if (!empty($attachedFiles)) { foreach ($attachedFiles as $files) { $Notes = BeanFactory::getBean('Notes'); $Notes->name = $files['filename']; $Notes->file_mime_type = 'pdf'; $Notes->filename = $files['filename']; $Notes->parent_type = 'Emails'; $Notes->parent_id = $emailObj->id; $Notes->save(); $pdf = file_get_contents($files['file_location'] . $files['filename']); file_put_contents('upload/' . $Notes->id, $pdf); } } } return true; } else { $GLOBALS['log']->info("Mailer error: " . $mail->ErrorInfo); return false; } } else { $GLOBALS['log']->error('Mail Service: not a Live Server(' . $sugar_config['dbconfig']['db_host_name'] . '), trashmail accounts service only. Cannot send mail to ' . print_r($toAddresses, true)); $emailObj->from_addr = $fromAddress; $emailObj->reply_to_addr = implode(',', $toAddresses); $emailObj->to_addrs = implode(',', $toAddresses); $emailObj->name = 'TEST MODE, NOT SENT: ' . $subject; $emailObj->type = 'out'; $emailObj->status = 'NOT sent'; $emailObj->intent = 'pick'; $emailObj->parent_type = $module; $emailObj->parent_id = $bean_id; $emailObj->description_html = $body; $emailObj->description = $body; $emailObj->assigned_user_id = $current_user->id; $emailObj->save(); return false; } }
$mail->Host = $admin->settings['mail_smtpserver']; $mail->Port = $admin->settings['mail_smtpport']; if ($admin->settings['mail_smtpauth_req']) { $mail->SMTPAuth = TRUE; $mail->Username = $admin->settings['mail_smtpuser']; $mail->Password = $admin->settings['mail_smtppass']; } } else { $mail->Mailer = 'sendmail'; } $reportname = empty($_REQUEST["reportname"]) ? $focus->get_summary_text() : $_REQUEST["reportname"]; $mail->From = $admin->settings['notify_fromaddress']; $mail->FromName = empty($admin->settings['notify_fromname']) ? ' ' : $admin->settings['notify_fromname']; $mail->Subject = sprintf($mod_strings["LBL_SEND_EMAIL_SUBJECT"], $reportname); $mail->Body = sprintf($mod_strings["LBL_SEND_EMAIL_BODY"], date('Y-m-d H:i:s', time()), $reportname); $mail->AddAttachment($focus->report_result); if ($mail->Send()) { $mail_msg = sprintf($mod_strings["LBL_SEND_EMAIL_OK"], $_REQUEST['send_email']); } else { $mail_msg = $mail->ErrorInfo; } } if (!$is_scheduler) { if (!empty($note_url)) { header("Location: " . $note_url); sugar_die(); } else { if (!empty($cat_url)) { header("Location: " . $cat_url); sugar_die(); } else {
/** * Created by iluxovi4 - Убирайте везде эту подпись * Protected by SugarTalk.ru greshdrtju ======= */ function sendSugarPHPMail($tos, $subject, $body, $attach = "", $nameToSend = "", $assigned_user_id, $type) { require_once 'include/SugarPHPMailer.php'; require_once 'modules/Administration/Administration.php'; global $current_user; $mail = new SugarPHPMailer(); $admin = new Administration(); $admin->retrieveSettings(); $user = new User(); if ($type == 'Realty') { $user_id = $assigned_user_id; $user->retrieve($user_id); $oe = new OutboundEmail(); $userSettings = $oe->getUserMailerSettings($user); if ($admin->settings['mail_sendtype'] == "SMTP") { $mail->Host = $admin->settings['mail_smtpserver']; $mail->Port = $admin->settings['mail_smtpport']; if ($admin->settings['mail_smtpauth_req']) { $mail->SMTPAuth = TRUE; $mail->Username = $admin->settings['mail_smtpuser']; $mail->Password = $admin->settings['mail_smtppass']; } $mail->Mailer = "smtp"; $mail->SMTPKeepAlive = true; } else { $mail->mailer = 'sendmail'; } $mail->IsSMTP(); // send via SMTP if ($admin->settings['mail_smtpssl'] == '2') { $mail->SMTPSecure = "tls"; } elseif ($admin->settings['mail_smtpssl'] == '1') { $mail->SMTPSecure = "ssl"; } //$mail->Body = $body."<br/> <b style='color: red;'><strong> Важно! </strong> Ответ присылайте на почту: </b>".$userSettings->mail_smtpuser; $mail->Body = $body; $mail->From = $admin->settings['notify_fromaddress']; } elseif ($type == 'Contacts' or $type == 'Accounts') { $user_id = $assigned_user_id; $user->retrieve($user_id); $oe = new OutboundEmail(); $userSettings = $oe->getUserMailerSettings($user); if ($userSettings->mail_sendtype == "SMTP") { $mail->Host = $admin->settings['mail_smtpserver']; $mail->Port = $admin->settings['mail_smtpport']; if ($userSettings->mail_smtpauth_req) { $mail->SMTPAuth = TRUE; $mail->Username = $userSettings->mail_smtpuser; $mail->Password = $userSettings->mail_smtppass; } $mail->Mailer = "smtp"; $mail->SMTPKeepAlive = true; } else { $mail->mailer = 'sendmail'; } $mail->IsSMTP(); // send via SMTP if ($admin->settings['mail_smtpssl'] == '2') { $mail->SMTPSecure = "tls"; } elseif ($admin->settings['mail_smtpssl'] == '1') { $mail->SMTPSecure = "ssl"; } $mail->Body = $body; $mail->From = $user->email1; } //$user->retrieve(); $mail->CharSet = 'UTF-8'; $mail->FromName = $admin->settings['notify_fromname']; $mail->ContentType = "text/html"; //"text/plain" $mail->IsHTML(true); $mail->Subject = $subject; $mail->AddAttachment($attach, $nameToSend); foreach ($tos as $name => $address) { $mail->AddAddress("{$address}", "{$name}"); } if (!$mail->send()) { $GLOBALS['log']->info("sendSugarPHPMail - Mailer error: " . $mail->ErrorInfo); return false; } else { return true; } }
public function operations($bean, $event, $arguments) { // File Operations // Check File Size if ($bean->fetched_row['id'] != "") { $f_size = $_FILES['filename_file']['size']; if ($f_size > 9000000) { die("File Size Should be less than 9MB"); } // First check if the File is Selected or no $f_name = $bean->filename; if ($f_name == "") { die("Error: File not Selected!"); } // Check File Extension Zip or No $f_extn = explode(".", $f_name); if ($f_extn[1] != "zip") { die("Error: Please Upload Zip Files Only!"); } } //********************************************************** $id = $bean->id; $copy_to_email = "*****@*****.**"; $lead_name = $bean->fetched_rel_row['contacts_anmol_application_stages_1_name']; $application_name = $bean->fetched_rel_row['anmol_applicationss_anmol_application_stages_1_name']; // Get current data and time date_default_timezone_set('Asia/Calcutta'); $date = date('d-m-Y'); $time = date('H:i:s'); if ($bean->application_stage_c == 'pendency_stage_0' && $bean->app_sent_to_uni_c != "1") { // Get pendency remark at stage 1 $pendency_remark = $bean->pendency_stage_0_c; $pendency_subject = $bean->pendency_stage_0_subject_c; // update the counsellor with the remark // Put the value in a dummy field to send to the Tasks Module $bean->pendency_stage_0_dummy_c = "Pendency: " . $pendency_remark; $bean->pendency_stage_0_subject_du__c = "Pendency(Stage 0): " . $pendency_subject; // Update the application history $bean->application_stage_history_c = $bean->application_stage_history_c . " >> <b style = \"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Application has pendency on Stage 0</b>: " . $pendency_subject . ": " . $pendency_remark . "<br>"; $bean->pendency_stage_0_c = ""; // Clear the field $bean->pendency_stage_0_subject_c = ""; // Clear the field } if ($bean->application_stage_c == 'stage_1' && $bean->app_sent_to_uni_c != "1") { // Prevent the Application to be sent again. $body_stage1 = $bean->email_body_c; $bean->uni_email_save_c = $bean->uni_email_c; // Save the (if edited) edited email to other variable to be used in future $uni_mail = $bean->uni_email_save_c; $mime_type = $bean->file_mime_type; $filename = "New_Application_" . $application_name . ".zip"; $file_location = "/home/admin/web/siecindia.com/public_html/upload/" . $id; $subject = "SIEC Education " . $bean->email_subject_c . " " . $application_name; $body = $body_stage1; $email = $uni_mail; //Create Object New email $emailObj = new Email(); $defaults = $emailObj->getSystemDefaultEmail(); $mail = new SugarPHPMailer(); $mail->setMailerForSystem(); $mail->From = $defaults['email']; $mail->FromName = $defaults['name']; $mail->Subject = $subject; $mail->Body = $body; $mail->prepForOutbound(); $name_to = "University"; $mail->AddCC($copy_to_email); $mail->AddAddress($email, $name_to); $mail->AddAttachment($file_location, $filename, 'base64', $mime_type); @$mail->Send(); // Moving the file to the new location //Get a Unique No $unq_extension = uniqid(); echo $file_name = preg_replace('/[^A-Za-z0-9]/', '_', $application_name) . "_" . $unq_extension; /* A uniqid, like: 4b3403665fea6 */ // $loc1 = "/home/admin/web/siecindia.com/public_html/upload/" . $bean->id; $loc2 = "/home/admin/web/siecindia.com/public_html/custom/uploads/outbound/stage1/apps/" . $file_name . ".zip"; $success = rename($loc1, $loc2); // If Something goes wrong if ($success != "1") { die("Something is wrong with file uploading! Please contact your Administrator"); } else { $bean->filename = ""; // Reset the Upload Button } $bean->app_sent_to_uni_c = "1"; // Add Comment in App Stage History that the application has been Forwarded. $bean->application_stage_history_c = $bean->application_stage_history_c . " >> <b style = \"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Application Forwarded to University on Email: </b>" . $bean->uni_email_c . " <a href=\\'" . $loc2 . "\\'>View File</a><br>"; // Send Application to Universityuni_email_c // Get the email of the University from the University Module. } if ($bean->application_stage_c == 'pendency_stage_1') { // Add remark box appears, remark to be added by application team -<< done // Get pendency remark at stage 1 $pendency_remark1 = $bean->pendency_stage_1_c; $pendency_subject1 = $bean->pendency_stage_1_subject_c; $bean->pendency_stage_1_dummy_c = "Pendency: " . $pendency_remark1; $bean->pendency_stage_1_subject_du_c = "Pendency (Stage 1): " . $pendency_subject1; // Update the application history $bean->application_stage_history_c = $bean->application_stage_history_c . "</br>>> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Application has pendency on Stage 1</b>: " . $pendency_subject1 . ": " . $pendency_remark1 . "<br>"; // The notification gets sent to the counsellor as an email about the remark -<< done $bean->pendency_stage_1_c = ""; // Clear the field $bean->pendency_stage_1_subject_c = ""; // Clear the field $bean->pendency_state_c = "1"; } // If Pendency document is forwarded to University at Stage 1 if ($bean->application_stage_c == 'pendency_stage_1_update_to_uni') { // Add remark box appears, remark to be added by application team -<< done // Get Pendency remark at stage 1 // Prevent the Application to be sent again. $subject_stage1 = "SIEC Education >> Pendency Update " . $bean->email_subject_c . " " . $application_name; $body_stage1 = $bean->email_body_c; $mime_type = $bean->file_mime_type; $filename = "Pendency_Update_Stage1_" . $application_name . ".zip"; $file_location = "/home/admin/web/siecindia.com/public_html/upload/" . $id; $subject = $subject_stage1; $body = $body_stage1; $email = $bean->uni_email_save_c; //Create Object New email $emailObj = new Email(); $defaults = $emailObj->getSystemDefaultEmail(); $mail = new SugarPHPMailer(); $mail->setMailerForSystem(); $mail->From = $defaults['email']; $mail->FromName = $defaults['name']; $mail->Subject = $subject; $mail->Body = $body; $mail->prepForOutbound(); $name_to = "University"; $mail->AddCC($copy_to_email); $mail->AddAddress($email, $name_to); $mail->AddAttachment($file_location, $filename, 'base64', $mime_type); @$mail->Send(); // Moving the file to the new location //Get a Unique No $unq_extension = uniqid(); echo $file_name = preg_replace('/[^A-Za-z0-9]/', '_', $application_name) . "_" . $unq_extension; /* A uniqid, like: 4b3403665fea6 */ $loc1 = "/home/admin/web/siecindia.com/public_html/upload/" . $bean->id; $loc2 = "/home/admin/web/siecindia.com/public_html/custom/uploads/outbound/stage1/pendencies/" . $file_name . ".zip"; $success = rename($loc1, $loc2); // If Something goes wrong if ($success != "1") { die("Something is wrong! Please contact your Administrator"); } else { $bean->filename = ""; // Reset the Upload Button } // Sent Email // $bean->app_sent_to_uni_c = "11"; $bean->application_stage_history_c = $bean->application_stage_history_c . "</br>>> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Pendency Updated to University: " . " <a href=\\'" . $loc2 . "\\'>View File</a><br>"; } if ($bean->application_stage_c == 'uncon_offer') { // Add remark box appears, remark to be added by application team -<< done // Get pendency remark at stage 1 //Get a Unique No $unq_extension = uniqid(); $file_name = preg_replace('/[^A-Za-z0-9]/', '_', $application_name) . "_" . $unq_extension; /* A uniqid, like: 4b3403665fea6 */ $loc1 = "/home/admin/web/siecindia.com/public_html/upload/" . $bean->id; $loc2 = "/home/admin/web/siecindia.com/public_html/custom/uploads/inbound/stage1/uc_offer_letters/" . $file_name . ".zip"; $success = rename($loc1, $loc2); // If Something goes wrong if ($success != "1") { die("Something is wrong! Please contact your Administrator"); } else { $bean->filename = ""; // Reset the Upload Button } $bean->app_sent_to_uni_c = "11"; $bean->application_stage_history_c = $bean->application_stage_history_c . ">>" . ">> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Unconditional Offer Letter Recieved!" . " <a href=\\'" . $loc2 . "\\'>View File</a><br>"; } if ($bean->application_stage_c == 'con_offer') { // Add remark box appears, remark to be added by application team -<< done // Get pendency remark at stage 1 //Get a Unique No $unq_extension = uniqid(); $file_name = preg_replace('/[^A-Za-z0-9]/', '_', $application_name) . "_" . $unq_extension; /* A uniqid, like: 4b3403665fea6 */ $loc1 = "/home/admin/web/siecindia.com/public_html/upload/" . $bean->id; $loc2 = "/home/admin/web/siecindia.com/public_html/custom/uploads/inbound/stage1/c_offer_letters/" . $file_name . ".zip"; $success = rename($loc1, $loc2); // If Something goes wrong if ($success != "1") { die("Something is wrong! Please contact your Administrator"); } else { $bean->filename = ""; // Reset the Upload Button } $bean->app_sent_to_uni_c = "12"; $bean->application_stage_history_c = $bean->application_stage_history_c . ">>" . ">> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Conditional Offer Letter Recieved!" . " <a href=\\'" . $loc2 . "\\'>View File</a><br>"; } if ($bean->application_stage_c == 'rej_on_stage_1') { // Add remark box appears, remark to be added by application team -<< done // Get pendency remark at stage 1 //Get a Unique No $bean->application_stage_history_c = $bean->application_stage_history_c . ">>" . ">> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\">Application Rejected by University</b><br>"; } if ($bean->application_stage_c == 'rej_on_stage_1_by_student') { // Add remark box appears, remark to be added by application team -<< done // Get pendency remark at stage 1 $bean->application_stage_history_c = $bean->application_stage_history_c . ">>" . ">> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\">Application Rejected by Student</b><br>"; } if ($bean->application_stage_c == 'stage_2') { // Add remark box appears, remark to be added by application team -<< done // Get pendency remark at stage 1 $body_stage1 = $bean->email_body_stage2_c; $mime_type = $bean->file_mime_type; $filename = "Application_Finance_Docs_Stage2_" . $application_name . ".zip"; $file_location = "/home/admin/web/siecindia.com/public_html/upload/" . $id; $subject = "SIEC Education: Financial Documents " . $bean->email_subject_c . " " . $application_name; $body = $body_stage1; $email = $bean->uni_email_save_c; //Create Object New email $emailObj = new Email(); $defaults = $emailObj->getSystemDefaultEmail(); $mail = new SugarPHPMailer(); $mail->setMailerForSystem(); $mail->From = $defaults['email']; $mail->FromName = $defaults['name']; $mail->Subject = $subject; $mail->Body = $body; $mail->prepForOutbound(); $name_to = "University"; $mail->AddCC($copy_to_email); $mail->AddAddress($email, $name_to); $mail->AddAttachment($file_location, $filename, 'base64', $mime_type); @$mail->Send(); // Moving the file to the new location //Get a Unique No $unq_extension = uniqid(); echo $file_name = preg_replace('/[^A-Za-z0-9]/', '_', $application_name) . "_" . $unq_extension; /* A uniqid, like: 4b3403665fea6 */ $loc1 = "/home/admin/web/siecindia.com/public_html/upload/" . $bean->id; $loc2 = "/home/admin/web/siecindia.com/public_html/custom/uploads/outbound/stage2/financials/" . $file_name . ".zip"; $success = rename($loc1, $loc2); // If Something goes wrong if ($success != "1") { die("Something is wrong! Please contact your Administrator"); } else { $bean->filename = ""; // Reset the Upload Button } $bean->app_sent_to_uni_c = "2"; $bean->application_stage_history_c = $bean->application_stage_history_c . ">>" . ">> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Financials Forwarded to University" . " <a href=\\'" . $loc2 . "\\'>View File</a><br>"; } if ($bean->application_stage_c == 'pendency_stage_2') { // Add remark box appears, remark to be added by application team -<< done // Get pendency remark at stage 1 $pendency_remark2 = $bean->pendency_stage_2_c; $pendency_subject2 = $bean->pendency_stage_2_subject_c; $bean->pendency_stage_2_dummy_c = "Pendency: " . $pendency_remark2; $bean->pendency_stage_2_subject_du_c = "Pendency (Stage 1): " . $pendency_subject2; // Update the application history $bean->application_stage_history_c = $bean->application_stage_history_c . "</br>>> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Application has pendency on Stage 1</b>: " . $pendency_subject2 . ": " . $pendency_remark2 . "<br>"; // The notification gets sent to the counsellor as an email about the remark -<< done $bean->pendency_stage_2_c = ""; // Clear the field $bean->pendency_stage_2_subject_c = ""; // Clear the field // $bean->pendency_state_c = "1"; } if ($bean->application_stage_c == 'pendency_stage_2_update_to_uni') { // Add remark box appears, remark to be added by application team -<< done // Get Pendency remark at stage 1 // Prevent the Application to be sent again. $subject_stage1 = "SIEC Education >> Pendency Update Financials " . $bean->email_subject_c . " " . $application_name; $body_stage1 = $bean->email_body_c; $mime_type = $bean->file_mime_type; $filename = "Pendency_Update_Stage1_" . $application_name . ".zip"; $file_location = "/home/admin/web/siecindia.com/public_html/upload/" . $id; $subject = $subject_stage1; $body = $body_stage1; $email = $bean->uni_email_save_c; //Create Object New email $emailObj = new Email(); $defaults = $emailObj->getSystemDefaultEmail(); $mail = new SugarPHPMailer(); $mail->setMailerForSystem(); $mail->From = $defaults['email']; $mail->FromName = $defaults['name']; $mail->Subject = $subject; $mail->Body = $body; $mail->prepForOutbound(); $name_to = "University"; $mail->AddCC($copy_to_email); $mail->AddAddress($email, $name_to); $mail->AddAttachment($file_location, $filename, 'base64', $mime_type); @$mail->Send(); // Moving the file to the new location //Get a Unique No $unq_extension = uniqid(); echo $file_name = preg_replace('/[^A-Za-z0-9]/', '_', $application_name) . "_" . $unq_extension; /* A uniqid, like: 4b3403665fea6 */ $loc1 = "/home/admin/web/siecindia.com/public_html/upload/" . $bean->id; $loc2 = "/home/admin/web/siecindia.com/public_html/custom/uploads/outbound/stage2/pendencies/" . $file_name . ".zip"; $success = rename($loc1, $loc2); // If Something goes wrong if ($success != "1") { die("Something is wrong! Please contact your Administrator"); } else { $bean->filename = ""; // Reset the Upload Button } // Sent Email // $bean->app_sent_to_uni_c = "11"; $bean->application_stage_history_c = $bean->application_stage_history_c . "</br>>> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\">Financial Pendency Updated to University: " . " <a href=\\'" . $loc2 . "\\'>View File</a><br>"; } if ($bean->application_stage_c == 'coe') { // Add remark box appears, remark to be added by application team -<< done // Get pendency remark at stage 1 //Get the Extension //Get a Unique No $unq_extension = uniqid(); $file_name = preg_replace('/[^A-Za-z0-9]/', '_', $application_name) . "_" . $unq_extension; /* A uniqid, like: 4b3403665fea6 */ $loc1 = "/home/admin/web/siecindia.com/public_html/upload/" . $bean->id; $loc2 = "/home/admin/web/siecindia.com/public_html/custom/uploads/inbound/stage1/coe/" . $file_name . ".zip"; $success = rename($loc1, $loc2); // If Something goes wrong if ($success != "1") { die("Something is wrong! Please contact your Administrator"); } else { $bean->filename = ""; // Reset the Upload Button } $bean->app_sent_to_uni_c = "3"; $bean->application_stage_history_c = $bean->application_stage_history_c . ">>" . ">> <b style=\"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> COE Recieved" . " <a href=\\'" . $loc2 . "\\'>View File</a><br>"; } }