update v 1.0.7.5
This commit is contained in:
116
app/Http/Controllers/Common/ApiSettings.php
Normal file
116
app/Http/Controllers/Common/ApiSettings.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\Api\ApiSetting;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
class ApiSettings extends Controller
|
||||
{
|
||||
public $api;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth', ['except' => ['ticketDetailEvent', 'postHook', 'postForm']]);
|
||||
$this->middleware('roles', ['except' => ['ticketDetailEvent', 'postHook', 'postForm']]);
|
||||
|
||||
$api = new ApiSetting();
|
||||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
try {
|
||||
$details = [];
|
||||
$ticket_detail = '';
|
||||
$settings = $this->api;
|
||||
if ($settings->get()->count() > 0) {
|
||||
$details = $this->api->lists('value', 'key')->toArray();
|
||||
}
|
||||
if (array_key_exists('ticket_detail', $details)) {
|
||||
$ticket_detail = $details['ticket_detail'];
|
||||
}
|
||||
|
||||
return view('themes.default1.common.api.settings', compact('ticket_detail'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postSettings(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'ticket_detail' => 'url',
|
||||
]);
|
||||
try {
|
||||
$settings = $this->api;
|
||||
if ($settings->get()->count() > 0) {
|
||||
foreach ($settings->get() as $set) {
|
||||
$set->delete();
|
||||
}
|
||||
}
|
||||
foreach ($request->except('_token') as $key => $value) {
|
||||
$settings->create(['key' => $key, 'value' => $value]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Updated Successfully');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function ticketDetailEvent($detail)
|
||||
{
|
||||
try {
|
||||
$ticket = new Tickets();
|
||||
$ticketid = $detail->ticket_id;
|
||||
$data = $ticket
|
||||
->join('ticket_thread', function ($join) use ($ticketid) {
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->where('ticket_thread.ticket_id', '=', $ticketid);
|
||||
})
|
||||
->join('users', 'ticket_thread.user_id', '=', 'users.id')
|
||||
->select('ticket_thread.title', 'ticket_thread.body', 'users.first_name', 'users.last_name', 'users.email', 'ticket_thread.created_at')
|
||||
->get()
|
||||
->toJson();
|
||||
$this->postHook($data);
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
throw new Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postHook($data)
|
||||
{
|
||||
try {
|
||||
$set = $this->api->where('key', 'ticket_detail')->first();
|
||||
if ($set) {
|
||||
if ($set->value) {
|
||||
$this->postForm($data, $set->value);
|
||||
}
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
throw new Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postForm($data, $url)
|
||||
{
|
||||
try {
|
||||
$post_data = [
|
||||
'data' => $data,
|
||||
];
|
||||
$upgrade_controller = new \App\Http\Controllers\Update\UpgradeController();
|
||||
$upgrade_controller->postCurl($url, $post_data);
|
||||
Log::info('ticket details has send to : '.$url.' and details are : '.$data);
|
||||
} catch (Exception $ex) {
|
||||
throw new Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,8 @@ class NotificationController extends Controller
|
||||
{
|
||||
$notifications = UserNotification::join('notifications', 'user_notification.notification_id', '=', 'notifications.id')
|
||||
->join('notification_types', 'notifications.type_id', '=', 'notification_types.id')
|
||||
->where('user_notification.is_read', '=', '0')
|
||||
->where('user_notification.user_id', '=', \Auth::user()->id)
|
||||
->get();
|
||||
->paginate(10);
|
||||
|
||||
return $notifications;
|
||||
}
|
||||
@@ -41,7 +40,7 @@ class NotificationController extends Controller
|
||||
}
|
||||
//dd($forwhome);
|
||||
//system notification
|
||||
$notification = new Notification();
|
||||
$notification = new Notification();
|
||||
$UN = new UserNotification();
|
||||
|
||||
$notify = $notification->create(['model_id' => $model_id, 'userid_created' => $userid_created, 'type_id' => $type_id]);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* ***************************
|
||||
@@ -130,9 +131,9 @@ class SettingsController extends Controller
|
||||
try {
|
||||
$widget->save();
|
||||
|
||||
return redirect()->back()->with('success', $widget->name.' Saved Successfully');
|
||||
return redirect()->back()->with('success', $widget->name.Lang::get('lang.saved_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +462,6 @@ class SettingsController extends Controller
|
||||
public function GetPlugin()
|
||||
{
|
||||
$plugins = $this->fetchConfig();
|
||||
//dd($plugins);
|
||||
|
||||
return \Datatable::collection(new Collection($plugins))
|
||||
->searchColumns('name')
|
||||
@@ -683,24 +683,37 @@ class SettingsController extends Controller
|
||||
{
|
||||
$configs = $this->ReadConfigs();
|
||||
//dd($configs);
|
||||
$plug = new Plugin();
|
||||
$plug = $plug->select('path', 'status')->orderBy('name')->get()->toArray();
|
||||
//$fields = [];
|
||||
if ($configs !== 'null') {
|
||||
$plugs = new Plugin();
|
||||
$fields = [];
|
||||
$attributes = [];
|
||||
if ($configs != 'null') {
|
||||
foreach ($configs as $key => $config) {
|
||||
$fields[$key] = include $config;
|
||||
|
||||
if ($plug != null) {
|
||||
$fields[$key]['path'] = $plug[$key]['path'];
|
||||
$fields[$key]['status'] = $plug[$key]['status'];
|
||||
} else {
|
||||
$fields[$key]['path'] = $fields[$key]['name'];
|
||||
$fields[$key]['status'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
//dd($fields);
|
||||
if (count($fields) > 0) {
|
||||
foreach ($fields as $key => $field) {
|
||||
$plug = $plugs->where('name', $field['name'])->select('path', 'status')->orderBy('name')->get()->toArray();
|
||||
if ($plug) {
|
||||
foreach ($plug as $i => $value) {
|
||||
$attributes[$key]['path'] = $plug[$i]['path'];
|
||||
$attributes[$key]['status'] = $plug[$i]['status'];
|
||||
}
|
||||
} else {
|
||||
$attributes[$key]['path'] = $field['name'];
|
||||
$attributes[$key]['status'] = 0;
|
||||
}
|
||||
$attributes[$key]['name'] = $field['name'];
|
||||
$attributes[$key]['settings'] = $field['settings'];
|
||||
$attributes[$key]['description'] = $field['description'];
|
||||
$attributes[$key]['website'] = $field['website'];
|
||||
$attributes[$key]['version'] = $field['version'];
|
||||
$attributes[$key]['author'] = $field['author'];
|
||||
}
|
||||
}
|
||||
//dd($attributes);
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
public function DeletePlugin($slug)
|
||||
@@ -730,7 +743,7 @@ class SettingsController extends Controller
|
||||
$plug = $plugs->where('name', $slug)->first();
|
||||
if (!$plug) {
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
@@ -744,7 +757,7 @@ class SettingsController extends Controller
|
||||
$plug->status = 1;
|
||||
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
@@ -755,7 +768,7 @@ class SettingsController extends Controller
|
||||
/*
|
||||
* remove service provider from app.php
|
||||
*/
|
||||
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$path_to_file = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
|
||||
$file_contents = file_get_contents($path_to_file);
|
||||
@@ -766,4 +779,8 @@ class SettingsController extends Controller
|
||||
|
||||
return redirect()->back()->with('success', 'Status has changed');
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
258
app/Http/Controllers/Common/TemplateController.php
Normal file
258
app/Http/Controllers/Common/TemplateController.php
Normal file
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\TemplateRequest;
|
||||
use App\Http\Requests\helpdesk\TemplateUdate;
|
||||
use App\Model\Common\Template;
|
||||
use App\Model\Common\TemplateType;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* |======================================================
|
||||
* | Class Template Controller
|
||||
* |======================================================
|
||||
* This controller is for CRUD email templates.
|
||||
*/
|
||||
class TemplateController extends Controller
|
||||
{
|
||||
public $template;
|
||||
public $type;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
|
||||
$template = new Template();
|
||||
$this->template = $template;
|
||||
|
||||
$type = new TemplateType();
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the list of templates.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.common.template.inbox');
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show template
|
||||
* This template to show a particular template.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function showTemplate($id)
|
||||
{
|
||||
try {
|
||||
$templates = Template::where('set_id', '=', $id)->get();
|
||||
|
||||
return view('themes.default1.common.template.list-templates', compact('templates'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to display chumper datatables of the template list.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return type datatable
|
||||
*/
|
||||
public function GetTemplates(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
|
||||
return \Datatable::collection($this->template->where('set_id', '=', $id)->select('id', 'name', 'type')->get())
|
||||
->showColumns('name')
|
||||
->addColumn('type', function ($model) {
|
||||
return $this->type->where('id', $model->type)->first()->name;
|
||||
})
|
||||
->addColumn('action', function ($model) {
|
||||
return '<a href='.url('templates/'.$model->id.'/edit')." class='btn btn-sm btn-primary'>Edit</a>";
|
||||
})
|
||||
->searchColumns('name')
|
||||
->orderColumns('name')
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
try {
|
||||
$i = $this->template->orderBy('created_at', 'desc')->first()->id + 1;
|
||||
$type = $this->type->lists('name', 'id')->toArray();
|
||||
|
||||
return view('themes.default1.common.template.create', compact('type'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To store a set of templates.
|
||||
*
|
||||
* @param \App\Http\Requests\helpdesk\TemplateRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function store(TemplateRequest $request)
|
||||
{
|
||||
try {
|
||||
//dd($request);
|
||||
$this->template->fill($request->input())->save();
|
||||
|
||||
return redirect('templates')->with('success', Lang::get('lang.template_saved_successfully'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
try {
|
||||
$i = $this->template->orderBy('created_at', 'desc')->first()->id + 1;
|
||||
$template = $this->template->where('id', $id)->first();
|
||||
$type = $this->type->lists('name', 'id')->toArray();
|
||||
|
||||
return view('themes.default1.common.template.edit', compact('type', 'template'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id, TemplateUdate $request)
|
||||
{
|
||||
try {
|
||||
//dd($request);
|
||||
$template = $this->template->where('id', $id)->first();
|
||||
$template->fill($request->input())->save();
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.template_updated_successfully'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
try {
|
||||
$ids = $request->input('select');
|
||||
if (!empty($ids)) {
|
||||
foreach ($ids as $id) {
|
||||
$template = $this->template->where('id', $id)->first();
|
||||
if ($template) {
|
||||
$template->delete();
|
||||
} else {
|
||||
echo "<div class='alert alert-danger alert-dismissable'>
|
||||
<i class='fa fa-ban'></i>
|
||||
<b>".\Lang::get('message.alert').'!</b>
|
||||
<button type=button class=close data-dismiss=alert aria-hidden=true>×</button>
|
||||
'.\Lang::get('message.no-record').'
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
echo "<div class='alert alert-success alert-dismissable'>
|
||||
<i class='fa fa-ban'></i>
|
||||
<b>
|
||||
<button type=button class=close data-dismiss=alert aria-hidden=true>×</button>
|
||||
".\Lang::get('message.deleted-successfully').'
|
||||
</div>';
|
||||
} else {
|
||||
echo "<div class='alert alert-danger alert-dismissable'>
|
||||
<i class='fa fa-ban'></i>
|
||||
<b>".\Lang::get('message.alert').'!</b>
|
||||
<button type=button class=close data-dismiss=alert aria-hidden=true>×</button>
|
||||
'.\Lang::get('message.select-a-row').'
|
||||
</div>';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo "<div class='alert alert-danger alert-dismissable'>
|
||||
<i class='fa fa-ban'></i>
|
||||
<b>".\Lang::get('message.alert').'!</b>
|
||||
<button type=button class=close data-dismiss=alert aria-hidden=true>×</button>
|
||||
'.$e->getMessage().'
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
//dd($currency);
|
||||
try {
|
||||
if ($this->template->where('type', 3)->where('id', $id)->first()) {
|
||||
$data = $this->template->where('type', 3)->where('id', $id)->first()->data;
|
||||
$products = $this->product->where('id', '!=', 1)->take(4)->get();
|
||||
if (count($products) > 0) {
|
||||
$template = '';
|
||||
foreach ($products as $product) {
|
||||
//dd($this->checkPriceWithTaxClass($product->id, $currency));
|
||||
$url = $product->shoping_cart_link;
|
||||
$title = $product->name;
|
||||
if ($product->description) {
|
||||
$description = str_replace('</ul>', '', str_replace('<ul>', '', $product->description));
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
$currency = \Session::get('currency');
|
||||
if ($this->price->where('product_id', $product->id)->where('currency', $currency)->first()) {
|
||||
$product_currency = $this->price->where('product_id', $product->id)->where('currency', $currency)->first();
|
||||
$code = $product_currency->currency;
|
||||
$currency = $this->currency->where('code', $code)->first();
|
||||
if ($currency->symbol) {
|
||||
$currency = $currency->symbol;
|
||||
} else {
|
||||
$currency = $currency->code;
|
||||
}
|
||||
$price = \App\Http\Controllers\Front\CartController::calculateTax($product->id, $product_currency->currency, 1, 0, 1);
|
||||
|
||||
$subscription = $this->plan->where('id', $product_currency->subscription)->first()->name;
|
||||
} else {
|
||||
return redirect('/')->with('fails', \Lang::get('message.no-such-currency-in-system'));
|
||||
}
|
||||
|
||||
$array1 = ['{{title}}', '{{currency}}', '{{price}}', '{{subscription}}', '<li>{{feature}}</li>', '{{url}}'];
|
||||
$array2 = [$title, $currency, $price, $subscription, $description, $url];
|
||||
$template .= str_replace($array1, $array2, $data);
|
||||
}
|
||||
|
||||
//dd($template);
|
||||
return view('themes.default1.common.template.shoppingcart', compact('template'));
|
||||
} else {
|
||||
$template = '<p>No Products</p>';
|
||||
|
||||
return view('themes.default1.common.template.shoppingcart', compact('template'));
|
||||
}
|
||||
} else {
|
||||
return redirect('/')->with('fails', 'no such record');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
|
||||
return redirect('/')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
151
app/Http/Controllers/Common/TemplateSetController.php
Normal file
151
app/Http/Controllers/Common/TemplateSetController.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\TemplateSetRequest;
|
||||
use App\Model\Common\Template;
|
||||
use App\Model\Common\TemplateSet;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
class TemplateSetController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$tempcon = new TemplateController();
|
||||
$this->tempcon = $tempcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the list of template sets.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$sets = TemplateSet::all();
|
||||
|
||||
return view('themes.default1.common.template.sets', compact('sets'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(TemplateSet $sets, TemplateSetRequest $request)
|
||||
{
|
||||
try {
|
||||
$sets->name = $request->input('name');
|
||||
$sets->save();
|
||||
$templates = Template::where('set_id', '=', '1')->get();
|
||||
foreach ($templates as $template) {
|
||||
\DB::table('templates')->insert(['set_id' => $sets->id, 'name' => $template->name, 'variable' => $template->variable, 'type' => $template->type, 'subject' => $template->subject, 'message' => $template->message]);
|
||||
}
|
||||
|
||||
return redirect('template-sets')->with('success', Lang::get('lang.you_have_created_a_new_template_set'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect('template-sets')->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function activateSet($id)
|
||||
{
|
||||
try {
|
||||
if (strpos($id, '_') !== false) {
|
||||
$ratName = str_replace('_', ' ', $id);
|
||||
} else {
|
||||
$ratName = $id;
|
||||
}
|
||||
\DB::table('settings_email')->update(['template' => $ratName]);
|
||||
|
||||
return \Redirect::back()->with('success', Lang::get('lang.you_have_successfully_activated_this_set'));
|
||||
} catch (Exception $ex) {
|
||||
return \Redirect::back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
try {
|
||||
$this->tempcon->showTemplate($id);
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function deleteSet($id)
|
||||
{
|
||||
try {
|
||||
$templates = Template::where('set_id', '=', $id)->get();
|
||||
foreach ($templates as $template) {
|
||||
$template->delete();
|
||||
}
|
||||
TemplateSet::whereId($id)->delete();
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.template_set_deleted_successfully'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user