From c138a85707776ed68ae29edbab5aba54d1495ff1 Mon Sep 17 00:00:00 2001 From: KNaveenraj-ladybird Date: Thu, 5 Oct 2023 17:35:09 +0530 Subject: [PATCH] func_corrections --- app/Http/Controllers/Auth/AuthController.php | 5 +- .../Client/helpdesk/UnAuthController.php | 113 +++- .../helpdesk/unauth/showticket.blade.php | 554 ++++++++++++------ routes/web.php | 8 +- 4 files changed, 497 insertions(+), 183 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 0931fac95..4c0aed9a1 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -410,10 +410,9 @@ class AuthController extends Controller return \Redirect::route($request->input('referer')); } - return \Redirect::route('/'); - } else { - return redirect()->intended($this->redirectPath()); + // return \Redirect::route('/'); } + return redirect()->intended($this->redirectPath()); } } } diff --git a/app/Http/Controllers/Client/helpdesk/UnAuthController.php b/app/Http/Controllers/Client/helpdesk/UnAuthController.php index ac82e531a..6ef2e5b38 100755 --- a/app/Http/Controllers/Client/helpdesk/UnAuthController.php +++ b/app/Http/Controllers/Client/helpdesk/UnAuthController.php @@ -267,7 +267,6 @@ class UnAuthController extends Controller $email = $user->email; $user_name = $user->user_name; - $ticket_number = $tickets->ticket_number; $sending_emails = Emails::where('department', '=', $ticket_status->dept_id)->first(); @@ -331,13 +330,13 @@ class UnAuthController extends Controller * * @return response */ - public static function changeLanguage($lang) + public static function changeLanguage($ids,$lang) { -// if(Cache::has('language')) -// { -// return Cache::get('language'); -// } else return 'false'; -// Cache::put('language',$); + /* if(Cache::has('language')) + { + return Cache::get('language'); + } else return 'false'; + Cache::put('language',$); $path = base_path('lang'); // Path to check available language packages if (array_key_exists($lang, \Config::get('languages')) && in_array($lang, scandir($path))) { // dd(array_key_exists($lang, Config::get('languages'))); @@ -350,7 +349,20 @@ class UnAuthController extends Controller return false; } - return true; + return true;*/ + + $path = base_path('lang'); // Path to check available language packages + if (array_key_exists($lang, \Config::get('languages')) && in_array($lang, scandir($path))) { + if (Auth::check()) { + $id = Auth::user()->id; + $user = User::find($id); + $user->user_language = $lang; + $user->save(); + } else { + Session::put('language', $lang); + } + } + return redirect()->back(); } // Follow up tickets @@ -446,4 +458,89 @@ class UnAuthController extends Controller return redirect()->back(); } + + public function close($id, Tickets $ticket) + { + + $tickets = Tickets::where('id', '=', $id)->first(); + $tickets->status = 3; + $ticket_status = Ticket_Status::where('id', '=', 3)->first(); + if ($ticket_status->state == 'closed') { + $tickets->closed = $ticket_status->id; + $tickets->closed_at = date('Y-m-d H:i:s'); + } + $tickets->save(); + $ticket_thread = Ticket_Thread::where('ticket_id', '=', $ticket_status->id)->first(); + $ticket_subject = $ticket_thread->title; + + $user = User::where('id', '=', $tickets->user_id)->first(); + + $thread = new Ticket_Thread(); + $thread->ticket_id = $tickets->id; + $thread->user_id = $tickets->user_id; + $thread->is_internal = 1; + $thread->body = $ticket_status->message.' '.$user->user_name; + $thread->save(); + + $email = $user->email; + $user_name = $user->user_name; + $ticket_number = $tickets->ticket_number; + + $sending_emails = Emails::where('department', '=', $ticket_status->dept_id)->first(); + if ($sending_emails == null) { + $from_email = $this->system_mail(); + } else { + $from_email = $sending_emails->id; + } + + try { + $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $tickets->dept_id), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'scenario' => 'close-ticket'], $template_variables = ['ticket_number' => $ticket_number]); + } catch (\Exception $e) { + return 0; + } + + return Lang::get('lang.your_ticket_has_been').' '.$ticket_status->state; + + } + + public function open($id, Tickets $ticket) + { + + $ticket_status = $ticket->where('id', '=', $id)->first(); + $ticket_status->status = 1; + $ticket_status->reopened_at = date('Y-m-d H:i:s'); + $ticket_status->save(); + $ticket_status_message = Ticket_Status::where('id', '=', $ticket_status->status)->first(); + $thread = new Ticket_Thread(); + $user = User::where('id', '=', $ticket->user_id)->first(); + $thread->ticket_id = $ticket_status->id; + $thread->user_id = $ticket->user_id; + $thread->is_internal = 1; + $thread->body = $ticket_status->message.' '.$user->user_name; + $thread->save(); + + + return 'your ticket'.$ticket_status->ticket_number.' has been opened'; + } + + public function resolve($id, Tickets $ticket) + { + + $ticket_status = $ticket->where('id', '=', $id)->first(); + + $ticket_status->status = 2; + $ticket_status->closed = 1; + $ticket_status->closed_at = date('Y-m-d H:i:s'); + $ticket_status->save(); + $ticket_status_message = Ticket_Status::where('id', '=', $ticket_status->status)->first(); + $thread = new Ticket_Thread(); + $user = User::where('id', '=', $ticket->user_id)->first(); + $thread->ticket_id = $ticket_status->id; + $thread->user_id = $ticket->user_id; + $thread->is_internal = 1; + + $thread->save(); + + return Lang::get('lang.your_ticket_has_been').' '.$ticket_status->state; + } } diff --git a/resources/views/themes/default1/client/helpdesk/unauth/showticket.blade.php b/resources/views/themes/default1/client/helpdesk/unauth/showticket.blade.php index b2dd2249e..a4ed72c61 100755 --- a/resources/views/themes/default1/client/helpdesk/unauth/showticket.blade.php +++ b/resources/views/themes/default1/client/helpdesk/unauth/showticket.blade.php @@ -1,174 +1,265 @@ @extends('themes.default1.client.layout.client') -@section('content') +@section('content') id)->first(); //$user = App\User::where('id','=',$id1)->first(); ?> + + + + -
-
-
-
-

{{$thread->title}}

( {{$tickets->ticket_number}} ) -
-
-
-
- - {{-- --}} - -
- - +
- -
+
+ +

{{$thread->title}} + + ( {{$tickets->ticket_number}} ) +

+
+ +
+ +
+ + + + +
{!! Form::close() !!}
-

-
- -
- - get(); ?> + +
+ +
+ +
+ + + get(); ?> {!! csrf_field() !!} - @foreach($ratings as $rating) + @foreach($ratings as $rating) - @if($rating->rating_area == 'Helpdesk Area') - id)->where('ticket_id', '=', $tickets->id)->first(); - if ($rating_value == null) { - $ratingval = '0'; - } else { - $ratingval = $rating_value->rating_value; - } - ?> - -   - - - @endif + @if($rating->rating_area == 'Helpdesk Area') + id)->where('ticket_id', '=', $tickets->id)->first(); + if ($rating_value == null) { + $ratingval = '0'; + } else { + $ratingval = $rating_value->rating_value; + } + ?> + + + +   + + + + @endif @endforeach -
{!! $rating->name !!}  
- rating_scale; $i++) { ?> - /> - -
{!! $rating->name !!}  
+ + rating_scale; $i++) { ?> + /> + +
+ + +
-
-
-
- +
id)->where('is_internal', '=', 0)->paginate(10); foreach ($conversations as $conversation) { @@ -179,12 +270,13 @@ foreach ($conversations as $conversation) { $time = $ConvDate[1]; $time = substr($time, 0, -3); if (isset($data) && $date == $data) { - + } else { $data = $ConvDate[0]; } $role = App\User::where('id', '=', $conversation->user_id)->first(); + $attachment = App\Model\helpdesk\Ticket\Ticket_attachments::where('thread_id', '=', $conversation->id)->first(); if ($attachment == null) { $body = $conversation->body; @@ -193,9 +285,9 @@ foreach ($conversations as $conversation) { $attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('thread_id', '=', $conversation->id)->orderBy('id', 'DESC')->get(); foreach ($attachments as $attachment) { if ($attachment->type == 'pdf') { - + } elseif ($attachment->type == 'docx') { - + } else { $image = @imagecreatefromstring($attachment->file); ob_start(); @@ -209,7 +301,7 @@ foreach ($conversations as $conversation) { $start = ""; $end = ""; if (strpos($string, $start) == false || strpos($string, $start) == false) { - + } else { $ini = strpos($string, $start); $ini += strlen($start); @@ -225,7 +317,7 @@ foreach ($conversations as $conversation) { $start = ""; $end = ""; if (strpos($string, $start) == false || strpos($string, $start) == false) { - + } else { $ini = strpos($string, $start); $ini += strlen($start); @@ -237,8 +329,9 @@ foreach ($conversations as $conversation) { ?>
  1. +
    -