Exemplo n.º 1
0
 public function index(CustomField $custom_field)
 {
     if (!Entrust::can('manage_custom_field')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $custom_fields = $custom_field->get();
     $col_data = array();
     $col_heads = array(trans('messages.Form'), trans('messages.Field Title'), trans('messages.Field Type'), trans('messages.Field Value'), trans('messages.Required'), trans('messages.Option'));
     foreach ($custom_fields as $custom_field) {
         $col_data[] = array(Helper::toWord($custom_field->form), $custom_field->field_title, $custom_field->field_type, implode('<br />', explode(',', $custom_field->field_values)), $custom_field->field_required ? 'Yes' : 'No', delete_form(['custom_field.destroy', $custom_field->id]));
     }
     Helper::writeResult($col_data);
     $data = ['col_heads' => $col_heads];
     return view('custom_field.index', $data);
 }
Exemplo n.º 2
0
 public function store(NewTemplateRequest $request)
 {
     $template_subject = Helper::createSlug($request->input('template_subject'));
     $templates = Helper::getTemplate();
     if (array_key_exists($template_subject, $templates)) {
         return redirect()->back()->withErrors('This template already exists.');
     }
     if ($request->input('category') == 'user') {
         $fields = 'CURRENT_DATE_TIME,CURRENT_DATE,NAME,USERNAME,EMAIL';
     } elseif ($request->input('category') == 'ticket') {
         $fields = 'CURRENT_DATE_TIME, CURRENT_DATE, TICKET_NO, DEPARTMENT, TICKET_SUBJECT, TICKET_STATUS, TICKET_PRIORITY, TICKET_TYPE, USERNAME, NAME, EMAIL, RESPONSE_TIME, RESOLUTION_TIME';
     } else {
         $fields = '';
     }
     $templates[$template_subject] = array('title' => Helper::toWord($template_subject), 'fields' => $fields, 'category' => $request->input('category'));
     $filename = base_path() . '/config/template.php';
     File::put($filename, var_export($templates, true));
     File::prepend($filename, '<?php return ');
     File::append($filename, ';');
     return redirect()->back()->withSuccess('Template added.');
 }
Exemplo n.º 3
0
 public static function templateContent($content, $property_type, $property)
 {
     if ($property_type == 'ticket') {
         $content = str_replace('[NAME]', $property->User->name, $content);
         $content = str_replace('[USERNAME]', $property->User->username, $content);
         $content = str_replace('[EMAIL]', $property->User->email, $content);
         $content = str_replace('[TICKET_NO]', $property->ticket_no, $content);
         $content = str_replace('[DEPARTMENT]', $property->Department->department_name, $content);
         $content = str_replace('[TICKET_SUBJECT]', $property->ticket_subject, $content);
         $content = str_replace('[TICKET_STATUS]', Helper::toWord($property->ticket_status), $content);
         $content = str_replace('[TICKET_PRIORITY]', Helper::toWord($property->ticket_priority), $content);
         $content = str_replace('[TICKET_TYPE]', $property->TicketType->ticket_type_name, $content);
         $content = str_replace('[RESPONSE_TIME]', Helper::showDateTime($property->response_due_time), $content);
         $content = str_replace('[RESOLUTION_TIME]', Helper::showDateTime($property->resolution_due_time), $content);
         $content = str_replace('[CURRENT_DATE]', Helper::showDate(date('Y-m-d')), $content);
         $content = str_replace('[CURRENT_DATE_TIME]', Helper::showDateTime(date('Y-m-d, H:i:s')), $content);
     } elseif ($property_type == 'user') {
         $content = str_replace('[NAME]', $property->name, $content);
         $content = str_replace('[USERNAME]', $property->username, $content);
         $content = str_replace('[EMAIL]', $property->email, $content);
         $content = str_replace('[DEPARTMENT]', $property->Profile->Department->department_name, $content);
     }
     return $content;
 }
Exemplo n.º 4
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'));
 }