static function getUpdatedFields($is_fake = false, $ticket_id = 0, $msg_id = 0) { if (!$is_fake) { $ticket = Tickets::where('id', $ticket_id)->first(); $thread_message = ThreadMessages::where('id', $msg_id)->first(); $ticket_attachment = TicketAttachments::where('message_id', $msg_id)->first(); $customer = User::where('id', $ticket->customer_id)->first(); $operator = User::where('id', $ticket->operator_id)->first(); $company = Company::where('id', $ticket->company_id)->first(); $department = Department::where('id', $ticket->department_id)->first(); $receiver = Input::get('user_id') == $ticket->operator_id ? $customer : $operator; $mailer_extra = ['ticket_id' => $ticket->id, 'ticket_subject' => $ticket->subject, 'ticket_description' => $ticket->description, 'ticket_status' => $ticket->status, 'ticket_status_txt' => self::resolveStatus($ticket->status), 'ticket_priority' => $ticket->priority, 'ticket_priority_txt' => self::resolveStatus($ticket->priority), 'company_name' => $company->name, 'company_description' => $company->description, 'company_domain' => $company->domain, 'company_logo' => $company->logo, 'department_name' => $department->name, 'has_attachment' => $ticket_attachment->has_attachment, 'attachment_path' => $ticket_attachment->attachment_path, 'updated_message' => $thread_message->message, 'receiver_name' => $receiver->name, 'receiver_email' => $receiver->email]; } else { $mailer_extra = ['ticket_id' => 1, 'ticket_subject' => "How can i use contact us form", 'ticket_description' => "Hi , Sir how can i use contact us form", 'ticket_status' => 1, 'ticket_status_txt' => self::resolveStatus(1), 'ticket_priority' => 1, 'ticket_priority_txt' => self::resolveStatus(1), 'company_name' => "KODEINFO", 'company_description' => "We are a small and dedicated team of designers/developers. This is our web design and development focused blog.We focus on pushing the boundaries of standards based web technologies.", 'company_domain' => "http://www.kodeinfo.com", 'company_logo' => "http://kodeinfo.com/img/shortlogo.png", 'department_name' => "General Queries", 'has_attachment' => false, 'attachment_path' => "", 'updated_message' => "This is a updated message from customer/operator", 'receiver_name' => "Imran", 'receiver_email' => "*****@*****.**"]; } return $mailer_extra; }
public static function getTicketMessages($thread_id, $last_message_id) { ThreadMessages::where('thread_id', $thread_id)->where('sender_id', 0)->update(['sender_id' => Auth::user()->id]); $thread = MessageThread::find($thread_id); if ($last_message_id > 0) { $messages = ThreadMessages::where('thread_id', $thread_id)->where('id', '>', $last_message_id)->get(); } else { $messages = ThreadMessages::where('thread_id', $thread_id)->get(); } foreach ($messages as $message) { $message->user = User::find($message->sender_id); $attachment = TicketAttachments::where('message_id', $message->id)->where('thread_id', $thread_id)->first(); $message->attachment = $attachment; } $message_str = View::make('tickets.stub-ticket-message', ["messages" => $messages, "thread" => $thread])->render(); if (sizeof($messages) > 0) { $last_message_id = $messages[sizeof($messages) - 1]->id; } else { $last_message_id = $last_message_id; } return ["messages_arr" => $messages, 'last_message_id' => $last_message_id, "messages_str" => $message_str]; }
public function delete($user_id) { $tickets = Tickets::where('customer_id', $user_id)->get(); //Delete tickets foreach ($tickets as $ticket) { TicketAttachments::where('thread_id', $ticket->id)->delete(); MessageThread::where('id', $ticket->thread_id)->delete(); ThreadMessages::where('thread_id', $ticket->thread_id)->delete(); } Tickets::where('customer_id', $user_id)->delete(); //Delete Chat and Conversations $online_users = OnlineUsers::where('user_id', $user_id)->get(); foreach ($online_users as $online_user) { MessageThread::where('id', $online_user->thread_id)->delete(); ThreadMessages::where('thread_id', $online_user->thread_id)->delete(); } OnlineUsers::where('user_id', $user_id)->delete(); $closed_conversations = ClosedConversations::where('user_id', $user_id)->get(); foreach ($closed_conversations as $closed_conversation) { MessageThread::where('id', $closed_conversation->thread_id)->delete(); ThreadMessages::where('thread_id', $closed_conversation->thread_id)->delete(); } ClosedConversations::where('user_id', $user_id)->delete(); UsersGroups::where('user_id', $user_id)->delete(); CompanyCustomers::where("customer_id", $user_id)->delete(); User::where("id", $user_id)->delete(); RecentActivities::createActivity("Customer deleted by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name); Session::flash('success_msg', trans('msgs.customer_deleted_success')); return Redirect::to('/customers/all'); }
public function delete($company_id) { $departments = Department::where('company_id', $company_id)->get(); if (Config::get('site-config.is_demo') && $company_id == 1) { Session::flash('error_msg', 'Demo : Feature is disabled'); return Redirect::to('/dashboard'); } foreach ($departments as $department) { if (!empty($department)) { $tickets = Tickets::where('department_id', $department->id)->get(); //Delete tickets foreach ($tickets as $ticket) { TicketAttachments::where('thread_id', $ticket->id)->delete(); MessageThread::where('id', $ticket->thread_id)->delete(); ThreadMessages::where('thread_id', $ticket->thread_id)->delete(); } Tickets::where('department_id', $department->id)->delete(); //Delete Chat and Conversations $online_users = OnlineUsers::where('department_id', $department->id)->get(); foreach ($online_users as $online_user) { MessageThread::where('id', $online_user->thread_id)->delete(); ThreadMessages::where('thread_id', $online_user->thread_id)->delete(); } OnlineUsers::where('department_id', $department->id)->delete(); $closed_conversations = ClosedConversations::where('department_id', $department->id)->get(); foreach ($closed_conversations as $closed_conversation) { MessageThread::where('id', $closed_conversation->thread_id)->delete(); ThreadMessages::where('thread_id', $closed_conversation->thread_id)->delete(); } ClosedConversations::where('department_id', $department->id)->delete(); $operators = OperatorsDepartment::where('department_id', $department->id)->lists('user_id'); if (sizeof($operators) > 0) { User::whereIn('id', $operators)->delete(); UsersGroups::whereIn('user_id', $operators)->delete(); } OperatorsDepartment::where('department_id', $department->id)->delete(); $department_admin = DepartmentAdmins::where('department_id', $department->id)->first(); if (!empty($department_admin)) { UsersGroups::where('user_id', $department_admin->user_id)->delete(); User::where("id", $department_admin->user_id)->delete(); CompanyDepartmentAdmins::where("user_id", $department_admin->user_id)->delete(); CannedMessages::where('operator_id', $operators)->delete(); } } DepartmentAdmins::where('department_id', $department->id)->delete(); Department::where('id', $department->id)->delete(); } $company = Company::where('id', $company_id)->first(); RecentActivities::createActivity("Company <a href='/companies/all'>" . $company->name . "</a> deleted by User Name " . Auth::user()->name . " User ID " . Auth::user()->id); Company::where('id', $company_id)->delete(); Session::flash('success_msg', trans('msgs.company_deleted_success')); return Redirect::to('/companies/all'); }
public function delete($thread_id) { Tickets::where('thread_id', $thread_id)->delete(); TicketAttachments::where('thread_id', $thread_id)->delete(); MessageThread::where('id', $thread_id)->delete(); ThreadMessages::where('thread_id', $thread_id)->delete(); ThreadGeoInfo::where('thread_id', $thread_id)->delete(); RecentActivities::createActivity("Ticket deleted by User ID:" . Auth::user()->id . " User Name:" . Auth::user()->name); Session::flash('success_msg', trans('msgs.ticket_deleted_success')); return Redirect::to('/tickets/all'); }