Exemplo n.º 1
0
 public function copyTemplate(Request $request)
 {
     $path = base_path() . '/config/template/' . config('config.domain') . '/' . $request->input('name');
     $content = '';
     if (File::exists($path)) {
         $content = File::get($path);
     }
     $type = $request->input('type');
     $id = $request->input('id');
     if ($type == 'ticket') {
         $ticket = \App\Ticket::find($id);
         if ($ticket) {
             $content = Helper::templateContent($content, $ticket);
             $title_content = Helper::templateContent(config('template.' . $request->input('name') . '.title'), $ticket);
         }
     }
     $response = ['data' => $content, 'title_data' => $title_content, 'status' => 'success'];
     return response()->json($response, 200, array('Access-Controll-Allow-Origin' => '*'));
 }
Exemplo n.º 2
0
 public function store(TicketRequest $request, Ticket $ticket)
 {
     if (!Entrust::can('create_ticket')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $data = $request->all();
     $ticket->fill($data);
     $ticket->ticket_status = 'open';
     $ticket->user_id = Auth::user()->id;
     $service_time = Helper::getServiceTime($ticket->ticket_priority);
     if ($service_time['resolution_time_type'] == 'business_hour') {
         $ticket->resolution_due_time = Helper::calculateDueTime($service_time['resolution_time'], date('Y-m-d H:i'));
     } else {
         $ticket->resolution_due_time = date('Y-m-d H:i', $service_time['resolution_time'] * 60 + strtotime(date('Y-m-d H:i')));
     }
     if ($service_time['response_time_type'] == 'business_hour') {
         $ticket->response_due_time = Helper::calculateDueTime($service_time['response_time'], date('Y-m-d H:i'));
     } else {
         $ticket->response_due_time = date('Y-m-d H:i', $service_time['response_time'] * 60 + strtotime(date('Y-m-d H:i')));
     }
     $max_ticket_no = Ticket::max('ticket_no');
     $next_ticket_no = config('config.next_ticket_no');
     if ($max_ticket_no >= $next_ticket_no) {
         $ticket->ticket_no = ++$max_ticket_no;
     } else {
         $ticket->ticket_no = $next_ticket_no;
     }
     $ticket->save();
     Helper::storeCustomField($this->form, $ticket->id, $data);
     $activity = 'New Ticket added';
     Activity::log($activity);
     $path = base_path() . '/config/template/' . config('config.domain') . '/new_ticket';
     $content = '';
     if (File::exists($path)) {
         $content = File::get($path);
     }
     $content = Helper::templateContent($content, 'ticket', $ticket);
     if ($content != '' && config('config.new_ticket_send_mail')) {
         $title = Helper::templateContent(config('template.new_ticket.title'), 'ticket', $ticket);
         Mail::send('template.mail', compact('content'), function ($message) use($ticket, $title) {
             $message->to($ticket->User->email)->subject($title);
         });
     }
     if (Entrust::hasRole('user')) {
         return redirect('/view-ticket/' . $ticket->id)->withSuccess(config('constants.ADDED'));
     } else {
         return redirect('/ticket/' . $ticket->id)->withSuccess(config('constants.ADDED'));
     }
 }
Exemplo n.º 3
0
 public function postRegister(RegisterRequest $request, User $user)
 {
     if (!Entrust::can('create_user')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $user->fill($request->all());
     $user->password = bcrypt($request->input('password'));
     $key = config('app.key');
     $user->confirmation_code = hash_hmac('sha256', str_random(40), $key);
     $user->confirmed = 1;
     $user->save();
     $profile = new Profile();
     $profile->user()->associate($user);
     $profile->department_id = $request->input('department_id') ?: null;
     $profile->save();
     $user->attachRole($request->input('role_id'));
     Helper::storeCustomField('user-form', $user->id, $request->all());
     $path = base_path() . '/config/template/' . config('config.domain') . '/new_user';
     $content = '';
     if (File::exists($path)) {
         $content = File::get($path);
     }
     $content = Helper::templateContent($content, 'user', $user);
     $content = str_replace('[PASSWORD]', $request->input('password'), $content);
     if ($content != '' && $request->input('send_mail')) {
         $title = Helper::templateContent(config('template.new_user.title'), 'user', $user);
         Mail::send('template.mail', compact('content'), function ($message) use($user, $title) {
             $message->to($user->email)->subject($title);
         });
     }
     $activity = Auth::user()->name . ' created a User (' . $user->name . ')';
     Activity::log($activity);
     return redirect()->back()->withSuccess('User created successfully. ');
 }