Update v1.0.6.5
This commit is contained in:
@@ -37,6 +37,7 @@ use Exception;
|
||||
use Hash;
|
||||
use Illuminate\support\Collection;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Mail;
|
||||
use PDF;
|
||||
use UTC;
|
||||
@@ -80,7 +81,7 @@ class TicketController extends Controller
|
||||
|
||||
return \Datatable::collection(new Collection($tickets))
|
||||
->addColumn('id', function ($ticket) {
|
||||
return "<input type='checkbox' name='select_all[]' class='icheckbox_flat-blue' value='".$ticket->id."'></input>";
|
||||
return "<input type='checkbox' name='select_all[]' id='".$ticket->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$ticket->id."'></input>";
|
||||
})
|
||||
->addColumn('subject', function ($ticket) {
|
||||
$subject = DB::table('ticket_thread')->select('title')->where('ticket_id', '=', $ticket->id)->first();
|
||||
@@ -801,8 +802,13 @@ class TicketController extends Controller
|
||||
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
|
||||
|
||||
$tickets = Tickets::where('id', '=', $id)->where('dept_id', '=', $dept->id)->first();
|
||||
} else {
|
||||
} elseif (Auth::user()->role == 'admin') {
|
||||
$tickets = Tickets::where('id', '=', $id)->first();
|
||||
} elseif (Auth::user()->role == 'user') {
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $id)->first();
|
||||
$ticket_id = \Crypt::encrypt($id);
|
||||
// dd($ticket_id);
|
||||
return redirect()->route('check_ticket', compact('ticket_id'));
|
||||
}
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $id)->first();
|
||||
//$tickets = Tickets::where('id', '=', $id)->first();
|
||||
@@ -2577,4 +2583,151 @@ class TicketController extends Controller
|
||||
}
|
||||
// return '<div id="alert11" class="alert alert-dismissable" ><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-user"></i>'.$data->user_name.'</h4><div id="message-success1">'.$data->email.'</div></div>';
|
||||
}
|
||||
|
||||
public function getMergeTickets($id)
|
||||
{
|
||||
if ($id == 0) {
|
||||
$t_id = Input::get('data1');
|
||||
foreach ($t_id as $value) {
|
||||
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $value)->first();
|
||||
echo "<option value='$value'>".$title->title.'</option>';
|
||||
}
|
||||
} else {
|
||||
$ticket = Tickets::select('user_id')->where('id', '=', $id)->first();
|
||||
$ticket_data = Tickets::select('ticket_number', 'id')
|
||||
->where('user_id', '=', $ticket->user_id)->where('id', '!=', $id)->where('status', '=', 1)->get();
|
||||
foreach ($ticket_data as $value) {
|
||||
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $value->id)->first();
|
||||
echo "<option value='$value->id'>".$title->title.'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkMergeTickets($id)
|
||||
{
|
||||
if ($id == 0) {
|
||||
if (Input::get('data1') == null || count(Input::get('data1')) == 1) {
|
||||
return 0;
|
||||
} else {
|
||||
$t_id = Input::get('data1');
|
||||
$previousValue = null;
|
||||
$match = 1;
|
||||
foreach ($t_id as $value) {
|
||||
$ticket = Tickets::select('user_id')->where('id', '=', $value)->first();
|
||||
if ($previousValue == null || $previousValue == $ticket->user_id) {
|
||||
$previousValue = $ticket->user_id;
|
||||
$match = 1;
|
||||
} else {
|
||||
$match = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $match;
|
||||
}
|
||||
} else {
|
||||
$ticket = Tickets::select('user_id')->where('id', '=', $id)->first();
|
||||
$ticket_data = Tickets::select('ticket_number', 'id')
|
||||
->where('user_id', '=', $ticket->user_id)
|
||||
->where('id', '!=', $id)
|
||||
->where('status', '=', 1)->get();
|
||||
if (isset($ticket_data) && count($ticket_data) >= 1) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function mergeTickets($id)
|
||||
{
|
||||
// split the phrase by any number of commas or space characters,
|
||||
// which include " ", \r, \t, \n and \f
|
||||
$t_id = preg_split("/[\s,]+/", $id);
|
||||
if (count($t_id) > 1) {
|
||||
$p_id = Input::get('p_id');
|
||||
$t_id = array_diff($t_id, [$p_id]);
|
||||
} else {
|
||||
$t_id = Input::get('t_id'); //getting array of tickets to merge
|
||||
if ($t_id == null) {
|
||||
return 2;
|
||||
} else {
|
||||
$temp_id = Input::get('p_id'); //getting parent ticket
|
||||
if ($id == $temp_id) {
|
||||
$p_id = $id;
|
||||
} else {
|
||||
$p_id = $temp_id;
|
||||
array_push($t_id, $id);
|
||||
$t_id = array_diff($t_id, [$temp_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$parent_ticket = Tickets::select('ticket_number')->where('id', '=', $p_id)->first();
|
||||
$parent_thread = Ticket_thread::where('ticket_id', '=', $p_id)->first();
|
||||
foreach ($t_id as $value) {//to create new thread of the tickets to be merged with parent
|
||||
$thread = Ticket_thread::where('ticket_id', '=', $value)->first();
|
||||
$ticket = Tickets::select('ticket_number')->where('id', '=', $value)->first();
|
||||
Ticket_thread::where('ticket_id', '=', $value)
|
||||
->update(['ticket_id' => $p_id]);
|
||||
Ticket_Form_Data::where('ticket_id', '=', $value)
|
||||
->update(['ticket_id' => $p_id]);
|
||||
Ticket_Collaborator::where('ticket_id', '=', $value)
|
||||
->update(['ticket_id' => $p_id]);
|
||||
Tickets::where('id', '=', $value)
|
||||
->update(['status' => 3]);
|
||||
if (!empty(Input::get('reason'))) {
|
||||
$reason = Input::get('reason');
|
||||
} else {
|
||||
$reason = '';
|
||||
}
|
||||
if (!empty(Input::get('title'))) {
|
||||
Ticket_thread::where('ticket_id', '=', $p_id)->first()
|
||||
->update(['title' => Input::get('title')]);
|
||||
}
|
||||
|
||||
$new_thread = new Ticket_thread();
|
||||
$new_thread->ticket_id = $thread->ticket_id;
|
||||
$new_thread->user_id = Auth::user()->id;
|
||||
$new_thread->poster = $thread->poster;
|
||||
$new_thread->source = $thread->source;
|
||||
$new_thread->is_internal = 0;
|
||||
$new_thread->title = $thread->title;
|
||||
$new_thread->body = Lang::get('lang.get_merge_message').
|
||||
" <a href='".route('ticket.thread', [$p_id]).
|
||||
"'>#".$parent_ticket->ticket_number.'</a><br>'.$reason;
|
||||
$new_thread->format = $thread->format;
|
||||
$new_thread->ip_address = $thread->ip_address;
|
||||
//$new_thread->save();
|
||||
|
||||
$new_parent_thread = new Ticket_thread();
|
||||
$new_parent_thread->ticket_id = $p_id;
|
||||
$new_parent_thread->user_id = Auth::user()->id;
|
||||
$new_parent_thread->poster = $parent_thread->poster;
|
||||
$new_parent_thread->source = $parent_thread->source;
|
||||
$new_parent_thread->is_internal = 1;
|
||||
$new_parent_thread->title = $thread->title;
|
||||
$new_parent_thread->body = Lang::get('lang.ticket')." <a href='".route('ticket.thread', [$value])."'>#".$ticket->ticket_number.'</a> '.Lang::get('lang.ticket_merged').'<br>'.$reason;
|
||||
$new_parent_thread->format = $parent_thread->format;
|
||||
$new_parent_thread->ip_address = $parent_thread->ip_address;
|
||||
//$new_parent_thread->save();
|
||||
if ($new_thread->save() && $new_parent_thread->save()) {
|
||||
$success = 1;
|
||||
} else {
|
||||
$success = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function getParentTickets($id)
|
||||
{
|
||||
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $id)->first();
|
||||
echo "<option value='$id'>".$title->title.'</option>';
|
||||
$tickets = Input::get('data1');
|
||||
foreach ($tickets as $value) {
|
||||
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $value)->first();
|
||||
echo "<option value='$value'>".$title->title.'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user