update v 1.0.7.5

This commit is contained in:
Sujit Prasad
2016-06-13 20:41:55 +05:30
parent aa9786d829
commit 283d97e3ea
5078 changed files with 339851 additions and 175995 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller;
use App\Model\Common\TemplateType;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Settings\Company;
@@ -10,10 +11,9 @@ use App\Model\helpdesk\Settings\Email;
use App\User;
use Auth;
class PhpMailController extends Controller
{
public function fetch_smtp_details($id)
{
class PhpMailController extends Controller {
public function fetch_smtp_details($id) {
$emails = Emails::where('id', '=', $id)->first();
if ($emails->sending_status == 1) {
return $emails;
@@ -29,8 +29,7 @@ class PhpMailController extends Controller
*
* @return Mail
*/
public function sendmail($from, $to, $message, $template_variables)
{
public function sendmail($from, $to, $message, $template_variables) {
// dd($from);
$from_address = $this->fetch_smtp_details($from);
if ($from_address == null) {
@@ -43,6 +42,7 @@ class PhpMailController extends Controller
$smtpsecure = $from_address->sending_encryption;
$host = $from_address->sending_host;
$port = $from_address->sending_port;
$protocol = $from_address->sending_protocol;
if (isset($to['email'])) {
$recipants = $to['email'];
@@ -64,11 +64,11 @@ class PhpMailController extends Controller
} else {
$bc = null;
}
if (isset($message['subject'])) {
$subject = $message['subject'];
} else {
$subject = null;
}
// if (isset($message['subject'])) {
// $subject = $message['subject'];
// } else {
// $subject = null;
// }
if (isset($message['body'])) {
$content = $message['body'];
} else {
@@ -182,11 +182,28 @@ class PhpMailController extends Controller
$path2 = \Config::get('view.paths');
$directory = $path2[0].DIRECTORY_SEPARATOR.'emails'.DIRECTORY_SEPARATOR.$status->template.DIRECTORY_SEPARATOR;
// $directory = $path2[0].DIRECTORY_SEPARATOR.'emails'.DIRECTORY_SEPARATOR.$status->template.DIRECTORY_SEPARATOR;
//
// $handle = fopen($directory.$template.'.blade.php', 'r');
// $contents = fread($handle, filesize($directory.$template.'.blade.php'));
// fclose($handle);
$handle = fopen($directory.$template.'.blade.php', 'r');
$contents = fread($handle, filesize($directory.$template.'.blade.php'));
fclose($handle);
$template = TemplateType::where('name', '=', $template)->first();
$set = \App\Model\Common\TemplateSet::where('name', '=', $status->template)->first();
if (isset($set['id'])) {
$template_data = \App\Model\Common\Template::where('set_id', '=', $set->id)->where('type', '=', $template->id)->first();
$contents = $template_data->message;
if ($template_data->subject) {
$subject = $template_data->subject;
} else {
$subject = $message['subject'];
}
} else {
$contents = null;
$subject = null;
}
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}'];
@@ -203,22 +220,30 @@ class PhpMailController extends Controller
}
// dd($messagebody);
//$mail->SMTPDebug = 3; // Enable verbose debug output
//$mail->SMTPDebug = 3; // Enable verbose debug output
if ($protocol == "smtp") {
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $host; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $username; // SMTP username
$mail->Password = $password; // SMTP password
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
$mail->Port = $port; // TCP port to connect to
$mail->setFrom($username, $fromname);
$mail->addAddress($recipants); // Add a recipient
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $host; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $username; // SMTP username
$mail->Password = $password; // SMTP password
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
$mail->Port = $port; // TCP port to connect to
$mail->setFrom($username, $fromname);
} elseif ($protocol == "mail") {
$mail->IsSendmail(); // telling the class to use SendMail transport
if ($username == $fromname) {
$mail->setFrom($username);
} else {
$mail->setFrom($username, $fromname);
}
}
$mail->addAddress($recipants); // Add a recipient
// Name is optional
// $mail->addReplyTo('sada059@gmail.com', 'Information');
// Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->isHTML(true); // Set email format to HTML
if ($cc != null) {
foreach ($cc as $collaborator) {
//mail to collaborators
@@ -229,7 +254,7 @@ class PhpMailController extends Controller
}
}
$mail->addBCC($bc);
// $mail->addBCC($bc);
if ($attachment != null) {
$size = count($message['attachments']);
@@ -244,9 +269,9 @@ class PhpMailController extends Controller
$mail->Subject = $subject;
if ($template == 'ticket-reply-agent') {
$line = '---Reply above this line--- <br/><br/>';
$mail->Body = $line.$messagebody;
$mail->Body = utf8_decode($line . $messagebody);
} else {
$mail->Body = $messagebody;
$mail->Body = utf8_decode($messagebody);
}
// $mail->AltBody = $altbody;
@@ -267,8 +292,7 @@ class PhpMailController extends Controller
*
* @return MailNotification
*/
public function sendEmail($from, $to, $message)
{
public function sendEmail($from, $to, $message) {
// dd($from);
$from_address = $this->fetch_smtp_details($from);
@@ -394,8 +418,7 @@ class PhpMailController extends Controller
*
* @return type
*/
public function company()
{
public function company() {
$company = Company::Where('id', '=', '1')->first();
if ($company->company_name == null) {
$company = 'Support Center';
@@ -457,8 +480,7 @@ class PhpMailController extends Controller
*
* @return type integer
*/
public function mailfrom($reg, $dept_id)
{
public function mailfrom($reg, $dept_id) {
$email = Email::where('id', '=', '1')->first();
if ($reg == 1) {
return $email->sys_email;
@@ -471,4 +493,5 @@ class PhpMailController extends Controller
}
}
}
}