Inbox changes

This commit is contained in:
Manish Verma
2018-08-09 16:14:58 +05:30
parent d46c28e985
commit a26c2cdd7c
15 changed files with 3010 additions and 685 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,339 @@
<?php
namespace App\Http\Controllers\Agent\helpdesk\Filter;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Filters\Filter;
use App\Model\helpdesk\Filters\Label;
use App\Model\helpdesk\Ticket\Tickets;
use Auth;
use DB;
use Illuminate\Http\Request;
class FilterControllerOld extends Controller
{
protected $request;
public function __construct(Request $req)
{
$this->middleware(['auth', 'role.agent']);
$this->request = $req;
}
public function getFilter(Request $request)
{
$labels = $this->request->input('labels');
$tags = $this->request->input('tags');
if ($request->has('department')) {
$table = $this->departmentTickets($request->input('department'), $request->input('status'));
} else {
$segment = $this->request->input('segment');
$table = $this->segments($segment);
}
$tickets = [];
$render = false;
if (is_array($labels) && count($labels) > 0) {
$table = $table
->leftJoin('filters as label', function ($join) {
$join->on('tickets.id', '=', 'label.ticket_id')
->where('label.key', '=', 'label');
})
->whereIn('label.value', $labels);
}
if (is_array($tags) && count($tags) > 0) {
$table = $table
->leftJoin('filters as tag', function ($join) {
$join->on('tickets.id', '=', 'tag.ticket_id')
->where('tag.key', '=', 'tag');
})
->whereIn('tag.value', $tags);
}
if ((is_array($tags) && count($tags) > 0) || (is_array($labels) && count($labels) > 0)) {
$render = true;
}
// return \Datatables::of($table)->make();
return \Ttable::getTable($table);
}
public function filterByKey($key, $labels = [])
{
$filter = new Filter();
$query = $filter->where('key', $key)
->where(function ($query) use ($labels) {
if (is_array($labels) && count($labels) > 0) {
for ($i = 0; $i < count($labels); $i++) {
$query->orWhere('value', 'LIKE', '%'.$labels[$i].'%');
}
}
})
->pluck('ticket_id')
->toArray();
return $query;
}
public function segments($segment)
{
if (strpos($segment, 'user') !== false) {
return $this->formatUserTickets($segment);
}
$table = $this->table();
switch ($segment) {
case '/ticket/inbox':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id)->orWhere('assigned_to', '=', Auth::user()->id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status')
->whereIn('ticket_status.id', [1, 7]);
});
case '/ticket/closed':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status')
->whereIn('ticket_status.state', ['closed']);
});
case '/ticket/myticket':
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status');
})
->orWhere('tickets.assigned_to', '=', Auth::user()->id)
->where('tickets.status', '=', 1);
case '/unassigned':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.assigned_to', '=', null)
->where('tickets.status', '=', 1);
case '/ticket/overdue':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.status', '=', 1)
->where('tickets.isanswered', '=', 0)
->whereNotNull('tickets.duedate')
->where('tickets.duedate', '!=', '00-00-00 00:00:00')
// ->where('duedate','>',\Carbon\Carbon::now());
->where('tickets.duedate', '<', \Carbon\Carbon::now());
case '/ticket/approval/closed':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status', '=', 7);
});
case '/trash':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status', '=', 5);
});
case '/ticket/answered':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->Join('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status', '=', 1)
->where('tickets.isanswered', '=', 1);
});
case '/ticket/assigned':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.assigned_to', '>', 0)
->where('tickets.status', '=', 1);
case '/ticket/open':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('isanswered', '=', 0)
->where('tickets.status', '=', 1);
case '/duetoday':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.status', '=', 1)
->whereNotNull('tickets.duedate')
->whereDate('tickets.duedate', '=', \Carbon\Carbon::now()->format('Y-m-d'));
case '/ticket/followup':
if (Auth::user()->role == 'agent') {
$id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id);
}
return $table
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.status', '=', 1)
// ->where('tickets.isanswered', '=', 0)
->where('tickets.follow_up', '=', 1);
}
}
public function table()
{
// if (Auth::user()->role == 'admin') {
$ticket = new Tickets();
$tickets = $ticket
->leftJoin('ticket_thread', function ($join) {
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
->whereNotNull('title')
->where('ticket_thread.is_internal', '<>', 1);
})
->leftJoin('ticket_thread as ticket_thread2', 'ticket_thread2.ticket_id', '=', 'tickets.id')
->Join('ticket_source', 'ticket_source.id', '=', 'tickets.source')
->leftJoin('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->leftJoin('users as u', 'u.id', '=', 'tickets.user_id')
->leftJoin('users as u1', 'u1.id', '=', 'tickets.assigned_to')
->leftJoin('ticket_attachment', 'ticket_attachment.thread_id', '=', 'ticket_thread.id')
->leftJoin('ticket_collaborator', 'ticket_collaborator.ticket_id', '=', 'tickets.id')
->select(
'tickets.id',
'ticket_thread.title',
'tickets.ticket_number',
'ticket_priority.priority',
'u.user_name as user_name',
'u1.user_name as assign_user_name',
\DB::raw('max(ticket_thread.updated_at) as updated_at'),
\DB::raw('min(ticket_thread.updated_at) as created_at'),
'u.first_name as first_name',
'u.last_name as last_name',
'u1.first_name as assign_first_name',
'u1.last_name as assign_last_name',
'ticket_priority.priority_color',
DB::raw('COUNT(DISTINCT ticket_thread2.id) as countthread'),
DB::raw('COUNT(ticket_attachment.thread_id) as countattachment'),
DB::raw('COUNT(ticket_collaborator.ticket_id) as countcollaborator'),
'tickets.status',
'tickets.user_id',
'tickets.priority_id', 'tickets.assigned_to',
'ticket_status.name as tickets_status',
'ticket_source.css_class as css',
DB::raw('substring_index(group_concat(ticket_thread.poster order by ticket_thread.id desc) , ",", 1) as last_replier'),
DB::raw('substring_index(group_concat(ticket_thread.title order by ticket_thread.id asc) , ",", 1) as ticket_title'),
'u.active as verified')
->groupby('tickets.id');
return $tickets;
}
public function filter($render, $ticket_id = [])
{
if (Auth::user()->role == 'admin') {
$tickets = Tickets::whereIn('status', [1, 7]);
} else {
$dept = DB::table('department')->where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::whereIn('status', [1, 7])->where('dept_id', '=', $dept->id);
}
if ($render == true) {
$tickets = $tickets->whereIn('id', $ticket_id);
}
return $tickets;
}
public function ticketController()
{
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
$ticket_controller = new TicketController($PhpMailController, $NotificationController);
return $ticket_controller;
}
public function departmentTickets($dept, $status)
{
$table = $this->table();
return $table->leftJoin('department as dep', 'tickets.dept_id', '=', 'dep.id')
->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('dep.name', $dept)
->where('ticket_status.name', $status);
}
/**
*@category function to format and return user tickets
*
*@param string $segment
*
*@return builder
*/
public function formatUserTickets($segment)
{
$convert_to_array = explode('/', $segment);
$user_id = $convert_to_array[2];
$user = \DB::table('users')->select('role', 'id')->where('id', '=', $user_id)->first();
$table = $this->table();
if ($user->role == 'user') {
$table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('tickets.user_id', '=', $user->id)
->where('ticket_status.name', $convert_to_array[3]);
} else {
$table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('tickets.assigned_to', '=', $user->id)
->where('ticket_status.name', $convert_to_array[3]);
}
return $table;
}
}

View File

@@ -70,126 +70,6 @@ class TicketController extends Controller
$this->middleware('auth');
}
/**
* Show the Inbox ticket list page.
*
* @return type response
*/
public function inbox_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.inbox', compact('table'));
}
/**
* Show the Open ticket list page.
*
* @return type response
*/
public function open_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.open', compact('table'));
}
/**
* Show the answered ticket list page.
*
* @return type response
*/
public function answered_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.answered', compact('table'));
}
/**
* Show the Myticket list page.
*
* @return type response
*/
public function myticket_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.myticket', compact('table'));
}
/**
* Show the Overdue ticket list page.
*
* @return type response
*/
public function overdue_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.overdue', compact('table'));
}
/**
* Show the Open ticket list page.
*
* @return type response
*/
public function dueTodayTicketlist()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.duetodayticket', compact('table'));
}
/**
* Show the Closed ticket list page.
*
* @return type response
*/
public function closed_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.closed', compact('table'));
}
/**
* Show the ticket list page.
*
* @return type response
*/
public function assigned_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.assigned', compact('table'));
}
/**
* Show the New ticket page.
*
@@ -1691,51 +1571,6 @@ class TicketController extends Controller
return $system;
}
/**
* shows trashed tickets.
*
* @return type response
*/
public function trash()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.trash', compact('table'));
}
/**
* shows unassigned tickets.
*
* @return type
*/
public function unassigned()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.unassigned', compact('table'));
}
/**
* shows tickets assigned to Auth::user().
*
* @return type
*/
public function myticket()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.myticket', compact('table'));
}
/**
* cleanMe.
*
@@ -2011,41 +1846,6 @@ class TicketController extends Controller
$ticket->save();
}
/**
* Show the deptopen ticket list page.
*
* @return type response
*/
public function deptopen($id)
{
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->primary_dpt == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.tickets', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.tickets', compact('id'));
}
}
public function deptTicket($dept, $status)
{
if (\Auth::user()->role === 'agent') {
$dept2 = Department::where('id', '=', \Auth::user()->primary_dpt)->first();
if ($dept !== $dept2->name) {
return redirect()->back()->with('fails', Lang::get('lang.unauthorized_access'));
}
}
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.dept-ticket.tickets', compact('dept', 'status', 'table'));
}
/**
* Show the deptclose ticket list page.
*
@@ -2479,110 +2279,6 @@ class TicketController extends Controller
}
}
/*
* chumper's function to return data to chumper datatable.
* @param Array-object $tickets
*
* @return Array-object
*/
public static function getTable($tickets)
{
return \Datatables::of($tickets)
->addColumn('id', function ($tickets) {
return "<input type='checkbox' name='select_all[]' id='".$tickets->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$tickets->id."'></input>";
})
->addColumn('title', function ($tickets) {
if (isset($tickets->ticket_title)) {
$string = str_limit($tickets->ticket_title, 20);
} else {
$string = '(no subject)';
}
$collab = $tickets->countcollaborator;
if ($collab > 0) {
$collabString = '&nbsp;<i class="fa fa-users"></i>';
} else {
$collabString = null;
}
$attachCount = $tickets->countattachment;
if ($attachCount > 0) {
$attachString = '&nbsp;<i class="fa fa-paperclip"></i>';
} else {
$attachString = '';
}
$css = $tickets->css;
$titles = '';
if ($tickets->ticket_title) {
$titles = $tickets->ticket_title;
}
$tooltip_script = self::tooltip($tickets->id);
return "<div class='tooltip1' id='tool".$tickets->id."'>
<a href='".route('ticket.thread', [$tickets->id])."'>".ucfirst($string)."&nbsp;<span style='color:green'>(".$tickets->countthread.") <i class='".$css."'></i></span>
</a>".$collabString.$attachString.$tooltip_script.
"<span class='tooltiptext' id='tooltip".$tickets->id."'>Loading...</span></div>";
})
->addColumn('ticket_number', function ($tickets) {
return "<a href='".route('ticket.thread', [$tickets->id])."' title='".$tickets->ticket_number."'>#".$tickets->ticket_number.'</a>';
})
->addColumn('priority', function ($tickets) {
$rep = ($tickets->last_replier == 'client') ? '#F39C12' : '#000';
$priority = $tickets->priority;
if ($priority != null) {
$prio = '<button class="btn btn-xs '.$rep.'" style="background-color: '.$tickets->priority_color.'; color:#F7FBCB">'.ucfirst($tickets->priority).'</button>';
} else {
$prio = $tickets->last_relier_role;
}
return $prio;
})
->addColumn('user_name', function ($tickets) {
$from = $tickets->first_name;
$url = route('user.show', $tickets->user_id);
$name = '';
if ($from) {
$name = $tickets->first_name.' '.$tickets->last_name;
} else {
$name = $tickets->user_name;
}
$color = '';
if ($tickets->verified == 0 || $tickets->verified == '0') {
$color = "<i class='fa fa-exclamation-triangle' title='".Lang::get('lang.accoutn-not-verified')."'></i>";
}
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.ucfirst($tickets->user_name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".ucfirst(str_limit($name, 30)).' <span style="color:#f75959">'.$color.'</span></span></a>';
})
->addColumn('assign_user_name', function ($tickets) {
if ($tickets->assigned_to == null) {
return "<span style='color:red'>Unassigned</span>";
} else {
$assign = $tickets->assign_user_name;
$url = route('user.show', $tickets->assigned_to);
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.ucfirst($tickets->assign_first_name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:green'>".ucfirst($tickets->assign_first_name).' '.ucfirst($tickets->assign_last_name).'</span></a>';
}
})
->addColumn('updated_at', function ($tickets) {
$TicketDatarow = $tickets->updated_at;
$updated = '--';
if ($TicketDatarow) {
$updated = $tickets->updated_at;
}
return '<span style="display:none">'.$updated.'</span>'.UTC::usertimezone($updated);
})
->addColumn('created_at', function ($tickets) {
$TicketDatarow = $tickets->created_at;
$updated = '--';
if ($TicketDatarow) {
$updated = $tickets->created_at;
}
return '<span style="display:none">'.$updated.'</span>'.UTC::usertimezone($updated);
})
->make();
}
/**
*@category function to call and show ticket details in tool tip via ajax
*
@@ -2864,23 +2560,6 @@ class TicketController extends Controller
}
}
/**
* @return type
*/
public function followupTicketList()
{
try {
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.followup.followup', compact('table'));
} catch (Exception $e) {
return Redirect()->back()->with('fails', $e->getMessage());
}
}
public static function getSubject($subject)
{
//$subject = $this->attributes['title'];
@@ -2966,4 +2645,483 @@ class TicketController extends Controller
//catch the exception
}
}
/**
* Ticket table rendering related functions
*/
/**
* Function to get basic datatable format
*
* @return object
*/
public function getTableFormat()
{
return \Datatable::table()
->addColumn(
'<a class="checkbox-toggle"><i class="fa fa-square-o fa-2x"></i></a>', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity')
)->noScript();
}
/**
* Function to return new ticket table view
*
* @return repsone/view
*/
public function getTicketsView()
{
$table = $this->getTableFormat();
return view('themes.default1.agent.helpdesk.ticket.tickets', compact('table'));
}
/**
* chumper's function to return data to chumper datatable.
* @param Array-object $tickets
*
* @return Array-object
*/
public static function genreateTableJson($tickets)
{
return \Datatables::of($tickets)
->editColumn('id', function ($tickets) {
$rep = ($tickets->last_replier == 'client') ? '#F39C12'
: '#000';
return "<center><input type='checkbox' name='select_all[]' id='".$tickets->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue ".$tickets->color.' '.$rep."' value='".$tickets->id."'></input></center>";
})
->addColumn('title', function ($tickets) {
if (isset($tickets->ticket_title)) {
$string = utfEncoding($tickets->ticket_title);
if (strlen($string) > 25) {
$string = str_limit($string, 30).'...';
}
} else {
$string = Lang::get('lang.no-subject');
}
$collab = $tickets->countcollaborator;
if ($collab > 0) {
$collabString = '&nbsp;<i class="fa fa-users" title="'.Lang::get('lang.ticket_has_collaborator').'"></i>';
} else {
$collabString = null;
}
$attachCount = $tickets->countattachment;
if ($attachCount > 0) {
$attachString = '&nbsp;<i class="fa fa-paperclip" title="'.Lang::get('lang.ticket_has_attachments').'"></i>';
} else {
$attachString = '';
}
$css = $tickets->css;
$source = $tickets->source;
$titles = '';
if ($tickets->ticket_title) {
$titles = $tickets->ticket_title;
}
$due = '';
if ($tickets->duedate != null) {
$now = strtotime(\Carbon\Carbon::now()->tz(timezone()));
$duedate = strtotime($tickets->duedate);
if ($duedate - $now < 0) {
$due = '&nbsp;<span style="background-color: rgba(221, 75, 57, 0.67) !important" title="'.Lang::get('lang.is_overdue').'" class="label label-danger">'.Lang::get('lang.overdue').'</span>';
} else {
if (date('Ymd', $duedate) == date('Ymd', $now)) {
$due = '&nbsp;<span style="background-color: rgba(240, 173, 78, 0.67) !important" title="'.Lang::get('lang.going-overdue-today').'" class="label label-warning">'.Lang::get('lang.duetoday').'</span>';
}
}
}
$thread_count = '('.$tickets->countthread.')';
if (Lang::getLocale() == 'ar') {
$thread_count = '&rlm;('.$tickets->countthread.')';
}
$tooltip_script = self::tooltip($tickets->id);
return "<div class='tooltip1' id='tool".$tickets->id."'>
<a href='".route('ticket.thread', [$tickets->id])."'>".$string."&nbsp;<span style='color:green'>".$thread_count."</span>
</a> <span><i style='color:green' title='".Lang::get('lang.ticket_created_source', ['source' => $source])."' class='".$css."'></i></span>".$collabString.$attachString.$due.$tooltip_script.
"<span class='tooltiptext' id='tooltip".$tickets->id."' style='height:auto;width:300px;background-color:#fff;color:black;border-radius:3px;border:2px solid gainsboro;position:absolute;z-index:1;top:150%;left:50%;margin-left:-23px;word-wrap:break-word;'>".Lang::get('lang.loading').'</span></div>';
})
->editColumn('ticket_number', function ($tickets) {
return "<a href='".route('ticket.thread', [$tickets->id])."' class='$".ucfirst($tickets->priority)."*' title='".Lang::get('lang.click-here-to-see-more-details')."'>#".$tickets->ticket_number.'</a>';
})
->editColumn('c_uname', function ($tickets) {
$from = $tickets->c_fname;
$url = route('user.show', $tickets->c_uid);
$name = $tickets->c_uname;
if ($from) {
$name = utfEncoding($tickets->c_fname).' '.utfEncoding($tickets->c_lname);
}
$color = '';
if ($tickets->verified == 0 || $tickets->verified == '0') {
$color = "<i class='fa fa-exclamation-triangle' title='".Lang::get('lang.accoutn-not-verified')."'></i>";
}
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.$name.'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".str_limit($name, 30).' <span style="color:#f75959">'.$color.'</span></span></a>';
})
->editColumn('a_uname', function ($tickets) {
if ($tickets->assigned_to == null && $tickets->name == null) {
return "<span style='color:red'>Unassigned</span>";
} else {
$assign = $tickets->assign_user_name;
if ($tickets->assigned_to != null) {
$assign = utfEncoding($tickets->a_fname).' '.utfEncoding($tickets->a_lname);
$url = route('user.show', $tickets->assigned_to);
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.$assign.'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:green'>".mb_substr($assign, 0, 30, 'UTF-8').'</span></a>';
} else {
$url1 = '#';
return "<a href='".$url1."' title='".Lang::get('lang.see-profile1').' '.ucfirst($tickets->name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:green'>".mb_substr(ucfirst($tickets->name), 0, 30, 'UTF-8').'</span></a>';
}
}
})
->editColumn('updated_at', function ($tickets) {
$TicketDatarow = $tickets->updated_at;
$updated = '--';
if ($TicketDatarow) {
$updated = faveoDate($tickets->updated_at);
}
return '<span style="display:none">'.$updated.'</span>'.$updated;
})
->make();
}
/**
* =====================================================================
* DEPRECATED FUNCTIONS BLOCK
* =====================================================================
* Functions under this block have been deprecated and are no
* longer used by the system.Though we have not removed these functions
* in v1.10 but we will remove these routes in upcoming releas
* =====================================================================
**/
/**
* Show the Inbox ticket list page.
*
* @return type response
*/
public function inbox_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.inbox', compact('table'));
}
/**
* Show the Open ticket list page.
*
* @return type response
*/
public function open_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.open', compact('table'));
}
/**
* Show the answered ticket list page.
*
* @return type response
*/
public function answered_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.answered', compact('table'));
}
/**
* Show the Myticket list page.
*
* @return type response
*/
public function myticket_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.myticket', compact('table'));
}
/**
* Show the Overdue ticket list page.
*
* @return type response
*/
public function overdue_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.overdue', compact('table'));
}
/**
* Show the Open ticket list page.
*
* @return type response
*/
public function dueTodayTicketlist()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.duetodayticket', compact('table'));
}
/**
* Show the Closed ticket list page.
*
* @return type response
*/
public function closed_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.closed', compact('table'));
}
/**
* Show the ticket list page.
*
* @return type response
*/
public function assigned_ticket_list()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.assigned', compact('table'));
}
/**
* Show the deptopen ticket list page.
*
* @return type response
*/
public function deptopen($id)
{
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->primary_dpt == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.tickets', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.tickets', compact('id'));
}
}
public function deptTicket($dept, $status)
{
if (\Auth::user()->role === 'agent') {
$dept2 = Department::where('id', '=', \Auth::user()->primary_dpt)->first();
if ($dept !== $dept2->name) {
return redirect()->back()->with('fails', Lang::get('lang.unauthorized_access'));
}
}
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.dept-ticket.tickets', compact('dept', 'status', 'table'));
}
/**
* shows trashed tickets.
*
* @return type response
*/
public function trash()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.trash', compact('table'));
}
/**
* shows unassigned tickets.
*
* @return type
*/
public function unassigned()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.unassigned', compact('table'));
}
/**
* shows tickets assigned to Auth::user().
*
* @return type
*/
public function myticket()
{
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.ticket.myticket', compact('table'));
}
/**
* @return type
*/
public function followupTicketList()
{
try {
$table = \Datatable::table()
->addColumn(
'', Lang::get('lang.subject'), Lang::get('lang.ticket_id'), Lang::get('lang.priority'), Lang::get('lang.from'), Lang::get('lang.assigned_to'), Lang::get('lang.last_activity'), Lang::get('lang.created-at'))
->noScript();
return view('themes.default1.agent.helpdesk.followup.followup', compact('table'));
} catch (Exception $e) {
return Redirect()->back()->with('fails', $e->getMessage());
}
}
/*
* chumper's function to return data to chumper datatable.
* @param Array-object $tickets
*
* @return Array-object
*/
public static function getTable($tickets)
{
return \Datatables::of($tickets)
->addColumn('id', function ($tickets) {
return "<input type='checkbox' name='select_all[]' id='".$tickets->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$tickets->id."'></input>";
})
->addColumn('title', function ($tickets) {
if (isset($tickets->ticket_title)) {
$string = str_limit($tickets->ticket_title, 20);
} else {
$string = '(no subject)';
}
$collab = $tickets->countcollaborator;
if ($collab > 0) {
$collabString = '&nbsp;<i class="fa fa-users"></i>';
} else {
$collabString = null;
}
$attachCount = $tickets->countattachment;
if ($attachCount > 0) {
$attachString = '&nbsp;<i class="fa fa-paperclip"></i>';
} else {
$attachString = '';
}
$css = $tickets->css;
$titles = '';
if ($tickets->ticket_title) {
$titles = $tickets->ticket_title;
}
$tooltip_script = self::tooltip($tickets->id);
return "<div class='tooltip1' id='tool".$tickets->id."'>
<a href='".route('ticket.thread', [$tickets->id])."'>".ucfirst($string)."&nbsp;<span style='color:green'>(".$tickets->countthread.") <i class='".$css."'></i></span>
</a>".$collabString.$attachString.$tooltip_script.
"<span class='tooltiptext' id='tooltip".$tickets->id."'>Loading...</span></div>";
})
->addColumn('ticket_number', function ($tickets) {
return "<a href='".route('ticket.thread', [$tickets->id])."' title='".$tickets->ticket_number."'>#".$tickets->ticket_number.'</a>';
})
->addColumn('priority', function ($tickets) {
$rep = ($tickets->last_replier == 'client') ? '#F39C12' : '#000';
$priority = $tickets->priority;
if ($priority != null) {
$prio = '<button class="btn btn-xs '.$rep.'" style="background-color: '.$tickets->priority_color.'; color:#F7FBCB">'.ucfirst($tickets->priority).'</button>';
} else {
$prio = $tickets->last_relier_role;
}
return $prio;
})
->addColumn('user_name', function ($tickets) {
$from = $tickets->first_name;
$url = route('user.show', $tickets->user_id);
$name = '';
if ($from) {
$name = $tickets->first_name.' '.$tickets->last_name;
} else {
$name = $tickets->user_name;
}
$color = '';
if ($tickets->verified == 0 || $tickets->verified == '0') {
$color = "<i class='fa fa-exclamation-triangle' title='".Lang::get('lang.accoutn-not-verified')."'></i>";
}
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.ucfirst($tickets->user_name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".ucfirst(str_limit($name, 30)).' <span style="color:#f75959">'.$color.'</span></span></a>';
})
->addColumn('assign_user_name', function ($tickets) {
if ($tickets->assigned_to == null) {
return "<span style='color:red'>Unassigned</span>";
} else {
$assign = $tickets->assign_user_name;
$url = route('user.show', $tickets->assigned_to);
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.ucfirst($tickets->assign_first_name).'&apos;'.Lang::get('lang.see-profile2')."'><span style='color:green'>".ucfirst($tickets->assign_first_name).' '.ucfirst($tickets->assign_last_name).'</span></a>';
}
})
->addColumn('updated_at', function ($tickets) {
$TicketDatarow = $tickets->updated_at;
$updated = '--';
if ($TicketDatarow) {
$updated = $tickets->updated_at;
}
return '<span style="display:none">'.$updated.'</span>'.UTC::usertimezone($updated);
})
->addColumn('created_at', function ($tickets) {
$TicketDatarow = $tickets->created_at;
$updated = '--';
if ($TicketDatarow) {
$updated = $tickets->created_at;
}
return '<span style="display:none">'.$updated.'</span>'.UTC::usertimezone($updated);
})
->make();
}
}