Exemplo n.º 1
0
 /**
  *This function will create new tickets
  *
  * Take Post Requsets and save them in the database
  * Task
  *	1. Create new tickets
  *
  * @return View
  **/
 public function inputs()
 {
     $user = Session::get('user');
     if (is_null($user)) {
         return Redirect::to('login');
     }
     if (Request::get('options') == "custom") {
         $heading = Request::get('heading');
     } else {
         $heading = Request::get('options');
     }
     $ticket = new tickets();
     $ticket->userid = Session::get('userid');
     $ticket->subject = $heading;
     $ticket->opened = 1;
     $ticket->save();
     $ticketMsg = new tickets_messages();
     $ticketMsg->user_id = Session::get('userid');
     $ticketMsg->message = Request::get('txtarea');
     $ticketMsg->ticket_id = $ticket->id;
     $ticketMsg->save();
     //return view('user.tickets.new-ticket')->with('user',$user)->with('created',1);
     return redirect('view-ticket');
     //return 1;
 }
Exemplo n.º 2
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);
     }
 }
 /**
  *
  * Get POST Requsets and Handle them
  * 
  * 
  * @return Json Response
  *
  */
 public function inputs()
 {
     $user = Session::get('user');
     if (Request::get('task') == "loadtableopendtickets") {
         $x = Request::get('skip');
         return $this->loadTableOpenedTickets($x);
     } elseif (Request::get('task') == "loadtableAvailabletickets") {
         $x = Request::get('skip');
         return $this->loadTableAvailableTickets($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") {
         $ids = Request::get('ticket');
         if (!is_null($ids)) {
             $ticketOwner;
             $ticket = tickets::find($ids);
             if (is_null($ticket)) {
                 abort(404);
             } else {
                 $ticketOwner = user::find($ticket->userid);
             }
             $ticketsMessages = tickets_messages::where('ticket_id', $ticket->id)->orderBy('id', 'asc')->get();
             return view('admin.reply')->with('user', $user)->with('messages', $ticketsMessages)->with('ticket', $ticket)->with('ticket_owner', $ticketOwner);
         } else {
             abort(404);
         }
     } elseif (Request::get('task') == "replyTickets") {
         $message = Request::get('text');
         $ticketId = Request::get('ticket_id');
         return $this->replyTickets($message, $ticketId);
     }
     return response()->json(['message' => 'Invalid Request', 'code' => 'error']);
     //return 1;
 }