コード例 #1
0
 /**
  *This function will handle the post requests
  *
  * 
  * Tasks
  *	1. Load Opend Tickets
  *	2. Load Closed Tickets 
  *	3. Close the tickets
  *	4. Open the tickets
  * 
  **/
 public function inputs()
 {
     if (Request::get('task') == "loadtableopendtickets") {
         $x = Request::get('skip');
         return $this->loadTableOpendTickets($x);
     } elseif (Request::get('task') == "loadtableclosedtickets") {
         $x = Request::get('skip');
         return $this->loadTableClosedTickets($x);
     } elseif (Request::get('task') == "closeTicket") {
         $ids = Request::get('tickets');
         return $this->closeTickets($ids);
     } elseif (Request::get('task') == "openTicket") {
         $ids = Request::get('tickets');
         return $this->openTickets($ids);
     } elseif (Request::get('task') == "viewTicket") {
         $user = Session::get('user');
         $ids = Request::get('ticket');
         if (!is_null($ids)) {
             $ticket = tickets::find($ids);
             if (is_null($ticket)) {
                 abort(404);
             }
             if ($ticket->userid != Session::get('userid') && $user->level < 10) {
                 abort(404);
             }
             $admin = adminUserTickets::where('ticketid', $ticket->id)->first();
             $staff = null;
             if (!is_null($admin)) {
                 $staff = user::find($admin->adminid);
             }
             $ticketsMessages = tickets_messages::where('ticket_id', $ticket->id)->orderBy('id', 'asc')->get();
             return view('user.tickets.reply')->with('user', $user)->with('messages', $ticketsMessages)->with('ticket', $ticket)->with('staff', $staff);
         } else {
             abort(404);
         }
     } elseif (Request::get('task') == "replyTickets") {
         $message = Request::get('text');
         $ticket_id = Request::get('ticket_id');
         return $this->replyTickets($message, $ticket_id);
     }
 }
コード例 #2
0
 /**
  *
  * Get the Tickets Reply
  * @param String $message Ticket body
  * @param Integer $ticketId Ticket ID
  * @return Json Response
  *
  */
 private function replyTickets($message, $ticketId)
 {
     $user = Session::get('user');
     $count = adminUserTickets::where('ticketid', $ticketId)->count();
     if ($count == 0) {
         $adminUt = new adminUserTickets();
         $adminUt->ticketid = $ticketId;
         $adminUt->adminid = $user->id;
         $adminUt->save();
     } else {
         $count = adminUserTickets::where('adminid', $user->id)->where('ticketid', $ticketId)->count();
         if ($count == 0) {
             return response()->json(['message' => 'Invalid Request', 'code' => 'error']);
         }
     }
     if (!is_null(trim($message)) && !is_null($ticketId)) {
         $ticket = tickets::find($ticketId);
         if (is_null($ticket)) {
             return response()->json(['message' => 'Invalid Request', 'code' => 'error']);
         }
         if ($ticket->opened == 0) {
             return response()->json(['message' => 'Ticket Should be opened', 'code' => 'error']);
         }
         $ticketMsg = new tickets_messages();
         $ticketMsg->user_id = Session::get('userid');
         $ticketMsg->message = $message;
         $ticketMsg->ticket_id = $ticket->id;
         $ticketMsg->save();
         return response()->json(['code' => 'success', 'task' => 'replyTickets', 'msg' => $ticketMsg]);
     } else {
         return response()->json(['message' => 'Invalid Request', 'code' => 'error']);
     }
 }