/** * user remove * @return type */ public function userremove() { $id = Input::get('data1'); $ticket_collaborator = Ticket_Collaborator::where('id', '=', $id)->delete(); return 1; }
/** * Replying a ticket * @param type Ticket_Thread $thread * @param type TicketRequest $request * @return type bool */ public function reply($thread, $request, $ta, $attach = '') { try { $check_attachment = null; $eventthread = $thread->where('ticket_id', $request->input('ticket_ID'))->first(); $eventuserid = $eventthread->user_id; $emailadd = User::where('id', $eventuserid)->first()->email; $source = $eventthread->source; $form_data = $request->except('ReplyContent', 'ticket_ID', 'attachment'); \Event::fire(new \App\Events\ClientTicketFormPost($form_data, $emailadd, $source)); $reply_content = $request->input('ReplyContent'); $thread->ticket_id = $request->input('ticket_ID'); $thread->poster = 'support'; $thread->body = $request->input('ReplyContent'); $thread->user_id = Auth::user()->id; $ticket_id = $request->input('ticket_ID'); $tickets = Tickets::where('id', '=', $ticket_id)->first(); $tickets->isanswered = '1'; $tickets->save(); $ticket_user = User::where('id', '=', $tickets->user_id)->first(); if ($tickets->assigned_to == 0) { $tickets->assigned_to = Auth::user()->id; $tickets->save(); $thread2 = new Ticket_Thread(); $thread2->ticket_id = $thread->ticket_id; $thread2->user_id = Auth::user()->id; $thread2->is_internal = 1; $thread2->body = "This Ticket have been assigned to " . Auth::user()->first_name . " " . Auth::user()->last_name; $thread2->save(); } if ($tickets->status > 1) { $tickets->status = '1'; $tickets->isanswered = '1'; $tickets->save(); } $thread->save(); if (!empty($attach)) { $check_attachment = $this->attach($thread->id, $attach); } $thread1 = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first(); $ticket_subject = $thread1->title; $user_id = $tickets->user_id; $user = User::where('id', '=', $user_id)->first(); $email = $user->email; $user_name = $user->user_name; $ticket_number = $tickets->ticket_number; $company = $this->company(); $username = $ticket_user->user_name; if (!empty(Auth::user()->agent_sign)) { $agentsign = Auth::user()->agent_sign; } else { $agentsign = null; } \Event::fire(new \App\Events\FaveoAfterReply($reply_content, $user->phone_number, $request, $tickets)); Mail::send(array('html' => 'emails.ticket_re-reply'), ['content' => $reply_content, 'ticket_number' => $ticket_number, 'From' => $company, 'name' => $username, 'Agent_Signature' => $agentsign], function ($message) use($email, $user_name, $ticket_number, $ticket_subject, $check_attachment) { $message->to($email, $user_name)->subject($ticket_subject . '[#' . $ticket_number . ']'); // if(isset($attachments)){ // if ($check_attachment == 1) { // $size = count($attach); // for ($i = 0; $i < $size; $i++) { // $message->attach($attachments[$i]->getRealPath(), ['as' => $attachments[$i]->getClientOriginalName(), 'mime' => $attachments[$i]->getClientOriginalExtension()]); // } // } }, true); $collaborators = Ticket_Collaborator::where('ticket_id', '=', $ticket_id)->get(); foreach ($collaborators as $collaborator) { //mail to collaborators $collab_user_id = $collaborator->user_id; $user_id_collab = User::where('id', '=', $collab_user_id)->first(); $collab_email = $user_id_collab->email; if ($user_id_collab->role == "user") { $collab_user_name = $user_id_collab->user_name; } else { $collab_user_name = $user_id_collab->first_name . " " . $user_id_collab->last_name; } Mail::send('emails.ticket_re-reply', ['content' => $reply_content, 'ticket_number' => $ticket_number, 'From' => $company, 'name' => $collab_user_name, 'Agent_Signature' => $agentsign], function ($message) use($collab_email, $collab_user_name, $ticket_number, $ticket_subject, $check_attachment) { $message->to($collab_email, $collab_user_name)->subject($ticket_subject . '[#' . $ticket_number . ']'); // if ($check_attachment == 1) { // $size = sizeOf($attachments); // for ($i = 0; $i < $size; $i++) { // $message->attach($attachments[$i]->getRealPath(), ['as' => $attachments[$i]->getClientOriginalName(), 'mime' => $attachments[$i]->getClientOriginalExtension()]); // } // } }, true); } return $thread; } catch (\Exception $e) { return $e->getMessage(); } }