/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAdmin()) { return $next($request); } // All Agents have access in none restricted mode if (Setting::grab('agent_restrict') == 'no') { if (Agent::isAgent()) { return $next($request); } } // if this is a ticket show page if ($request->route()->getName() == Setting::grab('main_route') . '.show') { $ticket_id = $request->route(Setting::grab('main_route')); } // if this is a new comment on a ticket if ($request->route()->getName() == Setting::grab('main_route') . '-comment.store') { $ticket_id = $request->get('ticket_id'); } // Assigned Agent has access in the restricted mode enabled if (Agent::isAgent() && Agent::isAssignedAgent($ticket_id)) { return $next($request); } // Ticket Owner has access if (Agent::isTicketOwner($ticket_id)) { return $next($request); } return redirect()->action('\\Kordy\\Ticketit\\Controllers\\TicketsController@index')->with('warning', trans('ticketit::lang.you-are-not-permitted-to-access')); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAgent() || Agent::isAdmin()) { return $next($request); } return redirect()->action('\\Kordy\\Ticketit\\Controllers\\TicketsController@index')->with('warning', trans('ticketit::lang.you-are-not-permitted-to-access')); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAgent() || Agent::isAdmin()) { return $next($request); } return back()->with('warning', 'You are not permitted to access this page!'); }
public function index($indicator_period = 2) { $tickets_count = Ticket::count(); $open_tickets_count = Ticket::whereNull('completed_at')->count(); $closed_tickets_count = Ticket::whereNotNull('completed_at')->count(); // Per Category pagination $categories = Category::paginate(10, ['*'], 'cat_page'); // Total tickets counter per category for google pie chart $categories_all = Category::all(); $categories_share = []; foreach ($categories_all as $cat) { $categories_share[$cat->name] = $cat->tickets()->count(); } // Total tickets counter per agent for google pie chart $agents_all = Agent::agents(); $agents_share = []; foreach ($agents_all as $agent_single) { $agents_share[$agent_single->name] = $agent_single->agentTickets(false)->count() + $agent_single->agentTickets(true)->count(); } // Per Agent $agents = Agent::agents(10); // Per User $users = Agent::users(10); // Per Category performance data $ticketController = new TicketsController(new Ticket(), new Agent()); $monthly_performance = $ticketController->monthlyPerfomance($indicator_period); return view('ticketit::admin.index', compact('open_tickets_count', 'closed_tickets_count', 'tickets_count', 'categories', 'agents', 'users', 'monthly_performance', 'categories_share', 'agents_share')); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAgent() || Agent::isAdmin()) { return $next($request); } return redirect()->action('\\Kordy\\Ticketit\\Controllers\\TicketsController@index')->with('warning', 'You are not permitted to access this page!'); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Agent::isAdmin()) { return $next($request); } // All Agents have access in none restricted mode if (config('ticketit.agent_restrict') == 'no') { if (Agent::isAgent()) { return $next($request); } } // if this is a ticket show page if ($request->route()->getName() == config('ticketit.main_route') . '.show') { $ticket_id = $request->route(config('ticketit.main_route')); } // if this is a new comment on a ticket if ($request->route()->getName() == config('ticketit.main_route') . '-comment.store') { $ticket_id = $request->get('ticket_id'); } // Assigned Agent has access in the restricted mode enabled if (Agent::isAgent() && Agent::isAssignedAgent($ticket_id)) { return $next($request); } // Ticket Owner has access if (Agent::isTicketOwner($ticket_id)) { return $next($request); } return redirect()->action('\\Kordy\\Ticketit\\Controllers\\TicketsController@index')->with('warning', 'You are not permitted to access this page!'); }
public function agentSelectList($category_id, $ticket_id) { $agents = ['auto' => 'Auto Select'] + Models\Agent::agentsLists($category_id); $selected_Agent = Models\Ticket::find($ticket_id)->agent->id; $select = '<select class="form-control" id="agent_id" name="agent_id">'; foreach ($agents as $id => $name) { $selected = $id == $selected_Agent ? "selected" : ""; $select .= '<option value="' . $id . '" ' . $selected . '>' . $name . '</option>'; } $select .= '</select>'; return $select; }
/** * Get the agent with the lowest tickets assigned in specific category * * @param integer $cat_id * @return integer $selected_agent_id */ public function autoSelectAgent($cat_id) { $agents = $agents = Models\Category::find($cat_id)->agents()->agents(); $count = 0; $lowest_tickets = 1000000; // If no agent selected, select the admin $first_admin = Agent::admins()->first(); $selected_agent_id = $first_admin->id; foreach ($agents as $agent) { if ($count == 0) { $lowest_tickets = $agent->agentTickets->count(); $selected_agent_id = $agent->id; } else { $tickets_count = $agent->agentTickets->count(); if ($tickets_count < $lowest_tickets) { $lowest_tickets = $tickets_count; $selected_agent_id = $agent->id; } } $count++; } return $selected_agent_id; }
/** * Bootstrap the application services. * * @return void */ public function boot() { $installer = new InstallController(); // if a migration is missing scape to the installation if (empty($installer->inactiveMigrations()) && DB::table('ticketit_settings')->count() != 0) { // Send the Agent User model to the view under $u view()->composer('*', function ($view) { if (auth()->check()) { $u = Agent::find(auth()->user()->id); $view->with('u', $u); } $setting = new Setting(); $view->with('setting', $setting); }); // Adding HTML5 color picker to form elements CollectiveForm::macro('custom', function ($type, $name, $value = "#000000", $options = []) { $field = $this->input($type, $name, $value, $options); return $field; }); // Passing to views the master view value from the setting file view()->composer('ticketit::*', function ($view) { $tools = new ToolsController(); $master = Setting::grab('master_template'); $email = Setting::grab('email.template'); $view->with(compact('master', 'email', 'tools')); }); // Send notification when new comment is added Comment::creating(function ($comment) { if (Setting::grab('comment_notification')) { $notification = new NotificationsController(); $notification->newComment($comment); } }); // Send notification when ticket status is modified Ticket::updating(function ($modified_ticket) { if (Setting::grab('status_notification')) { $original_ticket = Ticket::find($modified_ticket->id); if ($original_ticket->status_id != $modified_ticket->status_id || $original_ticket->completed_at != $modified_ticket->completed_at) { $notification = new NotificationsController(); $notification->ticketStatusUpdated($modified_ticket, $original_ticket); } } if (Setting::grab('assigned_notification')) { $original_ticket = Ticket::find($modified_ticket->id); if ($original_ticket->agent->id != $modified_ticket->agent->id) { $notification = new NotificationsController(); $notification->ticketAgentUpdated($modified_ticket, $original_ticket); } } return true; }); // Send notification when ticket status is modified Ticket::created(function ($ticket) { if (Setting::grab('assigned_notification')) { $notification = new NotificationsController(); $notification->newTicketNotifyAgent($ticket); } return true; }); $this->loadTranslationsFrom(__DIR__ . '/Translations', 'ticketit'); $this->loadViewsFrom(__DIR__ . '/Views', 'ticketit'); $this->publishes([__DIR__ . '/Views' => base_path('resources/views/vendor/ticketit')], 'views'); $this->publishes([__DIR__ . '/Translations' => base_path('resources/lang/vendor/ticketit')], 'lang'); $this->publishes([__DIR__ . '/Public' => public_path('vendor/ticketit')], 'public'); $this->publishes([__DIR__ . '/Migrations' => base_path('database/migrations')], 'db'); // Check public assets are present, publish them if not // $installer->publicAssets(); $main_route = Setting::grab('main_route'); $admin_route = Setting::grab('admin_route'); include __DIR__ . '/routes.php'; } elseif (Request::path() == 'tickets-install') { $this->loadTranslationsFrom(__DIR__ . '/Translations', 'ticketit'); $this->loadViewsFrom(__DIR__ . '/Views', 'ticketit'); $this->publishes([__DIR__ . '/Migrations' => base_path('database/migrations')], 'db'); Route::get('/tickets-install', ['middleware' => 'auth', 'uses' => 'Kordy\\Ticketit\\Controllers\\InstallController@index']); Route::post('/tickets-install', ['middleware' => 'auth', 'uses' => 'Kordy\\Ticketit\\Controllers\\InstallController@setup']); } }
/** * Sync Agent categories with the selected categories got from update form * @param $id * @param Request $request */ public function syncAgentCategories($id, Request $request) { $form_cats = $request->input('agent_cats') == null ? [] : $request->input('agent_cats'); $agent = Agent::find($id); $agent->categories()->sync($form_cats); }
/** * Sync Administrator categories with the selected categories got from update form * @param $id * @param Request $request */ public function syncAdministratorCategories($id, Request $request) { $form_cats = $request->input('administrator_cats') == null ? [] : $request->input('administrator_cats'); $administrator = Agent::find($id); $administrator->categories()->sync($form_cats); }
public function getTickets($complete = false) { $user = Agent::find(auth()->user()->id); if ($user->isAdmin()) { $tickets = $user->allTickets($complete); } elseif ($user->isAgent()) { $tickets = $user->agentTickets($complete); } else { $tickets = $user->userTickets($complete); } return $tickets; }