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'));
 }
Esempio n. 2
0
 /**
  * Check if user is the owner for a ticket
  * @param integer $id ticket id
  * @return boolean
  */
 public static function isTicketOwner($id)
 {
     if (Auth::check()) {
         if (Auth::user()->id == Ticket::find($id)->user->id) {
             return true;
         }
     }
 }
Esempio n. 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Requests\CommentFormRequest|Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $comment = new Models\Comment();
     $comment->content = $request->get('content');
     $comment->ticket_id = $request->get('ticket_id');
     $comment->user_id = \Auth::user()->id;
     $comment->save();
     $ticket = Models\Ticket::find($comment->ticket_id);
     $ticket->updated_at = $comment->created_at;
     $ticket->save();
     return back()->with('status', trans('ticketit::lang.comment-has-been-added-ok'));
 }
Esempio n. 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Requests\CommentFormRequest|Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $comment = new Models\Comment();
     $comment->content = $request->get('content');
     $comment->ticket_id = $request->get('ticket_id');
     $comment->user_id = \Auth::user()->id;
     $comment->save();
     $ticket = Models\Ticket::find($comment->ticket_id);
     $ticket->updated_at = $comment->created_at;
     $ticket->save();
     return back()->with('status', 'Comment has been added successfully');
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // Adding HTML5 color picker to form elements
     Form::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) {
         $master = config('ticketit.master_template');
         $view->with(compact('master'));
     });
     // Send notification when new comment is added
     Comment::creating(function ($comment) {
         if (config('ticketit.comment_notification') == 'yes') {
             $notification = new NotificationsController();
             $notification->newComment($comment);
         }
     });
     // Send notification when ticket status is modified
     Ticket::updating(function ($modified_ticket) {
         if (config('ticketit.status_notification') == 'yes') {
             $original_ticket = Ticket::find($modified_ticket->id);
             if ($original_ticket->status->id != $modified_ticket->status->id) {
                 $notification = new NotificationsController();
                 $notification->ticketStatusUpdated($modified_ticket, $original_ticket);
             }
         }
         if (config('ticketit.assigned_notification') == 'yes') {
             $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 (config('ticketit.assigned_notification') == 'yes') {
             $notification = new NotificationsController();
             $notification->newTicketNotifyAgent($ticket);
         }
         return true;
     });
     $this->loadViewsFrom(__DIR__ . '/views', 'ticketit');
     $this->publishes([__DIR__ . '/views' => base_path('resources/views/vendor/ticketit')], 'views');
     $this->publishes([__DIR__ . '/config/ticketit.php' => config_path('ticketit.php')], 'config');
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 /**
  * Calculate the average date length it took to solve tickets within date period
  * @param $from
  * @param $to
  * @return int
  */
 public function intervalPerformance($from, $to, $cat_id = false)
 {
     if ($cat_id) {
         $tickets = Ticket::where('category_id', $cat_id)->whereBetween('completed_at', array($from, $to))->get();
     } else {
         $tickets = Ticket::whereBetween('completed_at', array($from, $to))->get();
     }
     if (empty($tickets->first())) {
         return false;
     }
     $performance_count = 0;
     $counter = 0;
     foreach ($tickets as $ticket) {
         $performance_count += $this->ticketPerformance($ticket);
         $counter++;
     }
     $performance_average = $performance_count / $counter;
     return $performance_average;
 }
 /**
  * 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']);
     }
 }
Esempio n. 9
0
 public function allTickets($complete = false)
 {
     if ($complete) {
         return Ticket::whereNotNull('completed_at');
     } else {
         return Ticket::whereNull('completed_at');
     }
 }