public function composeNav()
 {
     view()->composer(['layouts._leftnav', 'layouts._filternav'], function ($view) {
         $view->with('backlogs', Backlog::all('id', 'name'));
         $view->with('open_tickets_count', Ticket::where('status', 'open')->count());
         $view->with('close_tickets_count', Ticket::where('status', 'close')->count());
         $view->with('bug_tickets_count', Ticket::where('type', 'bug')->count());
         $view->with('task_tickets_count', Ticket::where('type', 'task')->count());
         $view->with('high_prio_tickets_count', Ticket::where('priority', 'high')->count());
         $view->with('low_prio_tickets_count', Ticket::where('priority', 'low')->count());
         $view->with('medium_prio_tickets_count', Ticket::where('priority', 'medium')->count());
     });
     view()->composer(['tickets.create', 'tickets.show', 'tickets.edit'], function ($view) {
         $ticket = new Ticket();
         $view->with('ticket_types', $ticket->displayTypes());
         $view->with('ticket_priorities', $ticket->displayPriorities());
         $view->with('backlogs', Backlog::all('id', 'name'));
         $view->with('users', User::all('id', 'name'));
     });
     view()->composer(['user.profile'], function ($view) {
         $view->with('user_all_tickets', Auth::user()->tickets()->paginate(10));
     });
     view()->composer(['tickets.index', 'layouts._leftnav', 'layouts._filternav'], function ($view) {
         $view->with('all_tickets_count', Ticket::all()->count());
     });
 }
Ejemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (in_array(Auth::user()->id, [1, 2])) {
         $tickets = Ticket::all();
     } else {
         $tickets = Ticket::where('user_id', Auth::user()->id)->get();
     }
     return view('tickets.index', compact('tickets'));
 }
 public function searchTickets()
 {
     //str replace to fix an edge case - a user wants to search for a literal %
     $query = str_replace('%', '\\%', Input::get('query'));
     //collect tickets from various places matched by the search
     $tickets = Ticket::where('subject', 'like', "%{$query}%")->get()->merge(Message::where('text', 'like', "%{$query}%")->get()->map(function ($message) {
         return $message->ticket;
     }))->unique()->filter(function ($ticket) {
         return Gate::allows('view-ticket', $ticket);
     });
     return view("helpdesk/searchResults", compact('tickets'));
 }
Ejemplo n.º 4
0
 /**
  * @return mixed
  */
 public function myTicketsFilter()
 {
     if ($this->filter === 'all') {
         $view = \Auth::user()->tickets;
     } elseif ($this->filter === 'open') {
         $view = \App\Ticket::where('status', $this->filter)->where('user_id', \Auth::user()->id)->get();
     } elseif ($this->filter === 'closed') {
         $view = \App\Ticket::where('status', $this->filter)->where('user_id', \Auth::user()->id)->get();
     } elseif ($this->filter === 'started') {
         $view = \App\Ticket::where('activity', $this->filter)->where('user_id', \Auth::user()->id)->get();
     } elseif ($this->filter === 'not_started') {
         $view = \App\Ticket::where('activity', $this->filter)->where('user_id', \Auth::user()->id)->get();
     }
     return $view;
 }
Ejemplo n.º 5
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request, $status = 1, $group = '')
 {
     $my_groups = Customer::where('id', $this->my_customer_id)->first()->groups()->where('active', '1')->get();
     if ($group !== '') {
         $tickets = Ticket::where('group_id', $group)->where('status_id', $status)->get();
     } else {
         //$tickets = Ticket::where('user_id', $request->user()->id)->where('status_id', $status)->get();
         $_groups = [];
         foreach ($my_groups as $_group) {
             $_groups[] = $_group->id;
         }
         $tickets = Ticket::whereRaw('group_id in (' . implode(', ', $_groups) . ') and status_id = ' . $status)->orderBy('created_at')->get();
     }
     $statusList = StatusList::orderBy('id')->get();
     return view('layouts.ticket.index', ['tickets' => $tickets, 'my_groups' => $my_groups, 'sel_group' => $group, 'statusList' => $statusList, 'sel_status' => $status]);
 }
Ejemplo n.º 6
0
 public function show($id, LaravelFacebookSdk\LaravelFacebookSdk $fb)
 {
     // Find the event, or fail
     $data['event'] = Event::findOrFail($id);
     // Retrieve various attributes of the location
     $location = $data['event']->location;
     $data['location_name'] = $location->name;
     $data['partners'] = $data['event']->partners;
     // If the user is authorised, get the ticket
     // for the event
     if (Auth::check()) {
         try {
             $data['ticket'] = Ticket::where('user_id', Auth::user()->id)->where('event_id', $id)->firstOrFail();
         } catch (ModelNotFoundException $e) {
             $data['ticket'] = false;
         }
     } else {
         $data['ticket'] = false;
     }
     $userIds = DB::table('tickets')->where('event_id', $data['event']->id)->pluck('user_id');
     $token = Session::get('fb_user_access_token');
     if ($token) {
         $fb->setDefaultAccessToken($token);
         try {
             // Request Facebook user data
             $response = $fb->get('/me/friends?limit=5000&fields=id');
             $friendData = $response->getDecodedBody()["data"];
             $friendIds = array_flatten($friendData);
         } catch (Facebook\Exceptions\FacebookSDKException $e) {
             return Redirect::back()->withErrors([$e->getMessage()]);
         }
         $data['users'] = DB::table('users')->whereIn('id', $userIds)->whereIn('facebook_id', $friendIds)->take(10)->get();
         $data["friends"] = true;
     }
     if (!$token || empty($data["users"])) {
         $data['users'] = DB::table('users')->whereIn('id', $userIds)->take(10)->get();
         $data["friends"] = false;
     }
     $data = array_merge($data, MediaController::uploadFiles(Crypt::encrypt($data['event']->id)));
     // Return a view of the event
     return view('events.show')->with($data);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $ticket)
 {
     $this->validate($request, ['response' => 'required']);
     $response = TicketResponse::create(['user_id' => $this->my_id, 'response' => $request->response, 'source' => 'web', 'ticket_id' => $ticket]);
     if (isset($request->attachments)) {
         foreach ($request->attachments as $attachment) {
             // Check that the directory exists
             $uploadPath = storage_path() . '/attachments/' . $ticket;
             $fs = new Filesystem();
             if (!$fs->isDirectory($uploadPath)) {
                 // Create the directory
                 $fs->makeDirectory($uploadPath);
             }
             $attachment->move($uploadPath, $attachment->getClientOriginalName());
             $_attachment = Attachment::create(['user_id' => $this->my_id, 'name' => $attachment->getClientOriginalName(), 'ticket_response_id' => $response->id]);
         }
     }
     $_ticket = Ticket::where('id', $ticket)->first();
     Ticket::where('id', $ticket)->update(['status_id' => $request->status]);
     $this->dispatch(new EmailUpdatedTicket($_ticket, $response));
     return redirect('/ticket-response/' . $ticket);
 }
Ejemplo n.º 8
0
 /**
  * Get all tickets assigned to a given user.
  *
  * @param  User  $user
  * @return Collection
  */
 public function forUser(User $user)
 {
     return Ticket::where('assignee_id', $user->id)->orderBy('priority', 'desc')->paginate(3);
 }
Ejemplo n.º 9
0
 public function index(Request $request)
 {
     $start_date = $request->input('start_date') ?: date('Y-m-d', strtotime('-30 days'));
     $end_date = $request->input('end_date') ?: date('Y-m-d', strtotime(date('Y-m-d')));
     if (Entrust::hasRole('user')) {
         return redirect('/')->withErrors(config('constants.NA'));
     }
     $user_count = \App\User::with('roles')->whereHas('roles', function ($query) {
         $query->whereName('user');
     })->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
     $staff_count = \App\User::with('roles')->whereHas('roles', function ($query) {
         $query->where('name', '!=', 'user');
     })->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
     $ticket_count = \App\Ticket::where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
     $closed_ticket_count = \App\Ticket::where('ticket_status', '=', 'close')->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
     $closed_ticket_percentage = $ticket_count > 0 ? round($closed_ticket_count / $ticket_count * 100, 2) : 0;
     $ticket_status_stats = \App\Ticket::select('ticket_status', DB::raw('count(*) as total'))->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->groupBy('ticket_status')->get();
     $status_stats = array();
     foreach ($ticket_status_stats as $stat) {
         $status_stats[] = array('label' => Helper::toWord($stat->ticket_status), 'value' => $stat->total);
     }
     $ticket_priority_stats = \App\Ticket::select('ticket_priority', DB::raw('count(*) as total'))->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->groupBy('ticket_priority')->get();
     $priority_stats = array();
     foreach ($ticket_priority_stats as $stat) {
         $priority_stats[] = array('label' => Helper::toWord($stat->ticket_priority), 'value' => $stat->total);
     }
     $ticket_type_status = \App\Ticket::select('ticket_type_id', DB::raw('count(*) as total'))->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->groupBy('ticket_type_id')->get();
     $type_stats = array();
     foreach ($ticket_type_status as $stat) {
         $type_stats[] = array('label' => Helper::toWord($stat->TicketType->ticket_type_name), 'value' => $stat->total);
     }
     $ticket_department_stats = \App\Ticket::select('department_id', DB::raw('count(*) as total'))->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->groupBy('department_id')->get();
     $department_stats = array();
     foreach ($ticket_department_stats as $stat) {
         $department_stats[] = array('label' => Helper::toWord($stat->Department->department_name), 'value' => $stat->total);
     }
     $users = \App\User::with('roles')->whereHas('roles', function ($query) {
         $query->where('name', '!=', 'user');
     })->where('id', '!=', Auth::user()->id)->get();
     $user_list = array();
     foreach ($users as $user) {
         $user_list[$user->id] = $user->name . ' (Department : ' . $user->Profile->Department->department_name . ')';
     }
     $query = DB::table('activity_log')->join('users', 'users.id', '=', 'activity_log.user_id')->select(DB::raw('name,activity_log.created_at AS created_at,text,user_id'));
     if (!Entrust::hasRole('admin')) {
         $query->where('user_id', '=', Auth::user()->id);
     }
     $activities = $query->latest()->limit(100)->get();
     $holidays = \App\Holiday::all();
     $todos = \App\Todo::where('user_id', '=', Auth::user()->id)->orWhere(function ($query) {
         $query->where('user_id', '!=', Auth::user()->id)->where('visibility', '=', 'public');
     })->get();
     $events = array();
     foreach ($holidays as $holiday) {
         $start = $holiday->date;
         $title = 'Holiday: ' . $holiday->holiday_description;
         $color = '#1e5400';
         $events[] = array('title' => $title, 'start' => $start, 'color' => $color);
     }
     foreach ($todos as $todo) {
         $start = $todo->date;
         $title = 'To do: ' . $todo->todo_title . ' ' . $todo->todo_description;
         $color = '#ff0000';
         $url = '/todo/' . $todo->id . '/edit';
         $events[] = array('title' => $title, 'start' => $start, 'color' => $color, 'url' => $url);
     }
     $colors = ['#5CB85C', '#FFD600', '#D10D0D', '#1A89E8', '#458b00', '#f85931', '#ce1836', '#009989', '#00688b', '#8b1a1a'];
     shuffle($colors);
     $status_colors = $colors;
     shuffle($colors);
     $priority_colors = $colors;
     shuffle($colors);
     $type_colors = $colors;
     shuffle($colors);
     $department_colors = $colors;
     $assets = ['calendar', 'graph'];
     return view('dashboard', compact('user_count', 'staff_count', 'assets', 'activities', 'user_list', 'holidays', 'events', 'ticket_count', 'closed_ticket_percentage', 'status_stats', 'priority_stats', 'type_stats', 'department_stats', 'status_colors', 'priority_colors', 'type_colors', 'department_colors', 'start_date', 'end_date'));
 }
Ejemplo n.º 10
0
 /**
  * @return A JSON respnose with a list of all the tickets
  * scanned by this authenticated user, that haven't been marked done
  */
 public function ticketsToPrint()
 {
     return Ticket::where('scanned_by', Auth::user()->id)->where('printed', false)->get();
 }
 /**
  * Tickets for a given prio
  *
  * @param $priority
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function tickets_by_priority($priority)
 {
     $tickets = Ticket::where('priority', $priority)->latest()->paginate(10);
     $header = $priority . ' priority tickets';
     return view('tickets.index', compact('tickets', 'header'));
 }
Ejemplo n.º 12
0
 public function createTicket()
 {
     if (!Entrust::can('create_ticket')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $departments = Department::lists('department_name', 'id')->all();
     $ticket_types = TicketType::lists('ticket_type_name', 'id')->all();
     $tickets = Ticket::where('user_id', '=', Auth::user()->id)->get();
     $assets = ['hide_sidebar'];
     return view('ticket.create-ticket', compact('departments', 'ticket_types', 'assets', 'tickets'));
 }
Ejemplo n.º 13
0
 public function delivered()
 {
     $tickets = Ticket::where('entregado', '=', 1)->get();
     return response()->json($tickets);
 }
Ejemplo n.º 14
0
 /**
  * Get all tickets assigned to a given user.
  *
  * @param  User  $user
  * @return Collection
  */
 public function forUser(User $user)
 {
     return Ticket::where('assignee_id', $user->id)->orderBy('priority', 'asc')->get();
 }
Ejemplo n.º 15
0
 public function index()
 {
     $tickets = Ticket::where('scanned_by', Auth::user()->id)->where('printed', false)->get();
     return View::make('staff.index', compact('tickets'));
 }
Ejemplo n.º 16
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $config = Config::get('mail');
     switch ($config['encryption']) {
         case 'ssl':
             $connection_string = '{' . $config['host'] . ':993/imap/ssl}INBOX';
             break;
         case 'tls':
             $connection_string = '{' . $config['host'] . ':143/imap/tls}INBOX';
             break;
         case null:
         default:
             $connection_string = '{' . $config['host'] . ':143/imap}INBOX';
             break;
     }
     $this->info($connection_string);
     $tmp_attachment_path = storage_path() . '/attachments/tmp';
     $mailbox = new Mailbox($connection_string, $config['username'], $config['password'], $tmp_attachment_path);
     if (!$mailbox) {
         $this->error('Unable to connect to the IMAP server');
     }
     $mailIds = $mailbox->searchMailbox('UNSEEN');
     $this->info('Found ' . count($mailIds) . ' new emails to check');
     if (!empty($mailIds)) {
         foreach ($mailIds as $mailId) {
             $msg = $mailbox->getMail($mailId);
             $subject = str_replace(array('Re: ', 'RE: '), '', $msg->subject);
             $email = $msg->fromAddress;
             if ($msg->textHtml == '') {
                 $response = $msg->textPlain;
                 $response = str_replace("\n\r", '<br>', $response);
                 $response = str_replace("\n", '<br>', $response);
                 $response = '<p>' . $response . '</p>';
             } else {
                 $response = $msg->textHtml;
             }
             $_subjectParts = explode(' - ', $subject);
             if (count($_subjectParts) > 1) {
                 $_subjectParts = explode('[', $_subjectParts[1]);
                 $this->info('Email details:');
                 $this->info('Subject: ' . $subject);
                 $this->info('Email : ' . $email);
                 $this->info('TrackID : ' . $_subjectParts[0]);
                 // Find the ticket
                 $ticket = Ticket::where('track_id', $_subjectParts[0])->first();
                 // Find the user
                 $user = User::where('email', $email)->first();
                 if (count($ticket) > 0 || count($user) > 0) {
                     $this->info('Email associated with ticket ' . $ticket->id);
                     $this->info('Email associated with user ' . $user->first_name . ' ' . $user->last_name);
                     $uploadPath = storage_path() . '/attachments/' . $ticket->id;
                     $response = TicketResponse::create(['user_id' => $user->id, 'response' => $response, 'source' => 'email', 'ticket_id' => $ticket->id]);
                     $attachments = $msg->getAttachments();
                     if (count($attachments) > 0) {
                         $fs = new Filesystem();
                         if (!$fs->isDirectory($uploadPath)) {
                             $fs->makeDirectory($uploadPath);
                         }
                     }
                     foreach ($attachments as $attachment) {
                         $tmpPath = $attachment->filePath;
                         $fileName = $attachment->name;
                         $this->info('Trying to move file from ' . $tmpPath . ' to ' . $uploadPath . '/' . $fileName);
                         File::move($tmpPath, $uploadPath . '/' . $fileName);
                         Attachment::create(['user_id' => $user->id, 'name' => $fileName, 'ticket_response_id' => $response->id]);
                     }
                     $this->dispatch(new EmailUpdatedTicket($ticket, $response));
                 } else {
                     $this->info('Ticket or User not found');
                 }
             } else {
                 $this->info('Not an email for us');
             }
         }
     }
 }
Ejemplo n.º 17
0
 public function usuarioSinTicket($usuario_id)
 {
     $tickets = \App\Ticket::where('USUARIO_id', '=', $usuario_id)->whereIn('ESTADO_id', [10, 11])->get();
     if (count($tickets) == 0) {
         echo json_encode(['status' => true, 'mensaje' => 'OK: usuario sin tickets vigentes']);
     } else {
         header('Content-Type: application/json');
         echo json_encode(['status' => false, 'mensaje' => 'ERROR: usuario con tickets vigentes']);
     }
 }
Ejemplo n.º 18
0
 public function asignados(Request $request)
 {
     $tickets = Ticket::where('operador_id', $request->user()->id)->where('estado_id', 2)->orderBy('id', 'desc')->get();
     return view('generic.tickets_admin', ['rows' => $tickets, 'title' => 'Mis tickets asignados']);
 }
Ejemplo n.º 19
0
 public function barrerTicket()
 {
     $quince_minutos_antes = date('H:i:s', time() - 60 * 60 * 5 - 15 * 60);
     $tickets = \App\Ticket::where('fecha', '<=', Escritorio::getFechaEcuador())->where('hora_creacion', '<', $quince_minutos_antes)->whereNotIn('ESTADO_id', [11, 12, 13])->get();
     //dd($tickets,$quince_minutos_antes);
     $i = 0;
     if (count($tickets) > 0) {
         foreach ($tickets as $ticket) {
             $i++;
             $this->cambiarEstado($ticket->id, 'anulada');
             $this->cambiarEstadoBicicleta($ticket->id, 'buena');
         }
     }
     $mensaje = '<i class="fa fa-check"></i> Se han anulado ' . $i . ' tickets por expiraci&oacute;n';
     header('Content-Type: application/json');
     echo json_encode(['status' => true, 'mensaje' => $mensaje]);
 }
Ejemplo n.º 20
0
 /**
  * Search User specific tickets that have been acquired using a credit trade.
  *
  * @param  Ticket  $ticket     
  * @return Collection
  */
 public function searchUserTicketsAcquired($req, User $user)
 {
     $where["user_id"] = $user->id;
     $where["valid"] = '1';
     $where["tradable"] = '0';
     unset($req["_token"]);
     if (isset($req['dateofdeparture'])) {
         $depDate = $req['dateofdeparture'];
         unset($req['dateofdeparture']);
     } else {
         unset($depDate);
     }
     foreach ($req as $key => $value) {
         if (empty($value)) {
             unset($req[$key]);
         } else {
             $where[$key] = $value;
         }
     }
     if (isset($where['roundtrip'])) {
         if ($where['roundtrip'] == 'on') {
             $where['roundtrip'] = '1';
         } else {
             $where['roundtrip'] = '0';
         }
     }
     if ($depDate != '') {
         return Ticket::where($where)->whereBetween('dateofdeparture', [$depDate . " 00:00:01", $depDate . " 23:59:59"])->orderBy('created_at', 'asc')->get();
     } else {
         return Ticket::where($where)->orderBy('created_at', 'asc')->get();
     }
 }