update v1.0.6

This commit is contained in:
sujitprasad
2016-02-16 22:42:08 +05:30
parent e6b579d67b
commit 073a49a8af
587 changed files with 21487 additions and 22766 deletions

2
.env
View File

@@ -2,7 +2,7 @@ APP_ENV=local
APP_DEBUG=true APP_DEBUG=true
APP_KEY=SomeRandomString APP_KEY=SomeRandomString
DB_HOST=localhost DB_HOST=localhost
DB_DATABASE=fav222222 DB_DATABASE=faveo1.0.6
DB_USERNAME=root DB_USERNAME=root
DB_PASSWORD= DB_PASSWORD=
CACHE_DRIVER=file CACHE_DRIVER=file

View File

@@ -1,5 +1,5 @@
<h3>About Faveo</h3> <h3>About Faveo</h3>
<br><img src="https://travis-ci.org/ladybirdweb/faveo-helpdesk.svg?branch=master">&nbsp;<img src="https://img.shields.io/badge/License-OSL-blue.svg">&nbsp;<a href="https://gitter.im/ladybirdweb/faveo-helpdesk" target="_blank"><img src="https://badges.gitter.im/ladybirdweb/faveo-helpdesk.svg"></a></br> <br><img src="https://travis-ci.org/ladybirdweb/faveo-helpdesk.svg?branch=master">&nbsp;<img src="https://img.shields.io/badge/License-OSL-blue.svg"></br>
<p>Headquartered in Bangalore, Faveo HELPDESK provides Businesses with an automated Helpdesk system to manage customer support. <p>Headquartered in Bangalore, Faveo HELPDESK provides Businesses with an automated Helpdesk system to manage customer support.
<br/><br/> <br/><br/>
The word Faveo comes from Latin which means to be favourable. Which truly highlights vision and the scope as well as the functionality of the product that Faveo is. It is specifically designed to cater the needs of startups and SMEs empowering them with state of art, ticket based support system. In todays competitive startup scenario customer retention is one of the major challenges. Handling client query diligently is all the difference between retaining or losing a long lasting relationship. The company is driven with passion of providing tools for managing consumer queries for strategic insights and helping companies take those decisive decisions. The word Faveo comes from Latin which means to be favourable. Which truly highlights vision and the scope as well as the functionality of the product that Faveo is. It is specifically designed to cater the needs of startups and SMEs empowering them with state of art, ticket based support system. In todays competitive startup scenario customer retention is one of the major challenges. Handling client query diligently is all the difference between retaining or losing a long lasting relationship. The company is driven with passion of providing tools for managing consumer queries for strategic insights and helping companies take those decisive decisions.

View File

@@ -1,95 +1,93 @@
<?php namespace App\Exceptions; <?php
namespace App\Exceptions;
use Exception; use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
// use App\Http\Controllers\Common\SettingsController; // use App\Http\Controllers\Common\SettingsController;
//use App\Model\helpdesk\Email\Smtp; //use App\Model\helpdesk\Email\Smtp;
class Handler extends ExceptionHandler { class Handler extends ExceptionHandler {
/** /**
* A list of the exception types that should not be reported. * A list of the exception types that should not be reported.
* *
* @var array * @var array
*/ */
protected $dontReport = [ protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException' 'Symfony\Component\HttpKernel\Exception\HttpException'
]; ];
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type response * @return type response
*/ */
// public function __construct() { // public function __construct() {
// SettingsController::smtp(); // SettingsController::smtp();
// } // }
/** /**
* Report or log an exception. * Report or log an exception.
* *
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
* *
* @param \Exception $e * @param \Exception $e
* @return void * @return void
*/ */
public function report(Exception $e) public function report(Exception $e) {
{ return parent::report($e);
return parent::report($e); }
}
/** /**
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $e * @param \Exception $e
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function render($request, Exception $e) public function render($request, Exception $e) {
{
if(config('app.debug') == false) {
if ($this->isHttpException($e) && $e->getStatusCode() == 404) {
return response()->view('errors.404', []);
} else {
if(\Config::get('database.install') == 1) {
// if(\Config::get('app.ErrorLog') == '%1%') {
// \App\Http\Controllers\Common\SettingsController::smtp();
// \Mail::send('errors.report', array('e' => $e), function ($message) {
// $message->to('', '')->subject('Faveo HELPDESK Pro ERROR');
// });
// }
}
return response()->view('errors.500', []);
}
}
return parent::render($request, $e);
if ($this->isHttpException($e)) if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
{ return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
//dd($e);
} else if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
}
// if (config('app.debug') == false) {
// if ($this->isHttpException($e) && $e->getStatusCode() == 404) {
// return response()->view('errors.404', []);
// } else {
// if (\Config::get('database.install') == 1) {
// // if(\Config::get('app.ErrorLog') == '%1%') {
// // \App\Http\Controllers\Common\SettingsController::smtp();
// // $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => '', 'email' => ''], $message = ['subject' => '', 'scenario'=>'error-report'], $template_variables = ['e' =>$e ]);
// // }
// }
// return response()->view('errors.500', []);
// }
// }
// return parent::render($request, $e);
if ($this->isHttpException($e)) {
return $this->renderHttpException($e); return $this->renderHttpException($e);
} }
if (config('app.debug')) if (config('app.debug')) {
{
return $this->renderExceptionWithWhoops($e); return $this->renderExceptionWithWhoops($e);
} }
return parent::render($request, $e); return parent::render($request, $e);
}
} protected function renderExceptionWithWhoops(Exception $e) {
protected function renderExceptionWithWhoops(Exception $e)
{
$whoops = new \Whoops\Run; $whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
return new \Illuminate\Http\Response( return new \Illuminate\Http\Response(
$whoops->handleException($e), $whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()
$e->getStatusCode(),
$e->getHeaders()
); );
} }
} }

View File

@@ -1,13 +1,14 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controller // controller
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// request // request
use App\Http\Requests\helpdesk\AgentRequest; use App\Http\Requests\helpdesk\AgentRequest;
use App\Http\Requests\helpdesk\AgentUpdate; use App\Http\Requests\helpdesk\AgentUpdate;
// model // model
use App\User; use App\User;
use App\Model\helpdesk\Agent\Assign_team_agent; use App\Model\helpdesk\Agent\Assign_team_agent;
@@ -16,7 +17,8 @@ use App\Model\helpdesk\Agent\Groups;
use App\Model\helpdesk\Agent\Teams; use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Utility\Timezones; use App\Model\helpdesk\Utility\Timezones;
use App\Model\helpdesk\Settings\Company; use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Email\Emails;
// classes // classes
use DB; use DB;
use Mail; use Mail;
@@ -33,216 +35,222 @@ use Exception;
*/ */
class AgentController extends Controller { class AgentController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct(PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
SettingsController::smtp();
// checking authentication
$this->middleware('auth');
// checking admin roles
$this->middleware('roles');
}
/** /**
* Create a new controller instance. * Get all agent list page
* constructor to check * @param type User $user
* 1. authentication * @return type Response
* 2. user roles */
* 3. roles must be agent public function index() {
* @return void try {
*/ return view('themes.default1.admin.helpdesk.agent.agents.index');
public function __construct() { } catch (Exception $e) {
SettingsController::smtp(); return view('404');
// checking authentication }
$this->middleware('auth'); }
// checking admin roles
$this->middleware('roles');
}
/** /**
* Get all agent list page * creating a new agent
* @param type User $user * @param type Assign_team_agent $team_assign_agent
* @return type Response * @param type Timezones $timezone
*/ * @param type Groups $group
public function index() { * @param type Department $department
try { * @param type Teams $team
return view('themes.default1.admin.helpdesk.agent.agents.index'); * @return type view
} catch (Exception $e) { */
return view('404'); public function create(Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) {
} try {
} $team = $team->get();
$timezones = $timezone->get();
$groups = $group->get();
$departments = $department->get();
$teams = $team->lists('id', 'name');
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/** /**
* creating a new agent * store a new agent
* @param type Assign_team_agent $team_assign_agent * @param type User $user
* @param type Timezones $timezone * @param type AgentRequest $request
* @param type Groups $group * @param type Assign_team_agent $team_assign_agent
* @param type Department $department * @return type Response
* @param type Teams $team */
* @return type view public function store(User $user, AgentRequest $request, Assign_team_agent $team_assign_agent) {
*/
public function create(Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) {
try {
$team = $team->get();
$timezones = $timezone->get();
$groups = $group->get();
$departments = $department->get();
$teams = $team->lists('id', 'name');
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/** // dd($this->system_mail());
* store a new agent
* @param type User $user
* @param type AgentRequest $request
* @param type Assign_team_agent $team_assign_agent
* @return type Response
*/
public function store(User $user, AgentRequest $request, Assign_team_agent $team_assign_agent) {
/* Insert to user table */ /* Insert to user table */
$user->role = 'agent'; $user->role = 'agent';
$user->fill($request->input())->save(); $user->fill($request->input())->save();
$password = $this->generateRandomString(); $password = $this->generateRandomString();
$user->password = Hash::make($password); $user->password = Hash::make($password);
$requests = $request->input('team_id'); $requests = $request->input('team_id');
$id = $user->id; $id = $user->id;
// insert team // insert team
foreach ($requests as $req) { foreach ($requests as $req) {
DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]); // DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]);
} }
/* Succes And Failure condition */ /* Succes And Failure condition */
if ($user->save() == true) { if ($user->save() == true) {
$name = $user->user_name; $name = $user->user_name;
$email = $user->email; $email = $user->email;
$from = $this->company(); $system_from = $this->company();
// send mail on registration try {
try{ // send mail on registration
Mail::send('emails.pass', ['name' => $name, 'password' => $password, 'from' => $from, 'emailadd' => $email], function ($message) use ($email, $name) { $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $email], $message = ['subject' => 'Password', 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $email, 'user_password' => $password]);
$message->to($email, $name)->subject('[password]'); } catch (Exception $e) {
}); return redirect('agents')->with('fails', 'Some error occured while sending mail to the agent. Please check email settings and try again');
} catch (Exception $e) { }
return redirect('agents')->with('fails', 'Some error occuren while sending mail to the agent. Please check email settings'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('agents')->with('success', 'Agent Created sucessfully');
} } else {
return redirect('agents')->with('success', 'Agent Created sucessfully'); return redirect('agents')->with('fails', 'Agent can not Create');
} else { }
return redirect('agents')->with('fails', 'Agent can not Create'); }
}
}
/** /**
* Editing a selected agent * Editing a selected agent
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @param type Assign_team_agent $team_assign_agent * @param type Assign_team_agent $team_assign_agent
* @param type Timezones $timezone * @param type Timezones $timezone
* @param type Groups $group * @param type Groups $group
* @param type Department $department * @param type Department $department
* @param type Teams $team * @param type Teams $team
* @return type Response * @return type Response
*/ */
public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) { public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) {
try { try {
$user = $user->whereId($id)->first(); $user = $user->whereId($id)->first();
$team = $team->get(); $team = $team->get();
$teams1 = $team->lists('name', 'id'); $teams1 = $team->lists('name', 'id');
$timezones = $timezone->get(); $timezones = $timezone->get();
$groups = $group->get(); $groups = $group->get();
$departments = $department->get(); $departments = $department->get();
$table = $team_assign_agent->where('agent_id', $id)->first(); $table = $team_assign_agent->where('agent_id', $id)->first();
$teams = $team->lists('id', 'name'); $teams = $team->lists('id', 'name');
$assign = $team_assign_agent->where('agent_id', $id)->lists('team_id'); $assign = $team_assign_agent->where('agent_id', $id)->lists('team_id');
return view('themes.default1.admin.helpdesk.agent.agents.edit', compact('teams', 'assign', 'table', 'teams1', 'selectedTeams', 'user', 'timezones', 'groups', 'departments', 'team', 'exp', 'counted')); return view('themes.default1.admin.helpdesk.agent.agents.edit', compact('teams', 'assign', 'table', 'teams1', 'selectedTeams', 'user', 'timezones', 'groups', 'departments', 'team', 'exp', 'counted'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect('agents')->with('fail', 'No such file'); return redirect('agents')->with('fail', 'No such file');
} }
} }
/** /**
* Update the specified agent in storage. * Update the specified agent in storage.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @param type AgentUpdate $request * @param type AgentUpdate $request
* @param type Assign_team_agent $team_assign_agent * @param type Assign_team_agent $team_assign_agent
* @return type Response * @return type Response
*/ */
public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent) { public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent) {
// storing all the details // storing all the details
$user = $user->whereId($id)->first(); $user = $user->whereId($id)->first();
$daylight_save = $request->input('daylight_save'); $daylight_save = $request->input('daylight_save');
$limit_access = $request->input('limit_access'); $limit_access = $request->input('limit_access');
$directory_listing = $request->input('directory_listing'); $directory_listing = $request->input('directory_listing');
$vocation_mode = $request->input('vocation_mode'); $vocation_mode = $request->input('vocation_mode');
//============================================== //==============================================
$table = $team_assign_agent->where('agent_id', $id); $table = $team_assign_agent->where('agent_id', $id);
$table->delete(); $table->delete();
$requests = $request->input('team_id'); $requests = $request->input('team_id');
// inserting team details // inserting team details
foreach ($requests as $req) { foreach ($requests as $req) {
DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]); DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]);
} }
//Todo For success and failure conditions //Todo For success and failure conditions
try { try {
$user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save(); $user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save();
return redirect('agents')->with('success', 'Agent Updated sucessfully'); return redirect('agents')->with('success', 'Agent Updated sucessfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect('agents')->with('fails', 'Agent did not update'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('agents')->with('fails', 'Agent did not update' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Remove the specified agent from storage. * Remove the specified agent from storage.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @param type Assign_team_agent $team_assign_agent * @param type Assign_team_agent $team_assign_agent
* @return type Response * @return type Response
*/ */
public function destroy($id, User $user, Assign_team_agent $team_assign_agent) { public function destroy($id, User $user, Assign_team_agent $team_assign_agent) {
/* Becouse of foreign key we delete team_assign_agent first */ /* Becouse of foreign key we delete team_assign_agent first */
error_reporting(E_ALL & ~E_NOTICE); error_reporting(E_ALL & ~E_NOTICE);
$team_assign_agent = $team_assign_agent->where('agent_id', $id); $team_assign_agent = $team_assign_agent->where('agent_id', $id);
$team_assign_agent->delete(); $team_assign_agent->delete();
$user = $user->whereId($id)->first(); $user = $user->whereId($id)->first();
try { try {
$error = 'This staff is related to some tickets'; $error = 'This staff is related to some tickets';
$user->id; $user->id;
$user->delete(); $user->delete();
throw new \Exception($error); throw new \Exception($error);
return redirect('agents')->with('success', 'Agent Deleted sucessfully'); return redirect('agents')->with('success', 'Agent Deleted sucessfully');
} catch (\Exception $e) { } catch (\Exception $e) {
dd($e->errorInfo); dd($e->errorInfo);
return redirect('agents')->with('fails', $error); return redirect('agents')->with('fails', $error);
} }
} }
/**
* Generate a random string for password
* @param type $length
* @return type string
*/
public function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
/** /**
* Generate a random string for password * Fetching comapny name to send mail
* @param type $length * @return type
* @return type string */
*/ public function company() {
public function generateRandomString($length = 10) { $company = Company::Where('id', '=', '1')->first();
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; if ($company->company_name == null) {
$charactersLength = strlen($characters); $company = "Support Center";
$randomString = ''; } else {
for ($i = 0; $i < $length; $i++) { $company = $company->company_name;
$randomString .= $characters[rand(0, $charactersLength - 1)]; }
} return $company;
return $randomString; }
}
/**
* Fetching comapny name to send mail
* @return type
*/
public function company() {
$company = Company::Where('id','=','1')->first();
if($company->company_name == null){
$company = "Support Center";
}else{
$company = $company->company_name;
}
return $company;
}
// public function agent_profile($id) {
// $agent = User::where('id','=',$id)->first();
// return \View::make('themes.default1.admin.helpdesk.agent.agents.agent-profile',compact('agent'));
// }
/**
* System default email
*/
// public function system_mail() {
// $emails = Emails::all();
// $count_emails = $emails->count();
// if($count_emails > 1) {
// dd($emails);
// }
// $email = Email::where('id', '=', '1')->first();
// return $email->sys_email;
// }
} }

View File

@@ -1,15 +1,15 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controller // controller
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// request // request
use App\Http\Requests\helpdesk\BanlistRequest; use App\Http\Requests\helpdesk\BanlistRequest;
use App\Http\Requests\helpdesk\BanRequest; use App\Http\Requests\helpdesk\BanRequest;
// model // model
use App\User; use App\User;
use App\Model\helpdesk\Email\Banlist; use App\Model\helpdesk\Email\Banlist;
//classes //classes
use Exception; use Exception;
@@ -22,142 +22,142 @@ use Exception;
*/ */
class BanlistController extends Controller { class BanlistController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
// checking admin roles // checking admin roles
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* @param type Banlist $ban * @param type Banlist $ban
* @return type Response * @return type Response
*/ */
public function index() { public function index() {
try { try {
$bans = User::where('ban','=',1)->get(); $bans = User::where('ban', '=', 1)->get();
return view('themes.default1.admin.helpdesk.emails.banlist.index', compact('bans')); return view('themes.default1.admin.helpdesk.emails.banlist.index', compact('bans'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @return type Response * @return type Response
*/ */
public function create() { public function create() {
try { try {
return view('themes.default1.admin.helpdesk.emails.banlist.create'); return view('themes.default1.admin.helpdesk.emails.banlist.create');
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type banlist $ban * @param type banlist $ban
* @param type BanRequest $request * @param type BanRequest $request
* @param type User $user * @param type User $user
* @return type Response * @return type Response
*/ */
public function store(BanRequest $request, User $user) { public function store(BanRequest $request, User $user) {
// dd($request); // dd($request);
try { try {
//adding field to user whether it is banned or not //adding field to user whether it is banned or not
$adban = $request->input('email'); $adban = $request->input('email');
$use = $user->where('email', $adban)->first(); $use = $user->where('email', $adban)->first();
if ($use != null) { if ($use != null) {
$use->ban = $request->input('ban'); $use->ban = $request->input('ban');
$use->internal_note = $request->input('internal_note'); $use->internal_note = $request->input('internal_note');
$use->save(); $use->save();
// $user->create($request->input())->save(); // $user->create($request->input())->save();
return redirect('banlist')->with('success', 'Email Banned sucessfully'); return redirect('banlist')->with('success', 'Email Banned sucessfully');
} else { } else {
$user = new User; $user = new User;
$user->email = $adban; $user->email = $adban;
$user->ban = $request->input('ban'); $user->ban = $request->input('ban');
$user->internal_note = $request->input('internal_note'); $user->internal_note = $request->input('internal_note');
$user->save(); $user->save();
return redirect('banlist')->with('success', 'Email Banned sucessfully'); return redirect('banlist')->with('success', 'Email Banned sucessfully');
} }
} catch (Exception $e) { } catch (Exception $e) {
return redirect('banlist')->with('fails', 'Email can not Ban'); return redirect('banlist')->with('fails', 'Email can not Ban');
} }
} }
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
* @return Response * @return Response
*/ */
public function show($id) { public function show($id) {
// //
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* @param type int $id * @param type int $id
* @param type Banlist $ban * @param type Banlist $ban
* @return type Response * @return type Response
*/ */
public function edit($id, User $ban) { public function edit($id, User $ban) {
try { try {
$bans = $ban->whereId($id)->first(); $bans = $ban->whereId($id)->first();
return view('themes.default1.admin.helpdesk.emails.banlist.edit', compact('bans')); return view('themes.default1.admin.helpdesk.emails.banlist.edit', compact('bans'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type int $id * @param type int $id
* @param type Banlist $ban * @param type Banlist $ban
* @param type BanlistRequest $request * @param type BanlistRequest $request
* @return type Response * @return type Response
*/ */
public function update($id, User $ban, BanlistRequest $request) { public function update($id, User $ban, BanlistRequest $request) {
try { try {
$bans = $ban->whereId($id)->first(); $bans = $ban->whereId($id)->first();
$bans->internal_note = $request->input('internal_note'); $bans->internal_note = $request->input('internal_note');
$bans->ban = $request->input('ban'); $bans->ban = $request->input('ban');
// dd($request->input('ban')); // dd($request->input('ban'));
if ($bans->save()) { if ($bans->save()) {
return redirect('banlist')->with('success', 'Banned Email Updated sucessfully'); return redirect('banlist')->with('success', 'Banned Email Updated sucessfully');
} else { } else {
return redirect('banlist')->with('fails', 'Banned Email not Updated'); return redirect('banlist')->with('fails', 'Banned Email not Updated');
} }
} catch (Exception $e) { } catch (Exception $e) {
return redirect('banlist')->with('fails', 'Banned Email not Updated'); return redirect('banlist')->with('fails', 'Banned Email not Updated');
} }
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* @param type int $id * @param type int $id
* @param type Banlist $ban * @param type Banlist $ban
* @return type Response * @return type Response
*/ */
// public function destroy($id, Banlist $ban) { // public function destroy($id, Banlist $ban) {
// $bans = $ban->whereId($id)->first(); // $bans = $ban->whereId($id)->first();
// dd($bans); // dd($bans);
// /* Success and Falure condition */ // /* Success and Falure condition */
// try{ // try{
// $bans->delete(); // $bans->delete();
// return redirect('banlist')->with('success', 'Banned Email Deleted sucessfully'); // return redirect('banlist')->with('success', 'Banned Email Deleted sucessfully');
// } catch (Exception $e) { // } catch (Exception $e) {
// return redirect('banlist')->with('fails', 'Banned Email can not Delete'.'<li>'.$e->errorInfo[2].'</li>'); // return redirect('banlist')->with('fails', 'Banned Email can not Delete'.'<li>'.$e->errorInfo[2].'</li>');
// } // }
// } // }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controller // controller
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// request // request
@@ -29,214 +32,213 @@ use Exception;
*/ */
class DepartmentController extends Controller { class DepartmentController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* Get index page * Get index page
* @param type Department $department * @param type Department $department
* @return type Response * @return type Response
*/ */
public function index(Department $department) { public function index(Department $department) {
try { try {
$departments = $department->get(); $departments = $department->get();
return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments')); return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @param type User $user * @param type User $user
* @param type Group_assign_department $group_assign_department * @param type Group_assign_department $group_assign_department
* @param type Department $department * @param type Department $department
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @param type Template $template * @param type Template $template
* @param type Emails $email * @param type Emails $email
* @param type Groups $group * @param type Groups $group
* @return type Response * @return type Response
*/ */
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group) { public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group) {
try { try {
$slas = $sla->get(); $slas = $sla->get();
$user = $user->where('role', 'agent')->get(); $user = $user->where('role', 'agent')->get();
$emails = $email->get(); $emails = $email->get();
$templates = $template->get(); $templates = $template->get();
$department = $department->get(); $department = $department->get();
$groups = $group->lists('id', 'name'); $groups = $group->lists('id', 'name');
return view('themes.default1.admin.helpdesk.agent.departments.create', compact('department', 'templates', 'slas', 'user', 'emails', 'groups')); return view('themes.default1.admin.helpdesk.agent.departments.create', compact('department', 'templates', 'slas', 'user', 'emails', 'groups'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type Department $department * @param type Department $department
* @param type DepartmentRequest $request * @param type DepartmentRequest $request
* @return type Response * @return type Response
*/ */
public function store(Department $department, DepartmentRequest $request) { public function store(Department $department, DepartmentRequest $request) {
try { try {
$department->fill($request->except('group_id','manager'))->save(); $department->fill($request->except('group_id', 'manager'))->save();
$requests = $request->input('group_id'); $requests = $request->input('group_id');
$id = $department->id; $id = $department->id;
if($request->manager) { if ($request->manager) {
$department->manager = $request->input('manager'); $department->manager = $request->input('manager');
} else { } else {
$department->manager = null; $department->manager = null;
} }
// foreach ($requests as $req) { // foreach ($requests as $req) {
// DB::insert('insert into group_assign_department(group_id, department_id) values (?,?)', [$req, $id]); // DB::insert('insert into group_assign_department(group_id, department_id) values (?,?)', [$req, $id]);
// } // }
/* Succes And Failure condition */ /* Succes And Failure condition */
/* Check Whether the function Success or Fail */ /* Check Whether the function Success or Fail */
if ($department->save() == true) { if ($department->save() == true) {
return redirect('departments')->with('success', 'Department Created sucessfully'); return redirect('departments')->with('success', 'Department Created sucessfully');
} else { } else {
return redirect('departments')->with('fails', 'Department can not Create'); return redirect('departments')->with('fails', 'Department can not Create');
} }
} catch (Exception $e) { } catch (Exception $e) {
return redirect('departments')->with('fails', 'Department can not Create'); return redirect('departments')->with('fails', 'Department can not Create');
} }
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @param type Group_assign_department $group_assign_department * @param type Group_assign_department $group_assign_department
* @param type Template $template * @param type Template $template
* @param type Teams $team * @param type Teams $team
* @param type Department $department * @param type Department $department
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @param type Emails $email * @param type Emails $email
* @param type Groups $group * @param type Groups $group
* @return type Response * @return type Response
*/ */
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group) { public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group) {
try { try {
$slas = $sla->get(); $slas = $sla->get();
$user = $user->where('role', 'agent')->get(); $user = $user->where('role', 'agent')->get();
$emails = $email->get(); $emails = $email->get();
$templates = $template->get(); $templates = $template->get();
$departments = $department->whereId($id)->first(); $departments = $department->whereId($id)->first();
$groups = $group->lists('id', 'name'); $groups = $group->lists('id', 'name');
$assign = $group_assign_department->where('department_id', $id)->lists('group_id'); $assign = $group_assign_department->where('department_id', $id)->lists('group_id');
return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'groups')); return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'groups'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type int $id * @param type int $id
* @param type Group_assign_department $group_assign_department * @param type Group_assign_department $group_assign_department
* @param type Department $department * @param type Department $department
* @param type DepartmentUpdate $request * @param type DepartmentUpdate $request
* @return type Response * @return type Response
*/ */
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) { public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) {
// dd($id); // dd($id);
try { try {
$table = $group_assign_department->where('department_id', $id); $table = $group_assign_department->where('department_id', $id);
$table->delete(); $table->delete();
$requests = $request->input('group_id'); $requests = $request->input('group_id');
// foreach ($requests as $req) { // foreach ($requests as $req) {
// DB::insert('insert into group_assign_department (group_id, department_id) values (?,?)', [$req, $id]); // DB::insert('insert into group_assign_department (group_id, department_id) values (?,?)', [$req, $id]);
// } // }
$departments = $department->whereId($id)->first(); $departments = $department->whereId($id)->first();
if($request->manager) { if ($request->manager) {
$departments->manager = $request->input('manager'); $departments->manager = $request->input('manager');
} else { } else {
$departments->manager = null; $departments->manager = null;
} }
$departments->save(); $departments->save();
if ($departments->fill($request->except('group_access','manager'))->save()) { if ($departments->fill($request->except('group_access', 'manager'))->save()) {
return redirect('departments')->with('success', 'Department Updated sucessfully'); return redirect('departments')->with('success', 'Department Updated sucessfully');
} else { } else {
return redirect('departments')->with('fails', 'Department not Updated'); return redirect('departments')->with('fails', 'Department not Updated');
} }
} catch (Exception $e) { } catch (Exception $e) {
return redirect('departments')->with('fails', 'Department not Updated'); return redirect('departments')->with('fails', 'Department not Updated');
} }
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* @param type int $id * @param type int $id
* @param type Department $department * @param type Department $department
* @param type Group_assign_department $group_assign_department * @param type Group_assign_department $group_assign_department
* @return type Response * @return type Response
*/ */
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets) { public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets) {
// try { // try {
$system = $system->where('id','=','1')->first(); $system = $system->where('id', '=', '1')->first();
if($system->department == $id) { if ($system->department == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department'); return redirect('departments')->with('fails', 'You cannot delete default department');
} else { } else {
$tickets = DB::table('tickets')->where('dept_id','=',$id)->update(['dept_id' => $system->department]); $tickets = DB::table('tickets')->where('dept_id', '=', $id)->update(['dept_id' => $system->department]);
if($tickets > 0){ if ($tickets > 0) {
if($tickets > 1){ if ($tickets > 1) {
$text_tickets = "Tickets"; $text_tickets = "Tickets";
} else { } else {
$text_tickets = "Ticket"; $text_tickets = "Ticket";
} }
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default department</li>'; $ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default department</li>';
} else { } else {
$ticket = ""; $ticket = "";
} }
$users = DB::table('users')->where('primary_dpt','=',$id)->update(['primary_dpt' => $system->department]); $users = DB::table('users')->where('primary_dpt', '=', $id)->update(['primary_dpt' => $system->department]);
if($users > 0){ if ($users > 0) {
if($users > 1){ if ($users > 1) {
$text_user = "Users"; $text_user = "Users";
} else { } else {
$text_user = "User"; $text_user = "User";
} }
$user = '<li>'.$users.' '.$text_user.' have been moved to default department</li>'; $user = '<li>' . $users . ' ' . $text_user . ' have been moved to default department</li>';
} else { } else {
$user = ""; $user = "";
} }
$emails = DB::table('emails')->where('department','=',$id)->update(['department' => $system->department]); $emails = DB::table('emails')->where('department', '=', $id)->update(['department' => $system->department]);
if($emails > 0){ if ($emails > 0) {
if($emails > 1){ if ($emails > 1) {
$text_emails = "Emails"; $text_emails = "Emails";
} else { } else {
$text_emails = "Email"; $text_emails = "Email";
} }
$email = '<li>'.$emails.' System '.$text_emails.' have been moved to default department</li>'; $email = '<li>' . $emails . ' System ' . $text_emails . ' have been moved to default department</li>';
} else { } else {
$email = ""; $email = "";
} }
$helptopic = DB::table('help_topic')->where('department','=',$id)->update(['department' => null],['status' => '1']); $helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']);
if($helptopic > 0){ if ($helptopic > 0) {
$helptopic = '<li>The associated helptopic has been deactivated</li>'; $helptopic = '<li>The associated helptopic has been deactivated</li>';
} else { } else {
$helptopic = ""; $helptopic = "";
} }
$message = $ticket.$user.$email.$helptopic; $message = $ticket . $user . $email . $helptopic;
/* Becouse of foreign key we delete group_assign_department first */ /* Becouse of foreign key we delete group_assign_department first */
$group_assign_department = $group_assign_department->where('department_id', $id); $group_assign_department = $group_assign_department->where('department_id', $id);
$group_assign_department->delete(); $group_assign_department->delete();
$departments = $department->whereId($id)->first(); $departments = $department->whereId($id)->first();
/* Check the function is Success or Fail */ /* Check the function is Success or Fail */
if ($departments->delete() == true) { if ($departments->delete() == true) {
return redirect('departments')->with('success', 'Department Deleted sucessfully'.$message); return redirect('departments')->with('success', 'Department Deleted sucessfully' . $message);
} else { } else {
return redirect('departments')->with('fails', 'Department can not Delete'); return redirect('departments')->with('fails', 'Department can not Delete');
} }
}
} }
}
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// request // request
@@ -10,6 +13,7 @@ use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Utility\MailboxProtocol; use App\Model\helpdesk\Utility\MailboxProtocol;
use App\Model\helpdesk\Ticket\Ticket_Priority; use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Settings\Email;
// classes // classes
use Crypt; use Crypt;
use Exception; use Exception;
@@ -23,143 +27,187 @@ use Exception;
*/ */
class EmailsController extends Controller { class EmailsController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type * @return type
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* @param type Emails $emails * @param type Emails $emails
* @return type Response * @return type Response
*/ */
public function index(Emails $emails) { public function index(Emails $emails) {
try { try {
$emails = $emails->get(); $emails = $emails->get();
return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails')); return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @param type Department $department * @param type Department $department
* @param type Help_topic $help * @param type Help_topic $help
* @param type Priority $priority * @param type Priority $priority
* @param type MailboxProtocol $mailbox_protocol * @param type MailboxProtocol $mailbox_protocol
* @return type Response * @return type Response
*/ */
public function create(Department $department, Help_topic $help, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) { public function create(Department $department, Help_topic $help, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) {
try { try {
$departments = $department->get(); $departments = $department->get();
$helps = $help->get(); $helps = $help->get();
$priority = $priority->get(); $priority = $priority->get();
$mailbox_protocols = $mailbox_protocol->get(); $mailbox_protocols = $mailbox_protocol->get();
return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps')); return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type Emails $email * @param type Emails $email
* @param type EmailsRequest $request * @param type EmailsRequest $request
* @return type Response * @return type Response
*/ */
public function store(Emails $email, EmailsRequest $request) { public function store(Emails $email, EmailsRequest $request) {
try { try {
$password = $request->input('password'); $password = $request->input('password');
$encrypted = Crypt::encrypt($password); $encrypted = Crypt::encrypt($password);
$email->password = $encrypted; $department = $request->input('department');
if ($email->fill($request->except('password'))->save() == true) { $priority = $request->input('priority');
return redirect('emails')->with('success', 'Email Created sucessfully'); $help_topic = $request->input('help_topic');
} else {
return redirect('emails')->with('fails', 'Email can not Create');
}
} catch (Exception $e) {
return redirect('emails')->with('fails', 'Email can not Create');
}
}
/** if ($email->fill($request->except('password', 'department', 'priority', 'help_topic'))->save() == true) {
* Display the specified resource. if ($request->input('department')) {
* $email->department = $request->input('department');
* @param int $id } else {
* @return Response $email->department = null;
*/ }
public function show($id) { if ($request->input('priority')) {
// $email->priority = $request->input('priority');
} } else {
$email->priority = null;
}
if ($request->input('help_topic')) {
$email->help_topic = $request->input('help_topic');
} else {
$email->help_topic = null;
}
$email->password = $encrypted;
$email->save();
/** return redirect('emails')->with('success', 'Email Created sucessfully');
* Show the form for editing the specified resource. } else {
* @param type int $id return redirect('emails')->with('fails', 'Email can not Create');
* @param type Department $department }
* @param type Help_topic $help } catch (Exception $e) {
* @param type Emails $email return redirect('emails')->with('fails', 'Email can not Create');
* @param type Priority $priority }
* @param type MailboxProtocol $mailbox_protocol }
* @return type Response
*/
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) {
try {
$emails = $email->whereId($id)->first();
$departments = $department->get();
$helps = $help->get();
$priority = $priority->get();
$mailbox_protocols = $mailbox_protocol->get();
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails'));
} catch (Exception $e) {
return view('404');
}
}
/** /**
* Update the specified resource in storage. * Display the specified resource.
* @param type $id *
* @param type Emails $email * @param int $id
* @param type EmailsEditRequest $request * @return Response
* @return type Response */
*/ public function show($id) {
public function update($id, Emails $email, EmailsEditRequest $request) { //
$password = $request->input('password'); }
$encrypted = Crypt::encrypt($password);
//echo $encrypted;
//$value = Crypt::decrypt($encrypted);
//echo $value;
try {
$emails = $email->whereId($id)->first();
$emails->password = $encrypted;
$emails->fill($request->except('password'))->save();
return redirect('emails')->with('success', 'Email Updated sucessfully');
} catch (Exception $e) {
return redirect('emails')->with('fails', 'Email not updated');
}
}
/** /**
* Remove the specified resource from storage. * Show the form for editing the specified resource.
* @param type int $id * @param type int $id
* @param type Emails $email * @param type Department $department
* @return type Response * @param type Help_topic $help
*/ * @param type Emails $email
public function destroy($id, Emails $email) { * @param type Priority $priority
try { * @param type MailboxProtocol $mailbox_protocol
$emails = $email->whereId($id)->first(); * @return type Response
if ($emails->delete() == true) { */
return redirect('emails')->with('success', 'Email Deleted sucessfully'); public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) {
} else { try {
return redirect('emails')->with('fails', 'Email can not Delete '); $emails = $email->whereId($id)->first();
} $departments = $department->get();
} catch (Exception $e) { $helps = $help->get();
return redirect('emails')->with('fails', 'Email can not Delete '); $priority = $priority->get();
} $mailbox_protocols = $mailbox_protocol->get();
} return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Update the specified resource in storage.
* @param type $id
* @param type Emails $email
* @param type EmailsEditRequest $request
* @return type Response
*/
public function update($id, Emails $email, EmailsEditRequest $request) {
$password = $request->input('password');
$encrypted = Crypt::encrypt($password);
//echo $encrypted;
//$value = Crypt::decrypt($encrypted);
//echo $value;
try {
$emails = $email->whereId($id)->first();
// $emails->password = $encrypted;
$emails->fill($request->except('password', 'department', 'priority', 'help_topic'))->save();
if ($request->input('department')) {
$emails->department = $request->input('department');
} else {
$emails->department = null;
}
if ($request->input('priority')) {
$emails->priority = $request->input('priority');
} else {
$emails->priority = null;
}
if ($request->input('help_topic')) {
$emails->help_topic = $request->input('help_topic');
} else {
$emails->help_topic = null;
}
$emails->password = $encrypted;
$emails->save();
return redirect('emails')->with('success', 'Email Updated sucessfully');
} catch (Exception $e) {
return redirect('emails')->with('fails', 'Email not updated');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Emails $email
* @return type Response
*/
public function destroy($id, Emails $email) {
$default_system_email = Email::where('id', '=', '1')->first();
if ($default_system_email->id) {
if ($id == $default_system_email->id) {
return redirect('emails')->with('fails', 'You cannot delete system default Email');
}
}
try {
$emails = $email->whereId($id)->first();
if ($emails->delete() == true) {
return redirect('emails')->with('success', 'Email Deleted sucessfully');
} else {
return redirect('emails')->with('fails', 'Email can not Delete ');
}
} catch (Exception $e) {
return redirect('emails')->with('fails', 'Email can not Delete ');
}
}
} }

View File

@@ -1,16 +1,15 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// Controller // Controller
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// Model // Model
use App\Model\helpdesk\Form\Fields; use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Form\Forms; use App\Model\helpdesk\Form\Forms;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
// Request // Request
use Illuminate\Http\Request; use Illuminate\Http\Request;
// Class // Class
use Input; use Input;
use Redirect; use Redirect;
@@ -25,14 +24,14 @@ use Exception;
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class FormController extends Controller { class FormController extends Controller {
private $fields; private $fields;
private $forms; private $forms;
public function __construct(Fields $fields, Forms $forms) {
public function __construct(Fields $fields,Forms $forms) {
$this->fields = $fields; $this->fields = $fields;
$this->forms = $forms; $this->forms = $forms;
// $this->middleware('auth'); // $this->middleware('auth');
} }
/** /**
@@ -49,7 +48,7 @@ class FormController extends Controller {
* @return Response * @return Response
*/ */
public function index(Forms $forms) { public function index(Forms $forms) {
return view('themes.default1.admin.helpdesk.manage.form.index',compact('forms')); return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms'));
} }
/** /**
@@ -61,12 +60,12 @@ class FormController extends Controller {
} }
/** /**
* Display the specified resource. * Display the specified resource.
* @param int $id * @param int $id
* @return Response * @return Response
*/ */
public function show($id) { public function show($id) {
return view('themes.default1.admin.helpdesk.manage.form.preview',compact('id')); return view('themes.default1.admin.helpdesk.manage.form.preview', compact('id'));
} }
/** /**
@@ -75,56 +74,50 @@ class FormController extends Controller {
* @return Response * @return Response
*/ */
public function store(Forms $forms) { public function store(Forms $forms) {
if(!Input::get('formname')) { if (!Input::get('formname')) {
return Redirect::back()->with('fails','Please fill Form name'); return Redirect::back()->with('fails', 'Please fill Form name');
}
$required = Input::get('required');
$count = count($required);
$require = array();
for ($i = 2; $i < $count + 2; $i++) {
for ($j = 0; $j < 1; $j++) {
array_push($require, $required[$i][$j]);
}
} }
$required = Input::get('required');
$count = count($required);
$require = array();
for($i=2;$i<$count+2;$i++) {
for($j=0;$j<1;$j++) {
array_push($require,$required[$i][$j]);
}
}
$forms->formname = Input::get('formname'); $forms->formname = Input::get('formname');
$forms->save(); $forms->save();
$count = count(Input::get('name')); $count = count(Input::get('name'));
$fields = array(); $fields = array();
for($i=0; $i<=$count; $i++) { for ($i = 0; $i <= $count; $i++) {
if(!empty(Input::get('name')[$i])) { if (!empty(Input::get('name')[$i])) {
array_push($fields, array( array_push($fields, array(
'forms_id' => $forms->id, 'forms_id' => $forms->id,
'label' => Input::get('label')[$i], 'label' => Input::get('label')[$i],
'name' => Input::get('name')[$i], 'name' => Input::get('name')[$i],
'type' => Input::get('type')[$i], 'type' => Input::get('type')[$i],
'value' => Input::get('value')[$i], 'value' => Input::get('value')[$i],
'required'=>$require[$i], 'required' => $require[$i],
)); ));
} }
} }
Fields::insert($fields); Fields::insert($fields);
return Redirect::back()->with('success','Successfully created Form'); return Redirect::back()->with('success', 'Successfully created Form');
} }
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic) {
$fields = $field->where('forms_id', $id)->get();
public function delete($id,Forms $forms, Fields $field, Help_topic $help_topic) { $help_topics = $help_topic->where('custom_form', '=', $id)->get();
$fields = $field->where('forms_id',$id)->get(); foreach ($help_topics as $help_topic) {
$help_topics = $help_topic->where('custom_form','=',$id)->get();
foreach($help_topics as $help_topic) {
$help_topic->custom_form = null; $help_topic->custom_form = null;
$help_topic->save(); $help_topic->save();
} }
foreach($fields as $field) { foreach ($fields as $field) {
$field->delete(); $field->delete();
} }
$forms = $forms->where('id',$id)->first(); $forms = $forms->where('id', $id)->first();
$forms->delete(); $forms->delete();
return redirect()->back()->with('success', 'Deleted Successfully'); return redirect()->back()->with('success', 'Deleted Successfully');
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -12,6 +15,7 @@ use App\User;
// classes // classes
use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Input;
use Exception; use Exception;
/** /**
* GroupController * GroupController
* *
@@ -21,161 +25,162 @@ use Exception;
*/ */
class GroupController extends Controller { class GroupController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type void * @return type void
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* @param type Groups $group * @param type Groups $group
* @param type Department $department * @param type Department $department
* @param type Group_assign_department $group_assign_department * @param type Group_assign_department $group_assign_department
* @return type Response * @return type Response
*/ */
public function index(Groups $group, Department $department, Group_assign_department $group_assign_department) { public function index(Groups $group, Department $department, Group_assign_department $group_assign_department) {
try { try {
$groups = $group->get(); $groups = $group->get();
$departments = $department->lists('id'); $departments = $department->lists('id');
return view('themes.default1.admin.helpdesk.agent.groups.index', compact('departments', 'group_assign_department', 'groups')); return view('themes.default1.admin.helpdesk.agent.groups.index', compact('departments', 'group_assign_department', 'groups'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @return type Response * @return type Response
*/ */
public function create() { public function create() {
try { try {
return view('themes.default1.admin.helpdesk.agent.groups.create'); return view('themes.default1.admin.helpdesk.agent.groups.create');
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type Groups $group * @param type Groups $group
* @param type GroupRequest $request * @param type GroupRequest $request
* @return type Response * @return type Response
*/ */
public function store(Groups $group, GroupRequest $request) { public function store(Groups $group, GroupRequest $request) {
try { try {
/* Check Whether function success or not */ /* Check Whether function success or not */
$group->fill($request->input())->save(); $group->fill($request->input())->save();
return redirect('groups')->with('success', 'Group Created Successfully'); return redirect('groups')->with('success', 'Group Created Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('groups')->with('fails', 'Groups can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* @param type int $id * @param type int $id
* @param type Groups $group * @param type Groups $group
* @return type Response * @return type Response
*/ */
public function edit($id, Groups $group) { public function edit($id, Groups $group) {
try { try {
$groups = $group->whereId($id)->first(); $groups = $group->whereId($id)->first();
return view('themes.default1.admin.helpdesk.agent.groups.edit', compact('groups')); return view('themes.default1.admin.helpdesk.agent.groups.edit', compact('groups'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('groups')->with('fails', 'Groups can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type int $id * @param type int $id
* @param type Groups $group * @param type Groups $group
* @param type Request $request * @param type Request $request
* @return type Response * @return type Response
*/ */
public function update($id, Groups $group, Request $request) { public function update($id, Groups $group, Request $request) {
$var = $group->whereId($id)->first(); $var = $group->whereId($id)->first();
//Updating Status //Updating Status
$status = $request->Input('group_status'); $status = $request->Input('group_status');
$var->group_status = $status; $var->group_status = $status;
//Updating can_create_ticket field //Updating can_create_ticket field
$createTicket = $request->Input('can_create_ticket'); $createTicket = $request->Input('can_create_ticket');
$var->can_create_ticket = $createTicket; $var->can_create_ticket = $createTicket;
//Updating can_edit_ticket field //Updating can_edit_ticket field
$editTicket = $request->Input('can_edit_ticket'); $editTicket = $request->Input('can_edit_ticket');
$var->can_edit_ticket = $editTicket; $var->can_edit_ticket = $editTicket;
//Updating can_post_ticket field //Updating can_post_ticket field
$postTicket = $request->Input('can_post_ticket'); $postTicket = $request->Input('can_post_ticket');
$var->can_post_ticket = $postTicket; $var->can_post_ticket = $postTicket;
//Updating can_close_ticket field //Updating can_close_ticket field
$closeTicket = $request->Input('can_close_ticket'); $closeTicket = $request->Input('can_close_ticket');
$var->can_close_ticket = $closeTicket; $var->can_close_ticket = $closeTicket;
//Updating can_assign_ticket field //Updating can_assign_ticket field
$assignTicket = $request->Input('can_assign_ticket'); $assignTicket = $request->Input('can_assign_ticket');
$var->can_assign_ticket = $assignTicket; $var->can_assign_ticket = $assignTicket;
//Updating can_trasfer_ticket field //Updating can_trasfer_ticket field
$trasferTicket = $request->Input('can_trasfer_ticket'); $trasferTicket = $request->Input('can_trasfer_ticket');
$var->can_trasfer_ticket = $trasferTicket; $var->can_trasfer_ticket = $trasferTicket;
//Updating can_delete_ticket field //Updating can_delete_ticket field
$deleteTicket = $request->Input('can_delete_ticket'); $deleteTicket = $request->Input('can_delete_ticket');
$var->can_delete_ticket = $deleteTicket; $var->can_delete_ticket = $deleteTicket;
//Updating can_ban_email field //Updating can_ban_email field
$banEmail = $request->Input('can_ban_email'); $banEmail = $request->Input('can_ban_email');
$var->can_ban_email = $banEmail; $var->can_ban_email = $banEmail;
//Updating can_manage_canned field //Updating can_manage_canned field
$manageCanned = $request->Input('can_manage_canned'); $manageCanned = $request->Input('can_manage_canned');
$var->can_manage_canned = $manageCanned; $var->can_manage_canned = $manageCanned;
//Updating can_manage_faq field //Updating can_manage_faq field
$manageFaq = $request->Input('can_manage_faq'); $manageFaq = $request->Input('can_manage_faq');
$var->can_manage_faq = $manageFaq; $var->can_manage_faq = $manageFaq;
//Updating can_view_agent_stats field //Updating can_view_agent_stats field
$viewAgentStats = $request->Input('can_view_agent_stats'); $viewAgentStats = $request->Input('can_view_agent_stats');
$var->can_view_agent_stats = $viewAgentStats; $var->can_view_agent_stats = $viewAgentStats;
//Updating department_access field //Updating department_access field
$departmentAccess = $request->Input('department_access'); $departmentAccess = $request->Input('department_access');
$var->department_access = $departmentAccess; $var->department_access = $departmentAccess;
//Updating admin_notes field //Updating admin_notes field
$adminNotes = $request->Input('admin_notes'); $adminNotes = $request->Input('admin_notes');
$var->admin_notes = $adminNotes; $var->admin_notes = $adminNotes;
/* Check whether function success or not */ /* Check whether function success or not */
try { try {
$var->save(); $var->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('groups')->with('success', 'Group Updated Successfully'); return redirect('groups')->with('success', 'Group Updated Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('groups')->with('fails', 'Groups can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Groups $group
* @param type Group_assign_department $group_assign_department
* @return type Response
*/
public function destroy($id, Groups $group, Group_assign_department $group_assign_department) {
$users = User::where('assign_group', '=', $id)->first();
if ($users) {
$user = '<li>There are agents assigned to this group. Please unassign them from this group to delete</li>';
return redirect('groups')->with('fails', 'Group cannot Delete ' . $user);
}
$group_assign_department->where('group_id', $id)->delete();
$groups = $group->whereId($id)->first();
/* Check whether function success or not */
try {
$groups->delete();
/* redirect to Index page with Success Message */
return redirect('groups')->with('success', 'Group Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('groups')->with('fails', 'Groups cannot Create' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Groups $group
* @param type Group_assign_department $group_assign_department
* @return type Response
*/
public function destroy($id, Groups $group, Group_assign_department $group_assign_department) {
$users = User::where('assign_group', '=', $id)->first();
if($users){
$user = '<li>There are agents assigned to this group. Please unassign them from this group to delete</li>';
return redirect('groups')->with('fails', 'Group cannot Delete ' . $user);
}
$group_assign_department->where('group_id', $id)->delete();
$groups = $group->whereId($id)->first();
/* Check whether function success or not */
try {
$groups->delete();
/* redirect to Index page with Success Message */
return redirect('groups')->with('success', 'Group Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('groups')->with('fails', 'Groups cannot Create'.'<li>'.$e->errorInfo[2].'</li>');
}
}
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -26,201 +29,202 @@ use Exception;
*/ */
class HelptopicController extends Controller { class HelptopicController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type vodi * @return type vodi
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* @param type Help_topic $topic * @param type Help_topic $topic
* @return type Response * @return type Response
*/ */
public function index(Help_topic $topic) { public function index(Help_topic $topic) {
try { try {
$topics = $topic->get(); $topics = $topic->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.index', compact('topics')); return view('themes.default1.admin.helpdesk.manage.helptopic.index', compact('topics'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @param type Priority $priority * @param type Priority $priority
* @param type Department $department * @param type Department $department
* @param type Help_topic $topic * @param type Help_topic $topic
* @param type Form_name $form * @param type Form_name $form
* @param type Agents $agent * @param type Agents $agent
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @return type Response * @return type Response
*/ */
/* /*
================================================ ================================================
| Route to Create view file passing Model Values | Route to Create view file passing Model Values
| 1.Department Model | 1.Department Model
| 2.Help_topic Model | 2.Help_topic Model
| 3.Agents Model | 3.Agents Model
| 4.Sla_plan Model | 4.Sla_plan Model
| 5.Forms Model | 5.Forms Model
================================================ ================================================
*/ */
public function create(Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, User $agent, Sla_plan $sla) { public function create(Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, User $agent, Sla_plan $sla) {
try { try {
$departments = $department->get(); $departments = $department->get();
$topics = $topic->get(); $topics = $topic->get();
$forms = $form->get(); $forms = $form->get();
$agents = $agent->where('role','=','agent')->get(); $agents = $agent->where('role', '=', 'agent')->get();
$slas = $sla->get(); $slas = $sla->get();
$priority = $priority->get(); $priority = $priority->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas')); return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type Help_topic $topic * @param type Help_topic $topic
* @param type HelptopicRequest $request * @param type HelptopicRequest $request
* @return type Response * @return type Response
*/ */
public function store(Help_topic $topic, HelptopicRequest $request) { public function store(Help_topic $topic, HelptopicRequest $request) {
try { try {
if($request->custom_form){ if ($request->custom_form) {
$custom_form = $request->custom_form; $custom_form = $request->custom_form;
} else { } else {
$custom_form = null; $custom_form = null;
} }
if($request->auto_assign){ if ($request->auto_assign) {
$auto_assign = $request->auto_assign; $auto_assign = $request->auto_assign;
} else { } else {
$auto_assign = null; $auto_assign = null;
} }
/* Check whether function success or not */ /* Check whether function success or not */
$topic->fill($request->except('custom_form','auto_assign'))->save(); $topic->fill($request->except('custom_form', 'auto_assign'))->save();
// $topics->fill($request->except('custom_form','auto_assign'))->save(); // $topics->fill($request->except('custom_form','auto_assign'))->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Created Successfully'); return redirect('helptopic')->with('success', 'Helptopic Created Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('helptopic')->with('fails', 'Helptopic can not Create'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('helptopic')->with('fails', 'Helptopic can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* @param type $id * @param type $id
* @param type Priority $priority * @param type Priority $priority
* @param type Department $department * @param type Department $department
* @param type Help_topic $topic * @param type Help_topic $topic
* @param type Form_name $form * @param type Form_name $form
* @param type Agents $agent * @param type Agents $agent
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @return type Response * @return type Response
*/ */
public function edit($id, Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, Sla_plan $sla) { public function edit($id, Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, Sla_plan $sla) {
try { try {
$agents = User::where('role','=','agent')->get(); $agents = User::where('role', '=', 'agent')->get();
$departments = $department->get(); $departments = $department->get();
$topics = $topic->whereId($id)->first(); $topics = $topic->whereId($id)->first();
$forms = $form->get(); $forms = $form->get();
$slas = $sla->get(); $slas = $sla->get();
$priority = $priority->get(); $priority = $priority->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas')); return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect('helptopic')->with('fails', '<li>'.$e->errorInfo[2].'</li>'); return redirect('helptopic')->with('fails', '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type $id * @param type $id
* @param type Help_topic $topic * @param type Help_topic $topic
* @param type HelptopicUpdate $request * @param type HelptopicUpdate $request
* @return type Response * @return type Response
*/ */
public function update($id, Help_topic $topic, HelptopicUpdate $request) { public function update($id, Help_topic $topic, HelptopicUpdate $request) {
// dd($request); // dd($request);
try { try {
$topics = $topic->whereId($id)->first(); $topics = $topic->whereId($id)->first();
if($request->custom_form){ if ($request->custom_form) {
$custom_form = $request->custom_form; $custom_form = $request->custom_form;
} else { } else {
$custom_form = null; $custom_form = null;
} }
if($request->auto_assign){ if ($request->auto_assign) {
$auto_assign = $request->auto_assign; $auto_assign = $request->auto_assign;
} else { } else {
$auto_assign = null; $auto_assign = null;
} }
/* Check whether function success or not */ /* Check whether function success or not */
$topics->fill($request->except('custom_form','auto_assign'))->save(); $topics->fill($request->except('custom_form', 'auto_assign'))->save();
$topics->custom_form = $custom_form; $topics->custom_form = $custom_form;
$topics->auto_assign = $auto_assign; $topics->auto_assign = $auto_assign;
$topics->save(); $topics->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Updated Successfully'); return redirect('helptopic')->with('success', 'Helptopic Updated Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('helptopic')->with('fails', 'Helptopic can not Update'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('helptopic')->with('fails', 'Helptopic can not Update' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* @param type int $id * @param type int $id
* @param type Help_topic $topic * @param type Help_topic $topic
* @return type Response * @return type Response
*/ */
public function destroy($id, Help_topic $topic, Ticket $ticket_setting) { public function destroy($id, Help_topic $topic, Ticket $ticket_setting) {
$ticket_settings = $ticket_setting->where('id','=','1')->first(); $ticket_settings = $ticket_setting->where('id', '=', '1')->first();
if($ticket_settings->help_topic == $id) { if ($ticket_settings->help_topic == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department'); return redirect('departments')->with('fails', 'You cannot delete default department');
} else { } else {
$tickets = DB::table('tickets')->where('help_topic_id','=',$id)->update(['help_topic_id' => $ticket_settings->help_topic]); $tickets = DB::table('tickets')->where('help_topic_id', '=', $id)->update(['help_topic_id' => $ticket_settings->help_topic]);
if($tickets > 0){ if ($tickets > 0) {
if($tickets > 1){ if ($tickets > 1) {
$text_tickets = "Tickets"; $text_tickets = "Tickets";
} else { } else {
$text_tickets = "Ticket"; $text_tickets = "Ticket";
} }
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default Help Topic</li>'; $ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default Help Topic</li>';
} else { } else {
$ticket = ""; $ticket = "";
} }
$emails = DB::table('emails')->where('help_topic','=',$id)->update(['help_topic' => $ticket_settings->help_topic]); $emails = DB::table('emails')->where('help_topic', '=', $id)->update(['help_topic' => $ticket_settings->help_topic]);
if($emails > 0){ if ($emails > 0) {
if($emails > 1){ if ($emails > 1) {
$text_emails = "Emails"; $text_emails = "Emails";
} else { } else {
$text_emails = "Email"; $text_emails = "Email";
} }
$email = '<li>'.$emails.' System '.$text_emails.' have been moved to default Help Topic</li>'; $email = '<li>' . $emails . ' System ' . $text_emails . ' have been moved to default Help Topic</li>';
} else { } else {
$email = ""; $email = "";
} }
$message = $ticket.$email; $message = $ticket . $email;
$topics = $topic->whereId($id)->first();
/* Check whether function success or not */
try {
$topics->delete();
/* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Deleted Successfully' . $message);
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('helptopic')->with('fails', 'Helptopic can not Delete' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
}
$topics = $topic->whereId($id)->first();
/* Check whether function success or not */
try{
$topics->delete();
/* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Deleted Successfully'.$message);
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('helptopic')->with('fails', 'Helptopic can not Delete'.'<li>'.$e->errorInfo[2].'</li>');
}
}
}
} }

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
/** /**
* ----------------------------------------------- * -----------------------------------------------
@@ -14,21 +16,21 @@
*/ */
class HomeController extends Controller { class HomeController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
} }
/** /**
* Show the application dashboard to the user. * Show the application dashboard to the user.
* *
* @return Response * @return Response
*/ */
public function index() { public function index() {
return view('themes/default1/admin/dashboard'); return view('themes/default1/admin/dashboard');
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -43,109 +46,99 @@ class LanguageController extends Controller {
* @return type response * @return type response
*/ */
public function switchLanguage($lang) { public function switchLanguage($lang) {
//if(Cache::has('language')) //if(Cache::has('language'))
//{ //{
// return Cache::get('language'); // return Cache::get('language');
//} else return 'false'; //} else return 'false';
// Cache::put('language',$) // Cache::put('language',$)
$path = '../resources/lang';// Path to check available language packages $path = '../resources/lang'; // Path to check available language packages
if(array_key_exists($lang, Config::get('languages')) && in_array($lang, scandir($path))) { if (array_key_exists($lang, Config::get('languages')) && in_array($lang, scandir($path))) {
// dd(array_key_exists($lang, Config::get('languages'))); // dd(array_key_exists($lang, Config::get('languages')));
// app()->setLocale($lang); // app()->setLocale($lang);
Cache::forever('language', $lang); Cache::forever('language', $lang);
// dd(Cache::get('language')); // dd(Cache::get('language'));
// dd() // dd()
} else { } else {
return Redirect::back()->with('fails', Lang::get("lang.language-error")); return Redirect::back()->with('fails', Lang::get("lang.language-error"));
}
return Redirect::back();
} }
return Redirect::back();
}
/** /**
*Shows language page * Shows language page
*@return type response * @return type response
*/ */
public function index(){ public function index() {
return view('themes.default1.admin.helpdesk.language.index'); return view('themes.default1.admin.helpdesk.language.index');
} }
/** /**
*Shows Language upload form * Shows Language upload form
*@return type response * @return type response
*/ */
public function getForm(){ public function getForm() {
return view('themes.default1.admin.helpdesk.language.create'); return view('themes.default1.admin.helpdesk.language.create');
} }
/** /**
*Provide language datatable to language page * Provide language datatable to language page
*@return type * @return type
*/ */
public function getLanguages() public function getLanguages() {
{
$path = '../resources/lang'; $path = '../resources/lang';
$values = scandir($path); //Extracts names of directories present in lang directory $values = scandir($path); //Extracts names of directories present in lang directory
$values = array_slice($values, 2); // skips array element $value[0] = '.' & $value[1] = '..' $values = array_slice($values, 2); // skips array element $value[0] = '.' & $value[1] = '..'
return \Datatable::collection(new Collection($values)) return \Datatable::collection(new Collection($values))
->addColumn('language', function($model) {
->addColumn('language', function($model){ return Config::get('languages.' . $model);
return Config::get('languages.'.$model); })
}) ->addColumn('id', function($model) {
return $model;
->addColumn('id', function($model){ })
return $model; ->addColumn('status', function($model) {
}) if (Lang::getLocale() === $model) {
return "<span style='color:green'>" . Lang::trans("lang.active") . "</span>";
->addColumn('status',function($model){ } else
if(Lang::getLocale()===$model){return "<span style='color:green'>".Lang::trans("lang.active")."</span>"; } else return "<span style='color:red'>".Lang::trans("lang.inactive")."</span>"; return "<span style='color:red'>" . Lang::trans("lang.inactive") . "</span>";
}) })
->addColumn('Action', function($model) {
->addColumn('Action', function($model){ if (Lang::getLocale() === $model) {
if(Lang::getLocale()===$model){ return "<a href='change-language/" . $model . "'><input type='button' class='btn btn-info btn-xs btn-flat' disabled value='" . Lang::trans("lang.disable") . "'/></a>
return "<a href='change-language/".$model."'><input type='button' class='btn btn-info btn-xs btn-flat' disabled value='". Lang::trans("lang.disable")."'/></a> <a href='change-language/" . $model . "' class='btn btn-danger btn-xs btn-flat' disabled><i class='fa fa-trash' style='color:black;'> </i> " . Lang::trans("lang.delete") . "</a>";
<a href='change-language/".$model."' class='btn btn-danger btn-xs btn-flat' disabled><i class='fa fa-trash' style='color:black;'> </i> ". Lang::trans("lang.delete")."</a>"; } else {
} else { return "<a href='change-language/" . $model . "'><input type='button' class='btn btn-info btn-xs btn-flat' value='" . Lang::trans("lang.enable") . "'/></a>
return "<a href='change-language/".$model."'><input type='button' class='btn btn-info btn-xs btn-flat' value='". Lang::trans("lang.enable")."'/></a> <a href='delete-language/" . $model . "' class='btn btn-danger btn-xs btn-flat'><i class='fa fa-trash' style='color:black;'> </i> " . Lang::trans("lang.delete") . "</a>";
<a href='delete-language/".$model."' class='btn btn-danger btn-xs btn-flat'><i class='fa fa-trash' style='color:black;'> </i> ". Lang::trans("lang.delete")."</a>"; }
} })
}) ->searchColumns('language', 'id')
->searchColumns('language','id') ->make();
->make();
} }
/** /**
*handle language file uploading * handle language file uploading
*@return response * @return response
*/ */
public function postForm() { public function postForm() {
// getting all of the post data // getting all of the post data
$file = array( $file = array(
'File' => Input::file('File'), 'File' => Input::file('File'),
'language-name' => Input::input('language-name'), 'language-name' => Input::input('language-name'),
'iso-code' => Input::input('iso-code') 'iso-code' => Input::input('iso-code')
); );
// setting up rules // setting up rules
$rules = array( $rules = array(
'File' => 'required|mimes:zip|max:30000', 'File' => 'required|mimes:zip|max:30000',
'language-name' => 'required', 'language-name' => 'required',
'iso-code' => 'required|max:2' 'iso-code' => 'required|max:2'
); // and for max size ); // and for max size
// doing the validation, passing post data, rules and the messages // doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules); $validator = Validator::make($file, $rules);
if ($validator->fails()) { if ($validator->fails()) {
// send back to the page with the input data and errors // send back to the page with the input data and errors
return Redirect::back()->withInput()->withErrors($validator); return Redirect::back()->withInput()->withErrors($validator);
} else { } else {
@@ -155,44 +148,40 @@ class LanguageController extends Controller {
//sending back with error message //sending back with error message
Session::flash('fails', Lang::get('lang.package_exist')); Session::flash('fails', Lang::get('lang.package_exist'));
Session::flash('link',"change-language/".strtolower(Input::get('iso-code'))); Session::flash('link', "change-language/" . strtolower(Input::get('iso-code')));
return Redirect::back()->withInput(); return Redirect::back()->withInput();
} elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))) {//Checking Valid ISO code form Languages.php
} elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))){//Checking Valid ISO code form Languages.php
//sending back with error message //sending back with error message
Session::flash('fails', Lang::get('lang.iso-code-error')); Session::flash('fails', Lang::get('lang.iso-code-error'));
return Redirect::back()->withInput(); return Redirect::back()->withInput();
} else { } else {
// checking file is valid. // checking file is valid.
if (Input::file('File')->isValid()) { if (Input::file('File')->isValid()) {
$name = Input::file('File')->getClientOriginalName(); //uploaded file's original name $name = Input::file('File')->getClientOriginalName(); //uploaded file's original name
$destinationPath = '../public/uploads/'; // defining uploading path $destinationPath = '../public/uploads/'; // defining uploading path
$extractpath = '../resources/lang/'.strtolower(Input::get('iso-code'));//defining extracting path $extractpath = '../resources/lang/' . strtolower(Input::get('iso-code')); //defining extracting path
mkdir($extractpath); //creating directroy for extracting uploadd file mkdir($extractpath); //creating directroy for extracting uploadd file
//mkdir($destinationPath); //mkdir($destinationPath);
Input::file('File')->move($destinationPath, $name); // uploading file to given path Input::file('File')->move($destinationPath, $name); // uploading file to given path
\Zipper::make($destinationPath.'/'.$name)->extractTo($extractpath);//extracting file to give path \Zipper::make($destinationPath . '/' . $name)->extractTo($extractpath); //extracting file to give path
//check if Zip extract foldercontains any subfolder //check if Zip extract foldercontains any subfolder
$directories = File::directories($extractpath); $directories = File::directories($extractpath);
//$directories = glob($extractpath. '/*' , GLOB_ONLYDIR); //$directories = glob($extractpath. '/*' , GLOB_ONLYDIR);
if(!empty($directories)){ //if extract folder contains subfolder if (!empty($directories)) { //if extract folder contains subfolder
$success = File::deleteDirectory($extractpath); //remove extracted folder and it's subfolder from lang $success = File::deleteDirectory($extractpath); //remove extracted folder and it's subfolder from lang
//$success2 = File::delete($destinationPath.'/'.$name); //$success2 = File::delete($destinationPath.'/'.$name);
if($success){ if ($success) {
//sending back with error message //sending back with error message
Session::flash('fails', Lang::get('lang.zipp-error')); Session::flash('fails', Lang::get('lang.zipp-error'));
Session::flash('link2',"http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages"); Session::flash('link2', "http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages");
return Redirect::back()->withInput(); return Redirect::back()->withInput();
} }
} else { } else {
// sending back with success message // sending back with success message
Session::flash('success', Lang::get("lang.upload-success")); Session::flash('success', Lang::get("lang.upload-success"));
Session::flash('link',"change-language/".strtolower(Input::get('iso-code'))); Session::flash('link', "change-language/" . strtolower(Input::get('iso-code')));
return Redirect::route('LanguageController'); return Redirect::route('LanguageController');
} }
} else { } else {
// sending back with error message. // sending back with error message.
@@ -204,8 +193,8 @@ class LanguageController extends Controller {
} }
/** /**
*allow user to download language template file * allow user to download language template file
*@return type * @return type
*/ */
Public function download() { Public function download() {
return response()->download('../public/downloads/en.zip'); return response()->download('../public/downloads/en.zip');
@@ -216,11 +205,11 @@ class LanguageController extends Controller {
* @param type $lang * @param type $lang
* @return type response * @return type response
*/ */
public function deleteLanguage($lang){ public function deleteLanguage($lang) {
if($lang !== App::getLocale()){ if ($lang !== App::getLocale()) {
$deletePath = '../resources/lang/'.$lang; //define file path to delete $deletePath = '../resources/lang/' . $lang; //define file path to delete
$success = File::deleteDirectory($deletePath); //remove extracted folder and it's subfolder from lang $success = File::deleteDirectory($deletePath); //remove extracted folder and it's subfolder from lang
if($success) { if ($success) {
//sending back with success message //sending back with success message
Session::flash('success', Lang::get('lang.delete-success')); Session::flash('success', Lang::get('lang.delete-success'));
return Redirect::back(); return Redirect::back();
@@ -235,4 +224,5 @@ class LanguageController extends Controller {
return redirect('languages'); return redirect('languages');
} }
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -21,103 +24,104 @@ use Exception;
*/ */
class ProfileController extends Controller { class ProfileController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type void * @return type void
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* Get profile page * Get profile page
* @return type Response * @return type Response
*/ */
public function getProfile() { public function getProfile() {
try { try {
$user = Auth::user(); $user = Auth::user();
if ($user) { if ($user) {
return view('themes.default1.agent.helpdesk.user.profile', compact('user')); return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} else { } else {
return redirect('404'); return redirect('404');
} }
} catch (Exception $e) { } catch (Exception $e) {
return redirect('404'); return redirect('404');
} }
} }
/** /**
* Get profile Edit page * Get profile Edit page
* @return type Response * @return type Response
*/ */
public function getProfileedit() { public function getProfileedit() {
try { try {
$user = Auth::user(); $user = Auth::user();
if ($user) { if ($user) {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user')); return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} else { } else {
return redirect('404'); return redirect('404');
} }
} catch (Exception $e) { } catch (Exception $e) {
return redirect('404'); return redirect('404');
} }
} }
/** /**
* Post profile page * Post profile page
* @param type int $id * @param type int $id
* @param type ProfileRequest $request * @param type ProfileRequest $request
* @return type Response * @return type Response
*/ */
public function postProfile($id, ProfileRequest $request) { public function postProfile($id, ProfileRequest $request) {
$user = Auth::user(); $user = Auth::user();
$user->gender = $request->input('gender'); $user->gender = $request->input('gender');
$user->save(); $user->save();
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') { if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
if ($request->input('gender') == 1) { if ($request->input('gender') == 1) {
$name = 'avatar5.png'; $name = 'avatar5.png';
$destinationPath = 'lb-faveo/profilepic'; $destinationPath = 'lb-faveo/profilepic';
$user->profile_pic = $name; $user->profile_pic = $name;
} elseif ($request->input('gender') == 0) { } elseif ($request->input('gender') == 0) {
$name = 'avatar2.png'; $name = 'avatar2.png';
$destinationPath = 'lb-faveo/profilepic'; $destinationPath = 'lb-faveo/profilepic';
$user->profile_pic = $name; $user->profile_pic = $name;
} }
} }
if (Input::file('profile_pic')) { if (Input::file('profile_pic')) {
//$extension = Input::file('profile_pic')->getClientOriginalExtension(); //$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName(); $name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/profilepic'; $destinationPath = 'lb-faveo/profilepic';
$fileName = rand(0000, 9999) . '.' . $name; $fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName; //echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName); Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName; $user->profile_pic = $fileName;
} else { } else {
$user->fill($request->except('profile_pic', 'gender'))->save(); $user->fill($request->except('profile_pic', 'gender'))->save();
return redirect('guest')->with('success', 'Profile Updated sucessfully'); return redirect('guest')->with('success', 'Profile Updated sucessfully');
} }
if ($user->fill($request->except('profile_pic'))->save()) { if ($user->fill($request->except('profile_pic'))->save()) {
return redirect('guest')->with('success', 'Profile Updated sucessfully'); return redirect('guest')->with('success', 'Profile Updated sucessfully');
} }
} }
/**
* Post Profile password page
* @param type int $id
* @param type User $user
* @param type ProfilePassword $request
* @return type Response
*/
public function postProfilePassword($id, User $user, ProfilePassword $request) {
$user = Auth::user();
//echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password'));
$user->save();
return redirect('guest')->with('success', 'Password Updated sucessfully');
} else {
return redirect('guest')->with('fails', 'Password was not Updated');
}
}
/**
* Post Profile password page
* @param type int $id
* @param type User $user
* @param type ProfilePassword $request
* @return type Response
*/
public function postProfilePassword($id, User $user, ProfilePassword $request) {
$user = Auth::user();
//echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password'));
$user->save();
return redirect('guest')->with('success', 'Password Updated sucessfully');
} else {
return redirect('guest')->with('fails', 'Password was not Updated');
}
}
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -27,7 +30,6 @@ use App\Model\helpdesk\Utility\Time_format;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Input; use Input;
use Exception; use Exception;
use DB;
/** /**
* SettingsController * SettingsController
@@ -38,415 +40,428 @@ use DB;
*/ */
class SettingsController extends Controller { class SettingsController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// $this->smtp(); // $this->smtp();
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* Main Settings Page * Main Settings Page
* @return type view * @return type view
*/ */
public function settings() { public function settings() {
return view('themes.default1.admin.helpdesk.setting'); return view('themes.default1.admin.helpdesk.setting');
} }
public function RatingSettings() {
$ratings = DB::table('settings_ratings')->get();
return view('themes.default1.admin.helpdesk.settings.ratings',compact('ratings')); /**
} * @param int $id
public function PostRatingSettings($slug) { * @return Response
$name = Input::get('rating_name'); * @param $compant instance of company table
$publish = Input::get('publish'); *
$modify = Input::get('modify'); * get the form for company setting page
*/
public function getcompany(Company $company) {
try {
/* fetch the values of company from company table */
$companys = $company->whereId('1')->first();
/* Direct to Company Settings Page */
return view('themes.default1.admin.helpdesk.settings.company', compact('companys'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
DB::table('settings_ratings')->whereSlug($slug)->update(array('rating_name' => $name,'publish' => $publish, 'modify' => $modify)); /**
* Update the specified resource in storage.
* @param type int $id
* @param type Company $company
* @param type CompanyRequest $request
* @return Response
*/
public function postcompany($id, Company $company, CompanyRequest $request) {
/* fetch the values of company request */
$companys = $company->whereId('1')->first();
if (Input::file('logo')) {
$name = Input::file('logo')->getClientOriginalName();
$destinationPath = 'lb-faveo/media/company/';
$fileName = rand(0000, 9999) . '.' . $name;
Input::file('logo')->move($destinationPath, $fileName);
$companys->logo = $fileName;
}
if ($request->input('use_logo') == null) {
$companys->use_logo = '0';
}
/* Check whether function success or not */
try {
$companys->fill($request->except('logo'))->save();
/* redirect to Index page with Success Message */
return redirect('getcompany')->with('success', 'Company Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getcompany')->with('fails', 'Company can not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
return redirect()->back()->with('success', 'Successfully updated'); /**
} * get the form for System setting page
public function RatingDelete($slug) { * @param type System $system
DB::table('settings_ratings')->whereSlug($slug)->delete(); * @param type Department $department
* @param type Timezones $timezone
* @param type Date_format $date
* @param type Date_time_format $date_time
* @param type Time_format $time
* @return type Response
*/
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time) {
try {
/* fetch the values of system from system table */
$systems = $system->whereId('1')->first();
/* Fetch the values from Department table */
$departments = $department->get();
/* Fetch the values from Timezones table */
$timezones = $timezone->get();
/* Direct to System Settings Page */
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
return redirect()->back()->with('success', 'Successfully Deleted'); /**
} * Update the specified resource in storage.
/** * @param type int $id
* @param int $id * @param type System $system
* @return Response * @param type SystemRequest $request
* @param $compant instance of company table * @return type Response
* */
* get the form for company setting page public function postsystem($id, System $system, SystemRequest $request) {
*/ try {
public function getcompany(Company $company) { // dd($request);
try { /* fetch the values of system request */
/* fetch the values of company from company table */ $systems = $system->whereId('1')->first();
$companys = $company->whereId('1')->first(); /* fill the values to coompany table */
/* Direct to Company Settings Page */ /* Check whether function success or not */
return view('themes.default1.admin.helpdesk.settings.company', compact('companys')); $systems->fill($request->input())->save();
} catch (Exception $e) { /* redirect to Index page with Success Message */
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect('getsystem')->with('success', 'System Updated Successfully');
} } catch (Exception $e) {
} /* redirect to Index page with Fails Message */
return redirect('getsystem')->with('fails', 'System can not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/** /**
* Update the specified resource in storage. * get the form for Ticket setting page
* @param type int $id * @param type Ticket $ticket
* @param type Company $company * @param type Sla_plan $sla
* @param type CompanyRequest $request * @param type Help_topic $topic
* @return Response * @param type Priority $priority
*/ * @return type Response
public function postcompany($id, Company $company, CompanyRequest $request) { */
/* fetch the values of company request */ public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) {
$companys = $company->whereId('1')->first(); try {
if (Input::file('logo')) { /* fetch the values of ticket from ticket table */
$name = Input::file('logo')->getClientOriginalName(); $tickets = $ticket->whereId('1')->first();
$destinationPath = 'lb-faveo/media/company/'; /* Fetch the values from SLA Plan table */
$fileName = rand(0000, 9999) . '.' . $name; $slas = $sla->get();
Input::file('logo')->move($destinationPath, $fileName); /* Fetch the values from Help_topic table */
$companys->logo = $fileName; $topics = $topic->get();
} /* Direct to Ticket Settings Page */
if($request->input('use_logo')==null) { return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority'));
$companys->use_logo = '0'; } catch (Exception $e) {
} return redirect()->back()->with('fails', $e->errorInfo[2]);
/* Check whether function success or not */ }
try { }
$companys->fill($request->except('logo'))->save();
/* redirect to Index page with Success Message */
return redirect('getcompany')->with('success', 'Company Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getcompany')->with('fails', 'Company can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/** /**
* get the form for System setting page * Update the specified resource in storage.
* @param type System $system * @param type int $id
* @param type Department $department * @param type Ticket $ticket
* @param type Timezones $timezone * @param type Request $request
* @param type Date_format $date * @return type Response
* @param type Date_time_format $date_time */
* @param type Time_format $time public function postticket($id, Ticket $ticket, Request $request) {
* @return type Response try {
*/ /* fetch the values of ticket request */
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time) { $tickets = $ticket->whereId('1')->first();
try { /* fill the values to coompany table */
/* fetch the values of system from system table */ $tickets->fill($request->except('captcha', 'claim_response', 'assigned_ticket', 'answered_ticket', 'agent_mask', 'html', 'client_update'))->save();
$systems = $system->whereId('1')->first(); /* insert checkbox to Database */
/* Fetch the values from Department table */ $tickets->captcha = $request->input('captcha');
$departments = $department->get(); $tickets->claim_response = $request->input('claim_response');
/* Fetch the values from Timezones table */ $tickets->assigned_ticket = $request->input('assigned_ticket');
$timezones = $timezone->get(); $tickets->answered_ticket = $request->input('answered_ticket');
/* Direct to System Settings Page */ $tickets->agent_mask = $request->input('agent_mask');
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time')); $tickets->html = $request->input('html');
} catch (Exception $e) { $tickets->client_update = $request->input('client_update');
return redirect()->back()->with('fails',$e->errorInfo[2]); $tickets->collision_avoid = $request->input('collision_avoid');
} /* Check whether function success or not */
} $tickets->save();
/* redirect to Index page with Success Message */
return redirect('getticket')->with('success', 'Ticket Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getticket')->with('fails', 'Ticket can not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/** /**
* Update the specified resource in storage. * get the form for Email setting page
* @param type int $id * @param type Email $email
* @param type System $system * @param type Template $template
* @param type SystemRequest $request * @param type Emails $email1
* @return type Response * @return type Response
*/ */
public function postsystem($id, System $system, SystemRequest $request) { public function getemail(Email $email, Template $template, Emails $email1) {
try { try {
// dd($request); /* fetch the values of email from Email table */
/* fetch the values of system request */ $emails = $email->whereId('1')->first();
$systems = $system->whereId('1')->first(); /* Fetch the values from Template table */
/* fill the values to coompany table */ $templates = $template->get();
/* Check whether function success or not */ /* Fetch the values from Emails table */
$systems->fill($request->input())->save(); $emails1 = $email1->get();
/* redirect to Index page with Success Message */ /* Direct to Email Settings Page */
return redirect('getsystem')->with('success', 'System Updated Successfully'); return view('themes.default1.admin.helpdesk.settings.email', compact('emails', 'templates', 'emails1'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ return redirect()->back()->with('fails', $e->errorInfo[2]);
return redirect('getsystem')->with('fails', 'System can not Updated'.'<li>'.$e->errorInfo[2].'</li>'); }
} }
}
/** /**
* get the form for Ticket setting page * Update the specified resource in storage.
* @param type Ticket $ticket * @param type int $id
* @param type Sla_plan $sla * @param type Email $email
* @param type Help_topic $topic * @param type EmailRequest $request
* @param type Priority $priority * @return type Response
* @return type Response */
*/ public function postemail($id, Email $email, EmailRequest $request) {
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) { try {
try { /* fetch the values of email request */
/* fetch the values of ticket from ticket table */ $emails = $email->whereId('1')->first();
$tickets = $ticket->whereId('1')->first(); /* fill the values to email table */
/* Fetch the values from SLA Plan table */ $emails->fill($request->except('email_fetching', 'all_emails', 'email_collaborator', 'strip', 'attachment'))->save();
$slas = $sla->get(); /* insert checkboxes to database */
/* Fetch the values from Help_topic table */ $emails->email_fetching = $request->input('email_fetching');
$topics = $topic->get(); $emails->notification_cron = $request->input('notification_cron');
/* Direct to Ticket Settings Page */ $emails->all_emails = $request->input('all_emails');
return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority')); $emails->email_collaborator = $request->input('email_collaborator');
} catch (Exception $e) { $emails->strip = $request->input('strip');
return redirect()->back()->with('fails',$e->errorInfo[2]); $emails->attachment = $request->input('attachment');
} /* Check whether function success or not */
} $emails->save();
/* redirect to Index page with Success Message */
return redirect('getemail')->with('success', 'Email Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getemail')->with('fails', 'Email can not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/** /**
* Update the specified resource in storage. * get the form for Access setting page
* @param type int $id * @param type Access $access
* @param type Ticket $ticket * @return type Response
* @param type Request $request */
* @return type Response // public function getaccess(Access $access) {
*/ // try {
public function postticket($id, Ticket $ticket, Request $request) { // /* fetch the values of access from access table */
try { // $accesses = $access->whereId('1')->first();
/* fetch the values of ticket request */
$tickets = $ticket->whereId('1')->first();
/* fill the values to coompany table */
$tickets->fill($request->except('captcha', 'claim_response', 'assigned_ticket', 'answered_ticket', 'agent_mask', 'html', 'client_update'))->save();
/* insert checkbox to Database */
$tickets->captcha = $request->input('captcha');
$tickets->claim_response = $request->input('claim_response');
$tickets->assigned_ticket = $request->input('assigned_ticket');
$tickets->answered_ticket = $request->input('answered_ticket');
$tickets->agent_mask = $request->input('agent_mask');
$tickets->html = $request->input('html');
$tickets->client_update = $request->input('client_update');
/* Check whether function success or not */
$tickets->save();
/* redirect to Index page with Success Message */
return redirect('getticket')->with('success', 'Ticket Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getticket')->with('fails', 'Ticket can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* get the form for Email setting page
* @param type Email $email
* @param type Template $template
* @param type Emails $email1
* @return type Response
*/
public function getemail(Email $email, Template $template, Emails $email1) {
try {
/* fetch the values of email from Email table */
$emails = $email->whereId('1')->first();
/* Fetch the values from Template table */
$templates = $template->get();
/* Fetch the values from Emails table */
$emails1 = $email1->get();
/* Direct to Email Settings Page */
return view('themes.default1.admin.helpdesk.settings.email', compact('emails', 'templates', 'emails1'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Email $email
* @param type EmailRequest $request
* @return type Response
*/
public function postemail($id, Email $email, EmailRequest $request) {
try {
/* fetch the values of email request */
$emails = $email->whereId('1')->first();
/* fill the values to email table */
$emails->fill($request->except('email_fetching', 'all_emails', 'email_collaborator', 'strip', 'attachment'))->save();
/* insert checkboxes to database */
$emails->email_fetching = $request->input('email_fetching');
$emails->notification_cron = $request->input('notification_cron');
$emails->all_emails = $request->input('all_emails');
$emails->email_collaborator = $request->input('email_collaborator');
$emails->strip = $request->input('strip');
$emails->attachment = $request->input('attachment');
/* Check whether function success or not */
$emails->save();
/* redirect to Index page with Success Message */
return redirect('getemail')->with('success', 'Email Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getemail')->with('fails', 'Email can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* get the form for Access setting page
* @param type Access $access
* @return type Response
*/
// public function getaccess(Access $access) {
// try {
// /* fetch the values of access from access table */
// $accesses = $access->whereId('1')->first();
// // Direct to Access Settings Page // // Direct to Access Settings Page
// return view('themes.default1.admin.helpdesk.settings.access', compact('accesses')); // return view('themes.default1.admin.helpdesk.settings.access', compact('accesses'));
// } catch (Exception $e) { // } catch (Exception $e) {
// return view('404'); // return view('404');
// } // }
// } // }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type Access $access * @param type Access $access
* @param type Request $request * @param type Request $request
* @return type Response * @return type Response
*/ */
// public function postaccess(Access $access, Request $request) { // public function postaccess(Access $access, Request $request) {
// try { // try {
// /* fetch the values of access request */ // /* fetch the values of access request */
// $accesses = $access->whereId('1')->first(); // $accesses = $access->whereId('1')->first();
// /* fill the values to access table */ // /* fill the values to access table */
// $accesses->fill($request->except('password_reset', 'bind_agent_ip', 'reg_require', 'quick_access'))->save(); // $accesses->fill($request->except('password_reset', 'bind_agent_ip', 'reg_require', 'quick_access'))->save();
// /* insert checkbox value to DB */ // /* insert checkbox value to DB */
// $accesses->password_reset = $request->input('password_reset'); // $accesses->password_reset = $request->input('password_reset');
// $accesses->bind_agent_ip = $request->input('bind_agent_ip'); // $accesses->bind_agent_ip = $request->input('bind_agent_ip');
// $accesses->reg_require = $request->input('reg_require'); // $accesses->reg_require = $request->input('reg_require');
// $accesses->quick_access = $request->input('quick_access'); // $accesses->quick_access = $request->input('quick_access');
// /* Check whether function success or not */ // /* Check whether function success or not */
// if ($accesses->save() == true) { // if ($accesses->save() == true) {
// /* redirect to Index page with Success Message */ // /* redirect to Index page with Success Message */
// return redirect('getaccess')->with('success', 'Access Updated Successfully'); // return redirect('getaccess')->with('success', 'Access Updated Successfully');
// } else { // } else {
// /* redirect to Index page with Fails Message */ // /* redirect to Index page with Fails Message */
// return redirect('getaccess')->with('fails', 'Access can not Updated'); // return redirect('getaccess')->with('fails', 'Access can not Updated');
// } // }
// } catch (Exception $e) { // } catch (Exception $e) {
// /* redirect to Index page with Fails Message */ // /* redirect to Index page with Fails Message */
// return redirect('getaccess')->with('fails', 'Access can not Updated'); // return redirect('getaccess')->with('fails', 'Access can not Updated');
// } // }
// } // }
/** /**
* get the form for Responder setting page * get the form for Responder setting page
* @param type Responder $responder * @param type Responder $responder
* @return type Response * @return type Response
*/ */
public function getresponder(Responder $responder) { public function getresponder(Responder $responder) {
try { try {
/* fetch the values of responder from responder table */ /* fetch the values of responder from responder table */
$responders = $responder->whereId('1')->first(); $responders = $responder->whereId('1')->first();
/* Direct to Responder Settings Page */ /* Direct to Responder Settings Page */
return view('themes.default1.admin.helpdesk.settings.responder', compact('responders')); return view('themes.default1.admin.helpdesk.settings.responder', compact('responders'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type Responder $responder * @param type Responder $responder
* @param type Request $request * @param type Request $request
* @return type * @return type
*/ */
public function postresponder(Responder $responder, Request $request) { public function postresponder(Responder $responder, Request $request) {
try { try {
/* fetch the values of responder request */ /* fetch the values of responder request */
$responders = $responder->whereId('1')->first(); $responders = $responder->whereId('1')->first();
/* insert Checkbox value to DB */ /* insert Checkbox value to DB */
$responders->new_ticket = $request->input('new_ticket'); $responders->new_ticket = $request->input('new_ticket');
$responders->agent_new_ticket = $request->input('agent_new_ticket'); $responders->agent_new_ticket = $request->input('agent_new_ticket');
$responders->submitter = $request->input('submitter'); $responders->submitter = $request->input('submitter');
$responders->participants = $request->input('participants'); $responders->participants = $request->input('participants');
$responders->overlimit = $request->input('overlimit'); $responders->overlimit = $request->input('overlimit');
/* fill the values to coompany table */ /* fill the values to coompany table */
/* Check whether function success or not */ /* Check whether function success or not */
$responders->save(); $responders->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('getresponder')->with('success', 'Responder Updated Successfully'); return redirect('getresponder')->with('success', 'Responder Updated Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('getresponder')->with('fails', 'Responder can not Updated'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('getresponder')->with('fails', 'Responder can not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* get the form for Alert setting page * get the form for Alert setting page
* @param type Alert $alert * @param type Alert $alert
* @return type Response * @return type Response
*/ */
public function getalert(Alert $alert) { public function getalert(Alert $alert) {
try { try {
/* fetch the values of alert from alert table */ /* fetch the values of alert from alert table */
$alerts = $alert->whereId('1')->first(); $alerts = $alert->whereId('1')->first();
/* Direct to Alert Settings Page */ /* Direct to Alert Settings Page */
return view('themes.default1.admin.helpdesk.settings.alert', compact('alerts')); return view('themes.default1.admin.helpdesk.settings.alert', compact('alerts'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type $id * @param type $id
* @param type Alert $alert * @param type Alert $alert
* @param type Request $request * @param type Request $request
* @return type Response * @return type Response
*/ */
public function postalert($id, Alert $alert, Request $request) { public function postalert($id, Alert $alert, Request $request) {
try { try {
/* fetch the values of alert request */ /* fetch the values of alert request */
$alerts = $alert->whereId('1')->first(); $alerts = $alert->whereId('1')->first();
/* Insert Checkbox to DB */ /* Insert Checkbox to DB */
$alerts->assignment_status = $request->input('assignment_status'); $alerts->assignment_status = $request->input('assignment_status');
$alerts->ticket_status = $request->input('ticket_status'); $alerts->ticket_status = $request->input('ticket_status');
$alerts->overdue_department_member = $request->input('overdue_department_member'); $alerts->overdue_department_member = $request->input('overdue_department_member');
$alerts->sql_error = $request->input('sql_error'); $alerts->sql_error = $request->input('sql_error');
$alerts->excessive_failure = $request->input('excessive_failure'); $alerts->excessive_failure = $request->input('excessive_failure');
$alerts->overdue_status = $request->input('overdue_status'); $alerts->overdue_status = $request->input('overdue_status');
$alerts->overdue_assigned_agent = $request->input('overdue_assigned_agent'); $alerts->overdue_assigned_agent = $request->input('overdue_assigned_agent');
$alerts->overdue_department_manager = $request->input('overdue_department_manager'); $alerts->overdue_department_manager = $request->input('overdue_department_manager');
$alerts->internal_status = $request->input('internal_status'); $alerts->internal_status = $request->input('internal_status');
$alerts->internal_last_responder = $request->input('internal_last_responder'); $alerts->internal_last_responder = $request->input('internal_last_responder');
$alerts->internal_assigned_agent = $request->input('internal_assigned_agent'); $alerts->internal_assigned_agent = $request->input('internal_assigned_agent');
$alerts->internal_department_manager = $request->input('internal_department_manager'); $alerts->internal_department_manager = $request->input('internal_department_manager');
$alerts->assignment_assigned_agent = $request->input('assignment_assigned_agent'); $alerts->assignment_assigned_agent = $request->input('assignment_assigned_agent');
$alerts->assignment_team_leader = $request->input('assignment_team_leader'); $alerts->assignment_team_leader = $request->input('assignment_team_leader');
$alerts->assignment_team_member = $request->input('assignment_team_member'); $alerts->assignment_team_member = $request->input('assignment_team_member');
$alerts->system_error = $request->input('system_error'); $alerts->system_error = $request->input('system_error');
$alerts->transfer_department_member = $request->input('transfer_department_member'); $alerts->transfer_department_member = $request->input('transfer_department_member');
$alerts->transfer_department_manager = $request->input('transfer_department_manager'); $alerts->transfer_department_manager = $request->input('transfer_department_manager');
$alerts->transfer_assigned_agent = $request->input('transfer_assigned_agent'); $alerts->transfer_assigned_agent = $request->input('transfer_assigned_agent');
$alerts->transfer_status = $request->input('transfer_status'); $alerts->transfer_status = $request->input('transfer_status');
$alerts->message_organization_accmanager = $request->input('message_organization_accmanager'); $alerts->message_organization_accmanager = $request->input('message_organization_accmanager');
$alerts->message_department_manager = $request->input('message_department_manager'); $alerts->message_department_manager = $request->input('message_department_manager');
$alerts->message_assigned_agent = $request->input('message_assigned_agent'); $alerts->message_assigned_agent = $request->input('message_assigned_agent');
$alerts->message_last_responder = $request->input('message_last_responder'); $alerts->message_last_responder = $request->input('message_last_responder');
$alerts->message_status = $request->input('message_status'); $alerts->message_status = $request->input('message_status');
$alerts->ticket_organization_accmanager = $request->input('ticket_organization_accmanager'); $alerts->ticket_organization_accmanager = $request->input('ticket_organization_accmanager');
$alerts->ticket_department_manager = $request->input('ticket_department_manager'); $alerts->ticket_department_manager = $request->input('ticket_department_manager');
$alerts->ticket_department_member = $request->input('ticket_department_member'); $alerts->ticket_department_member = $request->input('ticket_department_member');
$alerts->ticket_admin_email = $request->input('ticket_admin_email'); $alerts->ticket_admin_email = $request->input('ticket_admin_email');
if($request->input('system_error') == null){ if ($request->input('system_error') == null) {
$str = '%0%'; $str = '%0%';
$path = app_path('../config/app.php'); $path = app_path('../config/app.php');
$content = \File::get($path); $content = \File::get($path);
$content = str_replace('%1%', $str, $content); $content = str_replace('%1%', $str, $content);
\File::put($path, $content); \File::put($path, $content);
} else { } else {
$str = '%1%'; $str = '%1%';
$path = app_path('../config/app.php'); $path = app_path('../config/app.php');
$content = \File::get($path); $content = \File::get($path);
$content = str_replace('%0%', $str, $content); $content = str_replace('%0%', $str, $content);
\File::put($path, $content); \File::put($path, $content);
} }
/* fill the values to coompany table */ /* fill the values to coompany table */
/* Check whether function success or not */ /* Check whether function success or not */
$alerts->save(); $alerts->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('getalert')->with('success', 'Alert Updated Successfully'); return redirect('getalert')->with('success', 'Alert Updated Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('getalert')->with('fails', 'Alert can not Updated'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('getalert')->with('fails', 'Alert can not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/**
* To display the list of ratings in the system
* @return type View
*/
public function RatingSettings() {
$ratings = DB::table('settings_ratings')->get();
return view('themes.default1.admin.helpdesk.settings.ratings', compact('ratings'));
}
/**
* To store rating data
* @return type Redirect
*/
public function PostRatingSettings($slug) {
$name = Input::get('rating_name');
$publish = Input::get('publish');
$modify = Input::get('modify');
DB::table('settings_ratings')->whereSlug($slug)->update(array('rating_name' => $name, 'publish' => $publish, 'modify' => $modify));
return redirect()->back()->with('success', 'Successfully updated');
}
/**
* To delete a type of rating
* @return type Redirect
*/
public function RatingDelete($slug) {
DB::table('settings_ratings')->whereSlug($slug)->delete();
return redirect()->back()->with('success', 'Successfully Deleted');
}
} }

View File

@@ -1,16 +1,15 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
use App\Http\Requests\helpdesk\SlaRequest; use App\Http\Requests\helpdesk\SlaRequest;
use App\Http\Requests\helpdesk\SlaUpdate; use App\Http\Requests\helpdesk\SlaUpdate;
// models // models
use App\Model\helpdesk\Manage\Sla_plan; use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Settings\Ticket; use App\Model\helpdesk\Settings\Ticket;
//classes //classes
use DB; use DB;
use Exception; use Exception;
@@ -24,163 +23,163 @@ use Exception;
*/ */
class SlaController extends Controller { class SlaController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type void * @return type void
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @return type Response * @return type Response
*/ */
public function index(Sla_plan $sla) { public function index(Sla_plan $sla) {
try { try {
/* Declare a Variable $slas to store all Values From Sla_plan Table */ /* Declare a Variable $slas to store all Values From Sla_plan Table */
$slas = $sla->get(); $slas = $sla->get();
/* Listing the values From Sla_plan Table */ /* Listing the values From Sla_plan Table */
return view('themes.default1.admin.helpdesk.manage.sla.index', compact('slas')); return view('themes.default1.admin.helpdesk.manage.sla.index', compact('slas'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @return type Response * @return type Response
*/ */
public function create() { public function create() {
try { try {
/* Direct to Create Page */ /* Direct to Create Page */
return view('themes.default1.admin.helpdesk.manage.sla.create'); return view('themes.default1.admin.helpdesk.manage.sla.create');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @param type SlaRequest $request * @param type SlaRequest $request
* @return type Response * @return type Response
*/ */
public function store(Sla_plan $sla, SlaRequest $request) { public function store(Sla_plan $sla, SlaRequest $request) {
try { try {
/* Fill the request values to Sla_plan Table */ /* Fill the request values to Sla_plan Table */
/* Check whether function success or not */ /* Check whether function success or not */
$sla->fill($request->input())->save(); $sla->fill($request->input())->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Created Successfully'); return redirect('sla')->with('success', 'SLA Plan Created Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('sla')->with('fails', 'SLA Plan can not Create'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('sla')->with('fails', 'SLA Plan can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* @param type int $id * @param type int $id
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @return type Response * @return type Response
*/ */
public function edit($id, Sla_plan $sla) { public function edit($id, Sla_plan $sla) {
try { try {
/* Direct to edit page along values of perticular field using Id */ /* Direct to edit page along values of perticular field using Id */
$slas = $sla->whereId($id)->first(); $slas = $sla->whereId($id)->first();
$slas->get(); $slas->get();
return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas')); return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type int $id * @param type int $id
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @param type SlaUpdate $request * @param type SlaUpdate $request
* @return type Response * @return type Response
*/ */
public function update($id, Sla_plan $sla, SlaUpdate $request) { public function update($id, Sla_plan $sla, SlaUpdate $request) {
try { try {
/* Fill values to selected field using Id except Check box */ /* Fill values to selected field using Id except Check box */
$slas = $sla->whereId($id)->first(); $slas = $sla->whereId($id)->first();
$slas->fill($request->except('transient', 'ticket_overdue'))->save(); $slas->fill($request->except('transient', 'ticket_overdue'))->save();
/* Update transient checkox field */ /* Update transient checkox field */
$slas->transient = $request->input('transient'); $slas->transient = $request->input('transient');
/* Update ticket_overdue checkox field */ /* Update ticket_overdue checkox field */
$slas->ticket_overdue = $request->input('ticket_overdue'); $slas->ticket_overdue = $request->input('ticket_overdue');
/* Check whether function success or not */ /* Check whether function success or not */
$slas->save(); $slas->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Updated Successfully'); return redirect('sla')->with('success', 'SLA Plan Updated Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('sla')->with('fails', 'SLA Plan can not Update'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('sla')->with('fails', 'SLA Plan can not Update' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* @param type int $id * @param type int $id
* @param type Sla_plan $sla * @param type Sla_plan $sla
* @return type Response * @return type Response
*/ */
public function destroy($id, Sla_plan $sla) { public function destroy($id, Sla_plan $sla) {
$default_sla = Ticket::where('id','=','1')->first(); $default_sla = Ticket::where('id', '=', '1')->first();
if($default_sla->sla == $id) { if ($default_sla->sla == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department'); return redirect('departments')->with('fails', 'You cannot delete default department');
} else { } else {
$tickets = DB::table('tickets')->where('sla','=',$id)->update(['sla' => $default_sla->sla]); $tickets = DB::table('tickets')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]);
if($tickets > 0) { if ($tickets > 0) {
if($tickets > 1) { if ($tickets > 1) {
$text_tickets = "Tickets"; $text_tickets = "Tickets";
} else { } else {
$text_tickets = "Ticket"; $text_tickets = "Ticket";
} }
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default SLA</li>'; $ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default SLA</li>';
} else { } else {
$ticket = ""; $ticket = "";
} }
$dept = DB::table('department')->where('sla','=',$id)->update(['sla' => $default_sla->sla]); $dept = DB::table('department')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]);
if($dept > 0){ if ($dept > 0) {
if($dept > 1){ if ($dept > 1) {
$text_dept = "Emails"; $text_dept = "Emails";
} else { } else {
$text_dept = "Email"; $text_dept = "Email";
} }
$dept = '<li>Associated department have been moved to default SLA</li>'; $dept = '<li>Associated department have been moved to default SLA</li>';
} else { } else {
$dept = ""; $dept = "";
} }
$topic = DB::table('help_topic')->where('sla_plan','=',$id)->update(['sla_plan' => $default_sla->sla]); $topic = DB::table('help_topic')->where('sla_plan', '=', $id)->update(['sla_plan' => $default_sla->sla]);
if($topic > 0){ if ($topic > 0) {
if($topic > 1){ if ($topic > 1) {
$text_topic = "Emails"; $text_topic = "Emails";
} else { } else {
$text_topic = "Email"; $text_topic = "Email";
} }
$topic = '<li>Associated Help Topic have been moved to default SLA</li>'; $topic = '<li>Associated Help Topic have been moved to default SLA</li>';
} else { } else {
$topic = ""; $topic = "";
} }
$message = $ticket.$dept.$topic; $message = $ticket . $dept . $topic;
/* Delete a perticular field from the database by delete() using Id */ /* Delete a perticular field from the database by delete() using Id */
$slas = $sla->whereId($id)->first(); $slas = $sla->whereId($id)->first();
/* Check whether function success or not */ /* Check whether function success or not */
try{ try {
$slas->delete(); $slas->delete();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Deleted Successfully'.$message); return redirect('sla')->with('success', 'SLA Plan Deleted Successfully' . $message);
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('sla')->with('fails', 'SLA Plan can not Delete'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('sla')->with('fails', 'SLA Plan can not Delete' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
} }
} }

View File

@@ -1,17 +1,16 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
use App\Http\Requests\helpdesk\TeamRequest; use App\Http\Requests\helpdesk\TeamRequest;
use App\Http\Requests\helpdesk\TeamUpdate; use App\Http\Requests\helpdesk\TeamUpdate;
// models // models
use App\Model\helpdesk\Agent\Assign_team_agent; use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Agent\Teams; use App\Model\helpdesk\Agent\Teams;
use App\User; use App\User;
// classes // classes
use DB; use DB;
use Exception; use Exception;
@@ -25,145 +24,146 @@ use Exception;
*/ */
class TeamController extends Controller { class TeamController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type void * @return type void
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
/** /**
* get Index page * get Index page
* @param type Teams $team * @param type Teams $team
* @param type Assign_team_agent $assign_team_agent * @param type Assign_team_agent $assign_team_agent
* @return type Response * @return type Response
*/ */
public function index(Teams $team, Assign_team_agent $assign_team_agent) { public function index(Teams $team, Assign_team_agent $assign_team_agent) {
try { try {
$teams = $team->get(); $teams = $team->get();
/* find out the Number of Members in the Team */ /* find out the Number of Members in the Team */
$id = $teams->lists('id'); $id = $teams->lists('id');
$assign_team_agent = $assign_team_agent->get(); $assign_team_agent = $assign_team_agent->get();
return view('themes.default1.admin.helpdesk.agent.teams.index', compact('assign_team_agent', 'teams')); return view('themes.default1.admin.helpdesk.agent.teams.index', compact('assign_team_agent', 'teams'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @param type User $user * @param type User $user
* @return type Response * @return type Response
*/ */
public function create(User $user) { public function create(User $user) {
try { try {
$user = $user->get(); $user = $user->get();
return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user')); return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type Teams $team * @param type Teams $team
* @param type TeamRequest $request * @param type TeamRequest $request
* @return type Response * @return type Response
*/ */
public function store(Teams $team, TeamRequest $request) { public function store(Teams $team, TeamRequest $request) {
if($request->team_lead){ if ($request->team_lead) {
$team_lead = $request->team_lead; $team_lead = $request->team_lead;
} else { } else {
$team_lead = null; $team_lead = null;
} }
$team->team_lead = $team_lead; $team->team_lead = $team_lead;
try { try {
/* Check whether function success or not */ /* Check whether function success or not */
$team->fill($request->except('team_lead'))->save(); $team->fill($request->except('team_lead'))->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Created Successfully'); return redirect('teams')->with('success', 'Teams Created Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('teams')->with('fails', 'Teams can not Create'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('teams')->with('fails', 'Teams can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* @param type $id * @param type $id
* @param type User $user * @param type User $user
* @param type Assign_team_agent $assign_team_agent * @param type Assign_team_agent $assign_team_agent
* @param type Teams $team * @param type Teams $team
* @return type Response * @return type Response
*/ */
public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team) { public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team) {
try { try {
$user = $user->whereId($id)->first(); $user = $user->whereId($id)->first();
$teams = $team->whereId($id)->first(); $teams = $team->whereId($id)->first();
$agent_team = $assign_team_agent->where('team_id', $id)->get(); $agent_team = $assign_team_agent->where('team_id', $id)->get();
$agent_id = $agent_team->lists('agent_id', 'agent_id'); $agent_id = $agent_team->lists('agent_id', 'agent_id');
return view('themes.default1.admin.helpdesk.agent.teams.edit', compact('agent_id', 'user', 'teams', 'allagents')); return view('themes.default1.admin.helpdesk.agent.teams.edit', compact('agent_id', 'user', 'teams', 'allagents'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type int $id * @param type int $id
* @param type Teams $team * @param type Teams $team
* @param type TeamUpdate $request * @param type TeamUpdate $request
* @return type Response * @return type Response
*/ */
public function update($id, Teams $team, TeamUpdate $request) { public function update($id, Teams $team, TeamUpdate $request) {
$teams = $team->whereId($id)->first(); $teams = $team->whereId($id)->first();
//updating check box //updating check box
if($request->team_lead){ if ($request->team_lead) {
$team_lead = $request->team_lead; $team_lead = $request->team_lead;
} else { } else {
$team_lead = null; $team_lead = null;
} }
$teams->team_lead = $team_lead; $teams->team_lead = $team_lead;
$teams->save(); $teams->save();
$alert = $request->input('assign_alert'); $alert = $request->input('assign_alert');
$teams->assign_alert = $alert; $teams->assign_alert = $alert;
$teams->save(); //saving check box $teams->save(); //saving check box
//updating whole field //updating whole field
/* Check whether function success or not */ /* Check whether function success or not */
try { try {
$teams->fill($request->except('team_lead'))->save(); $teams->fill($request->except('team_lead'))->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Updated Successfully'); return redirect('teams')->with('success', 'Teams Updated Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('teams')->with('fails', 'Teams can not Update'.'<li>'.$e->errorInfo[2].'</li>'); return redirect('teams')->with('fails', 'Teams can not Update' . '<li>' . $e->errorInfo[2] . '</li>');
} }
} }
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Teams $team
* @param type Assign_team_agent $assign_team_agent
* @return type Response
*/
public function destroy($id, Teams $team, Assign_team_agent $assign_team_agent) {
try {
$assign_team_agent->where('team_id', $id)->delete();
$teams = $team->whereId($id)->first();
$tickets = DB::table('tickets')->where('team_id', '=', $id)->update(['team_id' => null]);
/* Check whether function success or not */
$teams->delete();
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('teams')->with('fails', 'Teams can not Delete' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Teams $team
* @param type Assign_team_agent $assign_team_agent
* @return type Response
*/
public function destroy($id, Teams $team, Assign_team_agent $assign_team_agent) {
try {
$assign_team_agent->where('team_id', $id)->delete();
$teams = $team->whereId($id)->first();
$tickets = DB::table('tickets')->where('team_id','=',$id)->update(['team_id' => null]);
/* Check whether function success or not */
$teams->delete();
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('teams')->with('fails', 'Teams can not Delete'.'<li>'.$e->errorInfo[2].'</li>');
}
}
} }

View File

@@ -1,7 +1,11 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// requests // requests
use App\Http\Requests\helpdesk\TemplateRequest; use App\Http\Requests\helpdesk\TemplateRequest;
use App\Http\Requests\helpdesk\TemplateUdate; use App\Http\Requests\helpdesk\TemplateUdate;
@@ -24,230 +28,260 @@ use Input;
*/ */
class TemplateController extends Controller { class TemplateController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type void * @return type void
*/ */
public function __construct() { public function __construct(PhpMailController $PhpMailController) {
SettingsController::smtp(); $this->PhpMailController = $PhpMailController;
$this->middleware('auth'); SettingsController::smtp();
$this->middleware('roles'); $this->middleware('auth');
} $this->middleware('roles');
}
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* @param type Template $template * @param type Template $template
* @return type Response * @return type Response
*/ */
public function index(Template $template) { public function index(Template $template) {
try { try {
$templates = $template->get(); $templates = $template->get();
return view('themes.default1.admin.helpdesk.emails.template.index', compact('templates')); return view('themes.default1.admin.helpdesk.emails.template.index', compact('templates'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @param type Languages $language * @param type Languages $language
* @param type Template $template * @param type Template $template
* @return type Response * @return type Response
*/ */
public function create(Languages $language, Template $template) { public function create(Languages $language, Template $template) {
try { try {
$templates = $template->get(); $templates = $template->get();
$languages = $language->get(); $languages = $language->get();
return view('themes.default1.admin.helpdesk.emails.template.create', compact('languages', 'templates')); return view('themes.default1.admin.helpdesk.emails.template.create', compact('languages', 'templates'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type Template $template * @param type Template $template
* @param type TemplateRequest $request * @param type TemplateRequest $request
* @return type Response * @return type Response
*/ */
public function store(Template $template, TemplateRequest $request) { public function store(Template $template, TemplateRequest $request) {
try { try {
/* Check whether function success or not */ /* Check whether function success or not */
if ($template->fill($request->input())->save() == true) { if ($template->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('template')->with('success', 'Teams Created Successfully'); return redirect('template')->with('success', 'Teams Created Successfully');
} else { } else {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Create'); return redirect('template')->with('fails', 'Teams can not Create');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Create');
}
}
/**
* Display the specified resource.
* @param int $id
* @return Response
*/
public function show($id) {
//
}
/**
* Show the form for editing the specified resource.
* @param type $id
* @param type Template $template
* @param type Languages $language
* @return type Response
*/
public function listtemplates() {
$path = '../resources/views/emails/';
$templates = scandir($path);
$directory = str_replace('/', '-', $path);
return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates','directory'));
}
public function readtemplate($template,$path) {
$directory = str_replace('-', '/', $path);
$directory2 = $directory.$template;
if (is_dir($directory2)) {
$templates = scandir($directory2);
$directory = str_replace('/', '-', $directory2.'/');
return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates','directory'));
} }
else { } catch (Exception $e) {
$handle = fopen($directory.$template, "r"); /* redirect to Index page with Fails Message */
$contents = fread($handle, filesize($directory.$template)); return redirect('template')->with('fails', 'Teams can not Create');
fclose($handle); }
} }
return view('themes.default1.admin.helpdesk.emails.template.readtemplates', compact('contents','template','path'));
} /**
public function createtemplate() { * Display the specified resource.
$directory = '../resources/views/emails/'; * @param int $id
$fname = Input::get('folder_name'); * @return Response
$filename = $directory.$fname; */
public function show($id) {
//
}
/**
* Show the form for editing the specified resource.
* @param type $id
* @param type Template $template
* @param type Languages $language
* @return type Response
*/
public function listdirectories() {
$path = '../resources/views/emails/';
$directories = scandir($path);
$directory = str_replace('/', '-', $path);
return view('themes.default1.admin.helpdesk.emails.template.listdirectories', compact('directories', 'directory'));
}
public function listtemplates($template, $path) {
$paths = str_replace('-', '/', $path);
$directory2 = $paths . $template;
$templates = scandir($directory2);
$directory = str_replace('/', '-', $directory2 . '/');
return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates', 'directory'));
}
public function readtemplate($template, $path) {
$directory = str_replace('-', '/', $path);
$handle = fopen($directory . $template, "r");
$contents = fread($handle, filesize($directory . $template));
fclose($handle);
return view('themes.default1.admin.helpdesk.emails.template.readtemplates', compact('contents', 'template', 'path'));
}
public function createtemplate() {
$directory = '../resources/views/emails/';
$fname = Input::get('folder_name');
$filename = $directory . $fname;
// images folder creation using php // images folder creation using php
// $mydir = dirname( __FILE__ )."/html/images"; // $mydir = dirname( __FILE__ )."/html/images";
// if(!is_dir($mydir)){ // if(!is_dir($mydir)){
// mkdir("html/images"); // mkdir("html/images");
// } // }
// Move all images files // Move all images files
if(!file_exists($filename)) { if (!file_exists($filename)) {
mkdir($filename,0777); mkdir($filename, 0777);
} }
$files = array_filter(scandir($directory.'default')); $files = array_filter(scandir($directory . 'default'));
foreach($files as $file){ foreach ($files as $file) {
if ($file === '.' or $file === '..') continue; if ($file === '.' or $file === '..')
if(!is_dir($file)) { continue;
// $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file); if (!is_dir($file)) {
$destination = $directory.$fname.'/'; // $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file);
$destination = $directory . $fname . '/';
copy($directory.'default/'.$file, $destination.$file); copy($directory . 'default/' . $file, $destination . $file);
} }
} }
return \Redirect::back()->with('success', 'Successfully copied'); return \Redirect::back()->with('success', 'Successfully copied');
} }
public function writetemplate($template,$path) {
$directory = str_replace('-', '/', $path);
$b = Input::get('templatedata');
file_put_contents($directory.$template, print_r($b, true)); public function writetemplate($template, $path) {
return \Redirect::back()->with('success', 'Successfully updated'); $directory = str_replace('-', '/', $path);
} $b = Input::get('templatedata');
public function edit($id, Template $template, Languages $language) { file_put_contents($directory . $template, print_r($b, true));
try { return \Redirect::back()->with('success', 'Successfully updated');
$templates = $template->whereId($id)->first(); }
$languages = $language->get();
return view('themes.default1.admin.helpdesk.emails.template.edit', compact('templates', 'languages'));
} catch (Exception $e) {
return view('404');
}
}
/** public function deletetemplate($template, $path) {
* Update the specified resource in storage. $directory = str_replace('-', '/', $path);
* @param type int $id $dir = $directory . $template;
* @param type Template $template $status = \DB::table('settings_email')->first();
* @param type TemplateUdate $request if ($template == 'default' or $template == $status->template) {
* @return type Response return \Redirect::back()->with('fails', 'You cannot delete a default or active directory!');
*/ }
public function update($id, Template $template, TemplateUdate $request) { if (is_dir($dir)) {
try { $objects = scandir($dir);
//TODO validation foreach ($objects as $object) {
$templates = $template->whereId($id)->first(); if ($object != "." && $object != "..") {
/* Check whether function success or not */ unlink($dir . "/" . $object);
if ($templates->fill($request->input())->save() == true) { }
/* redirect to Index page with Success Message */ }
return redirect('template')->with('success', 'Teams Updated Successfully'); rmdir($dir);
} else { } else {
/* redirect to Index page with Fails Message */ rmdir($dir);
return redirect('template')->with('fails', 'Teams can not Update'); }
} return \Redirect::back()->with('success', 'Successfully Deleted');
} catch (Exception $e) { }
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Update');
}
}
/** public function activateset($setname) {
* Remove the specified resource from storage. \DB::table('settings_email')->update(array('template' => $setname));
* @param type int $id return \Redirect::back()->with('success', 'You have Successfully Activated this Set');
* @param type Template $template }
* @return type Response
*/
public function destroy($id, Template $template) {
try {
$templates = $template->whereId($id)->first();
/* Check whether function success or not */
if ($templates->delete() == true) {
/* redirect to Index page with Success Message */
return redirect('template')->with('success', 'Teams Deleted Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Delete');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Delete');
}
}
/** public function edit($id, Template $template, Languages $language) {
* Form for Email connection checking. try {
* @param type Emails $email $templates = $template->whereId($id)->first();
* @return type Response $languages = $language->get();
*/ return view('themes.default1.admin.helpdesk.emails.template.edit', compact('templates', 'languages'));
public function formDiagno(Emails $email) { } catch (Exception $e) {
try { return view('404');
$emails = $email->get(); }
return view('themes.default1.admin.helpdesk.emails.template.formDiagno', compact('emails')); }
} catch (Exception $e) {
return view('404');
}
}
/** /**
* function to send emails * Update the specified resource in storage.
* @param type Request $request * @param type int $id
* @return type * @param type Template $template
*/ * @param type TemplateUdate $request
public function postDiagno(Request $request) { * @return type Response
$email = $request->input('to'); */
if($email == null) public function update($id, Template $template, TemplateUdate $request) {
{ try {
return redirect('getdiagno')->with('fails', 'Please provide E-mail address !'); //TODO validation
} $templates = $template->whereId($id)->first();
$mail = Mail::send('themes.default1.admin.helpdesk.emails.template.connection', array('link' => url('getmail'), 'username' => $email), function ($message) use ($email) { /* Check whether function success or not */
$message->to($email)->subject('Checking the connection'); if ($templates->fill($request->input())->save() == true) {
}); /* redirect to Index page with Success Message */
return redirect('getdiagno')->with('success', 'Please check your mail. An E-mail has been sent to your E-mail address'); return redirect('template')->with('success', 'Teams Updated Successfully');
} } else {
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Update');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Update');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Template $template
* @return type Response
*/
public function destroy($id, Template $template) {
try {
$templates = $template->whereId($id)->first();
/* Check whether function success or not */
if ($templates->delete() == true) {
/* redirect to Index page with Success Message */
return redirect('template')->with('success', 'Teams Deleted Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Delete');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Delete');
}
}
/**
* Form for Email connection checking.
* @param type Emails $email
* @return type Response
*/
public function formDiagno(Emails $email) {
try {
$emails = $email->get();
return view('themes.default1.admin.helpdesk.emails.template.formDiagno', compact('emails'));
} catch (Exception $e) {
return view('404');
}
}
/**
* function to send emails
* @param type Request $request
* @return type
*/
public function postDiagno(Request $request) {
$email = $request->input('to');
if ($email == null) {
return redirect('getdiagno')->with('fails', 'Please provide E-mail address !');
}
// sending mail via php mailer
$mail = $this->PhpMailController->sendmail($from = 1, $to = ['email' => $email], $message = ['subject' => 'Checking the connection', 'scenario' => 'error-report', 'content' => 'Email Received Successfully'], $template_variables = ['system_error' => 'hello']);
return redirect('getdiagno')->with('success', 'Please check your mail. An E-mail has been sent to your E-mail address');
}
} }

View File

@@ -1,14 +1,15 @@
<?php namespace App\Http\Controllers\Admin\helpdesk; <?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// models // models
use App\Model\helpdesk\Priority; use App\Model\helpdesk\Priority;
use App\Model\helpdesk\Ticket_thread; use App\Model\helpdesk\Ticket_thread;
// classes // classes
use Exception; use Exception;
/** /**
* ThreadController * ThreadController
* *
@@ -18,22 +19,23 @@ use Exception;
*/ */
class ThreadController extends Controller { class ThreadController extends Controller {
/** /**
* get the values from ticket_thread Table and direct to view page * get the values from ticket_thread Table and direct to view page
* @param type Ticket_thread $thread * @param type Ticket_thread $thread
* @param type Priority $priority * @param type Priority $priority
* @return type Response * @return type Response
*/ */
public function getTickets(Ticket_thread $thread, Priority $priority) { public function getTickets(Ticket_thread $thread, Priority $priority) {
try { try {
/* get the values of Ticket_thread from Ticket_thread Table */ /* get the values of Ticket_thread from Ticket_thread Table */
$threads = $thread->get(); $threads = $thread->get();
/* get the values of priority from Priority Table */ /* get the values of priority from Priority Table */
$priorities = $priority->get(); $priorities = $priority->get();
/* Direct to view page */ /* Direct to view page */
return view('themes.default1.admin.helpdesk.tickets.ticket', compact('threads', 'priorities')); return view('themes.default1.admin.helpdesk.tickets.ticket', compact('threads', 'priorities'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
} }

View File

@@ -1,92 +0,0 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// models
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Email\Emails;
use App\User;
// classes
use DB;
use View;
use Auth;
/**
* DashboardController
*
* @package Controllers
* @subpackage Controller
* @author Ladybird <info@ladybirdweb.com>
*/
class DashboardController extends Controller {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('role.agent');
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function index() {
try {
if(Auth::user()->role == "user"){
return \Redirect::route('home');
}
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
} catch (Exception $e) {
return view('404');
}
}
/**
* ChartData
* @return type
*/
public function ChartData()
{
$date2 = strtotime(Date('Y-m-d'));
$date3 = Date('Y-m-d');
$format = 'Y-m-d';
$date1 = strtotime(Date($format,strtotime('-1 month'. $date3)));
$return = "";
$last = "";
for ( $i = $date1; $i <= $date2; $i = $i + 86400 ) {
$thisDate = date( 'Y-m-d', $i );
$created = \DB::table('tickets')->select('created_at')->where('created_at','LIKE','%'.$thisDate.'%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at','LIKE','%'.$thisDate.'%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at','LIKE','%'.$thisDate.'%')->count();
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
$array = array_map('htmlentities',$value);
$json = html_entity_decode(json_encode($array));
$return .= $json.',';
}
$last = rtrim($return,',');
return '['.$last.']';
// $ticketlist = DB::table('tickets')
// ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),
// DB::raw('count(*) as totaltickets'))
// ->groupBy('month')
// ->orderBy('month', 'asc')
// ->get();
// return $ticketlist;
}
}

View File

@@ -1,234 +0,0 @@
@extends('themes.default1.agent.layout.agent')
@section('Dashboard')
class="active"
@stop
@section('dashboard-bar')
active
@stop
@section('dashboard')
class="active"
@stop
@section('content')
<div class="box box-info">
<?php
// $tickets = App\Model\Ticket\Tickets::where('created_at','>=',date('Y-m-d'))->get();
// echo count($tickets);
?>
<div class="box-header with-border">
<h3 class="box-title">{!! Lang::get('lang.line_chart') !!}</h3>
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
<button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div>
<div class="box-body">
<div class="chart" >
<div id="legendDiv"></div>
<canvas class="chart-data" id="tickets-graph" width="1000" height="400"></canvas>
</div>
</div><!-- /.box-body -->
</div><!-- /.box -->
<hr/>
<div class="box">
<div class="box-header">
<h1>{!! Lang::get('lang.statistics') !!}</h1>
</div>
<div class="box-body">
<table class="table table-hover" style="overflow:hidden;">
<tr>
<th>{!! Lang::get('lang.department') !!}</th>
<th>{!! Lang::get('lang.opened') !!}</th>
<th>{!! Lang::get('lang.resolved') !!}</th>
<th>{!! Lang::get('lang.closed') !!}</th>
<th>{!! Lang::get('lang.deleted') !!}</th>
</tr>
<?php $departments = App\Model\helpdesk\Agent\Department::all(); ?>
@foreach($departments as $department)
<?php
$open = App\Model\helpdesk\Ticket\Tickets::where('dept_id','=',$department->id)->where('status','=',1)->count();
$resolve = App\Model\helpdesk\Ticket\Tickets::where('dept_id','=',$department->id)->where('status','=',2)->count();
$close = App\Model\helpdesk\Ticket\Tickets::where('dept_id','=',$department->id)->where('status','=',3)->count();
$delete = App\Model\helpdesk\Ticket\Tickets::where('dept_id','=',$department->id)->where('status','=',5)->count();
?>
<tr>
<td>{!! $department->name !!}</td>
<td>{!! $open !!}</td>
<td>{!! $resolve !!}</td>
<td>{!! $close !!}</td>
<td>{!! $delete !!}</td>
</tr>
@endforeach
</table>
</div>
</div>
<script src="{{asset("lb-faveo/plugins/chartjs/Chart.min.js")}}" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$.getJSON("agen", function (result) {
var labels = [],data=[],data2=[],data3=[],data4=[];
for (var i = 0; i < result.length; i++) {
$var12 = result[i].month;
if($var12 == 1){
$var13 = "January";
}
if($var12 == 2){
$var13 = "Febuary";
}
if($var12 == 3){
$var13 = "March";
}
if($var12 == 4){
$var13 = "April";
}
if($var12 == 5){
$var13 = "May";
}
if($var12 == 6){
$var13 = "June";
}
if($var12 == 7){
$var13 = "July";
}
if($var12 == 8){
$var13 = "August";
}
if($var12 == 9){
$var13 = "September";
}
if($var12 == 10){
$var13 = "October";
}
if($var12 == 11){
$var13 = "November";
}
if($var12 == 12){
$var13 = "December";
}
labels.push($var13);
data.push(result[i].totaltickets);
data2.push(result[i].closed);
data3.push(result[i].reopened);
data4.push(result[i].open);
}
var buyerData = {
labels : labels,
datasets : [
{
label : "Total Tickets" ,
fillColor : "rgba(240, 127, 110, 0.3)",
strokeColor : "#f56954",
pointColor : "#A62121",
pointStrokeColor : "#E60073",
data : data
}
,
{
label : "Open Tickets" ,
fillColor : "rgba(255, 102, 204, 0.4)",
strokeColor : "#f56954",
pointColor : "#FF66CC",
pointStrokeColor : "#fff",
pointHighlightFill : "#FF4DC3",
pointHighlightStroke : "rgba(151,187,205,1)",
data : data4
}
,
{
label : "Closed Tickets",
fillColor : "rgba(151,187,205,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#0000CC",
pointHighlightFill : "#0000E6",
pointHighlightStroke : "rgba(151,187,205,1)",
data : data2
}
,
{
label : "Reopened Tickets",
fillColor : "rgba(102,255,51,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(46,184,0,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(151,187,205,1)",
data : data3
}
]
};
var myLineChart = new Chart(document.getElementById("tickets-graph").getContext("2d")).Line(buyerData, {
showScale: true,
//Boolean - Whether grid lines are shown across the chart
scaleShowGridLines: false,
//String - Colour of the grid lines
scaleGridLineColor: "rgba(0,0,0,.05)",
//Number - Width of the grid lines
scaleGridLineWidth: 1,
//Boolean - Whether to show horizontal lines (except X axis)
scaleShowHorizontalLines: true,
//Boolean - Whether to show vertical lines (except Y axis)
scaleShowVerticalLines: true,
//Boolean - Whether the line is curved between points
bezierCurve: false,
//Number - Tension of the bezier curve between points
bezierCurveTension: 0.3,
//Boolean - Whether to show a dot for each point
pointDot: true,
//Number - Radius of each point dot in pixels
pointDotRadius: 4,
//Number - Pixel width of point dot stroke
pointDotStrokeWidth: 1,
//Number - amount extra to add to the radius to cater for hit detection outside the drawn point
pointHitDetectionRadius: 20,
//Boolean - Whether to show a stroke for datasets
datasetStroke: true,
//Number - Pixel width of dataset stroke
datasetStrokeWidth: 1,
//Boolean - Whether to fill the dataset with a color
datasetFill: true,
//String - A legend template
//Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: false,
//Boolean - whether to make the chart responsive to window resizing
responsive: true,
legendTemplate : '<ul style="list-style-type: square;">'
+'<% for (var i=0; i<datasets.length; i++) { %>'
+'<li style="color: <%=datasets[i].pointColor%>;">'
+'<span style=\"background-color:<%=datasets[i].pointColor%>\"></span>'
+'<% if (datasets[i].label) { %><%= datasets[i].label %><% } %>'
+'</li>'
+'<% } %>'
+'</ul>'
});
document.getElementById("legendDiv").innerHTML = myLineChart.generateLegend();
});
});
</script>
@stop

View File

@@ -1,16 +1,15 @@
<?php namespace App\Http\Controllers\Agent\helpdesk; <?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
use App\Http\Requests\helpdesk\CannedRequest; use App\Http\Requests\helpdesk\CannedRequest;
use App\Http\Requests\helpdesk\CannedUpdateRequest; use App\Http\Requests\helpdesk\CannedUpdateRequest;
// model // model
use App\Model\helpdesk\Agent_panel\Canned; use App\Model\helpdesk\Agent_panel\Canned;
use App\User; use App\User;
// classes // classes
use Exception; use Exception;
@@ -25,129 +24,129 @@ use Exception;
*/ */
class CannedController extends Controller { class CannedController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
// checking if role is agent // checking if role is agent
$this->middleware('role.agent'); $this->middleware('role.agent');
} }
/** /**
* Display a listing of the Canned Responses. * Display a listing of the Canned Responses.
* @return type View * @return type View
*/ */
public function index() { public function index() {
return view('themes.default1.agent.helpdesk.canned.index'); return view('themes.default1.agent.helpdesk.canned.index');
} }
/** /**
* Show the form for creating a new Canned Response * Show the form for creating a new Canned Response
* @return type View * @return type View
*/ */
public function create() { public function create() {
return view('themes.default1.agent.helpdesk.canned.create'); return view('themes.default1.agent.helpdesk.canned.create');
} }
/** /**
* Store a newly created Canned Response. * Store a newly created Canned Response.
* @param type CannedRequest $request * @param type CannedRequest $request
* @param type Canned $canned * @param type Canned $canned
* @return type Redirect * @return type Redirect
*/ */
public function store(CannedRequest $request, Canned $canned) { public function store(CannedRequest $request, Canned $canned) {
// fetching all the requested inputs // fetching all the requested inputs
$canned->user_id = \Auth::user()->id; $canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title'); $canned->title = $request->input('title');
$canned->message = $request->input('message'); $canned->message = $request->input('message');
try { try {
// saving inputs // saving inputs
$canned->save(); $canned->save();
return redirect()->route('canned.list')->with('success','Added Successfully'); return redirect()->route('canned.list')->with('success', 'Added Successfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->route('canned.list')->with('fails',$e->errorInfo[2]); return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Show the form for editing the Canned Response. * Show the form for editing the Canned Response.
* @param type $id * @param type $id
* @param type Canned $canned * @param type Canned $canned
* @return type View * @return type View
*/ */
public function edit($id, Canned $canned) { public function edit($id, Canned $canned) {
// fetching requested canned response // fetching requested canned response
$canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id','=',$id)->first(); $canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id', '=', $id)->first();
return view('themes.default1.agent.helpdesk.canned.edit',compact('canned')); return view('themes.default1.agent.helpdesk.canned.edit', compact('canned'));
} }
/** /**
* Update the Canned Response in database. * Update the Canned Response in database.
* @param type $id * @param type $id
* @param type CannedUpdateRequest $request * @param type CannedUpdateRequest $request
* @param type Canned $canned * @param type Canned $canned
* @return type Redirect * @return type Redirect
*/ */
public function update($id, CannedUpdateRequest $request, Canned $canned) { public function update($id, CannedUpdateRequest $request, Canned $canned) {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$canned = $canned->where('id','=',$id)->where('user_id', '=', \Auth::user()->id)->first(); $canned = $canned->where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
// fetching all the requested inputs // fetching all the requested inputs
$canned->user_id = \Auth::user()->id; $canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title'); $canned->title = $request->input('title');
$canned->message = $request->input('message'); $canned->message = $request->input('message');
try { try {
// saving inputs // saving inputs
$canned->save(); $canned->save();
return redirect()->route('canned.list')->with('success','Updated Successfully'); return redirect()->route('canned.list')->with('success', 'Updated Successfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->route('canned.list')->with('fails',$e->errorInfo[2]); return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Delete the Canned Response from storage. * Delete the Canned Response from storage.
* @param type $id * @param type $id
* @param type Canned $canned * @param type Canned $canned
* @return type Redirect * @return type Redirect
*/ */
public function destroy($id, Canned $canned) { public function destroy($id, Canned $canned) {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$canned = $canned->whereId($id)->first(); $canned = $canned->whereId($id)->first();
/* delete the selected field */ /* delete the selected field */
/* Check whether function success or not */ /* Check whether function success or not */
try { try {
$canned->delete(); $canned->delete();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect()->route('canned.list')->with('success', 'User Deleted Successfully'); return redirect()->route('canned.list')->with('success', 'User Deleted Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]); return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Fetch Canned Response in the ticket detail page. * Fetch Canned Response in the ticket detail page.
* @param type $id * @param type $id
* @return type json * @return type json
*/ */
public function get_canned($id) { public function get_canned($id) {
// checking for the canned response with requested value // checking for the canned response with requested value
if($id != "zzz") { if ($id != "zzz") {
// fetching canned response // fetching canned response
$canned = Canned::where('id','=',$id)->where('user_id','=',\Auth::user()->id)->first(); $canned = Canned::where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
$msg = $canned->message; $msg = $canned->message;
} else { } else {
$msg = ""; $msg = "";
} }
// returning the canned response in JSON format // returning the canned response in JSON format
return \Response::json($msg); return \Response::json($msg);
} }
} }

View File

@@ -1,14 +1,14 @@
<?php namespace App\Http\Controllers\Agent\helpdesk; <?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// models // models
use App\Model\helpdesk\Settings\Company; use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Ticket\Ticket_Collaborator; use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
use App\User; use App\User;
// classes // classes
use DB; use DB;
use View; use View;
@@ -25,73 +25,71 @@ use Exception;
*/ */
class DashboardController extends Controller { class DashboardController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// checking for authentication // checking for authentication
$this->middleware('auth'); $this->middleware('auth');
// checking if the role is agent // checking if the role is agent
$this->middleware('role.agent'); $this->middleware('role.agent');
} }
/** /**
* Get the dashboard page * Get the dashboard page
* @return type view * @return type view
*/ */
public function index() { public function index() {
// if(Auth::user()->role == "user"){ // if(Auth::user()->role == "user"){
// return \Redirect::route('home'); // return \Redirect::route('home');
// } // }
try { try {
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard'); return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
} catch (Exception $e) { } catch (Exception $e) {
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard'); return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
} }
} }
/** /**
* Fetching dashboard graph data to implement graph * Fetching dashboard graph data to implement graph
* @return type Json * @return type Json
*/ */
public function ChartData($date111 = "",$date122 = "") public function ChartData($date111 = "", $date122 = "") {
{ $date11 = strtotime($date122);
$date12 = strtotime($date111);
$date11 = strtotime($date122); if ($date11 && $date12) {
$date12 = strtotime($date111); $date2 = $date12;
if($date11 && $date12){ $date1 = $date11;
$date2 = $date12; } else {
$date1 = $date11;
} else {
// generating current date // generating current date
$date2 = strtotime(Date('Y-m-d')); $date2 = strtotime(Date('Y-m-d'));
$date3 = Date('Y-m-d'); $date3 = Date('Y-m-d');
$format = 'Y-m-d'; $format = 'Y-m-d';
// generating a date range of 1 month // generating a date range of 1 month
$date1 = strtotime(Date($format,strtotime('-1 month'. $date3))); $date1 = strtotime(Date($format, strtotime('-1 month' . $date3)));
} }
$return = ""; $return = "";
$last = ""; $last = "";
for ( $i = $date1; $i <= $date2; $i = $i + 86400 ) { for ($i = $date1; $i <= $date2; $i = $i + 86400) {
$thisDate = date( 'Y-m-d', $i ); $thisDate = date('Y-m-d', $i);
$created = \DB::table('tickets')->select('created_at')->where('created_at','LIKE','%'.$thisDate.'%')->count(); $created = \DB::table('tickets')->select('created_at')->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at','LIKE','%'.$thisDate.'%')->count(); $closed = \DB::table('tickets')->select('closed_at')->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at','LIKE','%'.$thisDate.'%')->count(); $reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened]; $value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
$array = array_map('htmlentities',$value); $array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array)); $json = html_entity_decode(json_encode($array));
$return .= $json.','; $return .= $json . ',';
} }
$last = rtrim($return,','); $last = rtrim($return, ',');
return '['.$last.']'; return '[' . $last . ']';
// $ticketlist = DB::table('tickets') // $ticketlist = DB::table('tickets')
// ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),DB::raw('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'), // ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),DB::raw('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'),
@@ -99,7 +97,6 @@ class DashboardController extends Controller {
// ->groupBy('month') // ->groupBy('month')
// ->orderBy('month', 'asc') // ->orderBy('month', 'asc')
// ->get(); // ->get();
// return $ticketlist; // return $ticketlist;
} }

View File

@@ -1,8 +1,10 @@
<?php namespace App\Http\Controllers\Agent\helpdesk; <?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
// models // models
use App\User; use App\User;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
@@ -10,17 +12,17 @@ use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Ticket_attachments; use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_Thread; use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Settings\System; use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Ticket;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Utility\MailboxProtocol; use App\Model\helpdesk\Utility\MailboxProtocol;
use App\Model\helpdesk\Ticket\Ticket_source; use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Priority; use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
// classes // classes
use PhpImap\Mailbox as ImapMailbox; use PhpImap\Mailbox as ImapMailbox;
use PhpImap\IncomingMail; use PhpImap\IncomingMail;
use PhpImap\IncomingMailAttachment; use PhpImap\IncomingMailAttachment;
use ForceUTF8\Encoding; use \ForceUTF8\Encoding;
use App; use App;
use DB; use DB;
use Crypt; use Crypt;
@@ -28,9 +30,7 @@ use Schedule;
use File; use File;
use Artisan; use Artisan;
use Exception; use Exception;
use Phpmailer\PHPMailerautoload;
//$root = realpath($_SERVER["DOCUMENT_ROOT"]);
//include_once($root.'\vendor\phpmailer\phpmailer\PHPMailerautoload.php');
/** /**
* MailController * MailController
* *
@@ -40,211 +40,218 @@ use Phpmailer\PHPMailerautoload;
*/ */
class MailController extends Controller { class MailController extends Controller {
/** /**
* constructor * constructor
* Create a new controller instance. * Create a new controller instance.
* @param type TicketController $TicketController * @param type TicketController $TicketController
*/ */
public function __construct(TicketController $TicketController) { public function __construct(TicketController $TicketController) {
$this->TicketController = $TicketController; $this->TicketController = $TicketController;
} }
/** /**
* Reademails * Reademails
* @return type * @return type
*/ */
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) {
// $path_url = $system->first()->url;
if ($settings_email->first()->email_fetching == 1) {
if ($settings_email->first()->all_emails == 1) {
// $helptopic = $this->TicketController->default_helptopic();
// $sla = $this->TicketController->default_sla();
$email = $emails->get();
foreach ($email as $e_mail) {
$priority = $e_mail->priority;
$dept = $e_mail->department;
$helptopic = $e_mail->help_topic;
if ($priority == null) {
$priority = $ticket->first()->priority;
}
public function readmails(Emails $emails, Email $settings_email, System $system) if ($dept == null) {
{ $dept = $system->first()->department;
// $path_url = $system->first()->url; }
if($settings_email->first()->email_fetching == 1)
{
if($settings_email->first()->all_emails == 1)
{
// $helptopic = $this->TicketController->default_helptopic();
// $sla = $this->TicketController->default_sla();
$email = $emails->get();
foreach($email as $e_mail)
{
$helptopic = $e_mail->help_topic;
$get_helptopic = Help_topic::where('id', '=', $helptopic)->first();
$sla = $get_helptopic->sla_plan;
$dept = $e_mail->department;
$host = $e_mail->fetching_host;
$port = $e_mail->fetching_port;
$protocol = $e_mail->mailbox_protocol;
$get_mailboxprotocol = MailboxProtocol::where('id','=',$protocol)->first();
$protocol = $get_mailboxprotocol->value;
$imap_config = '{'.$host.':'.$port.$protocol.'}INBOX';
$password = Crypt::decrypt($e_mail->password);
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
$mails = array();
$mailsIds = $mailbox->searchMailBox('SINCE '. date('d-M-Y', strtotime("-1 day")));
if(!$mailsIds) {
die('Mailbox is empty');
}
foreach($mailsIds as $mailId) {
$overview = $mailbox->get_overview($mailId);
$var = $overview[0]->seen ? 'read' : 'unread';
if ($var == 'unread') {
$mail = $mailbox->getMail($mailId);
if($settings_email->first()->email_collaborator == 1) {
$collaborator = $mail->cc;
} else {
$collaborator = null;
}
$body = $mail->textHtml;
if($body == null) {
$body = $mailbox->backup_getmail($mailId);
$body = str_replace('\r\n', '<br/>', $body);
// var_dump($body);
}
$date = $mail->date;
$datetime = $overview[0]->date;
$date_time = explode(" ", $datetime);
$date = $date_time[1] . "-" . $date_time[2] . "-" . $date_time[3] . " " . $date_time[4];
$date = date('Y-m-d H:i:s', strtotime($date));
// dd($date);
if(isset($mail->subject)){ if ($helptopic == null) {
$subject = $mail->subject; $helptopic = $ticket->first()->help_topic;
} else { }
$subject = "No Subject"; // dd($dept);
}
// dd($subject); $get_helptopic = Help_topic::where('id', '=', $helptopic)->first();
$fromname = $mail->fromName; $sla = $get_helptopic->sla_plan;
$fromaddress = $mail->fromAddress; // $dept = $e_mail->department;
$ticket_source = Ticket_source::where('name','=','email')->first(); $host = $e_mail->fetching_host;
$source = $ticket_source->id; $port = $e_mail->fetching_port;
$phone = ""; $protocol = $e_mail->mailbox_protocol;
$priority = $get_helptopic->priority; $get_mailboxprotocol = MailboxProtocol::where('id', '=', $protocol)->first();
// Ticket_Priority::where('') $protocol = $get_mailboxprotocol->value;
$imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX';
$password = Crypt::decrypt($e_mail->password);
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
$mails = array();
$mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime("-1 day")));
if (!$mailsIds) {
die('Mailbox is empty');
}
foreach ($mailsIds as $mailId) {
$overview = $mailbox->get_overview($mailId);
$var = $overview[0]->seen ? 'read' : 'unread';
if ($var == 'unread') {
$mail = $mailbox->getMail($mailId);
if ($settings_email->first()->email_collaborator == 1) {
$collaborator = $mail->cc;
} else {
$collaborator = null;
}
$body = $mail->textHtml;
if ($body == null) {
$body = $mailbox->backup_getmail($mailId);
$body = str_replace('\r\n', '<br/>', $body);
// var_dump($body);
}
$date = $mail->date;
$datetime = $overview[0]->date;
$date_time = explode(" ", $datetime);
$date = $date_time[1] . "-" . $date_time[2] . "-" . $date_time[3] . " " . $date_time[4];
$date = date('Y-m-d H:i:s', strtotime($date));
// dd($date);
$assign = $get_helptopic->auto_assign; if (isset($mail->subject)) {
$form_data = null; $subject = $mail->subject;
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data); } else {
// dd($result); $subject = "No Subject";
if ($result[1] == true) { }
$ticket_table = Tickets::where('ticket_number', '=' , $result[0])->first();
$thread_id = Ticket_Thread::where('ticket_id','=',$ticket_table->id)->max('id');
// $thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
$thread_id = $thread_id;
foreach($mail->getAttachments() as $attachment) { // dd($subject);
$support = "support"; $fromname = $mail->fromName;
// echo $_SERVER['DOCUMENT_ROOT']; $fromaddress = $mail->fromAddress;
$dir_img_paths = __DIR__; $ticket_source = Ticket_source::where('name', '=', 'email')->first();
$dir_img_path = explode('/code', $dir_img_paths); $source = $ticket_source->id;
// dd($attachment->filePath); $phone = "";
$filepath = explode('../../../../../public',$attachment->filePath);
// var_dump($attachment->filePath);
// dd($filepath);
// $path = $dir_img_path[0]."/code/public/".$filepath[1];
$path = public_path().$filepath[1];
// dd($path);
$filesize = filesize($path);
$file_data = file_get_contents($path);
$ext = pathinfo($attachment->filePath, PATHINFO_EXTENSION);
$imageid = $attachment->id;
$string = str_replace('-', '', $attachment->name);
$filename = explode('src', $attachment->filePath);
$filename = str_replace('\\', '', $filename);
$body = str_replace("cid:".$imageid, $filepath[1], $body);
$pos = strpos($body, $filepath[1]);
if($pos == false) { $assign = $get_helptopic->auto_assign;
if($settings_email->first()->attachment == 1) { $form_data = null;
$upload = new Ticket_attachments; $result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data);
$upload->file = $file_data; // dd($result);
$upload->thread_id = $thread_id; if ($result[1] == true) {
$upload->name = $filepath[1]; $ticket_table = Tickets::where('ticket_number', '=', $result[0])->first();
$upload->type = $ext; $thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
$upload->size = $filesize; // $thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
$upload->poster = "ATTACHMENT"; $thread_id = $thread_id;
$upload->save();
foreach ($mail->getAttachments() as $attachment) {
$support = "support";
// echo $_SERVER['DOCUMENT_ROOT'];
$dir_img_paths = __DIR__;
$dir_img_path = explode('/code', $dir_img_paths);
// dd($attachment->filePath);
$filepath = explode('../../../../../public', $attachment->filePath);
// var_dump($attachment->filePath);
// dd($filepath);
// $path = $dir_img_path[0]."/code/public/".$filepath[1];
$path = public_path() . $filepath[1];
// dd($path);
$filesize = filesize($path);
$file_data = file_get_contents($path);
$ext = pathinfo($attachment->filePath, PATHINFO_EXTENSION);
$imageid = $attachment->id;
$string = str_replace('-', '', $attachment->name);
$filename = explode('src', $attachment->filePath);
$filename = str_replace('\\', '', $filename);
$body = str_replace("cid:" . $imageid, $filepath[1], $body);
$pos = strpos($body, $filepath[1]);
if ($pos == false) {
if ($settings_email->first()->attachment == 1) {
$upload = new Ticket_attachments;
$upload->file = $file_data;
$upload->thread_id = $thread_id;
$upload->name = $filepath[1];
$upload->type = $ext;
$upload->size = $filesize;
$upload->poster = "ATTACHMENT";
$upload->save();
}
} else {
$upload = new Ticket_attachments;
$upload->file = $file_data;
$upload->thread_id = $thread_id;
$upload->name = $filepath[1];
$upload->type = $ext;
$upload->size = $filesize;
$upload->poster = "INLINE";
$upload->save();
}
unlink($path);
} }
} else { $body = Encoding::fixUTF8($body);
$upload = new Ticket_attachments; $thread = Ticket_Thread::where('id', '=', $thread_id)->first();
$upload->file = $file_data; $thread->body = $this->separate_reply($body);
$upload->thread_id = $thread_id; $thread->save();
$upload->name = $filepath[1]; }
$upload->type = $ext; }
$upload->size = $filesize; }
$upload->poster = "INLINE"; }
$upload->save(); }
} }
unlink($path); }
}
$body = Encoding::fixUTF8($body);
$thread = Ticket_Thread::where('id','=',$thread_id)->first();
$thread->body = $this->separate_reply($body) ;
$thread->save();
}
}
}
}
}
}
}
/** /**
* separate reply * separate reply
* @param type $body * @param type $body
* @return type string * @return type string
*/ */
public function separate_reply($body) { public function separate_reply($body) {
$body2 = explode('---Reply above this line---', $body); $body2 = explode('---Reply above this line---', $body);
$body3 = $body2[0]; $body3 = $body2[0];
return $body3; return $body3;
} }
/** /**
* Decode Imap text * Decode Imap text
* @param type $str * @param type $str
* @return type string * @return type string
*/ */
public function decode_imap_text($str) { public function decode_imap_text($str) {
$result = ''; $result = '';
$decode_header = imap_mime_header_decode($str); $decode_header = imap_mime_header_decode($str);
foreach ($decode_header AS $obj) { foreach ($decode_header AS $obj) {
$result .= htmlspecialchars(rtrim($obj->text, "\t")); $result .= htmlspecialchars(rtrim($obj->text, "\t"));
} }
return $result; return $result;
} }
/** /**
* fetch_attachments * fetch_attachments
* @return type * @return type
*/ */
public function fetch_attachments(){ public function fetch_attachments() {
$uploads = Upload::all(); $uploads = Upload::all();
foreach($uploads as $attachment) { foreach ($uploads as $attachment) {
$image = @imagecreatefromstring($attachment->file); $image = @imagecreatefromstring($attachment->file);
ob_start(); ob_start();
imagejpeg($image, null, 80); imagejpeg($image, null, 80);
$data = ob_get_contents(); $data = ob_get_contents();
ob_end_clean(); ob_end_clean();
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>'; $var = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
echo '<br/><span class="mailbox-attachment-icon has-img">'.$var.'</span>'; echo '<br/><span class="mailbox-attachment-icon has-img">' . $var . '</span>';
} }
} }
/** /**
* function to load data * function to load data
* @param type $id * @param type $id
* @return type file * @return type file
*/ */
public function get_data($id){ public function get_data($id) {
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id','=',$id)->get(); $attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
foreach($attachments as $attachment) foreach ($attachments as $attachment) {
{ header('Content-type: application/' . $attachment->type . '');
header('Content-type: application/'.$attachment->type.''); header('Content-Disposition: inline; filename=' . $attachment->name . '');
header('Content-Disposition: inline; filename='.$attachment->name.''); header('Content-Transfer-Encoding: binary');
header('Content-Transfer-Encoding: binary'); echo $attachment->file;
echo $attachment->file; }
} }
}
} }

View File

@@ -1,8 +1,9 @@
<?php namespace App\Http\Controllers\Agent\helpdesk; <?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// Model // Model
use App\User; use App\User;
use App\Model\helpdesk\Settings\Company; use App\Model\helpdesk\Settings\Company;
@@ -10,7 +11,6 @@ use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Utility\Log_notification; use App\Model\helpdesk\Utility\Log_notification;
use App\Model\helpdesk\settings\Email; use App\Model\helpdesk\settings\Email;
// classes // classes
use Exception; use Exception;
@@ -24,138 +24,138 @@ use Exception;
*/ */
class NotificationController extends Controller { class NotificationController extends Controller {
/** /**
* This function is for sending daily report/notification about the system * This function is for sending daily report/notification about the system
**/ * */
public function send_notification() { public function send_notification() {
//fetching email settings //fetching email settings
$email = Email::where('id','=','1')->first(); $email = Email::where('id', '=', '1')->first();
// checking if the daily notification is enabled or not // checking if the daily notification is enabled or not
if($email->notification_cron == 1){ if ($email->notification_cron == 1) {
// checking if current date is equal to the last entered daily notification log // checking if current date is equal to the last entered daily notification log
$notification = Log_notification::where('log','=','NOT-1')->orderBy('id','DESC')->first(); $notification = Log_notification::where('log', '=', 'NOT-1')->orderBy('id', 'DESC')->first();
$date = explode(" " , $notification->created_at); $date = explode(" ", $notification->created_at);
if(Date('Y-m-d') == $date[0]){ if (Date('Y-m-d') == $date[0]) {
} else {
// creating a daily notification log
Log_notification::create(['log'=>'NOT-1']);
$company = $this->company();
// Send notification details to admin
$this->send_notification_to_admin($company);
// Send notification details to team lead
$this->send_notification_to_team_lead($company);
// Send notification details to manager of a department
$this->send_notification_to_manager($company);
// Send notification details to all the agents
$this->send_notification_to_agent($company);
}
}
}
/** } else {
* Admin Notification/Report // creating a daily notification log
* @param company Log_notification::create(['log' => 'NOT-1']);
* @return mail $company = $this->company();
**/ // Send notification details to admin
public function send_notification_to_admin($company) { $this->send_notification_to_admin($company);
// get all admin users // Send notification details to team lead
$users = User::where('role','=','admin')->get(); $this->send_notification_to_team_lead($company);
foreach ($users as $user) { // Send notification details to manager of a department
// Send notification details to admin $this->send_notification_to_manager($company);
$email = $user->email; // Send notification details to all the agents
$user_name = $user->first_name . " " . $user->last_name; $this->send_notification_to_agent($company);
\Mail::send('emails.notifications.admin', ['company' => $company, 'name'=>$user_name], function ($message)use ($email, $user_name, $company) { }
$message->to($email, $user_name)->subject($company . ' Daily Report '); }
}); }
}
}
/** /**
* Department Manager Notification/Report * Admin Notification/Report
* @return mail * @param company
**/ * @return mail
public function send_notification_to_manager($company) { * */
// get all department managers public function send_notification_to_admin($company) {
$depts = Department::all(); // get all admin users
foreach ($depts as $dept) { $users = User::where('role', '=', 'admin')->get();
if(isset($dept->manager)) { foreach ($users as $user) {
$dept_name = $dept->name; // Send notification details to admin
$users = User::where('id','=',$dept->manager)->get(); $email = $user->email;
foreach ($users as $user) { $user_name = $user->first_name . " " . $user->last_name;
// Send notification details to manager of a department \Mail::send('emails.notifications.admin', ['company' => $company, 'name' => $user_name], function ($message)use ($email, $user_name, $company) {
$email = $user->email; $message->to($email, $user_name)->subject($company . ' Daily Report ');
$user_name = $user->first_name . " " . $user->last_name; });
\Mail::send('emails.notifications.manager', ['company' => $company, 'name'=>$user_name,'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message)use ($email, $user_name, $company, $dept_name) { }
$message->to($email, $user_name)->subject($company . ' Daily Report for department manager of '. $dept_name.' department.'); }
});
}
}
}
}
/** /**
* Team Lead Notification/Report * Department Manager Notification/Report
* @return mail * @return mail
**/ * */
public function send_notification_to_team_lead($company) { public function send_notification_to_manager($company) {
// get all Team leads // get all department managers
$teams = Teams::all(); $depts = Department::all();
foreach ($teams as $team) { foreach ($depts as $dept) {
if(isset($team->team_lead)) { if (isset($dept->manager)) {
$team_name = $team->name; $dept_name = $dept->name;
$users = User::where('id','=',$team->team_lead)->get(); $users = User::where('id', '=', $dept->manager)->get();
foreach ($users as $user) { foreach ($users as $user) {
// Send notification details to team lead // Send notification details to manager of a department
$email = $user->email; $email = $user->email;
$user_name = $user->first_name . " " . $user->last_name; $user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.lead', ['company' => $company, 'name'=>$user_name,'team_id' => $team->id], function ($message)use ($email, $user_name, $company, $team_name) { \Mail::send('emails.notifications.manager', ['company' => $company, 'name' => $user_name, 'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message)use ($email, $user_name, $company, $dept_name) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Team Lead of team '. $team_name); $message->to($email, $user_name)->subject($company . ' Daily Report for department manager of ' . $dept_name . ' department.');
}); });
} }
} }
} }
} }
/** /**
* Agent Notification/Report * Team Lead Notification/Report
* @return mail * @return mail
**/ * */
public function send_notification_to_agent($company) { public function send_notification_to_team_lead($company) {
// get all agents users // get all Team leads
$users = User::where('role','=','agent')->get(); $teams = Teams::all();
foreach ($users as $user) { foreach ($teams as $team) {
// Send notification details to all the agents if (isset($team->team_lead)) {
$email = $user->email; $team_name = $team->name;
$user_name = $user->first_name . " " . $user->last_name; $users = User::where('id', '=', $team->team_lead)->get();
\Mail::send('emails.notifications.agent', ['company' => $company, 'name'=>$user_name, 'user_id' => 1], function ($message)use ($email, $user_name, $company) { foreach ($users as $user) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Agents'); // Send notification details to team lead
}); $email = $user->email;
} $user_name = $user->first_name . " " . $user->last_name;
} \Mail::send('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id], function ($message)use ($email, $user_name, $company, $team_name) {
$message->to($email, $user_name)->subject($company . ' Daily Report for Team Lead of team ' . $team_name);
});
}
}
}
}
/** /**
* Fetching company name * Agent Notification/Report
* @return type variable * @return mail
*/ * */
public function company() { public function send_notification_to_agent($company) {
// fetching comapny model // get all agents users
$company = Company::Where('id','=','1')->first(); $users = User::where('role', '=', 'agent')->get();
// fetching company name foreach ($users as $user) {
if($company->company_name == null){ // Send notification details to all the agents
$company = "Support Center"; $email = $user->email;
}else{ $user_name = $user->first_name . " " . $user->last_name;
$company = $company->company_name; \Mail::send('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => 1], function ($message)use ($email, $user_name, $company) {
} $message->to($email, $user_name)->subject($company . ' Daily Report for Agents');
return $company; });
} }
}
// // testing /**
// public function test(){ * Fetching company name
// $email = "sujit.prasad@ladybirdweb.com"; * @return type variable
// $user_name = "sujit prasad"; */
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) { public function company() {
// $message->to($email, $user_name)->subject('testing reporting'); // fetching comapny model
// }); $company = Company::Where('id', '=', '1')->first();
// } // fetching company name
if ($company->company_name == null) {
$company = "Support Center";
} else {
$company = $company->company_name;
}
return $company;
}
// // testing
// public function test(){
// $email = "sujit.prasad@ladybirdweb.com";
// $user_name = "sujit prasad";
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
// $message->to($email, $user_name)->subject('testing reporting');
// });
// }
} }

View File

@@ -1,13 +1,14 @@
<?php namespace App\Http\Controllers\Agent\helpdesk; <?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
use App\Http\Requests\helpdesk\OrganizationRequest; use App\Http\Requests\helpdesk\OrganizationRequest;
/* include organization model */ /* include organization model */
use App\Http\Requests\helpdesk\OrganizationUpdate; use App\Http\Requests\helpdesk\OrganizationUpdate;
// models // models
/* Define OrganizationRequest to validate the create form */ /* Define OrganizationRequest to validate the create form */
use App\Model\helpdesk\Agent_panel\Organization; use App\Model\helpdesk\Agent_panel\Organization;
@@ -27,73 +28,73 @@ use Exception;
*/ */
class OrganizationController extends Controller { class OrganizationController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// checking for authentication // checking for authentication
$this->middleware('auth'); $this->middleware('auth');
// checking if the role is agent // checking if the role is agent
$this->middleware('role.agent'); $this->middleware('role.agent');
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* @param type Organization $org * @param type Organization $org
* @return type Response * @return type Response
*/ */
public function index() { public function index() {
try { try {
/* get all values of table organization */ /* get all values of table organization */
return view('themes.default1.agent.helpdesk.organization.index'); return view('themes.default1.agent.helpdesk.organization.index');
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* This function is used to display the list of Organizations * This function is used to display the list of Organizations
* @return datatable * @return datatable
*/ */
public function org_list() { public function org_list() {
// chumper datable package call to display Advance datatable // chumper datable package call to display Advance datatable
return \Datatable::collection(Organization::all()) return \Datatable::collection(Organization::all())
/* searchable name */ /* searchable name */
->searchColumns('name') ->searchColumns('name')
/* order by name and website */ /* order by name and website */
->orderColumns('name', 'website') ->orderColumns('name', 'website')
/* column name */ /* column name */
->addColumn('name', function ($model) { ->addColumn('name', function ($model) {
// return $model->name; // return $model->name;
if(strlen($model->name) > 20) { if (strlen($model->name) > 20) {
$orgname = substr($model->name, 0, 25); $orgname = substr($model->name, 0, 25);
$orgname = substr($orgname, 0, strrpos($orgname, ' ')).' ...'; $orgname = substr($orgname, 0, strrpos($orgname, ' ')) . ' ...';
} else { } else {
$orgname = $model->name; $orgname = $model->name;
} }
return $orgname; return $orgname;
}) })
/* column website */ /* column website */
->addColumn('website', function ($model) { ->addColumn('website', function ($model) {
$website = $model->website; $website = $model->website;
return $website; return $website;
}) })
/* column phone number */ /* column phone number */
->addColumn('phone', function ($model) { ->addColumn('phone', function ($model) {
$phone = $model->phone; $phone = $model->phone;
return $phone; return $phone;
}) })
/* column action buttons */ /* column action buttons */
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
// displaying action buttons // displaying action buttons
// modal popup to delete data // modal popup to delete data
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id .'"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href="'.route('organizations.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href="'.route('organizations.show', $model->id).'" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a> return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href="' . route('organizations.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href="' . route('organizations.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle'.$model->id .'"> <div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@@ -101,154 +102,154 @@ class OrganizationController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4> <h4 class="modal-title">Are You Sure ?</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
'.$model->user_name.' ' . $model->user_name . '
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
<a href="'.route('org.delete',$model->id).'"><button class="btn btn-danger">delete</button></a> <a href="' . route('org.delete', $model->id) . '"><button class="btn btn-danger">delete</button></a>
</div> </div>
</div><!-- /.modal-content --> </div><!-- /.modal-content -->
</div><!-- /.modal-dialog --> </div><!-- /.modal-dialog -->
</div>'; </div>';
}) })
->make(); ->make();
} }
/** /**
* Show the form for creating a new organization. * Show the form for creating a new organization.
* @return type Response * @return type Response
*/ */
public function create() { public function create() {
try { try {
return view('themes.default1.agent.helpdesk.organization.create'); return view('themes.default1.agent.helpdesk.organization.create');
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Store a newly created organization in storage. * Store a newly created organization in storage.
* @param type Organization $org * @param type Organization $org
* @param type OrganizationRequest $request * @param type OrganizationRequest $request
* @return type Redirect * @return type Redirect
*/ */
public function store(Organization $org, OrganizationRequest $request) { public function store(Organization $org, OrganizationRequest $request) {
try { try {
/* Insert the all input request to organization table */ /* Insert the all input request to organization table */
/* Check whether function success or not */ /* Check whether function success or not */
if ($org->fill($request->input())->save() == true) { if ($org->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Created Successfully'); return redirect('organizations')->with('success', 'Organization Created Successfully');
} else { } else {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create'); return redirect('organizations')->with('fails', 'Organization can not Create');
} }
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create'); return redirect('organizations')->with('fails', 'Organization can not Create');
} }
} }
/** /**
* Display the specified organization. * Display the specified organization.
* @param type $id * @param type $id
* @param type Organization $org * @param type Organization $org
* @return type view * @return type view
*/ */
public function show($id, Organization $org) { public function show($id, Organization $org) {
try { try {
/* select the field by id */ /* select the field by id */
$orgs = $org->whereId($id)->first(); $orgs = $org->whereId($id)->first();
/* To view page */ /* To view page */
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs')); return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Show the form for editing the specified organization. * Show the form for editing the specified organization.
* @param type $id * @param type $id
* @param type Organization $org * @param type Organization $org
* @return type view * @return type view
*/ */
public function edit($id, Organization $org) { public function edit($id, Organization $org) {
try { try {
/* select the field by id */ /* select the field by id */
$orgs = $org->whereId($id)->first(); $orgs = $org->whereId($id)->first();
/* To view page */ /* To view page */
return view('themes.default1.agent.helpdesk.organization.edit', compact('orgs')); return view('themes.default1.agent.helpdesk.organization.edit', compact('orgs'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Update the specified organization in storage. * Update the specified organization in storage.
* @param type $id * @param type $id
* @param type Organization $org * @param type Organization $org
* @param type OrganizationUpdate $request * @param type OrganizationUpdate $request
* @return type Redirect * @return type Redirect
*/ */
public function update($id, Organization $org, OrganizationUpdate $request) { public function update($id, Organization $org, OrganizationUpdate $request) {
/* select the field by id */ /* select the field by id */
$orgs = $org->whereId($id)->first(); $orgs = $org->whereId($id)->first();
/* update the organization table */ /* update the organization table */
/* Check whether function success or not */ /* Check whether function success or not */
try { try {
if ($orgs->fill($request->input())->save() == true) { if ($orgs->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Updated Successfully'); return redirect('organizations')->with('success', 'Organization Updated Successfully');
} else { } else {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Update'); return redirect('organizations')->with('fails', 'Organization can not Update');
} }
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]); return redirect('organizations')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Delete a specified organization from storage. * Delete a specified organization from storage.
* @param type int $id * @param type int $id
* @return type Redirect * @return type Redirect
*/ */
public function destroy($id, Organization $org, User_org $user_org) { public function destroy($id, Organization $org, User_org $user_org) {
/* select the field by id */ /* select the field by id */
$orgs = $org->whereId($id)->first(); $orgs = $org->whereId($id)->first();
$user_orgs = $user_org->where('org_id','=',$id)->get(); $user_orgs = $user_org->where('org_id', '=', $id)->get();
foreach ($user_orgs as $user_org) { foreach ($user_orgs as $user_org) {
$user_org->delete(); $user_org->delete();
} }
/* Delete the field selected from the table */ /* Delete the field selected from the table */
/* Check whether function success or not */ /* Check whether function success or not */
try { try {
$orgs->delete(); $orgs->delete();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Deleted Successfully'); return redirect('organizations')->with('success', 'Organization Deleted Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]); return redirect('organizations')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Soring an organization head * Soring an organization head
* @param type $id * @param type $id
* @return type boolean * @return type boolean
*/ */
public function Head_Org($id){ public function Head_Org($id) {
// get the user to make organization head // get the user to make organization head
$head_user = \Input::get('user'); $head_user = \Input::get('user');
// get an instance of the selected organization // get an instance of the selected organization
$org_head = Organization::where('id','=',$id)->first(); $org_head = Organization::where('id', '=', $id)->first();
$org_head->head = $head_user; $org_head->head = $head_user;
// save the user to organization head // save the user to organization head
$org_head->save(); $org_head->save();
return 1; return 1;
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Agent\helpdesk; <?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
@@ -36,64 +39,64 @@ use PDF;
*/ */
class Ticket2Controller extends Controller { class Ticket2Controller extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type response * @return type response
*/ */
public function __construct() { public function __construct() {
SettingsController::smtp(); SettingsController::smtp();
$this->middleware('auth'); $this->middleware('auth');
} }
/** /**
* Show the Inbox ticket list page * Show the Inbox ticket list page
* @return type response * @return type response
*/ */
public function deptopen($id) { public function deptopen($id) {
$dept = Department::where('name','=',$id)->first(); $dept = Department::where('name', '=', $id)->first();
if(Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) { if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.open',compact('id')); return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
} else { } else {
return redirect()->back()->with('fails','Unauthorised!'); return redirect()->back()->with('fails', 'Unauthorised!');
} }
} else { } else {
return view('themes.default1.agent.helpdesk.dept-ticket.open',compact('id')); return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
} }
} }
/** /**
* Show the Inbox ticket list page * Show the Inbox ticket list page
* @return type response * @return type response
*/ */
public function deptclose($id) { public function deptclose($id) {
$dept = Department::where('name','=',$id)->first(); $dept = Department::where('name', '=', $id)->first();
if(Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) { if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.closed',compact('id')); return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
} else { } else {
return redirect()->back()->with('fails','Unauthorised!'); return redirect()->back()->with('fails', 'Unauthorised!');
} }
} else { } else {
return view('themes.default1.agent.helpdesk.dept-ticket.closed',compact('id')); return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
} }
} }
/** /**
* Show the Inbox ticket list page * Show the Inbox ticket list page
* @return type response * @return type response
*/ */
public function deptinprogress($id) { public function deptinprogress($id) {
$dept = Department::where('name','=',$id)->first(); $dept = Department::where('name', '=', $id)->first();
if(Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) { if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress',compact('id')); return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
} else { } else {
return redirect()->back()->with('fails','Unauthorised!'); return redirect()->back()->with('fails', 'Unauthorised!');
} }
} else { } else {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress',compact('id')); return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,9 @@
<?php namespace App\Http\Controllers\Agent\helpdesk; <?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
/* Include Sys_user Model */ /* Include Sys_user Model */
use App\Http\Requests\helpdesk\ProfilePassword; use App\Http\Requests\helpdesk\ProfilePassword;
@@ -11,12 +13,10 @@ use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\Sys_userRequest; use App\Http\Requests\helpdesk\Sys_userRequest;
/* include guest_note model */ /* include guest_note model */
use App\Http\Requests\helpdesk\Sys_userUpdate; use App\Http\Requests\helpdesk\Sys_userUpdate;
// models // models
use App\Model\helpdesk\Agent_panel\Organization; use App\Model\helpdesk\Agent_panel\Organization;
use App\Model\helpdesk\Agent_panel\User_org; use App\Model\helpdesk\Agent_panel\User_org;
use App\User; use App\User;
// classes // classes
use Auth; use Auth;
use Hash; use Hash;
@@ -34,350 +34,350 @@ use Exception;
*/ */
class UserController extends Controller { class UserController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
// checking if role is agent // checking if role is agent
$this->middleware('role.agent'); $this->middleware('role.agent');
} }
/** /**
* Display all list of the users. * Display all list of the users.
* @param type User $user * @param type User $user
* @return type view * @return type view
*/ */
public function index() { public function index() {
try { try {
/* get all values in Sys_user */ /* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index'); return view('themes.default1.agent.helpdesk.user.index');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* This function is used to display the list of users using chumper datatables * This function is used to display the list of users using chumper datatables
* @return datatable * @return datatable
*/ */
public function user_list() { public function user_list() {
// displaying list of users with chumper datatables // displaying list of users with chumper datatables
return \Datatable::collection(User::where('role','!=','admin')->where('role','!=','agent')->get()) return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
/* searchable column username */ /* searchable column username */
->searchColumns('user_name') ->searchColumns('user_name')
/* order column username and email */ /* order column username and email */
->orderColumns('user_name', 'email') ->orderColumns('user_name', 'email')
/* column username */ /* column username */
->addColumn('user_name', function ($model) { ->addColumn('user_name', function ($model) {
if(strlen($model->user_name) > 20) { if (strlen($model->user_name) > 20) {
$username = substr($model->user_name, 0, 30); $username = substr($model->user_name, 0, 30);
$username = substr($username, 0, strrpos($username, ' ')).' ...'; $username = substr($username, 0, strrpos($username, ' ')) . ' ...';
} else { } else {
$username = $model->user_name; $username = $model->user_name;
} }
return $username; return $username;
}) })
/* column email */ /* column email */
->addColumn('email', function ($model) { ->addColumn('email', function ($model) {
$email = $model->email; $email = $model->email;
return $email; return $email;
}) })
/* column phone */ /* column phone */
->addColumn('phone', function ($model) { ->addColumn('phone', function ($model) {
$phone = ""; $phone = "";
if($model->phone_number) { if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number; $phone = $model->ext . ' ' . $model->phone_number;
} }
$mobile = ""; $mobile = "";
if($model->mobile) { if ($model->mobile) {
$mobile = $model->mobile; $mobile = $model->mobile;
} }
$phone = $phone ."&nbsp;&nbsp;&nbsp;". $mobile; $phone = $phone . "&nbsp;&nbsp;&nbsp;" . $mobile;
return $phone; return $phone;
}) })
/* column account status */ /* column account status */
->addColumn('status', function ($model) { ->addColumn('status', function ($model) {
$status = $model->active; $status = $model->active;
if($status == 1) { if ($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>'; $stat = '<button class="btn btn-success btn-xs">Active</button>';
} else { } else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>'; $stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
} }
return $stat; return $stat;
}) })
/* column ban status */ /* column ban status */
->addColumn('ban', function ($model) { ->addColumn('ban', function ($model) {
$status = $model->ban; $status = $model->ban;
if($status == 1) { if ($status == 1) {
$stat = '<button class="btn btn-danger btn-xs">Banned</button>'; $stat = '<button class="btn btn-danger btn-xs">Banned</button>';
} else { } else {
$stat = '<button class="btn btn-success btn-xs">Active</button>'; $stat = '<button class="btn btn-success btn-xs">Active</button>';
} }
return $stat; return $stat;
}) })
/* column last login date */ /* column last login date */
->addColumn('lastlogin', function ($model) { ->addColumn('lastlogin', function ($model) {
$t = $model->updated_at; $t = $model->updated_at;
return TicketController::usertimezone($t); return TicketController::usertimezone($t);
}) })
/* column actions */ /* column actions */
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp; <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>'; return '<a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp; <a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
}) })
->make(); ->make();
} }
/** /**
* Show the form for creating a new users. * Show the form for creating a new users.
* @return type view * @return type view
*/ */
public function create() { public function create() {
try { try {
return view('themes.default1.agent.helpdesk.user.create'); return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Store a newly created users in storage. * Store a newly created users in storage.
* @param type User $user * @param type User $user
* @param type Sys_userRequest $request * @param type Sys_userRequest $request
* @return type redirect * @return type redirect
*/ */
public function store(User $user, Sys_userRequest $request) { public function store(User $user, Sys_userRequest $request) {
/* insert the input request to sys_user table */ /* insert the input request to sys_user table */
/* Check whether function success or not */ /* Check whether function success or not */
$user->email = $request->input('email'); $user->email = $request->input('email');
$user->user_name = $request->input('full_name'); $user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile'); $user->mobile = $request->input('mobile');
$user->ext = $request->input('ext'); $user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number'); $user->phone_number = $request->input('phone_number');
$user->active = $request->input('active'); $user->active = $request->input('active');
$user->internal_note = $request->input('internal_note'); $user->internal_note = $request->input('internal_note');
$user->role = 'user'; $user->role = 'user';
try { try {
$user->save(); $user->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully'); return redirect('user')->with('success', 'User Created Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('user')->with('fails', $e->errorInfo[2]); return redirect('user')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Display the specified users. * Display the specified users.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @return type view * @return type view
*/ */
public function show($id, User $user) { public function show($id, User $user) {
try { try {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first(); $users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users')); return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @return type Response * @return type Response
*/ */
public function edit($id, User $user) { public function edit($id, User $user) {
try { try {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first(); $users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users')); return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Update the specified user in storage. * Update the specified user in storage.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @param type Sys_userUpdate $request * @param type Sys_userUpdate $request
* @return type Response * @return type Response
*/ */
public function update($id, User $user, Sys_userUpdate $request) { public function update($id, User $user, Sys_userUpdate $request) {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first(); $users = $user->whereId($id)->first();
/* Update the value by selected field */ /* Update the value by selected field */
/* Check whether function success or not */ /* Check whether function success or not */
try{ try {
$users->fill($request->input())->save(); $users->fill($request->input())->save();
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully'); return redirect('user')->with('success', 'User Updated Successfully');
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* get agent profile page * get agent profile page
* @return type view * @return type view
*/ */
public function getProfile() { public function getProfile() {
$user = Auth::user(); $user = Auth::user();
try { try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user')); return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} catch(Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* get profile edit page * get profile edit page
* @return type view * @return type view
*/ */
public function getProfileedit() { public function getProfileedit() {
$user = Auth::user(); $user = Auth::user();
try { try {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user')); return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* post profile edit * post profile edit
* @param type int $id * @param type int $id
* @param type ProfileRequest $request * @param type ProfileRequest $request
* @return type Redirect * @return type Redirect
*/ */
public function postProfileedit(ProfileRequest $request) { public function postProfileedit(ProfileRequest $request) {
// geet authenticated user details // geet authenticated user details
$user = Auth::user(); $user = Auth::user();
$user->gender = $request->input('gender'); $user->gender = $request->input('gender');
$user->save(); $user->save();
// checking availability of agent profile ppicture // checking availability of agent profile ppicture
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') { if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
if ($request->input('gender') == 1) { if ($request->input('gender') == 1) {
$name = 'avatar5.png'; $name = 'avatar5.png';
$destinationPath = 'lb-faveo/media/profilepic'; $destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name; $user->profile_pic = $name;
} elseif ($request->input('gender') == 0) { } elseif ($request->input('gender') == 0) {
$name = 'avatar2.png'; $name = 'avatar2.png';
$destinationPath = 'lb-faveo/media/profilepic'; $destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name; $user->profile_pic = $name;
} }
} }
// checking if the post system includes agent profile picture upload // checking if the post system includes agent profile picture upload
if (Input::file('profile_pic')) { if (Input::file('profile_pic')) {
// fetching picture name // fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName(); $name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path // fetching upload destination path
$destinationPath = 'lb-faveo/media/profilepic'; $destinationPath = 'lb-faveo/media/profilepic';
// adding a random value to profile picture filename // adding a random value to profile picture filename
$fileName = rand(0000, 9999) . '.' . $name; $fileName = rand(0000, 9999) . '.' . $name;
// moving the picture to a destination folder // moving the picture to a destination folder
Input::file('profile_pic')->move($destinationPath, $fileName); Input::file('profile_pic')->move($destinationPath, $fileName);
// saving filename to database // saving filename to database
$user->profile_pic = $fileName; $user->profile_pic = $fileName;
} else { } else {
try{ try {
$user->fill($request->except('profile_pic', 'gender'))->save(); $user->fill($request->except('profile_pic', 'gender'))->save();
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully'); return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
} catch (Exception $e){ } catch (Exception $e) {
return Redirect::route('profile')->with('success', $e->errorInfo[2]); return Redirect::route('profile')->with('success', $e->errorInfo[2]);
} }
}
if ($user->fill($request->except('profile_pic'))->save()) {
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
}
}
} /**
if ($user->fill($request->except('profile_pic'))->save()) { * Post profile password
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully'); * @param type int $id
} * @param type ProfilePassword $request
} * @return type Redirect
*/
public function postProfilePassword($id, ProfilePassword $request) {
// get authenticated user
$user = Auth::user();
// checking if the old password matches the new password
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password'));
try {
$user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} catch (Exception $e) {
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
}
} else {
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
}
}
/** /**
* Post profile password * Assigning an user to an organization
* @param type int $id * @param type $id
* @param type ProfilePassword $request * @return type boolean
* @return type Redirect */
*/ public function UserAssignOrg($id) {
public function postProfilePassword($id, ProfilePassword $request) { $org = Input::get('org');
// get authenticated user $user_org = new User_org;
$user = Auth::user(); $user_org->org_id = $org;
// checking if the old password matches the new password $user_org->user_id = $id;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { $user_org->save();
$user->password = Hash::make($request->input('new_password')); return 1;
try{ }
$user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} catch (Exception $e) {
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
}
} else {
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
}
}
/** /**
* Assigning an user to an organization * creating an organization in user profile page via modal popup
* @param type $id * @param type $id
* @return type boolean * @return type
*/ */
public function UserAssignOrg($id) { public function User_Create_Org($id) {
$org = Input::get('org'); // checking if the entered value for website is available in database
$user_org = new User_org; if (Input::get('website') != null) {
$user_org->org_id = $org; // checking website
$user_org->user_id = $id; $check = Organization::where('website', '=', Input::get('website'))->first();
$user_org->save(); } else {
return 1; $check = null;
} }
// checking if the name is unique
$check2 = Organization::where('name', '=', Input::get('name'))->first();
// if any of the fields is not available then return false
if (\Input::get('name') == null) {
return "Name is required";
} elseif ($check2 != null) {
return "Name should be Unique";
} elseif ($check != null) {
return "Website should be Unique";
} else {
// storing organization details and assigning the current user to that organization
$org = new Organization;
$org->name = Input::get('name');
$org->phone = Input::get('phone');
$org->website = Input::get('website');
$org->address = Input::get('address');
$org->internal_notes = Input::get('internal');
$org->save();
/** $user_org = new User_org;
* creating an organization in user profile page via modal popup $user_org->org_id = $org->id;
* @param type $id $user_org->user_id = $id;
* @return type $user_org->save();
*/ // for success return 0
public function User_Create_Org($id) { return 0;
// checking if the entered value for website is available in database }
if(Input::get('website')!=null) { }
// checking website
$check = Organization::where('website','=',Input::get('website'))->first();
} else {
$check = null;
}
// checking if the name is unique
$check2 = Organization::where('name','=',Input::get('name'))->first();
// if any of the fields is not available then return false
if (\Input::get('name') == null) {
return "Name is required";
} elseif($check2 != null) {
return "Name should be Unique";
} elseif($check != null) {
return "Website should be Unique";
} else {
// storing organization details and assigning the current user to that organization
$org = new Organization;
$org->name = Input::get('name');
$org->phone = Input::get('phone');
$org->website = Input::get('website');
$org->address = Input::get('address');
$org->internal_notes = Input::get('internal');
$org->save();
$user_org = new User_org;
$user_org->org_id = $org->id;
$user_org->user_id = $id;
$user_org->save();
// for success return 0
return 0;
}
}
} }

View File

@@ -1,22 +1,21 @@
<?php namespace App\Http\Controllers\Agent\kb; <?php
namespace App\Http\Controllers\Agent\kb;
// Controllers // Controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\kb\SettingsController; use App\Http\Controllers\Agent\kb\SettingsController;
use App\Http\Controllers\Client\kb\UserController; use App\Http\Controllers\Client\kb\UserController;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
// Requests // Requests
use App\Http\Requests\kb\ArticleRequest; use App\Http\Requests\kb\ArticleRequest;
use App\Http\Requests\kb\ArticleUpdate; use App\Http\Requests\kb\ArticleUpdate;
// Models // Models
use App\Model\kb\Article; use App\Model\kb\Article;
use App\Model\kb\Category; use App\Model\kb\Category;
use App\Model\kb\Relationship; use App\Model\kb\Relationship;
use App\Model\kb\Settings; use App\Model\kb\Settings;
use App\Model\kb\Comment; use App\Model\kb\Comment;
// Classes // Classes
use Auth; use Auth;
use Chumper\Datatable\Table; use Chumper\Datatable\Table;
@@ -36,52 +35,52 @@ use Exception;
*/ */
class ArticleController extends Controller { class ArticleController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
// checking roles // checking roles
$this->middleware('roles'); $this->middleware('roles');
SettingsController::language(); SettingsController::language();
} }
public function test() { public function test() {
//$table = $this->setDatatable(); //$table = $this->setDatatable();
return view('themes.default1.agent.kb.article.test'); return view('themes.default1.agent.kb.article.test');
} }
/** /**
* Fetching all the list of articles in a chumper datatable format * Fetching all the list of articles in a chumper datatable format
* @return type void * @return type void
*/ */
public function getData() { public function getData() {
// returns chumper datatable // returns chumper datatable
return Datatable::collection(Article::All()) return Datatable::collection(Article::All())
/* searcable column name */ /* searcable column name */
->searchColumns('name') ->searchColumns('name')
/* order column name and description */ /* order column name and description */
->orderColumns('name', 'description') ->orderColumns('name', 'description')
/* add column name */ /* add column name */
->addColumn('name', function ($model) { ->addColumn('name', function ($model) {
return $model->name; return $model->name;
}) })
/* add column Created */ /* add column Created */
->addColumn('Created', function ($model) { ->addColumn('Created', function ($model) {
$t = $model->created_at; $t = $model->created_at;
return TicketController::usertimezone($t); return TicketController::usertimezone($t);
}) })
/* add column action */ /* add column action */
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
/* here are all the action buttons and modal popup to delete articles with confirmations */ /* here are all the action buttons and modal popup to delete articles with confirmations */
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id .'"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href=article/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href=show/'.$model->slug .' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a> return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href=article/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href=show/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle'.$model->id .'"> <div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@@ -89,188 +88,192 @@ class ArticleController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4> <h4 class="modal-title">Are You Sure ?</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
'.$model->name.' ' . $model->name . '
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
<a href="article/delete/'.$model->slug.'"><button class="btn btn-danger">delete</button></a> <a href="article/delete/' . $model->slug . '"><button class="btn btn-danger">delete</button></a>
</div> </div>
</div><!-- /.modal-content --> </div><!-- /.modal-content -->
</div><!-- /.modal-dialog --> </div><!-- /.modal-dialog -->
</div>'; </div>';
}) })
->make(); ->make();
} }
/** /**
* List of Articles * List of Articles
* @return type view * @return type view
*/ */
public function index() { public function index() {
/* show article list */ /* show article list */
try{ try {
return view('themes.default1.agent.kb.article.index'); return view('themes.default1.agent.kb.article.index');
} catch(Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* Creating a Article * Creating a Article
* @param type Category $category * @param type Category $category
* @return type view * @return type view
*/ */
public function create(Category $category) { public function create(Category $category) {
/* get the attributes of the category */ /* get the attributes of the category */
$category = $category->lists('id', 'name'); $category = $category->lists('id', 'name');
/* get the create page */ /* get the create page */
try{ try {
return view('themes.default1.agent.kb.article.create', compact('category')); return view('themes.default1.agent.kb.article.create', compact('category'));
} catch(Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
}
} /**
* Insert the values to the article
* @param type Article $article
* @param type ArticleRequest $request
* @return type redirect
*/
public function store(Article $article, ArticleRequest $request) {
// requesting the values to store article data
$publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
/** $sl = $request->input('slug');
* Insert the values to the article $slug = str_slug($sl, "-");
* @param type Article $article $article->slug = $slug;
* @param type ArticleRequest $request $article->publish_time = $publishTime;
* @return type redirect $article->fill($request->except('created_at', 'slug'))->save();
*/ // creating article category relationship
public function store(Article $article, ArticleRequest $request) { $requests = $request->input('category_id');
// requesting the values to store article data $id = $article->id;
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$article->slug = $slug;
$article->fill($request->except('created_at','slug'))->save();
// creating article category relationship
$requests = $request->input('category_id');
$id = $article->id;
foreach ($requests as $req) {
DB::insert('insert into kb_article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
}
/* insert the values to the article table */
try{
$article->fill($request->except('slug'))->save();
return redirect('article')->with('success', 'Article Inserted Successfully');
} catch (Exception $e) {
return redirect('article')->with('fails', 'Article Not Inserted'. '<li>'.$e->errorInfo[2].'</li>');
}
}
/** foreach ($requests as $req) {
* Edit an Article by id DB::insert('insert into kb_article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
* @param type Integer $id }
* @param type Article $article /* insert the values to the article table */
* @param type Relationship $relation try {
* @param type Category $category $article->fill($request->except('slug'))->save();
* @return view return redirect('article')->with('success', 'Article Inserted Successfully');
*/ } catch (Exception $e) {
public function edit($slug, Article $article, Relationship $relation, Category $category) { return redirect('article')->with('fails', 'Article Not Inserted' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
$aid = $article->where('id', $slug)->first(); /**
$id = $aid->id; * Edit an Article by id
* @param type Integer $id
* @param type Article $article
* @param type Relationship $relation
* @param type Category $category
* @return view
*/
public function edit($slug, Article $article, Relationship $relation, Category $category) {
$aid = $article->where('id', $slug)->first();
$id = $aid->id;
/* define the selected fields */
$assign = $relation->where('article_id', $id)->lists('category_id');
/* get the attributes of the category */
$category = $category->lists('id', 'name');
/* get the selected article and display it at edit page */
/* Get the selected article with id */
$article = $article->whereId($id)->first();
/* send to the edit page */
try {
return view('themes.default1.agent.kb.article.edit', compact('assign', 'article', 'category'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/* define the selected fields */ /**
$assign = $relation->where('article_id', $id)->lists('category_id'); * Update an Artile by id
/* get the attributes of the category */ * @param type Integer $id
$category = $category->lists('id', 'name'); * @param type Article $article
/* get the selected article and display it at edit page */ * @param type Relationship $relation
/* Get the selected article with id */ * @param type ArticleRequest $request
$article = $article->whereId($id)->first(); * @return Response
/* send to the edit page */ */
try { public function update($slug, Article $article, Relationship $relation, ArticleUpdate $request) {
return view('themes.default1.agent.kb.article.edit', compact('assign', 'article', 'category')); $aid = $article->where('id', $slug)->first();
} catch(Exception $e){ $publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
} $id = $aid->id;
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
/** $article->slug = $slug;
* Update an Artile by id /* get the attribute of relation table where id==$id */
* @param type Integer $id $relation = $relation->where('article_id', $id);
* @param type Article $article $relation->delete();
* @param type Relationship $relation /* get the request of the current articles */
* @param type ArticleRequest $request $article = $article->whereId($id)->first();
* @return Response $requests = $request->input('category_id');
*/ $id = $article->id;
public function update($slug, Article $article, Relationship $relation, ArticleUpdate $request) { foreach ($requests as $req) {
$aid = $article->where('id', $slug)->first(); DB::insert('insert into kb_article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
$id = $aid->id; }
$sl = $request->input('slug'); /* update the value to the table */
$slug = str_slug($sl, "-"); try {
// dd($slug); $article->fill($request->all())->save();
$article->slug = $slug; $article->slug = $slug;
/* get the attribute of relation table where id==$id */ $article->publish_time = $publishTime;
$relation = $relation->where('article_id', $id); $article->save();
$relation->delete(); return redirect('article')->with('success', 'Article Updated Successfully');
/* get the request of the current articles */ } catch (Exception $e) {
$article = $article->whereId($id)->first(); return redirect('article')->with('fails', 'Article Not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
$requests = $request->input('category_id'); }
$id = $article->id; }
foreach ($requests as $req) {
DB::insert('insert into article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
}
/* update the value to the table */
try{
$article->fill($request->all())->save();
$article->slug = $slug;
$article->save();
return redirect('article')->with('success', 'Article Updated Successfully');
} catch(Exception $e){
return redirect('article')->with('fails', 'Article Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/** /**
* Delete an Agent by id * Delete an Agent by id
* @param type $id * @param type $id
* @param type Article $article * @param type Article $article
* @return Response * @return Response
*/ */
public function destroy($slug, Article $article, Relationship $relation, Comment $comment) { public function destroy($slug, Article $article, Relationship $relation, Comment $comment) {
/* delete the selected article from the table */ /* delete the selected article from the table */
$article = $article->where('slug',$slug)->first(); //get the selected article via id $article = $article->where('slug', $slug)->first(); //get the selected article via id
$id = $article->id; $id = $article->id;
$comments = $comment->where('article_id',$id)->get(); $comments = $comment->where('article_id', $id)->get();
if($comments) { if ($comments) {
foreach($comments as $comment) foreach ($comments as $comment)
$comment->delete(); $comment->delete();
} }
// deleting relationship // deleting relationship
$relation = $relation->where('article_id', $id)->first(); $relation = $relation->where('article_id', $id)->first();
if($relation) { if ($relation) {
$relation->delete(); $relation->delete();
} }
if($article) { if ($article) {
if ($article->delete()) {//true:redirect to index page with success message if ($article->delete()) {//true:redirect to index page with success message
return Redirect::back()->with('success', 'Article Deleted Successfully'); return Redirect::back()->with('success', 'Article Deleted Successfully');
} else { //redirect to index page with fails message } else { //redirect to index page with fails message
return Redirect::back()->with('fails', 'Article Not Deleted'); return Redirect::back()->with('fails', 'Article Not Deleted');
} }
} else { } else {
return Redirect::back()->with('fails', 'Article can Not Deleted'); return Redirect::back()->with('fails', 'Article can Not Deleted');
} }
} }
/** /**
* user time zone * user time zone
* fetching timezone * fetching timezone
* @param type $utc * @param type $utc
* @return type * @return type
*/ */
static function usertimezone($utc) { static function usertimezone($utc) {
$user = Auth::user(); $user = Auth::user();
$tz = $user->timezone; $tz = $user->timezone;
$set = Settings::whereId('1')->first(); $set = Settings::whereId('1')->first();
$format = $set->dateformat; $format = $set->dateformat;
//$utc = date('M d Y h:i:s A'); //$utc = date('M d Y h:i:s A');
date_default_timezone_set($tz); date_default_timezone_set($tz);
$offset = date('Z', strtotime($utc)); $offset = date('Z', strtotime($utc));
$date = date($format, strtotime($utc) + $offset); $date = date($format, strtotime($utc) + $offset);
echo $date; echo $date;
} }
} }

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Controllers\Agent\kb; <?php
namespace App\Http\Controllers\Agent\kb;
// Controllers // Controllers
use App\Http\Controllers\client\kb\UserController; use App\Http\Controllers\client\kb\UserController;
@@ -6,15 +8,12 @@ use App\Http\Controllers\admin\kb\ArticleController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\kb\SettingsController; use App\Http\Controllers\Agent\kb\SettingsController;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
// Requests // Requests
use App\Http\Requests\kb\CategoryRequest; use App\Http\Requests\kb\CategoryRequest;
use App\Http\Requests\kb\CategoryUpdate; use App\Http\Requests\kb\CategoryUpdate;
// Model // Model
use App\Model\kb\Category; use App\Model\kb\Category;
use App\Model\kb\Relationship; use App\Model\kb\Relationship;
// Classes // Classes
use Datatable; use Datatable;
use Redirect; use Redirect;
@@ -30,61 +29,61 @@ use Exception;
*/ */
class CategoryController extends Controller { class CategoryController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
// checking roles // checking roles
$this->middleware('roles'); $this->middleware('roles');
SettingsController::language(); SettingsController::language();
} }
/** /**
* Indexing all Category * Indexing all Category
* @param type Category $category * @param type Category $category
* @return Response * @return Response
*/ */
public function index() { public function index() {
/* get the view of index of the catogorys with all attributes /* get the view of index of the catogorys with all attributes
of category model */ of category model */
try{ try {
return view('themes.default1.agent.kb.category.index'); return view('themes.default1.agent.kb.category.index');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* fetching category list in chumper datatables * fetching category list in chumper datatables
* @return type chumper datatable * @return type chumper datatable
*/ */
public function getData() { public function getData() {
/* fetching chumper datatables */ /* fetching chumper datatables */
return Datatable::collection(Category::All()) return Datatable::collection(Category::All())
/* search column name */ /* search column name */
->searchColumns('name') ->searchColumns('name')
/* order column name and description */ /* order column name and description */
->orderColumns('name', 'description') ->orderColumns('name', 'description')
/* add column name */ /* add column name */
->addColumn('name', function ($model) { ->addColumn('name', function ($model) {
return $model->name; return $model->name;
}) })
/* add column Created */ /* add column Created */
->addColumn('Created', function ($model) { ->addColumn('Created', function ($model) {
$t = $model->created_at; $t = $model->created_at;
return TicketController::usertimezone($t); return TicketController::usertimezone($t);
}) })
/* add column Actions */ /* add column Actions */
/* there are action buttons and modal popup to delete a data column */ /* there are action buttons and modal popup to delete a data column */
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#deletecategory' . $model->slug . '"><a href="#" ><button class="btn btn-danger btn-xs"></a>'. \Lang::get("lang.delete") .'</button></span>&nbsp;<a href=category/' . $model->id . '/edit class="btn btn-warning btn-xs">'. \Lang::get("lang.edit") .'</a>&nbsp;<a href=article-list class="btn btn-primary btn-xs">'. \Lang::get("lang.view") .'</a> return '<span data-toggle="modal" data-target="#deletecategory' . $model->slug . '"><a href="#" ><button class="btn btn-danger btn-xs"></a>' . \Lang::get("lang.delete") . '</button></span>&nbsp;<a href=category/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get("lang.edit") . '</a>&nbsp;<a href=article-list class="btn btn-primary btn-xs">' . \Lang::get("lang.view") . '</a>
<div class="modal fade" id="deletecategory' . $model->slug . '"> <div class="modal fade" id="deletecategory' . $model->slug . '">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
@@ -93,7 +92,7 @@ class CategoryController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4> <h4 class="modal-title">Are You Sure ?</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
'.$model->name.' ' . $model->name . '
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
@@ -102,116 +101,114 @@ class CategoryController extends Controller {
</div> </div>
</div> </div>
</div>'; </div>';
}) })
->make(); ->make();
}
} /**
* Create a Category
* @param type Category $category
* @return type view
*/
public function create(Category $category) {
/* Get the all attributes in the category model */
$category = $category->get();
/* get the view page to create new category with all attributes
of category model */
try {
return view('themes.default1.agent.kb.category.create', compact('category'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/** /**
* Create a Category * To store the selected category
* @param type Category $category * @param type Category $category
* @return type view * @param type CategoryRequest $request
*/ * @return type Redirect
public function create(Category $category) { */
/* Get the all attributes in the category model */ public function store(Category $category, CategoryRequest $request) {
$category = $category->get(); /* Get the whole request from the form and insert into table via model */
/* get the view page to create new category with all attributes $sl = $request->input('slug');
of category model*/ $slug = str_slug($sl, "-");
try { $category->slug = $slug;
return view('themes.default1.agent.kb.category.create', compact('category')); // send success message to index page
} catch(Exception $e) { try {
return redirect()->back()->with('fails',$e->errorInfo[2]); $category->fill($request->except('slug'))->save();
} return Redirect::back()->with('success', 'Category Inserted Successfully');
} } catch (Exception $e) {
return Redirect::back()->with('fails', 'Category Not Inserted' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/** /**
* To store the selected category * Show the form for editing the specified category.
* @param type Category $category * @param type $slug
* @param type CategoryRequest $request * @param type Category $category
* @return type Redirect * @return type view
*/ */
public function store(Category $category, CategoryRequest $request) { public function edit($slug, Category $category) {
/* Get the whole request from the form and insert into table via model */ // fetch the category
$sl = $request->input('slug'); $cid = $category->where('id', $slug)->first();
$slug = str_slug($sl, "-"); $id = $cid->id;
$category->slug = $slug; /* get the atributes of the category model whose id == $id */
// send success message to index page $category = $category->whereId($id)->first();
try{ /* get the Edit page the selected category via id */
$category->fill($request->except('slug'))->save(); return view('themes.default1.agent.kb.category.edit', compact('category'));
return Redirect::back()->with('success', 'Category Inserted Successfully'); }
} catch(Exception $e) {
return Redirect::back()->with('fails', 'Category Not Inserted'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/** /**
* Show the form for editing the specified category. * Update the specified Category in storage.
* @param type $slug * @param type $slug
* @param type Category $category * @param type Category $category
* @return type view * @param type CategoryUpdate $request
*/ * @return type redirect
public function edit($slug, Category $category) { */
// fetch the category public function update($slug, Category $category, CategoryUpdate $request) {
$cid = $category->where('id', $slug)->first();
$id = $cid->id;
/* get the atributes of the category model whose id == $id */
$category = $category->whereId($id)->first();
/* get the Edit page the selected category via id */
return view('themes.default1.agent.kb.category.edit', compact('category'));
}
/** /* Edit the selected category via id */
* Update the specified Category in storage. $category = $category->where('id', $slug)->first();
* @param type $slug $sl = $request->input('slug');
* @param type Category $category $slug = str_slug($sl, "-");
* @param type CategoryUpdate $request // dd($slug);
* @return type redirect $category->slug = $slug;
*/ /* update the values at the table via model according with the request */
public function update($slug, Category $category, CategoryUpdate $request) { //redirct to index page with success message
try {
$category->fill($request->all())->save();
$category->slug = $slug;
$category->save();
return redirect('category')->with('success', 'Category Updated Successfully');
} catch (Exception $e) {
//redirect to index with fails message
return redirect('category')->with('fails', 'Category Not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/* Edit the selected category via id */ /**
$category = $category->where('id', $slug)->first(); * Remove the specified category from storage.
$sl = $request->input('slug'); * @param type $id
$slug = str_slug($sl, "-"); * @param type Category $category
// dd($slug); * @param type Relationship $relation
$category->slug = $slug; * @return type Redirect
/* update the values at the table via model according with the request */ */
//redirct to index page with success message public function destroy($id, Category $category, Relationship $relation) {
try{
$category->fill($request->all())->save();
$category->slug = $slug;
$category->save();
return redirect('category')->with('success', 'Category Updated Successfully');
} catch(Exception $e) {
//redirect to index with fails message
return redirect('category')->with('fails', 'Category Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/** $relation = $relation->where('category_id', $id)->first();
* Remove the specified category from storage. if ($relation != null) {
* @param type $id return Redirect::back()->with('fails', 'Category Not Deleted');
* @param type Category $category } else {
* @param type Relationship $relation /* delete the category selected, id == $id */
* @return type Redirect $category = $category->whereId($id)->first();
*/ // redirect to index with success message
public function destroy($id, Category $category, Relationship $relation) { try {
$category->delete();
$relation = $relation->where('category_id', $id)->first(); return Redirect::back()->with('success', 'Category Deleted Successfully');
if($relation != null){ } catch (Exception $e) {
return Redirect::back()->with('fails', 'Category Not Deleted'); return Redirect::back()->with('fails', 'Category Not Deleted' . '<li>' . $e->errorInfo[2] . '</li>');
} }
else { }
/* delete the category selected, id == $id */ }
$category = $category->whereId($id)->first();
// redirect to index with success message
try{
$category->delete();
return Redirect::back()->with('success', 'Category Deleted Successfully');
} catch(Exception $e){
return Redirect::back()->with('fails', 'Category Not Deleted'.'<li>'.$e->errorInfo[2].'</li>');
}
}
}
} }

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Controllers\Agent\kb; <?php
namespace App\Http\Controllers\Agent\kb;
// controllers // controllers
use App\Http\Controllers\client\kb\UserController; use App\Http\Controllers\client\kb\UserController;
@@ -6,15 +8,12 @@ use App\Http\Controllers\Agent\kb\ArticleController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\kb\SettingsController; use App\Http\Controllers\Agent\kb\SettingsController;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
// request // request
use App\Http\Requests\kb\PageRequest; use App\Http\Requests\kb\PageRequest;
use App\Http\Requests\kb\PageUpdate; use App\Http\Requests\kb\PageUpdate;
use Illuminate\Http\Request; use Illuminate\Http\Request;
// Model // Model
use App\Model\kb\Page; use App\Model\kb\Page;
// classes // classes
use Datatable; use Datatable;
use Exception; use Exception;
@@ -29,61 +28,61 @@ use Exception;
*/ */
class PageController extends Controller { class PageController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct(Page $page) { public function __construct(Page $page) {
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
// checking roles // checking roles
$this->middleware('roles'); $this->middleware('roles');
$this->page = $page; $this->page = $page;
SettingsController::language(); SettingsController::language();
} }
/** /**
* Display the list of pages * Display the list of pages
* @return type * @return type
*/ */
public function index() { public function index() {
$pages = $this->page->paginate(3); $pages = $this->page->paginate(3);
$pages->setPath('page'); $pages->setPath('page');
try{ try {
return view('themes.default1.agent.kb.pages.index', compact('pages')); return view('themes.default1.agent.kb.pages.index', compact('pages'));
} catch(Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* fetching pages list in chumper datatables * fetching pages list in chumper datatables
* @return type * @return type
*/ */
public function getData() { public function getData() {
/* fetching chumper datatables */ /* fetching chumper datatables */
return Datatable::collection(Page::All()) return Datatable::collection(Page::All())
/* search column name */ /* search column name */
->searchColumns('name') ->searchColumns('name')
/* order column name, description and created */ /* order column name, description and created */
->orderColumns('name', 'description', 'created') ->orderColumns('name', 'description', 'created')
/* add column name */ /* add column name */
->addColumn('name', function ($model) { ->addColumn('name', function ($model) {
return $model->name; return $model->name;
}) })
/* add column Created */ /* add column Created */
->addColumn('Created', function ($model) { ->addColumn('Created', function ($model) {
$t = $model->created_at; $t = $model->created_at;
return TicketController::usertimezone($t); return TicketController::usertimezone($t);
}) })
/* add column Actions */ /* add column Actions */
/* there are action buttons and modal popup to delete a data column */ /* there are action buttons and modal popup to delete a data column */
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#deletepage' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> '. \Lang::get('lang.delete') .'</button></span>&nbsp;<a href=page/' . $model->slug . '/edit class="btn btn-warning btn-xs">'. \Lang::get('lang.edit') .'</a>&nbsp;<a href=pages/' . $model->slug . ' class="btn btn-primary btn-xs">'. \Lang::get('lang.view') .'</a> return '<span data-toggle="modal" data-target="#deletepage' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . '</button></span>&nbsp;<a href=page/' . $model->slug . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href=pages/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletepage' . $model->id . '"> <div class="modal fade" id="deletepage' . $model->id . '">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
@@ -92,7 +91,7 @@ class PageController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4> <h4 class="modal-title">Are You Sure ?</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
'.$model->name.' ' . $model->name . '
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
@@ -101,85 +100,85 @@ class PageController extends Controller {
</div> </div>
</div> </div>
</div>'; </div>';
}) })
->make(); ->make();
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @return type view * @return type view
*/ */
public function create() { public function create() {
return view('themes.default1.agent.kb.pages.create'); return view('themes.default1.agent.kb.pages.create');
} }
/** /**
* To insert a value to the table Page * To insert a value to the table Page
* @param type Request $request * @param type Request $request
* @return type * @return type
*/ */
public function store(PageRequest $request) { public function store(PageRequest $request) {
$sl = $request->input('slug'); $sl = $request->input('slug');
$slug = str_slug($sl, "-"); $slug = str_slug($sl, "-");
$this->page->slug = $slug; $this->page->slug = $slug;
try{ try {
$this->page->fill($request->except('slug'))->save(); $this->page->fill($request->except('slug'))->save();
return redirect('page')->with('success','Page created successfully'); return redirect('page')->with('success', 'Page created successfully');
} catch(Exception $e) { } catch (Exception $e) {
return redirect('page')->with('fails',$e->errorInfo[2]); return redirect('page')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* To edit a page * To edit a page
* @param type $slug * @param type $slug
* @return type view * @return type view
*/ */
public function edit($slug) { public function edit($slug) {
try{ try {
$page = $this->page->where('slug', $slug)->first(); $page = $this->page->where('slug', $slug)->first();
return view('themes.default1.agent.kb.pages.edit', compact('page')); return view('themes.default1.agent.kb.pages.edit', compact('page'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect('page')->with('fails',$e->errorInfo[2]); return redirect('page')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* To update a page * To update a page
* @param type $slug * @param type $slug
* @param type PageUpdate $request * @param type PageUpdate $request
* @return type redirect * @return type redirect
*/ */
public function update($slug, PageUpdate $request) { public function update($slug, PageUpdate $request) {
// get pages with respect to slug // get pages with respect to slug
$pages = $this->page->where('slug', $slug)->first(); $pages = $this->page->where('slug', $slug)->first();
$sl = $request->input('slug'); $sl = $request->input('slug');
$slug = str_slug($sl, "-"); $slug = str_slug($sl, "-");
$this->page->slug = $slug; $this->page->slug = $slug;
try{ try {
$pages->fill($request->all())->save(); $pages->fill($request->all())->save();
$pages->slug = $slug; $pages->slug = $slug;
$pages->save(); $pages->save();
return redirect('page')->with('success', 'Your Page Updated Successfully'); return redirect('page')->with('success', 'Your Page Updated Successfully');
} catch(Exception $e) { } catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]); return redirect('page')->with('fails', $e->errorInfo[2]);
} }
} }
/** /**
* To Delete a Page * To Delete a Page
* @param type $id * @param type $id
* @return type redirect * @return type redirect
*/ */
public function destroy($id) { public function destroy($id) {
try{ try {
// get the page to be deleted // get the page to be deleted
$page = $this->page->whereId($id)->first(); $page = $this->page->whereId($id)->first();
$page->delete(); $page->delete();
return redirect('page')->with('success', 'Page Deleted Successfully'); return redirect('page')->with('success', 'Page Deleted Successfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]); return redirect('page')->with('fails', $e->errorInfo[2]);
} }
} }
} }

View File

@@ -1,10 +1,11 @@
<?php namespace App\Http\Controllers\Agent\kb; <?php
namespace App\Http\Controllers\Agent\kb;
// Controllers // Controllers
use App\Http\Controllers\Agent\kb\ArticleController; use App\Http\Controllers\Agent\kb\ArticleController;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// Request // Request
use App\Http\Requests\kb\FooterRequest; use App\Http\Requests\kb\FooterRequest;
use App\Http\Requests\kb\ProfilePassword; use App\Http\Requests\kb\ProfilePassword;
@@ -12,7 +13,6 @@ use App\Http\Requests\kb\ProfileRequest;
use App\Http\Requests\kb\SettingsRequests; use App\Http\Requests\kb\SettingsRequests;
use App\Http\Requests\kb\SocialRequest; use App\Http\Requests\kb\SocialRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
// Model // Model
use App\Model\kb\Comment; use App\Model\kb\Comment;
use App\Model\kb\Faq; use App\Model\kb\Faq;
@@ -22,7 +22,6 @@ use App\Model\kb\Side2;
use App\Model\kb\Social; use App\Model\kb\Social;
use App\Model\helpdesk\Utility\Timezones; use App\Model\helpdesk\Utility\Timezones;
use App\Model\helpdesk\Utility\Date_format; use App\Model\helpdesk\Utility\Date_format;
// Classes // Classes
use Auth; use Auth;
use Config; use Config;
@@ -42,244 +41,241 @@ use Exception;
*/ */
class SettingsController extends Controller { class SettingsController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
// checking roles // checking roles
$this->middleware('roles'); $this->middleware('roles');
$this->language(); $this->language();
} }
/** /**
* to get the settings page * to get the settings page
* @return response * @return response
* @package default * @package default
*/ */
public function settings(Settings $settings, Timezones $time, Date_format $date) { public function settings(Settings $settings, Timezones $time, Date_format $date) {
/* get the setting where the id == 1 */ /* get the setting where the id == 1 */
$settings = $settings->whereId('1')->first(); $settings = $settings->whereId('1')->first();
$time = $time->get(); $time = $time->get();
//$date = $date->get(); //$date = $date->get();
return view('themes.default1.agent.kb.settings.settings', compact('date', 'settings', 'time')); return view('themes.default1.agent.kb.settings.settings', compact('date', 'settings', 'time'));
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* *
* @param int $id * @param int $id
* @return Response * @return Response
*/ */
public function postSettings($id, Settings $settings, SettingsRequests $request) { public function postSettings($id, Settings $settings, SettingsRequests $request) {
try try {
{ /* fetch the values of company request */
/* fetch the values of company request */ $settings = $settings->whereId('1')->first();
$settings = $settings->whereId('1')->first(); if (Input::file('logo')) {
if (Input::file('logo')) { $name = Input::file('logo')->getClientOriginalName();
$name = Input::file('logo')->getClientOriginalName(); $destinationPath = 'lb-faveo/dist/image';
$destinationPath = 'lb-faveo/dist/image'; $fileName = rand(0000, 9999) . '.' . $name;
$fileName = rand(0000, 9999) . '.' . $name; //echo $fileName;
//echo $fileName; Input::file('logo')->move($destinationPath, $fileName);
Input::file('logo')->move($destinationPath, $fileName); $settings->logo = $fileName;
$settings->logo = $fileName; //$thDestinationPath = 'dist/th';
//$thDestinationPath = 'dist/th'; Image::make($destinationPath . '/' . $fileName, array(
Image::make($destinationPath . '/' . $fileName, array( 'width' => 300,
'width' => 300, 'height' => 300,
'height' => 300, 'grayscale' => false,
'grayscale' => false, ))->save('lb-faveo/dist/image/' . $fileName);
))->save('lb-faveo/dist/image/' . $fileName); }
} if (Input::file('background')) {
if (Input::file('background')) { $name = Input::file('background')->getClientOriginalName();
$name = Input::file('background')->getClientOriginalName(); $destinationPath = 'lb-faveo/dist/image';
$destinationPath = 'lb-faveo/dist/image'; $fileName = rand(0000, 9999) . '.' . $name;
$fileName = rand(0000, 9999) . '.' . $name; echo $fileName;
echo $fileName; Input::file('background')->move($destinationPath, $fileName);
Input::file('background')->move($destinationPath, $fileName); $settings->background = $fileName;
$settings->background = $fileName; //$thDestinationPath = 'dist/th';
//$thDestinationPath = 'dist/th'; Image::make($destinationPath . '/' . $fileName, array(
Image::make($destinationPath . '/' . $fileName, array( 'width' => 300,
'width' => 300, 'height' => 300,
'height' => 300, 'grayscale' => false,
'grayscale' => false, ))->save('lb-faveo/dist/image/' . $fileName);
))->save('lb-faveo/dist/image/' . $fileName); }
} /* Check whether function success or not */
/* Check whether function success or not */ if ($settings->fill($request->except('logo', 'background'))->save() == true) {
if ($settings->fill($request->except('logo', 'background'))->save() == true) { /* redirect to Index page with Success Message */
/* redirect to Index page with Success Message */ return redirect('settings')->with('success', 'Settings Updated Successfully');
return redirect('settings')->with('success', 'Settings Updated Successfully'); } else {
} else { /* redirect to Index page with Fails Message */
/* redirect to Index page with Fails Message */ return redirect('settings')->with('fails', 'Settings can not Updated');
return redirect('settings')->with('fails', 'Settings can not Updated'); }
} } catch (Exception $e) {
} catch (Exception $e) { /* redirect to Index page with Fails Message */
/* redirect to Index page with Fails Message */ return redirect('settings')->with('fails', 'Settings can not Updated');
return redirect('settings')->with('fails', 'Settings can not Updated'); }
} }
} /**
* To Moderate the commenting
* @param type Comment $comment
* @return Response
*/
public function comment(Comment $comment) {
return view('themes.default1.agent.kb.settings.comment');
}
/** /**
* To Moderate the commenting * getdata
* @param type Comment $comment * @return type
* @return Response */
*/ public function getData() {
public function comment(Comment $comment) { return \Datatable::collection(Comment::All())
return view('themes.default1.agent.kb.settings.comment'); ->searchColumns('name', 'email', 'comment', 'created')
} ->orderColumns('name')
->addColumn('name', function ($model) {
return $model->name;
})
->addColumn('email', function ($model) {
return $model->email;
})
->addColumn('website', function ($model) {
return $model->website;
})
->addColumn('comment', function ($model) {
return $model->comment;
})
->addColumn('status', function ($model) {
$status = $model->status;
if ($status == 1) {
return '<p style="color:blue"">' . \Lang::get('lang.published');
} else {
return '<p style="color:red"">' . \Lang::get('lang.not_published');
}
})
->addColumn('Created', function ($model) {
return TicketController::usertimezone(date($model->created_at));
})
->addColumn('Actions', function ($model) {
return '<a href=comment/delete/' . $model->id . ' class="btn btn-danger btn-xs">' . \Lang::get('lang.delete') . '</a>&nbsp;<a href=published/' . $model->id . ' class="btn btn-warning btn-xs">' . \Lang::get('lang.publish') . '</a>';
})
->make();
}
/** /**
* getdata * Admin can publish the comment
* @return type * @param type $id
*/ * @param type Comment $comment
public function getData() { * @return bool
return \Datatable::collection(Comment::All()) */
->searchColumns('name', 'email', 'comment', 'created') public function publish($id, Comment $comment) {
->orderColumns('name') $comment = $comment->whereId($id)->first();
->addColumn('name', function ($model) { $comment->status = 1;
return $model->name; if ($comment->save()) {
}) return redirect('comment')->with('success', $comment->name . '-' . 'Comment Published');
->addColumn('email', function ($model) { } else {
return $model->email; return redirect('comment')->with('fails', 'Can not Process');
}) }
->addColumn('website', function ($model) { }
return $model->website;
})
->addColumn('comment', function ($model) {
return $model->comment;
})
->addColumn('status', function ($model) {
$status = $model->status;
if ($status == 1) {
return '<p style="color:blue"">'.\Lang::get('lang.published');
} else {
return '<p style="color:red"">'.\Lang::get('lang.not_published');
}
})
->addColumn('Created', function ($model) {
return TicketController::usertimezone(date($model->created_at));
})
->addColumn('Actions', function ($model) {
return '<a href=comment/delete/' . $model->id . ' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a>&nbsp;<a href=published/' . $model->id . ' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a>';
})
->make();
}
/** /**
* Admin can publish the comment * delete the comment
* @param type $id * @param type $id
* @param type Comment $comment * @param type Comment $comment
* @return bool * @return type
*/ */
public function publish($id, Comment $comment) { public function delete($id, Comment $comment) {
$comment = $comment->whereId($id)->first(); $comment = $comment->whereId($id)->first();
$comment->status = 1; if ($comment->delete()) {
if ($comment->save()) { return redirect('comment')->with('success', $comment->name . "'s!" . 'Comment Deleted');
return redirect('comment')->with('success', $comment->name . '-' . 'Comment Published'); } else {
} else { return redirect('comment')->with('fails', 'Can not Process');
return redirect('comment')->with('fails', 'Can not Process'); }
} }
}
/** /**
* delete the comment * get profile page
* @param type $id * @return type view
* @param type Comment $comment */
* @return type public function getProfile() {
*/ $time = Timezone::all();
public function delete($id, Comment $comment) { $user = Auth::user();
$comment = $comment->whereId($id)->first(); return view('themes.default1.agent.kb.settings.profile', compact('user', 'time'));
if ($comment->delete()) { }
return redirect('comment')->with('success', $comment->name . "'s!" . 'Comment Deleted');
} else {
return redirect('comment')->with('fails', 'Can not Process');
}
}
/** /**
* get profile page * Post profile page
* @return type view * @param type ProfileRequest $request
*/ * @return type redirect
public function getProfile() { */
$time = Timezone::all(); public function postProfile(ProfileRequest $request) {
$user = Auth::user(); $user = Auth::user();
return view('themes.default1.agent.kb.settings.profile', compact('user', 'time')); $user->gender = $request->input('gender');
} $user->save();
if (is_null($user->profile_pic)) {
if ($request->input('gender') == 1) {
$name = 'avatar5.png';
$destinationPath = 'lb-faveo/dist/img';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/dist/img';
$user->profile_pic = $name;
}
}
if (Input::file('profile_pic')) {
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/dist/img';
$fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName;
} else {
$user->fill($request->except('profile_pic', 'gender'))->save();
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return redirect('profile')->with('success1', 'Profile Updated sucessfully');
} else {
return redirect('profile')->with('fails1', 'Profile Not Updated sucessfully');
}
}
/** /**
* Post profile page * post profile password
* @param type ProfileRequest $request * @param type $id
* @return type redirect * @param type ProfilePassword $request
*/ * @return type redirect
public function postProfile(ProfileRequest $request) { */
$user = Auth::user(); public function postProfilePassword($id, ProfilePassword $request) {
$user->gender = $request->input('gender'); $user = Auth::user();
$user->save(); //echo $user->password;
if (is_null($user->profile_pic)) {
if ($request->input('gender') == 1) {
$name = 'avatar5.png';
$destinationPath = 'lb-faveo/dist/img';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/dist/img';
$user->profile_pic = $name;
}
}
if (Input::file('profile_pic')) {
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/dist/img';
$fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName;
} else {
$user->fill($request->except('profile_pic', 'gender'))->save();
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return redirect('profile')->with('success1', 'Profile Updated sucessfully');
} else {
return redirect('profile')->with('fails1', 'Profile Not Updated sucessfully');
}
}
/** if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
* post profile password $user->password = Hash::make($request->input('new_password'));
* @param type $id $user->save();
* @param type ProfilePassword $request return redirect('profile')->with('success2', 'Password Updated sucessfully');
* @return type redirect } else {
*/ return redirect('profile')->with('fails2', 'Old password Wrong');
public function postProfilePassword($id, ProfilePassword $request) { }
$user = Auth::user(); }
//echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { /**
$user->password = Hash::make($request->input('new_password')); * het locale for language
$user->save(); * @return type config set
return redirect('profile')->with('success2', 'Password Updated sucessfully'); */
} else { static function language() {
return redirect('profile')->with('fails2', 'Old password Wrong'); // $set = Settings::whereId(1)->first();
} // $lang = $set->language;
Config::set('app.locale', 'en');
} Config::get('app');
}
/**
* het locale for language
* @return type config set
*/
static function language() {
// $set = Settings::whereId(1)->first();
// $lang = $set->language;
Config::set('app.locale', 'en');
Config::get('app');
}
} }

View File

@@ -13,7 +13,7 @@ use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Http\Requests\helpdesk\TicketRequest; use App\Http\Requests\helpdesk\TicketRequest;
use App\User; use App\User;
use App\Model\helpdesk\Agent\Teams; use App\Model\helpdesk\Agent\Teams;
use App\Model\kb\Settings; use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Manage\Sla_plan; use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Utility\Priority; use App\Model\helpdesk\Utility\Priority;
@@ -86,7 +86,7 @@ class ApiController extends Controller {
$team = new Teams(); $team = new Teams();
$this->team = $team; $this->team = $team;
$setting = new Settings(); $setting = new System();
$this->setting = $setting; $this->setting = $setting;
$helptopic = new Help_topic(); $helptopic = new Help_topic();
@@ -150,6 +150,7 @@ class ApiController extends Controller {
/** /**
* return ticket details * return ticket details
*/ */
//dd($response);
$result = $this->thread->where('id', $response)->first(); $result = $this->thread->where('id', $response)->first();
//$result = $this->attach($result->id,$file); //$result = $this->attach($result->id,$file);
return response()->json(compact('result')); return response()->json(compact('result'));
@@ -259,7 +260,7 @@ class ApiController extends Controller {
*/ */
public function OpenedTickets() { public function OpenedTickets() {
try { try {
$result = $this->model->where('status', '=', 1)->where('isanswered', '=', 0)->where('assigned_to', '=', 0)->orderBy('id', 'DESC')->get(); $result = $this->model->where('status', '=', 1)->where('isanswered', '=', 0)->where('assigned_to', '=', null)->orderBy('id', 'DESC')->get();
return response()->json(compact('result')); return response()->json(compact('result'));
} catch (\Exception $e) { } catch (\Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
@@ -278,7 +279,7 @@ class ApiController extends Controller {
*/ */
public function UnassignedTickets() { public function UnassignedTickets() {
try { try {
$result = $this->model->where('assigned_to', '=', 0)->where('status', '1')->orderBy('id', 'DESC')->get(); $result = $this->model->where('assigned_to', '=', null)->where('status', '1')->orderBy('id', 'DESC')->get();
return response()->json(compact('result')); return response()->json(compact('result'));
} catch (\Exception $e) { } catch (\Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
@@ -316,7 +317,7 @@ class ApiController extends Controller {
*/ */
public function GetAgents() { public function GetAgents() {
try { try {
$result = $this->faveoUser->where('role', 'agent')->where('active', 1)->get(); $result = $this->faveoUser->where('role', 'agent')->orWhere('role', 'admin')->where('active', 1)->get();
return response()->json(compact('result')); return response()->json(compact('result'));
} catch (Exception $e) { } catch (Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
@@ -505,8 +506,9 @@ class ApiController extends Controller {
} }
$url = $this->request->input('url'); $url = $this->request->input('url');
$url = $url . "/api/v1/helpdesk/check-url?token=" . \Config::get('app.token'); $url = $url . "/api/v1/helpdesk/check-url?api-key=" . $this->request->input('api-key') . "&token=" . \Config::get('app.token');
$result = $this->CallGetApi($url); $result = $this->CallGetApi($url);
//dd($result);
return response()->json(compact('result')); return response()->json(compact('result'));
} catch (Exception $ex) { } catch (Exception $ex) {
$error = $e->getMessage(); $error = $e->getMessage();
@@ -579,6 +581,7 @@ class ApiController extends Controller {
public function GenerateApiKey() { public function GenerateApiKey() {
try { try {
$set = $this->setting->where('id', '1')->first(); $set = $this->setting->where('id', '1')->first();
//dd($set);
if ($set->api_enable == 1) { if ($set->api_enable == 1) {
$key = str_random(32); $key = str_random(32);
$set->api_key = $key; $set->api_key = $key;
@@ -675,6 +678,7 @@ class ApiController extends Controller {
return response()->json(compact('error')); return response()->json(compact('error'));
} }
} }
/** /**
* Getting the tickets * Getting the tickets
* @return type json * @return type json
@@ -699,7 +703,6 @@ class ApiController extends Controller {
* Fetching the Inbox details * Fetching the Inbox details
* @return type json * @return type json
*/ */
public function Inbox() { public function Inbox() {
try { try {
$result = $this->user->join('tickets', 'users.id', '=', 'tickets.user_id') $result = $this->user->join('tickets', 'users.id', '=', 'tickets.user_id')
@@ -725,6 +728,7 @@ class ApiController extends Controller {
return response()->json(compact('error', 'file', 'line')); return response()->json(compact('error', 'file', 'line'));
} }
} }
/** /**
* Create internal note * Create internal note
* @return type json * @return type json
@@ -754,6 +758,4 @@ class ApiController extends Controller {
} }
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Api\v1; <?php
namespace App\Http\Controllers\Api\v1;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -37,124 +40,130 @@ use Exception;
*/ */
class InstallerApiController extends Controller { class InstallerApiController extends Controller {
/** /**
* config_database * config_database
* This function is to configure the database and install the application via API call. * This function is to configure the database and install the application via API call.
* @return type Json * @return type Json
*/ */
public function config_database(Request $request) { public function config_database(Request $request) {
error_reporting(E_ALL & ~E_NOTICE); error_reporting(E_ALL & ~E_NOTICE);
// Check for pre install // Check for pre install
if (\Config::get('database.install') == '%0%') { if (\Config::get('database.install') == '%0%') {
$default = $request->database; $default = $request->database;
$host = $request->host; $host = $request->host;
$database = $request->databasename; $database = $request->databasename;
$dbusername = $request->dbusername; $dbusername = $request->dbusername;
$dbpassword = $request->dbpassword; $dbpassword = $request->dbpassword;
$port = $request->port; $port = $request->port;
if(isset($default) && isset($host) && isset($database) && isset($dbusername)){ if (isset($default) && isset($host) && isset($database) && isset($dbusername)) {
// Setting environment values // Setting environment values
$_ENV['DB_TYPE'] = $default; $_ENV['DB_TYPE'] = $default;
$_ENV['DB_HOST'] = $host; $_ENV['DB_HOST'] = $host;
$_ENV['DB_PORT'] = $port; $_ENV['DB_PORT'] = $port;
$_ENV['DB_DATABASE'] = $database; $_ENV['DB_DATABASE'] = $database;
$_ENV['DB_USERNAME'] = $dbusername; $_ENV['DB_USERNAME'] = $dbusername;
$_ENV['DB_PASSWORD'] = $dbpassword; $_ENV['DB_PASSWORD'] = $dbpassword;
$config = ''; $config = '';
foreach ($_ENV as $key => $val) { foreach ($_ENV as $key => $val) {
$config .= "{$key}={$val}\n"; $config .= "{$key}={$val}\n";
} }
// Write environment file // Write environment file
$fp = fopen(base_path()."/.env", 'w'); $fp = fopen(base_path() . "/.env", 'w');
fwrite($fp, $config); fwrite($fp, $config);
fclose($fp); fclose($fp);
return ['response'=>'success','status'=>'1']; return ['response' => 'success', 'status' => '1'];
} else { } else {
return ['response'=>'fail','reason'=>'insufficient parameters','status'=>'0']; return ['response' => 'fail', 'reason' => 'insufficient parameters', 'status' => '0'];
} }
} else { } else {
return ['response'=>'fail','reason'=>'this system is already installed','status'=>'0']; return ['response' => 'fail', 'reason' => 'this system is already installed', 'status' => '0'];
} }
} }
/** /**
* config_database * config_database
* This function is to configure the database and install the application via API call. * This function is to configure the database and install the application via API call.
* @return type Json * @return type Json
*/ */
public function config_system(Request $request) { public function config_system(Request $request) {
// Check for pre install // Check for pre install
if (\Config::get('database.install') == '%0%') { if (\Config::get('database.install') == '%0%') {
$firstname = $request->firstname; $firstname = $request->firstname;
$lastname = $request->lastname; $lastname = $request->lastname;
$email = $request->email; $email = $request->email;
$username = $request->username; $username = $request->username;
$password = $request->password; $password = $request->password;
$timezone = $request->timezone; $timezone = $request->timezone;
$datetime = $request->datetime; $datetime = $request->datetime;
// Migrate database // Migrate database
Artisan::call('migrate', array('--force' => true)); Artisan::call('migrate', array('--force' => true));
Artisan::call('db:seed', array('--force' => true)); Artisan::call('db:seed', array('--force' => true));
// checking requested timezone for the admin and system // checking requested timezone for the admin and system
$timezones = Timezones::where('name','=',$timezone)->first(); $timezones = Timezones::where('name', '=', $timezone)->first();
if($timezones->id == null){ if ($timezones->id == null) {
return ['response'=>'fail','reason'=>'Invalid time-zone','status'=>'0']; return ['response' => 'fail', 'reason' => 'Invalid time-zone', 'status' => '0'];
} }
// checking requested date time format for the admin and system // checking requested date time format for the admin and system
$date_time_format = Date_time_format::where('format','=',$datetime)->first(); $date_time_format = Date_time_format::where('format', '=', $datetime)->first();
if($date_time_format->id == null){ if ($date_time_format->id == null) {
return ['response'=>'fail','reason'=>'invalid date-time format','status'=>'0']; return ['response' => 'fail', 'reason' => 'invalid date-time format', 'status' => '0'];
} }
// Creating minum settings for system // Creating minum settings for system
$system = new System; $system = new System;
$system->status = 1; $system->status = 1;
$system->department = 1; $system->department = 1;
$system->date_time_format = $date_time_format->id; $system->date_time_format = $date_time_format->id;
$system->time_zone = $timezones->id; $system->time_zone = $timezones->id;
$system->save(); $system->save();
// Creating user // Creating user
$user = User::create(array( $user = User::create(array(
'first_name' => $firstname, 'first_name' => $firstname,
'last_name' => $lastname, 'last_name' => $lastname,
'email' => $email, 'email' => $email,
'user_name' => $username, 'user_name' => $username,
'password' => Hash::make($password), 'password' => Hash::make($password),
'active' => 1, 'active' => 1,
'role' => 'admin', 'role' => 'admin',
'assign_group' => 1, 'assign_group' => 1,
'primary_dpt' => 1, 'primary_dpt' => 1,
)); ));
// Setting database installed status // Setting database installed status
$value = '1'; $value = '1';
$install = app_path('../config/database.php'); $install = app_path('../config/database.php');
$datacontent = File::get($install); $datacontent = File::get($install);
$datacontent = str_replace('%0%', $value, $datacontent); $datacontent = str_replace('%0%', $value, $datacontent);
File::put($install, $datacontent); File::put($install, $datacontent);
// Applying email configuration on route // Applying email configuration on route
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()"; $smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
$path22 = app_path('Http/routes.php'); $lfmpath = "url('photos').'/'";
$content23 = File::get($path22); $path22 = app_path('Http/routes.php');
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23); $path23 = app_path('config/lfm.php');
File::put($path22, $content23); $content23 = File::get($path22);
$content24 = File::get($path23);
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
$content24 = str_replace("'%url%'", $lfmpath, $content24);
File::put($path22, $content23);
File::put($path23, $content24);
// If user created return success
if ($user) {
return ['response' => 'success', 'status' => '1'];
}
} else {
return ['response' => 'fail', 'reason' => 'this system is already installed', 'status' => '0'];
}
}
// If user created return success
if($user){
return ['response'=>'success','status'=>'1'];
}
} else {
return ['response'=>'fail','reason'=>'this system is already installed','status'=>'0'];
}
}
} }

View File

@@ -57,27 +57,27 @@ class TestController extends Controller {
public function TicketReply() { public function TicketReply() {
$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png'); //$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
$data = [ $data = [
'ticket_ID' => '81', 'ticket_ID' => '13',
'ReplyContent' => 'reply for the ticket id', 'ReplyContent' => 'reply for the ticket id',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg', 'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg',
'attachments' => [ // 'attachments' => [
[ // [
'name' => 'ladybird', // 'name' => 'ladybird',
'size' => '26398', // 'size' => '26398',
'type' => 'png', // 'type' => 'png',
'file' => $file, // 'file' => $file,
], // ],
[ // [
'name' => 'ladybird', // 'name' => 'ladybird',
'size' => '26398', // 'size' => '26398',
'type' => 'png', // 'type' => 'png',
'file' => $file, // 'file' => $file,
] // ]
], // ],
]; ];
$data = http_build_query($data, '', '&'); $data = http_build_query($data, '', '&');
@@ -90,10 +90,10 @@ class TestController extends Controller {
public function CreateTicket() { public function CreateTicket() {
$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png'); //$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
$data = [ $data = [
'user_id' => '1', 'user_id' => 1,
'subject' => 'Api create via faveo api', 'subject' => 'Api create via faveo api',
'body' => 'Test me when call api', 'body' => 'Test me when call api',
'helptopic' => '1', 'helptopic' => '1',
@@ -101,24 +101,22 @@ class TestController extends Controller {
'priority' => '1', 'priority' => '1',
'headers' => [0 => 'vijaycodename47@gmail.com'], 'headers' => [0 => 'vijaycodename47@gmail.com'],
'dept' => '1', 'dept' => '1',
'assignto' => '0',
'source' => 'api',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg', 'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg',
/** if attachment */ /** if attachment */
'attachments' => [ // 'attachments' => [
[ // [
'name' => 'ladybird', // 'name' => 'ladybird',
'size' => '26398', // 'size' => '26398',
'type' => 'png', // 'type' => 'png',
'file' => $file, // 'file' => $file,
], // ],
[ // [
'name' => 'ladybird', // 'name' => 'ladybird',
'size' => '26398', // 'size' => '26398',
'type' => 'png', // 'type' => 'png',
'file' => $file, // 'file' => $file,
] // ]
], // ],
]; ];
$data = http_build_query($data, '', '&'); $data = http_build_query($data, '', '&');
@@ -162,7 +160,7 @@ class TestController extends Controller {
public function GetAuthUser() { public function GetAuthUser() {
$url = $this->server . "authenticate/user?token=" . \Config::get('app.token'); $url = $this->server . "authenticate/user?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
@@ -170,12 +168,12 @@ class TestController extends Controller {
public function EditTicket() { public function EditTicket() {
$data = [ $data = [
'ticket_id' => '81', 'ticket_id' => '13',
'subject' => 'Api editing ticket via faveo api', 'subject' => 'Api editing ticket via faveo api',
'sla_plan' => '2', 'sla_plan' => '2',
'help_topic' => '2', 'help_topic' => '2',
'ticket_source' => '2', 'ticket_source' => '2',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg', 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
'ticket_priority' => '2', 'ticket_priority' => '2',
]; ];
@@ -188,8 +186,8 @@ class TestController extends Controller {
public function DeleteTicket() { public function DeleteTicket() {
$data = [ $data = [
'ticket_id' => [], 'ticket_id' => [11],
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg' 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
]; ];
$data = http_build_query($data, '', '&'); $data = http_build_query($data, '', '&');
@@ -200,35 +198,35 @@ class TestController extends Controller {
} }
public function OpenedTickets() { public function OpenedTickets() {
$url = $this->server . "helpdesk/open?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/open?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
} }
public function UnassignedTickets() { public function UnassignedTickets() {
$url = $this->server . "helpdesk/unassigned?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/unassigned?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
} }
public function CloseTickets() { public function CloseTickets() {
$url = $this->server . "helpdesk/closed?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/closed?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
} }
public function GetAgents() { public function GetAgents() {
$url = $this->server . "helpdesk/agents?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/agents?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
} }
public function GetTeams() { public function GetTeams() {
$url = $this->server . "helpdesk/teams?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/teams?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
@@ -236,9 +234,9 @@ class TestController extends Controller {
public function AssignTicket() { public function AssignTicket() {
$data = [ $data = [
'ticket_id' => '8', 'ticket_id' => 1,
'user' => 'vijay.sebastian@ladybird.com', 'user' => 'vijay.sebastian@ladybirdweb.com',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg' 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
]; ];
$data = http_build_query($data, '', '&'); $data = http_build_query($data, '', '&');
$url = $this->server . "helpdesk/assign?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/assign?token=" . \Config::get('app.token');
@@ -250,7 +248,7 @@ class TestController extends Controller {
public function GetCustomers() { public function GetCustomers() {
$search = [ $search = [
'search' => 'vij', 'search' => 'vij',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg' 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
]; ];
$data = http_build_query($search, '', '&'); $data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/customers?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/customers?token=" . \Config::get('app.token');
@@ -263,7 +261,7 @@ class TestController extends Controller {
public function GetCustomer() { public function GetCustomer() {
$search = [ $search = [
'user_id' => '1', 'user_id' => '1',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg' 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
]; ];
$data = http_build_query($search, '', '&'); $data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/customer?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/customer?token=" . \Config::get('app.token');
@@ -276,7 +274,7 @@ class TestController extends Controller {
public function GetSearch() { public function GetSearch() {
$search = [ $search = [
'search' => 'api', 'search' => 'api',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg' 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
]; ];
$data = http_build_query($search, '', '&'); $data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/ticket-search?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/ticket-search?token=" . \Config::get('app.token');
@@ -288,8 +286,8 @@ class TestController extends Controller {
public function TicketThreads() { public function TicketThreads() {
$search = [ $search = [
'id' => '8', 'id' => '1',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg' 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
]; ];
$data = http_build_query($search, '', '&'); $data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/ticket-thread?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/ticket-thread?token=" . \Config::get('app.token');
@@ -301,8 +299,8 @@ class TestController extends Controller {
public function Url() { public function Url() {
$search = [ $search = [
'url' => 'http://localhost/FaveoHELPDESK+KBLatests', 'url' => 'http://localhost/Faveo-HelpDesk-My-Branch/public/',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg' 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
]; ];
$data = http_build_query($search, '', '&'); $data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/url?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/url?token=" . \Config::get('app.token');
@@ -313,21 +311,21 @@ class TestController extends Controller {
} }
public function GenerateApiKey() { public function GenerateApiKey() {
$url = $this->server . "helpdesk/api-key?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/api-key?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
} }
public function GetHelpTopic() { public function GetHelpTopic() {
$url = $this->server . "helpdesk/help-topic?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/help-topic?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
} }
public function GetSlaPlan() { public function GetSlaPlan() {
$url = $this->server . "helpdesk/sla-plan?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/sla-plan?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
@@ -341,21 +339,21 @@ class TestController extends Controller {
} }
public function GetDepartment() { public function GetDepartment() {
$url = $this->server . "helpdesk/department?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/department?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
} }
public function GetTickets() { public function GetTickets() {
$url = $this->server . "helpdesk/tickets?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/tickets?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
} }
public function Inbox() { public function Inbox() {
$url = $this->server . "helpdesk/inbox?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/inbox?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
$_this = new self(); $_this = new self();
$respose = $_this->CallGetApi($url); $respose = $_this->CallGetApi($url);
return $respose; return $respose;
@@ -366,7 +364,7 @@ class TestController extends Controller {
'ticketid' => '23', 'ticketid' => '23',
'userid' => 1, 'userid' => 1,
'body' => 'Testing the api internal note', 'body' => 'Testing the api internal note',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg' 'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
]; ];
$data = http_build_query($data, '', '&'); $data = http_build_query($data, '', '&');
$url = $this->server . "helpdesk/internal-note?token=" . \Config::get('app.token'); $url = $this->server . "helpdesk/internal-note?token=" . \Config::get('app.token');

View File

@@ -17,6 +17,7 @@ use App\Model\helpdesk\Ticket\Ticket_Status;
use App\Model\helpdesk\Ticket\Ticket_attachments; use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Settings\System; use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Alert; use App\Model\helpdesk\Settings\Alert;
use Hash;
/** /**
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
@@ -31,7 +32,6 @@ use App\Model\helpdesk\Settings\Alert;
* *
* *
*/ */
class TicketController extends Controller { class TicketController extends Controller {
/** /**
@@ -47,6 +47,7 @@ class TicketController extends Controller {
public function create_ticket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach = '') { public function create_ticket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach = '') {
try { try {
$max_number = Tickets::whereRaw('id = (select max(`id`) from tickets)')->first(); $max_number = Tickets::whereRaw('id = (select max(`id`) from tickets)')->first();
//dd($max_number);
if ($max_number == null) { if ($max_number == null) {
$ticket_number = "AAAA-9999-9999999"; $ticket_number = "AAAA-9999-9999999";
} else { } else {
@@ -56,6 +57,7 @@ class TicketController extends Controller {
} }
$ticket = new Tickets; $ticket = new Tickets;
$ticket->ticket_number = $this->ticket_number($ticket_number); $ticket->ticket_number = $this->ticket_number($ticket_number);
//dd($this->ticket_number($ticket_number));
$ticket->user_id = $user_id; $ticket->user_id = $user_id;
$ticket->dept_id = $dept; $ticket->dept_id = $dept;
$ticket->help_topic_id = $helptopic; $ticket->help_topic_id = $helptopic;
@@ -65,6 +67,7 @@ class TicketController extends Controller {
$ticket->priority_id = $priority; $ticket->priority_id = $priority;
$ticket->source = $source; $ticket->source = $source;
$ticket->save(); $ticket->save();
//dd($ticket);
$ticket_number = $ticket->ticket_number; $ticket_number = $ticket->ticket_number;
$id = $ticket->id; $id = $ticket->id;
if ($form_data != null) { if ($form_data != null) {
@@ -93,6 +96,7 @@ class TicketController extends Controller {
} }
return $thread; return $thread;
} catch (\Exception $e) { } catch (\Exception $e) {
dd($e);
return $e->getMessage(); return $e->getMessage();
} }
} }
@@ -170,6 +174,7 @@ class TicketController extends Controller {
*/ */
public function ticket_number($ticket_number) { public function ticket_number($ticket_number) {
try { try {
//dd($ticket_number);
$number = $ticket_number; $number = $ticket_number;
$number = explode('-', $number); $number = explode('-', $number);
$number1 = $number[0]; $number1 = $number[0];
@@ -193,6 +198,7 @@ class TicketController extends Controller {
$number = implode('-', $array); $number = implode('-', $array);
return $number; return $number;
} catch (\Exception $e) { } catch (\Exception $e) {
dd($e);
return $e->getMessage(); return $e->getMessage();
} }
} }
@@ -373,15 +379,24 @@ class TicketController extends Controller {
public function assign($id) { public function assign($id) {
try { try {
$UserEmail = Input::get('user'); $UserEmail = Input::get('user');
//dd($id); //dd($UserEmail);
// $UserEmail = 'sujitprasad12@yahoo.in'; // $UserEmail = 'sujitprasad12@yahoo.in';
$user = User::where('email', '=', $UserEmail)->first(); $user = User::where('email', '=', $UserEmail)->first();
if (!$user) {
return ['error' => 'No agent not found'];
}
$user_id = $user->id; $user_id = $user->id;
$ticket = Tickets::where('id', '=', $id)->first(); $ticket = Tickets::where('id', '=', $id)->first();
if (!$ticket) {
return ['error' => 'No ticket not found'];
}
$ticket_number = $ticket->ticket_number; $ticket_number = $ticket->ticket_number;
$ticket->assigned_to = $user_id; $ticket->assigned_to = $user_id;
$ticket->save(); $ticket->save();
$ticket_thread = Ticket_Thread::where('ticket_id', '=', $id)->first(); $ticket_thread = Ticket_Thread::where('ticket_id', '=', $id)->first();
if (!$ticket_thread) {
return ['error' => 'No thread not found'];
}
$ticket_subject = $ticket_thread->title; $ticket_subject = $ticket_thread->title;
$thread = New Ticket_Thread; $thread = New Ticket_Thread;
$thread->ticket_id = $ticket->id; $thread->ticket_id = $ticket->id;
@@ -497,6 +512,7 @@ class TicketController extends Controller {
return $e->getMessage(); return $e->getMessage();
} }
} }
/** /**
* Create Attachment * Create Attachment
* @param type $thread * @param type $thread

View File

@@ -23,31 +23,32 @@ use Illuminate\Support\Facades\Hash;
* *
* *
*/ */
class TokenAuthController extends Controller { class TokenAuthController extends Controller {
public function __construct() { public function __construct() {
$this->middleware('api'); $this->middleware('api');
} }
/** /**
* Authenticating user with username and password and retuen token * Authenticating user with username and password and retuen token
* @param Request $request * @param Request $request
* @return type json * @return type json
*/ */
public function authenticate(Request $request) { public function authenticate(Request $request) {
$usernameinput = $request->input('username');
$password = $request->input('password'); $usernameinput = $request->input('username');
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name'; $password = $request->input('password');
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
//$credentials = $request->only('email', 'password'); //$credentials = $request->only('email', 'password');
try { try {
if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password])) { if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password])) {
return response()->json(['error' => 'invalid_credentials', 'status_code'=>401]); return response()->json(['error' => 'invalid_credentials', 'status_code' => 401]);
} }
} catch (JWTException $e) { } catch (JWTException $e) {
return response()->json(['error' => 'could_not_create_token', 500]); return response()->json(['error' => 'could_not_create_token', 500]);
} catch (\Exception $e){ } catch (\Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
return response()->json(compact('error')); return response()->json(compact('error'));
} }
@@ -55,6 +56,7 @@ class TokenAuthController extends Controller {
// if no errors are encountered we can return a JWT // if no errors are encountered we can return a JWT
return response()->json(compact('token')); return response()->json(compact('token'));
} }
/** /**
* Get the user details from token * Get the user details from token
* @return type json * @return type json
@@ -75,8 +77,7 @@ class TokenAuthController extends Controller {
} catch (\Tymon\JWTAuth\Exceptions\JWTException $e) { } catch (\Tymon\JWTAuth\Exceptions\JWTException $e) {
return response()->json(['token_absent', $e->getStatusCode()]); return response()->json(['token_absent', $e->getStatusCode()]);
} } catch (\Exception $e) {
catch (\Exception $e){
$error = $e->getMessage(); $error = $e->getMessage();
return response()->json(compact('error')); return response()->json(compact('error'));
} }
@@ -110,6 +111,7 @@ class TokenAuthController extends Controller {
return response()->json(compact('error')); return response()->json(compact('error'));
} }
} }
/** /**
* verify the url is existing or not * verify the url is existing or not
* @return type json * @return type json
@@ -125,8 +127,7 @@ class TokenAuthController extends Controller {
} }
$url = $this->request->input('url'); $url = $this->request->input('url');
$url = $url.'/api/v1/helpdesk/check-url'; $url = $url . '/api/v1/helpdesk/check-url';
} catch (Exception $ex) { } catch (Exception $ex) {
$error = $e->getMessage(); $error = $e->getMessage();
return response()->json(compact('error')); return response()->json(compact('error'));

View File

@@ -1,14 +1,15 @@
<?php namespace App\Http\Controllers\Auth; <?php
namespace App\Http\Controllers\Auth;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// requests // requests
use App\Http\Requests\helpdesk\LoginRequest; use App\Http\Requests\helpdesk\LoginRequest;
use App\Http\Requests\helpdesk\RegisterRequest; use App\Http\Requests\helpdesk\RegisterRequest;
use App\User; use App\User;
// classes // classes
use Hash; use Hash;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
@@ -18,7 +19,6 @@ use Mail;
use Auth; use Auth;
use Exception; use Exception;
/** /**
* --------------------------------------------------- * ---------------------------------------------------
* AuthController * AuthController
@@ -33,131 +33,137 @@ use Exception;
*/ */
class AuthController extends Controller { class AuthController extends Controller {
use AuthenticatesAndRegistersUsers; use AuthenticatesAndRegistersUsers;
/* to redirect after login */ /* to redirect after login */
// if auth is agent
protected $redirectTo = '/dashboard';
// if auth is user
protected $redirectToUser = '/profile';
/* Direct After Logout */
protected $redirectAfterLogout = '/';
protected $loginPath = '/auth/login';
/** // if auth is agent
* Create a new authentication controller instance. protected $redirectTo = '/dashboard';
* // if auth is user
* @param \Illuminate\Contracts\Auth\Guard $auth protected $redirectToUser = '/profile';
* @param \Illuminate\Contracts\Auth\Registrar $registrar /* Direct After Logout */
* @return void protected $redirectAfterLogout = '/';
*/ protected $loginPath = '/auth/login';
public function __construct(Guard $auth, Registrar $registrar) {
SettingsController::smtp();
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
/** /**
* Get the form for registration * Create a new authentication controller instance.
* @return type Response *
*/ * @param \Illuminate\Contracts\Auth\Guard $auth
public function getRegister() { * @param \Illuminate\Contracts\Auth\Registrar $registrar
// Event for login * @return void
\Event::fire(new \App\Events\FormRegisterEvent()); */
if(Auth::user()) { public function __construct(Guard $auth, Registrar $registrar, PhpMailController $PhpMailController) {
if(Auth::user()->role == "admin" || Auth::user()->role == "agent") { $this->PhpMailController = $PhpMailController;
return \Redirect::route('dashboard'); SettingsController::smtp();
} elseif(Auth::user()->role == "user") { $this->auth = $auth;
// return view('auth.register'); $this->registrar = $registrar;
} $this->middleware('guest', ['except' => 'getLogout']);
} else { }
return view('auth.register');
}
}
/** /**
* Post registration form * Get the form for registration
* @param type User $user * @return type Response
* @param type RegisterRequest $request */
* @return type Response public function getRegister() {
*/ // Event for login
public function postRegister(User $user, RegisterRequest $request) { \Event::fire(new \App\Events\FormRegisterEvent());
// Event for login if (Auth::user()) {
\Event::fire(new \App\Events\LoginEvent($request)); if (Auth::user()->role == "admin" || Auth::user()->role == "agent") {
return \Redirect::route('dashboard');
} elseif (Auth::user()->role == "user") {
// return view('auth.register');
}
} else {
return view('auth.register');
}
}
$password = Hash::make($request->input('password')); /**
$user->password = $password; * Post registration form
$name = $request->input('full_name'); * @param type User $user
$user->user_name = $name; * @param type RegisterRequest $request
$user->email = $request->input('email'); * @return type Response
// $user->first_name = $request->input('first_name'); */
// $user->last_nmae = $request->input('last_nmae'); public function postRegister(User $user, RegisterRequest $request) {
// $user->phone_number = $request->input('phone_number'); // Event for login
// $user->company = $request->input('company'); \Event::fire(new \App\Events\LoginEvent($request));
$user->role = 'user';
$code = str_random(60); $password = Hash::make($request->input('password'));
$user->remember_token = $code; $user->password = $password;
$user->save(); $name = $request->input('full_name');
// send mail for successful registration $user->user_name = $name;
$mail = Mail::send('auth.activate', array('link' => url('getmail', $code), 'username' => $name), function ($message) use ($user) { $user->email = $request->input('email');
$message->to($user->email, $user->full_name)->subject('active your account'); // $user->first_name = $request->input('first_name');
}); // $user->last_nmae = $request->input('last_nmae');
return redirect('home')->with('success', 'Activate Your Account ! Click on Link that send to your mail'); // $user->phone_number = $request->input('phone_number');
} // $user->company = $request->input('company');
$user->role = 'user';
$code = str_random(60);
$user->remember_token = $code;
$user->save();
// send mail for successful registration
// $mail = Mail::send('auth.activate', array('link' => url('getmail', $code), 'username' => $name), function ($message) use ($user) {
// $message->to($user->email, $user->full_name)->subject('active your account');
// });
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => 'password', 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('password/reset/' . $code)]);
/**
* Get mail function
* @param type $token
* @param type User $user
* @return type Response
*/
public function getMail($token, User $user) {
$user = $user->where('remember_token', $token)->where('active', 0)->first();
if ($user) {
$user->active = 1;
$user->save();
return redirect('auth/login');
} else {
return redirect('auth/login');
}
}
/** return redirect('home')->with('success', 'Activate Your Account ! Click on Link that send to your mail');
* Get login page }
* @return type Response
*/
public function getLogin() {
if(Auth::user()) {
if(Auth::user()->role == "admin" || Auth::user()->role == "agent"){
return \Redirect::route('dashboard');
} elseif(Auth::user()->role == "user") {
return \Redirect::route('home');
}
} else {
return view('auth.login');
}
}
/** /**
* Post of login page * Get mail function
* @param type LoginRequest $request * @param type $token
* @return type Response * @param type User $user
*/ * @return type Response
public function postLogin(LoginRequest $request) { */
public function getMail($token, User $user) {
$user = $user->where('remember_token', $token)->where('active', 0)->first();
if ($user) {
$user->active = 1;
$user->save();
return redirect('auth/login');
} else {
return redirect('auth/login');
}
}
/**
* Get login page
* @return type Response
*/
public function getLogin() {
if (Auth::user()) {
if (Auth::user()->role == "admin" || Auth::user()->role == "agent") {
return \Redirect::route('dashboard');
} elseif (Auth::user()->role == "user") {
return \Redirect::route('home');
}
} else {
return view('auth.login');
}
}
/**
* Post of login page
* @param type LoginRequest $request
* @return type Response
*/
public function postLogin(LoginRequest $request) {
// Set login attempts and login time // Set login attempts and login time
$loginAttempts = 1; $loginAttempts = 1;
$usernameinput = $request->input('email'); $usernameinput = $request->input('email');
$password = $request->input('password'); $password = $request->input('password');
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name'; $field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
// If session has login attempts, retrieve attempts counter and attempts time // If session has login attempts, retrieve attempts counter and attempts time
if (\Session::has('loginAttempts')) { if (\Session::has('loginAttempts')) {
$loginAttempts = \Session::get('loginAttempts'); $loginAttempts = \Session::get('loginAttempts');
$loginAttemptTime = \Session::get('loginAttemptTime'); $loginAttemptTime = \Session::get('loginAttemptTime');
// $credentials = $request->only('email', 'password'); // $credentials = $request->only('email', 'password');
$usernameinput = $request->input('email'); $usernameinput = $request->input('email');
$password = $request->input('password'); $password = $request->input('password');
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name'; $field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
// If attempts > 3 and time < 10 minutes // If attempts > 3 and time < 10 minutes
if ($loginAttempts > 4 && (time() - $loginAttemptTime <= 600)) { if ($loginAttempts > 4 && (time() - $loginAttemptTime <= 600)) {
return redirect()->back()->with('error', 'Maximum login attempts reached. Try again in a while'); return redirect()->back()->with('error', 'Maximum login attempts reached. Try again in a while');
@@ -174,27 +180,27 @@ class AuthController extends Controller {
// If auth ok, redirect to restricted area // If auth ok, redirect to restricted area
\Session::put('loginAttempts', $loginAttempts + 1); \Session::put('loginAttempts', $loginAttempts + 1);
if ($this->auth->attempt([$field => $usernameinput, 'password' => $password], $request->has('remember'))) { if ($this->auth->attempt([$field => $usernameinput, 'password' => $password], $request->has('remember'))) {
if(Auth::user()->role == 'user') { if (Auth::user()->role == 'user') {
return \Redirect::route('/'); return \Redirect::route('/');
} else { } else {
return redirect()->intended($this->redirectPath()); return redirect()->intended($this->redirectPath());
} }
} }
return redirect($this->loginPath()) return redirect($this->loginPath())
->withInput($request->only('email', 'remember')) ->withInput($request->only('email', 'remember'))
->withErrors([ ->withErrors([
'email' => $this->getFailedLoginMessage(), 'email' => $this->getFailedLoginMessage(),
'password' => $this->getFailedLoginMessage(), 'password' => $this->getFailedLoginMessage(),
]); ]);
// Increment login attempts // Increment login attempts
} }
/** /**
* Get Failed login message * Get Failed login message
* @return type string * @return type string
*/ */
protected function getFailedLoginMessage() { protected function getFailedLoginMessage() {
return 'This Field do not match our records.'; return 'This Field do not match our records.';
} }
} }

View File

@@ -1,14 +1,15 @@
<?php namespace App\Http\Controllers\Auth; <?php
namespace App\Http\Controllers\Auth;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// request // request
use Illuminate\Http\Request; use Illuminate\Http\Request;
// model // model
use App\User; use App\User;
// classes // classes
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\PasswordBroker; use Illuminate\Contracts\Auth\PasswordBroker;
@@ -25,31 +26,61 @@ use Exception;
*/ */
class PasswordController extends Controller { class PasswordController extends Controller {
use ResetsPasswords; use ResetsPasswords;
/** /**
* Create a new password controller instance. * Create a new password controller instance.
* *
* @param \Illuminate\Contracts\Auth\Guard $auth * @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords * @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
* @return void * @return void
*/ */
public function __construct(Guard $auth, PasswordBroker $passwords) { public function __construct(Guard $auth, PasswordBroker $passwords, PhpMailController $PhpMailController) {
$this->auth = $auth; $this->PhpMailController = $PhpMailController;
$this->passwords = $passwords; $this->auth = $auth;
$this->middleware('guest'); $this->passwords = $passwords;
SettingsController::smtp(); $this->middleware('guest');
} SettingsController::smtp();
}
/**
* Display the form to request a password reset link.
*
* @return Response
*/
public function getEmail() {
return view('auth.password');
}
/** /**
* Display the form to request a password reset link. * Display the form to request a password reset link.
* *
* @return Response * @return Response
*/ */
public function getEmail() { public function postEmail(Request $request) {
return view('auth.password'); $date = date('Y-m-d H:i:s');
} $this->validate($request, ['email' => 'required|email']);
$user = User::where('email', '=', $request->only('email'))->first();
if (isset($user)) {
$user1 = $user->email;
//gen new code and pass
$code = str_random(60);
$password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->first();
if (isset($password_reset_table)) {
$password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->update(['token' => $code, 'created_at' => $date]);
// $password_reset_table->token = $code;
// $password_reset_table->update(['token' => $code]);
} else {
$create_password_reset = \DB::table('password_resets')->insert(['email' => $user->email, 'token' => $code, 'created_at' => $date]);
}
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user->user_name, 'email' => $user->email], $message = ['subject' => 'Your Password Reset Link', 'scenario' => 'reset-password'], $template_variables = ['user' => $user->user_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/' . $code)]);
return redirect()->back()->with('status', 'We have e-mailed your password reset link!');
} else {
return redirect()->back()->with('errors', "We can't find a user with that e-mail address.");
}
}
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Agent\helpdesk; <?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -37,81 +40,81 @@ use Redirect;
*/ */
class UserController extends Controller { class UserController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
* 1. authentication * 1. authentication
* 2. user roles * 2. user roles
* 3. roles must be agent * 3. roles must be agent
* *
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('role.agent'); $this->middleware('role.agent');
// $this->middleware('roles'); // $this->middleware('roles');
} }
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* @param type User $user * @param type User $user
* @return type Response * @return type Response
*/ */
public function index() { public function index() {
try { try {
/* get all values in Sys_user */ /* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index'); return view('themes.default1.agent.helpdesk.user.index');
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* This function is used to display the list of users * This function is used to display the list of users
* @return datatable * @return datatable
*/ */
public function user_list() { public function user_list() {
return \Datatable::collection(User::where('role','!=','admin')->where('role','!=','agent')->get()) return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
->searchColumns('user_name') ->searchColumns('user_name')
->orderColumns('user_name', 'email') ->orderColumns('user_name', 'email')
->addColumn('user_name', function ($model) { ->addColumn('user_name', function ($model) {
return $model->user_name; return $model->user_name;
}) })
->addColumn('email', function ($model) { ->addColumn('email', function ($model) {
$email = $model->email; $email = $model->email;
return $email; return $email;
}) })
->addColumn('phone', function ($model) { ->addColumn('phone', function ($model) {
$phone = ""; $phone = "";
if($model->phone_number) { if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number; $phone = $model->ext . ' ' . $model->phone_number;
} }
$mobile = ""; $mobile = "";
if($model->mobile) { if ($model->mobile) {
$mobile = $model->mobile; $mobile = $model->mobile;
} }
$phone = $phone ."&nbsp;&nbsp;&nbsp;". $mobile; $phone = $phone . "&nbsp;&nbsp;&nbsp;" . $mobile;
return $phone; return $phone;
}) })
->addColumn('status', function ($model) { ->addColumn('status', function ($model) {
$status = $model->active; $status = $model->active;
if($status == 1) { if ($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>'; $stat = '<button class="btn btn-success btn-xs">Active</button>';
} else { } else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>'; $stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
} }
return $stat; return $stat;
}) })
->addColumn('lastlogin', function ($model) { ->addColumn('lastlogin', function ($model) {
$t = $model->updated_at; $t = $model->updated_at;
return TicketController::usertimezone($t); return TicketController::usertimezone($t);
}) })
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
//return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a>&nbsp;<a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a>&nbsp;<a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>'; //return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a>&nbsp;<a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a>&nbsp;<a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
//return '<form action="article/delete/ ' . $model->id . '" method="post" onclick="alert()"><button type="sumbit" value="Delete"></button></form><a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a>&nbsp;<a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>'; //return '<form action="article/delete/ ' . $model->id . '" method="post" onclick="alert()"><button type="sumbit" value="Delete"></button></form><a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a>&nbsp;<a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id .'"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a> return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span>&nbsp;<a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp;<a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle'.$model->id .'"> <div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@@ -119,270 +122,271 @@ class UserController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4> <h4 class="modal-title">Are You Sure ?</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
'.$model->user_name.' ' . $model->user_name . '
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
<a href="'.route('user.delete',$model->id).'"><button class="btn btn-danger">delete</button></a> <a href="' . route('user.delete', $model->id) . '"><button class="btn btn-danger">delete</button></a>
</div> </div>
</div><!-- /.modal-content --> </div><!-- /.modal-content -->
</div><!-- /.modal-dialog --> </div><!-- /.modal-dialog -->
</div>'; </div>';
}) })
->make(); ->make();
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* @return type Response * @return type Response
*/ */
public function create() { public function create() {
try { try {
return view('themes.default1.agent.helpdesk.user.create'); return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* @param type User $user * @param type User $user
* @param type Sys_userRequest $request * @param type Sys_userRequest $request
* @return type Response * @return type Response
*/ */
public function store(User $user, Sys_userRequest $request) { public function store(User $user, Sys_userRequest $request) {
try { try {
/* insert the input request to sys_user table */ /* insert the input request to sys_user table */
/* Check whether function success or not */ /* Check whether function success or not */
$user->email = $request->input('email'); $user->email = $request->input('email');
$user->user_name = $request->input('full_name'); $user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile'); $user->mobile = $request->input('mobile');
$user->ext = $request->input('ext'); $user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number'); $user->phone_number = $request->input('phone_number');
$user->active = $request->input('active'); $user->active = $request->input('active');
$user->internal_note = $request->input('internal_note'); $user->internal_note = $request->input('internal_note');
$user->role = 'user'; $user->role = 'user';
if ($user->save() == true) { if ($user->save() == true) {
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully'); return redirect('user')->with('success', 'User Created Successfully');
} else { } else {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Create'); return redirect('user')->with('fails', 'User can not Create');
} }
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Create'); return redirect('user')->with('fails', 'User can not Create');
} }
} }
/** /**
* Display the specified resource. * Display the specified resource.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @return type Response * @return type Response
*/ */
public function show($id, User $user) { public function show($id, User $user) {
try { try {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first(); $users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users')); return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @return type Response * @return type Response
*/ */
public function edit($id, User $user) { public function edit($id, User $user) {
try { try {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first(); $users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users')); return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
} }
} }
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @param type Sys_userUpdate $request * @param type Sys_userUpdate $request
* @return type Response * @return type Response
*/ */
public function update($id, User $user, Sys_userUpdate $request) { public function update($id, User $user, Sys_userUpdate $request) {
try { try {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first(); $users = $user->whereId($id)->first();
/* Update the value by selected field */ /* Update the value by selected field */
/* Check whether function success or not */ /* Check whether function success or not */
if ($users->fill($request->input())->save() == true) { if ($users->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully'); return redirect('user')->with('success', 'User Updated Successfully');
} else { } else {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Update'); return redirect('user')->with('fails', 'User can not Update');
} }
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Update'); return redirect('user')->with('fails', 'User can not Update');
} }
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* @return type Response * @return type Response
*/ */
public function destroy($id, User $user) { public function destroy($id, User $user) {
try { try {
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first(); $users = $user->whereId($id)->first();
/* delete the selected field */ /* delete the selected field */
/* Check whether function success or not */ /* Check whether function success or not */
if ($users->delete() == true) { if ($users->delete() == true) {
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Deleted Successfully'); return redirect('user')->with('success', 'User Deleted Successfully');
} else { } else {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Delete'); return redirect('user')->with('fails', 'User can not Delete');
} }
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Delete'); return redirect('user')->with('fails', 'User can not Delete');
} }
} }
/** /**
* get profile page * get profile page
* @return type Response * @return type Response
*/ */
public function getProfile() { public function getProfile() {
$user = Auth::user(); $user = Auth::user();
return view('themes.default1.agent.helpdesk.user.profile', compact('user')); return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} }
/** /**
* get profile edit page * get profile edit page
* @return type Response * @return type Response
*/ */
public function getProfileedit() { public function getProfileedit() {
$user = Auth::user(); $user = Auth::user();
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user')); return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} }
/** /**
* post profile page * post profile page
* @param type int $id * @param type int $id
* @param type ProfileRequest $request * @param type ProfileRequest $request
* @return type Response * @return type Response
*/ */
public function postProfileedit(ProfileRequest $request) { public function postProfileedit(ProfileRequest $request) {
$user = Auth::user(); $user = Auth::user();
$user->gender = $request->input('gender'); $user->gender = $request->input('gender');
$user->save(); $user->save();
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') { if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
if ($request->input('gender') == 1) { if ($request->input('gender') == 1) {
$name = 'avatar5.png'; $name = 'avatar5.png';
$destinationPath = 'lb-faveo/profilepic'; $destinationPath = 'lb-faveo/profilepic';
$user->profile_pic = $name; $user->profile_pic = $name;
} elseif ($request->input('gender') == 0) { } elseif ($request->input('gender') == 0) {
$name = 'avatar2.png'; $name = 'avatar2.png';
$destinationPath = 'lb-faveo/profilepic'; $destinationPath = 'lb-faveo/profilepic';
$user->profile_pic = $name; $user->profile_pic = $name;
} }
} }
if (Input::file('profile_pic')) { if (Input::file('profile_pic')) {
//$extension = Input::file('profile_pic')->getClientOriginalExtension(); //$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName(); $name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/profilepic'; $destinationPath = 'lb-faveo/profilepic';
$fileName = rand(0000, 9999) . '.' . $name; $fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName; //echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName); Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName; $user->profile_pic = $fileName;
} else { } else {
$user->fill($request->except('profile_pic', 'gender'))->save(); $user->fill($request->except('profile_pic', 'gender'))->save();
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully'); return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
} }
if ($user->fill($request->except('profile_pic'))->save()) { if ($user->fill($request->except('profile_pic'))->save()) {
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully'); return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
} }
} }
/** /**
* Post profile password * Post profile password
* @param type int $id * @param type int $id
* @param type ProfilePassword $request * @param type ProfilePassword $request
* @return type Response * @return type Response
*/ */
public function postProfilePassword($id, ProfilePassword $request) { public function postProfilePassword($id, ProfilePassword $request) {
$user = Auth::user(); $user = Auth::user();
//echo $user->password; //echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password')); $user->password = Hash::make($request->input('new_password'));
$user->save(); $user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully'); return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} else { } else {
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password'); return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
} }
} }
/** /**
* User Assign Org * User Assign Org
* @param type $id * @param type $id
* @return type boolean * @return type boolean
*/ */
public function UserAssignOrg($id) { public function UserAssignOrg($id) {
$org = Input::get('org'); $org = Input::get('org');
$user_org = new User_org; $user_org = new User_org;
$user_org->org_id = $org; $user_org->org_id = $org;
$user_org->user_id = $id; $user_org->user_id = $id;
$user_org->save(); $user_org->save();
return 1; return 1;
} }
/** /**
* user create organisation * user create organisation
* @return type value * @return type value
*/ */
public function User_Create_Org($id) { public function User_Create_Org($id) {
if(Input::get('website')!=null) { if (Input::get('website') != null) {
// checking website // checking website
$check = Organization::where('website','=',Input::get('website'))->first(); $check = Organization::where('website', '=', Input::get('website'))->first();
} else { } else {
$check = null; $check = null;
} }
// checking name // checking name
$check2 = Organization::where('name','=',Input::get('name'))->first(); $check2 = Organization::where('name', '=', Input::get('name'))->first();
if (\Input::get('name') == null) { if (\Input::get('name') == null) {
return "Name is required"; return "Name is required";
} elseif($check2 != null) { } elseif ($check2 != null) {
return "Name should be Unique"; return "Name should be Unique";
} elseif($check != null) { } elseif ($check != null) {
return "Website should be Unique"; return "Website should be Unique";
} else { } else {
$org = new Organization; $org = new Organization;
$org->name = Input::get('name'); $org->name = Input::get('name');
$org->phone = Input::get('phone'); $org->phone = Input::get('phone');
$org->website = Input::get('website'); $org->website = Input::get('website');
$org->address = Input::get('address'); $org->address = Input::get('address');
$org->internal_notes = Input::get('internal'); $org->internal_notes = Input::get('internal');
$org->save(); $org->save();
$user_org = new User_org; $user_org = new User_org;
$user_org->org_id = $org->id; $user_org->org_id = $org->id;
$user_org->user_id = $id; $user_org->user_id = $id;
$user_org->save(); $user_org->save();
return 0;
}
}
return 0;
}
}
} }

View File

@@ -1,16 +1,16 @@
<?php namespace App\Http\Controllers\Client\helpdesk; <?php
namespace App\Http\Controllers\Client\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\SettingsController;
// requests // requests
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\helpdesk\CreateTicketRequest; use App\Http\Requests\helpdesk\CreateTicketRequest;
use App\Http\Requests\helpdesk\TicketRequest; use App\Http\Requests\helpdesk\TicketRequest;
use App\Http\Requests\helpdesk\TicketEditRequest; use App\Http\Requests\helpdesk\TicketEditRequest;
// models // models
use App\Model\helpdesk\Email\Banlist; use App\Model\helpdesk\Email\Banlist;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
@@ -24,7 +24,6 @@ use App\Model\helpdesk\Ticket\Ticket_Status;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Agent\Department;
use App\User; use App\User;
// classes // classes
use Auth; use Auth;
use Hash; use Hash;
@@ -42,55 +41,54 @@ use Exception;
*/ */
class ClientTicketController extends Controller { class ClientTicketController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type response * @return type response
*/ */
public function __construct() { public function __construct() {
SettingsController::smtp(); SettingsController::smtp();
// $this->middleware('auth'); // $this->middleware('auth');
// $this->middleware('role.user'); // $this->middleware('role.user');
} }
/** /**
* Get Checked ticket * Get Checked ticket
* @param type Tickets $ticket * @param type Tickets $ticket
* @param type User $user * @param type User $user
* @return type response * @return type response
*/ */
public function getCheckTicket(Tickets $ticket, User $user) { public function getCheckTicket(Tickets $ticket, User $user) {
return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket')); return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket'));
} }
/** /**
* reply * reply
* @param type $value * @param type $value
* @return type view * @return type view
*/ */
public function reply($id, Request $request) { public function reply($id, Request $request) {
$comment = $request->input('comment'); $comment = $request->input('comment');
if($comment != null) { if ($comment != null) {
$tickets = Tickets::where('id','=',$id)->first(); $tickets = Tickets::where('id', '=', $id)->first();
$tickets->closed_at = null; $tickets->closed_at = null;
$tickets->closed = 0; $tickets->closed = 0;
$tickets->reopened_at = date('Y-m-d H:i:s'); $tickets->reopened_at = date('Y-m-d H:i:s');
$tickets->reopened = 1; $tickets->reopened = 1;
$threads = new Ticket_Thread; $threads = new Ticket_Thread;
$threads->user_id = Auth::user()->id; $threads->user_id = Auth::user()->id;
$threads->ticket_id = $tickets->id; $threads->ticket_id = $tickets->id;
$threads->poster = "client"; $threads->poster = "client";
$threads->body = $comment; $threads->body = $comment;
try { try {
$threads->save(); $threads->save();
$tickets->save(); $tickets->save();
return \Redirect::back()->with('success1','Successfully replied'); return \Redirect::back()->with('success1', 'Successfully replied');
} catch(Exception $e) { } catch (Exception $e) {
return \Redirect::back()->with('fails1',$e->errorInfo[2]); return \Redirect::back()->with('fails1', $e->errorInfo[2]);
} }
} else { } else {
return \Redirect::back()->with('fails1','Please fill some data!'); return \Redirect::back()->with('fails1', 'Please fill some data!');
} }
} }
} }

View File

@@ -1,11 +1,11 @@
<?php namespace App\Http\Controllers\Client\helpdesk; <?php
namespace App\Http\Controllers\Client\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// models // models
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
// classes // classes
use Exception; use Exception;
@@ -18,15 +18,14 @@ use Exception;
*/ */
class OuthouseController extends Controller { class OuthouseController extends Controller {
/** /**
* post port * post port
* *
* @return string * @return string
*/ */
public static function port() public static function port() {
{ $port = Emails::where('id', '=', '1')->first();
$port = Emails::where('id','=','1')->first(); $portvalue = $port->option_value;
$portvalue = $port->option_value;
return $portvalue; return $portvalue;
} }
@@ -35,10 +34,9 @@ class OuthouseController extends Controller {
* *
* @return string * @return string
*/ */
public static function host() public static function host() {
{ $host = Option::where('option_name', '=', 'host')->first();
$host=Option::where('option_name','=','host')->first(); $hostvalue = $host->option_value;
$hostvalue=$host->option_value;
return $hostvalue; return $hostvalue;
} }
@@ -47,10 +45,9 @@ class OuthouseController extends Controller {
* *
* @return string * @return string
*/ */
public static function username() public static function username() {
{ $username = Option::where('option_name', '=', 'username')->first();
$username=Option::where('option_name','=','username')->first(); $uservalue = $username->option_value;
$uservalue=$username->option_value;
return $uservalue; return $uservalue;
} }
@@ -60,10 +57,9 @@ class OuthouseController extends Controller {
* *
* @return string * @return string
*/ */
public static function password() public static function password() {
{ $password = Option::where('option_name', '=', 'password')->first();
$password=Option::where('option_name','=','password')->first(); $passvalue = $password->option_value;
$passvalue=$password->option_value;
return $passvalue; return $passvalue;
} }
@@ -73,10 +69,9 @@ class OuthouseController extends Controller {
* *
* @return string * @return string
*/ */
public static function encryption() public static function encryption() {
{ $encryption = Option::where('option_name', '=', 'encryption')->first();
$encryption=Option::where('option_name','=','encryption')->first(); $encryptvalue = $encryption->option_value;
$encryptvalue=$encryption->option_value;
return $encryptvalue; return $encryptvalue;
} }

View File

@@ -1,14 +1,14 @@
<?php namespace App\Http\Controllers\Client\helpdesk; <?php
namespace App\Http\Controllers\Client\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\SettingsController;
// requests // requests
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\helpdesk\ClientRequest; use App\Http\Requests\helpdesk\ClientRequest;
// models // models
use App\Model\helpdesk\Form\Forms; use App\Model\helpdesk\Form\Forms;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
@@ -22,7 +22,6 @@ use App\Model\helpdesk\Ticket\Ticket_source;
use App\User; use App\User;
use App\Model\helpdesk\Form\Fields; use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Form\Form_value; use App\Model\helpdesk\Form\Form_value;
// classes // classes
use Form; use Form;
use Input; use Input;
@@ -43,152 +42,148 @@ use Exception;
*/ */
class FormController extends Controller { class FormController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* Constructor to check * Constructor to check
* @return void * @return void
*/ */
public function __construct(TicketController $TicketController) { public function __construct(TicketController $TicketController) {
// mail smtp settings // mail smtp settings
SettingsController::smtp(); SettingsController::smtp();
// creating a TicketController instance // creating a TicketController instance
$this->TicketController = $TicketController; $this->TicketController = $TicketController;
} }
/** /**
* getform * getform
* @param type Help_topic $topic * @param type Help_topic $topic
* @return type * @return type
*/ */
public function getForm(Help_topic $topic) { public function getForm(Help_topic $topic) {
if(\Config::get('database.install') == '%0%') { if (\Config::get('database.install') == '%0%') {
return \Redirect::route('license'); return \Redirect::route('license');
} }
if(System::first()->status == 1) { if (System::first()->status == 1) {
$topics = $topic->get(); $topics = $topic->get();
return view('themes.default1.client.helpdesk.form', compact('topics')); return view('themes.default1.client.helpdesk.form', compact('topics'));
} else { } else {
return \Redirect::route('home'); return \Redirect::route('home');
} }
} }
/** /**
* This Function to post the form for the ticket * This Function to post the form for the ticket
* @param type Form_name $name * @param type Form_name $name
* @param type Form_details $details * @param type Form_details $details
* @return type string * @return type string
*/ */
public function postForm($id, Help_topic $topic) { public function postForm($id, Help_topic $topic) {
// dd($id); // dd($id);
if($id != 0 ){ if ($id != 0) {
$helptopic = $topic->where('id', '=', $id)->first(); $helptopic = $topic->where('id', '=', $id)->first();
$custom_form = $helptopic->custom_form; $custom_form = $helptopic->custom_form;
$values = Fields::where('forms_id', '=', $custom_form)->get(); $values = Fields::where('forms_id', '=', $custom_form)->get();
if(!$values) { if (!$values) {
} if($values) {
foreach($values as $value){
if($value->type == "select") {
$data = $value->value;
$value = explode(',', $data);
echo '<select class="form-control">';
foreach($value as $option){
echo '<option>'.$option.'</option>';
}
echo '</select></br>';
} elseif ($value->type == "radio" ) {
$type2 = $value->value;
$val = explode(',', $type2);
echo '<label class="radio-inline">'.$value->label.'</label>&nbsp&nbsp&nbsp<input type="'.$value->type.'" name="'.$value->name.'">&nbsp;&nbsp;'.$val[0].'
&nbsp&nbsp&nbsp<input type="'.$value->type.'" name="'.$value->name.'">&nbsp;&nbsp;'.$val[1].'</br>';
} elseif($value->type == "textarea" ) {
$type3 = $value->value;
$v = explode(',', $type3);
//dd($v);
if(array_key_exists(1, $v)){
echo '<label>'.$value->label.'</label></br><textarea class=form-control rows="'.$v[0].'" cols="'.$v[1].'"></textarea></br>';
} else {
echo '<label>'.$value->label.'</label></br><textarea class=form-control rows="10" cols="60"></textarea></br>';
}
} elseif($value->type == "checkbox" ) {
$type4 = $value->value;
$check = explode(',', $type4);
echo '<label class="radio-inline">'.$value->label.'&nbsp&nbsp&nbsp<input type="'.$value->type.'" name="'.$value->name.'">&nbsp&nbsp'.$check[0].'</label><label class="radio-inline"><input type="'.$value->type.'" name="'.$value->name.'">&nbsp&nbsp'.$check[1].'</label></br>';
} else {
echo '<label>'.$value->label.'</label><input type="'.$value->type.'" class="form-control" name="'.$value->name.'" /></br>';
}
}
}
} else {
return null;
}
}
/** } if ($values) {
* Posted form foreach ($values as $value) {
* @param type Request $request if ($value->type == "select") {
* @param type User $user $data = $value->value;
*/ $value = explode(',', $data);
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source) { echo '<select class="form-control">';
foreach ($value as $option) {
echo '<option>' . $option . '</option>';
}
echo '</select></br>';
} elseif ($value->type == "radio") {
$type2 = $value->value;
$val = explode(',', $type2);
echo '<label class="radio-inline">' . $value->label . '</label>&nbsp&nbsp&nbsp<input type="' . $value->type . '" name="' . $value->name . '">&nbsp;&nbsp;' . $val[0] . '
&nbsp&nbsp&nbsp<input type="' . $value->type . '" name="' . $value->name . '">&nbsp;&nbsp;' . $val[1] . '</br>';
} elseif ($value->type == "textarea") {
$type3 = $value->value;
$v = explode(',', $type3);
//dd($v);
if (array_key_exists(1, $v)) {
echo '<label>' . $value->label . '</label></br><textarea class=form-control rows="' . $v[0] . '" cols="' . $v[1] . '"></textarea></br>';
} else {
echo '<label>' . $value->label . '</label></br><textarea class=form-control rows="10" cols="60"></textarea></br>';
}
} elseif ($value->type == "checkbox") {
$type4 = $value->value;
$check = explode(',', $type4);
echo '<label class="radio-inline">' . $value->label . '&nbsp&nbsp&nbsp<input type="' . $value->type . '" name="' . $value->name . '">&nbsp&nbsp' . $check[0] . '</label><label class="radio-inline"><input type="' . $value->type . '" name="' . $value->name . '">&nbsp&nbsp' . $check[1] . '</label></br>';
} else {
echo '<label>' . $value->label . '</label><input type="' . $value->type . '" class="form-control" name="' . $value->name . '" /></br>';
}
}
}
} else {
return null;
}
}
$form_extras = $request->except('Name','Phone','Email','Subject','Details','helptopic','_wysihtml5_mode','_token'); /**
* Posted form
* @param type Request $request
* @param type User $user
*/
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source) {
$name = $request->input('Name'); $form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token');
$phone = $request->input('Phone');
$email = $request->input('Email');
$subject = $request->input('Subject');
$details = $request->input('Details');
$System = System::where('id','=',1)->first(); $name = $request->input('Name');
$departments = Department::where('id','=',$System->department)->first(); $phone = $request->input('Phone');
$department = $departments->id; $email = $request->input('Email');
$subject = $request->input('Subject');
$details = $request->input('Details');
$status = $ticket_settings->first()->status; $System = System::where('id', '=', 1)->first();
$helptopic = $ticket_settings->first()->help_topic; $departments = Department::where('id', '=', $System->department)->first();
$sla = $ticket_settings->first()->sla; $department = $departments->id;
$priority = $ticket_settings->first()->priority;
$source = $ticket_source->where('name','=','web')->first();
$collaborator = null; $status = $ticket_settings->first()->status;
$assignto = null; $helptopic = $ticket_settings->first()->help_topic;
$sla = $ticket_settings->first()->sla;
$priority = $ticket_settings->first()->priority;
$source = $ticket_source->where('name', '=', 'web')->first();
if($this->TicketController->create_user($email, $name, $subject, $details, $phone, $helptopic, $sla, $priority, $source->id, $collaborator, $department,$assignto, $form_extras)) { $collaborator = null;
return Redirect::route('guest.getform')->with('success','Ticket Created Successfully'); $assignto = null;
}
}
if ($this->TicketController->create_user($email, $name, $subject, $details, $phone, $helptopic, $sla, $priority, $source->id, $collaborator, $department, $assignto, $form_extras)) {
return Redirect::route('guest.getform')->with('success', 'Ticket Created Successfully');
}
}
/**
/** * reply
* reply * @param type $value
* @param type $value * @return type view
* @return type view */
*/ public function post_ticket_reply($id, Request $request) {
public function post_ticket_reply($id, Request $request) { $comment = $request->input('comment');
$comment = $request->input('comment'); if ($comment != null) {
if($comment != null) { $tickets = Tickets::where('id', '=', $id)->first();
$tickets = Tickets::where('id','=',$id)->first(); $threads = new Ticket_Thread;
$threads = new Ticket_Thread; $tickets->closed_at = null;
$tickets->closed_at = null; $tickets->closed = 0;
$tickets->closed = 0; $tickets->reopened_at = date('Y-m-d H:i:s');
$tickets->reopened_at = date('Y-m-d H:i:s'); $tickets->reopened = 1;
$tickets->reopened = 1; $threads->user_id = $tickets->user_id;
$threads->user_id = $tickets->user_id; $threads->ticket_id = $tickets->id;
$threads->ticket_id = $tickets->id; $threads->poster = "client";
$threads->poster = "client"; $threads->body = $comment;
$threads->body = $comment; try {
try { $threads->save();
$threads->save(); $tickets->save();
$tickets->save(); return \Redirect::back()->with('success1', 'Successfully replied');
return \Redirect::back()->with('success1','Successfully replied'); } catch (Exception $e) {
} catch(Exception $e) { return \Redirect::back()->with('fails1', $e->errorInfo[2]);
return \Redirect::back()->with('fails1',$e->errorInfo[2]); }
} } else {
} else { return \Redirect::back()->with('fails1', 'Please fill some data!');
return \Redirect::back()->with('fails1','Please fill some data!'); }
} }
}
} }

View File

@@ -1,15 +1,16 @@
<?php namespace App\Http\Controllers\Client\helpdesk; <?php
namespace App\Http\Controllers\Client\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// requests // requests
use App\Http\Requests\helpdesk\CheckTicket; use App\Http\Requests\helpdesk\CheckTicket;
use App\Http\Requests\helpdesk\ProfilePassword; use App\Http\Requests\helpdesk\ProfilePassword;
use App\Http\Requests\helpdesk\ProfileRequest; use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\TicketRequest; use App\Http\Requests\helpdesk\TicketRequest;
// models // models
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
@@ -17,7 +18,6 @@ use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Settings\Company; use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\System; use App\Model\helpdesk\Settings\System;
use App\User; use App\User;
// classes // classes
use Auth; use Auth;
use Hash; use Hash;
@@ -33,234 +33,233 @@ use Exception;
*/ */
class GuestController extends Controller { class GuestController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance.
* @return type void * @return type void
*/ */
public function __construct(PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
SettingsController::smtp();
// checking authentication
$this->middleware('auth');
}
public function __construct() { /**
SettingsController::smtp(); * Get profile
// checking authentication * @return type Response
$this->middleware('auth'); */
} public function getProfile() {
$user = Auth::user();
return view('themes.default1.client.helpdesk.profile', compact('user'));
}
/** /**
* Get profile * Save profile data
* @return type Response * @param type $id
*/ * @param type ProfileRequest $request
public function getProfile() { * @return type Response
$user = Auth::user(); */
return view('themes.default1.client.helpdesk.profile', compact('user')); public function postProfile(ProfileRequest $request) {
} $user = User::where('id', '=', Auth::user()->id)->first();
$user->gender = $request->get('gender');
$user->save();
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
if ($request->input('gender') == 1) {
$name = 'avatar5.png';
$destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name;
}
}
if (Input::file('profile_pic')) {
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/media/profilepic';
$fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName;
} else {
$user->fill($request->except('profile_pic', 'gender'))->save();
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
}
}
/** /**
* Save profile data * Get Ticket page
* @param type $id * @param type Help_topic $topic
* @param type ProfileRequest $request * @return type Response
* @return type Response */
*/ public function getTicket(Help_topic $topic) {
public function postProfile(ProfileRequest $request) { $topics = $topic->get();
$user = User::where('id','=',Auth::user()->id)->first(); return view('themes.default1.client.helpdesk.tickets.form', compact('topics'));
$user->gender = $request->get('gender'); }
$user->save();
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
if ($request->input('gender') == 1) {
$name = 'avatar5.png';
$destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/media/profilepic';
$user->profile_pic = $name;
}
}
if (Input::file('profile_pic')) {
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/media/profilepic';
$fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName;
} else {
$user->fill($request->except('profile_pic', 'gender'))->save();
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
}
}
/** /**
* Get Ticket page * getform
* @param type Help_topic $topic * @param type Help_topic $topic
* @return type Response * @return type
*/ */
public function getTicket(Help_topic $topic) { public function getForm(Help_topic $topic) {
$topics = $topic->get(); if (\Config::get('database.install') == '%0%') {
return view('themes.default1.client.helpdesk.tickets.form', compact('topics')); return \Redirect::route('license');
} }
if (System::first()->status == 1) {
$topics = $topic->get();
return view('themes.default1.client.helpdesk.form', compact('topics'));
} else {
return \Redirect::route('home');
}
}
/** /**
* getform * Get my ticket
* @param type Help_topic $topic * @param type Tickets $tickets
* @return type * @param type Ticket_Thread $thread
*/ * @param type User $user
public function getForm(Help_topic $topic) { * @return type Response
if(\Config::get('database.install') == '%0%') { */
return \Redirect::route('license'); public function getMyticket() {
} return view('themes.default1.client.helpdesk.mytickets');
if(System::first()->status == 1) { }
$topics = $topic->get();
return view('themes.default1.client.helpdesk.form', compact('topics'));
} else {
return \Redirect::route('home');
}
}
/** /**
* Get my ticket * Get ticket-thread
* @param type Tickets $tickets * @param type Ticket_Thread $thread
* @param type Ticket_Thread $thread * @param type Tickets $tickets
* @param type User $user * @param type User $user
* @return type Response * @return type Response
*/ */
public function getMyticket() { public function thread(Ticket_Thread $thread, Tickets $tickets, User $user) {
return view('themes.default1.client.helpdesk.mytickets'); $user_id = Auth::user()->id;
} //dd($user_id);
/* get the ticket's id == ticket_id of thread */
$tickets = $tickets->where('user_id', '=', $user_id)->first();
//dd($ticket);
$thread = $thread->where('ticket_id', $tickets->id)->first();
//dd($thread);
// $tickets = $tickets->whereId($id)->first();
return view('themes.default1.client.guest-user.view_ticket', compact('thread', 'tickets'));
}
/** /**
* Get ticket-thread * ticket Edit
* @param type Ticket_Thread $thread * @return
* @param type Tickets $tickets */
* @param type User $user public function ticketEdit() {
* @return type Response
*/
public function thread(Ticket_Thread $thread, Tickets $tickets, User $user) {
$user_id = Auth::user()->id;
//dd($user_id);
/* get the ticket's id == ticket_id of thread */
$tickets = $tickets->where('user_id', '=', $user_id)->first();
//dd($ticket);
$thread = $thread->where('ticket_id', $tickets->id)->first();
//dd($thread);
// $tickets = $tickets->whereId($id)->first();
return view('themes.default1.client.guest-user.view_ticket', compact('thread', 'tickets'));
}
/** }
* ticket Edit
* @return
*/
public function ticketEdit() {
}
/** /**
* Post porfile password * Post porfile password
* @param type $id * @param type $id
* @param type ProfilePassword $request * @param type ProfilePassword $request
* @return type Response * @return type Response
*/ */
public function postProfilePassword(ProfilePassword $request) { public function postProfilePassword(ProfilePassword $request) {
$user = Auth::user(); $user = Auth::user();
//echo $user->password; //echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password')); $user->password = Hash::make($request->input('new_password'));
try{ try {
$user->save(); $user->save();
return redirect()->back()->with('success2', 'Password Updated sucessfully'); return redirect()->back()->with('success2', 'Password Updated sucessfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails2', $e->errorInfo[2]); return redirect()->back()->with('fails2', $e->errorInfo[2]);
} }
} else { } else {
return redirect()->back()->with('fails2', 'Password was not Updated. Incorrect old password'); return redirect()->back()->with('fails2', 'Password was not Updated. Incorrect old password');
} }
} }
/** /**
* Ticekt reply * Ticekt reply
* @param type Ticket_Thread $thread * @param type Ticket_Thread $thread
* @param type TicketRequest $request * @param type TicketRequest $request
* @return type Response * @return type Response
*/ */
public function reply(Ticket_Thread $thread, TicketRequest $request) { public function reply(Ticket_Thread $thread, TicketRequest $request) {
$thread->ticket_id = $request->input('ticket_ID'); $thread->ticket_id = $request->input('ticket_ID');
$thread->title = $request->input('To'); $thread->title = $request->input('To');
$thread->user_id = Auth::user()->id; $thread->user_id = Auth::user()->id;
$thread->body = $request->input('ReplyContent'); $thread->body = $request->input('ReplyContent');
$thread->poster = 'user'; $thread->poster = 'user';
$thread->save(); $thread->save();
$ticket_id = $request->input('ticket_ID'); $ticket_id = $request->input('ticket_ID');
$tickets = Tickets::where('id', '=', $ticket_id)->first(); $tickets = Tickets::where('id', '=', $ticket_id)->first();
$thread = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first(); $thread = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first();
return Redirect("thread/" . $ticket_id); return Redirect("thread/" . $ticket_id);
} }
/** /**
* Get Checked ticket * Get Checked ticket
* @param type Tickets $ticket * @param type Tickets $ticket
* @param type User $user * @param type User $user
* @return type response * @return type response
*/ */
public function getCheckTicket(Tickets $ticket, User $user) { public function getCheckTicket(Tickets $ticket, User $user) {
return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket')); return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket'));
} }
/** /**
* Post Check ticket * Post Check ticket
* @param type CheckTicket $request * @param type CheckTicket $request
* @param type User $user * @param type User $user
* @param type Tickets $ticket * @param type Tickets $ticket
* @param type Ticket_Thread $thread * @param type Ticket_Thread $thread
* @return type Response * @return type Response
*/ */
public function PostCheckTicket() { public function PostCheckTicket() {
$Email = \Input::get('email'); $Email = \Input::get('email');
$Ticket_number = \Input::get('ticket_number'); $Ticket_number = \Input::get('ticket_number');
$ticket = Tickets::where('ticket_number', '=', $Ticket_number)->first(); $ticket = Tickets::where('ticket_number', '=', $Ticket_number)->first();
if($ticket == null) { if ($ticket == null) {
return \Redirect::route('form')->with('fails', 'There is no such Ticket Number'); return \Redirect::route('form')->with('fails', 'There is no such Ticket Number');
} else { } else {
$userId = $ticket->user_id; $userId = $ticket->user_id;
$user = User::where('id', '=', $userId)->first(); $user = User::where('id', '=', $userId)->first();
if($user->role == 'user') { if ($user->role == 'user') {
$username = $user->user_name; $username = $user->user_name;
} else { } else {
$username = $user->first_name." ".$user->last_name; $username = $user->first_name . " " . $user->last_name;
} }
if($user->email != $Email) { if ($user->email != $Email) {
return \Redirect::route('form')->with('fails', "Email didn't match with Ticket Number"); return \Redirect::route('form')->with('fails', "Email didn't match with Ticket Number");
} else { } else {
$code = $ticket->id; $code = $ticket->id;
$code = \Crypt::encrypt($code); $code = \Crypt::encrypt($code);
$company = $this->company(); $company = $this->company();
\Mail::send('emails.check_ticket', $this->PhpMailController->sendmail(
array('link'=>\URL::route('check_ticket',$code),'user'=>$username, 'from'=>$company), $from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $user->email], $message = ['subject' => 'Ticket link Request [' . $Ticket_number . ']', 'scenario' => 'check-ticket'], $template_variables = ['user' => $username, 'ticket_link_with_number' => \URL::route('check_ticket', $code)]
function($message) use($user, $username, $Ticket_number) { );
$message->to($user->email, $username)->subject('Ticket link Request ['.$Ticket_number.']');
}
);
return \Redirect::back()
->with('success','We have sent you a link by Email. Please click on that link to view ticket');
}
}
}
/** return \Redirect::back()
* get ticket email ->with('success', 'We have sent you a link by Email. Please click on that link to view ticket');
* @param type $id }
* @return type }
*/ }
public function get_ticket_email($id) {
$id1 = \Crypt::decrypt($id); /**
return view('themes.default1.client.helpdesk.ckeckticket',compact('id')); * get ticket email
} * @param type $id
* @return type
*/
public function get_ticket_email($id) {
$id1 = \Crypt::decrypt($id);
return view('themes.default1.client.helpdesk.ckeckticket', compact('id'));
}
/** /**
* get ticket status * get ticket status
@@ -268,21 +267,21 @@ class GuestController extends Controller {
* @return type * @return type
*/ */
public function getTicketStat(Tickets $ticket) { public function getTicketStat(Tickets $ticket) {
return view('themes.default1.client.helpdesk.ckeckticket', compact('ticket')); return view('themes.default1.client.helpdesk.ckeckticket', compact('ticket'));
} }
/** /**
* get company * get company
* @return type * @return type
*/ */
public function company() { public function company() {
$company = Company::Where('id','=','1')->first(); $company = Company::Where('id', '=', '1')->first();
if($company->company_name == null){ if ($company->company_name == null) {
$company = "Support Center"; $company = "Support Center";
}else{ } else {
$company = $company->company_name; $company = $company->company_name;
} }
return $company; return $company;
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Client\helpdesk; <?php
namespace App\Http\Controllers\Client\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// models // models
@@ -17,26 +20,27 @@ use Exception;
*/ */
class WelcomepageController extends Controller { class WelcomepageController extends Controller {
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
* @return Response * @return Response
*/ */
public function get(System $note) { public function get(System $note) {
if(Config::get('database.install')=='%0%') { if (Config::get('database.install') == '%0%') {
return Redirect::route('licence'); return Redirect::route('licence');
} }
$notes = $note->get(); $notes = $note->get();
foreach ($notes as $note) { foreach ($notes as $note) {
$content = $note->content; $content = $note->content;
} }
return view('themes.default1.client.guest-user.guest', compact('heading', 'content')); return view('themes.default1.client.guest-user.guest', compact('heading', 'content'));
} }
public function index() { public function index() {
if(Config::get('database.install')=='%0%') { if (Config::get('database.install') == '%0%') {
return Redirect::route('licence'); return Redirect::route('licence');
} }
return view('themes.default1.client.helpdesk.guest-user.index'); return view('themes.default1.client.helpdesk.guest-user.index');
} }
} }

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Controllers\Client\kb; <?php
namespace App\Http\Controllers\Client\kb;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\kb\CommentRequest; use App\Http\Requests\kb\CommentRequest;
@@ -24,275 +26,281 @@ use Exception;
class UserController extends Controller { class UserController extends Controller {
public function __construct() { public function __construct() {
//$this->middleware('auth'); //$this->middleware('auth');
//SettingsController::language(); //SettingsController::language();
// $this->port(); // $this->port();
// $this->host(); // $this->host();
// $this->password(); // $this->password();
// $this->encryption(); // $this->encryption();
// $this->email(); // $this->email();
} }
/** /**
* @param * @param
* @return response * @return response
* @package default * @package default
*/ */
public function getArticle(Article $article, Category $category, Settings $settings) { public function getArticle(Article $article, Category $category, Settings $settings) {
$settings = $settings->first();
$pagination = $settings->pagination; $settings = $settings->first();
// $article = $article->where('status', '1'); $pagination = $settings->pagination;
// $article = $article->where('type', '1'); // $article = $article->where('status', '1');
$article = $article->paginate($pagination); // $article = $article->where('type', '1');
$article = $article->paginate($pagination);
// dd($article); // dd($article);
$article->setPath('article-list'); $article->setPath('article-list');
$categorys = $category->get(); $categorys = $category->get();
// $time = $this->timezone($utc); // $time = $this->timezone($utc);
return view('themes.default1.client.kb.article-list.articles', compact('time', 'categorys', 'article')); return view('themes.default1.client.kb.article-list.articles', compact('time', 'categorys', 'article'));
} }
/** /**
* Get excerpt from string * Get excerpt from string
* *
* @param String $str String to get an excerpt from * @param String $str String to get an excerpt from
* @param Integer $startPos Position int string to start excerpt from * @param Integer $startPos Position int string to start excerpt from
* @param Integer $maxLength Maximum length the excerpt may be * @param Integer $maxLength Maximum length the excerpt may be
* @return String excerpt * @return String excerpt
*/ */
static function getExcerpt($str, $startPos = 0, $maxLength = 50) { static function getExcerpt($str, $startPos = 0, $maxLength = 50) {
if (strlen($str) > $maxLength) { if (strlen($str) > $maxLength) {
$excerpt = substr($str, $startPos, $maxLength - 3); $excerpt = substr($str, $startPos, $maxLength - 3);
$lastSpace = strrpos($excerpt, ' '); $lastSpace = strrpos($excerpt, ' ');
$excerpt = substr($excerpt, 0, $lastSpace); $excerpt = substr($excerpt, 0, $lastSpace);
$excerpt .= '...'; $excerpt .= '...';
} else { } else {
$excerpt = $str; $excerpt = $str;
} }
return $excerpt; return $excerpt;
} }
public function search(SearchRequest $request, Category $category, Article $article, Settings $settings) { public function search(SearchRequest $request, Category $category, Article $article, Settings $settings) {
$settings = $settings->first(); $settings = $settings->first();
$pagination = $settings->pagination; $pagination = $settings->pagination;
$search = $request->input('s'); $search = $request->input('s');
$result = $article->search($search)->paginate($pagination); $result = $article->search($search)->paginate($pagination);
$result->setPath('search'); $result->setPath('search');
//dd($result); //dd($result);
$categorys = $category->get(); $categorys = $category->get();
return view('themes.default1.client.kb.article-list.search', compact('categorys', 'result')); return view('themes.default1.client.kb.article-list.search', compact('categorys', 'result'));
} }
/** /**
* to show the seleted article * to show the seleted article
* @return response * @return response
*/ */
public function show($slug, Article $article, Category $category) { public function show($slug, Article $article, Category $category) {
//ArticleController::timezone(); //ArticleController::timezone();
$arti = $article->where('slug', $slug)->where('status','1')->where('type','1')->first(); $tz = \App\Model\helpdesk\Settings\System::where('id', '1')->first()->time_zone;
$tz = \App\Model\helpdesk\Utility\Timezones::where('id', $tz)->first()->name;
date_default_timezone_set($tz);
$date = \Carbon\Carbon::now()->toDateTimeString();
$arti = $article->where('slug', $slug)->where('status', '1')->where('type', '1')->where('publish_time', '<', $date)->first();
if ($arti) {
return view('themes.default1.client.kb.article-list.show', compact('arti'));
} else {
return redirect()->back()->with('fails', 'No records on publish time');
}
}
// dd($arti); public function getCategory($slug, Article $article, Category $category, Relationship $relation) {
//$categorys = $category->get(); /* get the article_id where category_id == current category */
//$avatar->get('vijaycodename47@gmail.com'); $catid = $category->where('slug', $slug)->first();
return view('themes.default1.client.kb.article-list.show', compact('arti')); $id = $catid->id;
} $all = $relation->where('category_id', $id)->get();
// $all->setPath('');
/* from whole attribute pick the article_id */
$article_id = $all->lists('article_id');
$categorys = $category->get();
/* direct to view with $article_id */
return view('themes.default1.client.kb.article-list.category', compact('all', 'id', 'categorys', 'article_id'));
}
public function getCategory($slug, Article $article, Category $category, Relationship $relation) { public function home(Article $article, Category $category, Relationship $relation) {
/* get the article_id where category_id == current category */ if (Config::get('database.install') == '%0%') {
$catid = $category->where('slug', $slug)->first(); return redirect('step1');
$id = $catid->id; } else {
$all = $relation->where('category_id', $id)->get(); //$categorys = $category->get();
// $all->setPath(''); $categorys = $category->get();
/* from whole attribute pick the article_id */ // $categorys->setPath('home');
$article_id = $all->lists('article_id'); /* direct to view with $article_id */
$categorys = $category->get(); return view('themes.default1.client.kb.article-list.home', compact('categorys', 'article_id'));
/* direct to view with $article_id */ }
return view('themes.default1.client.kb.article-list.category', compact('all','id', 'categorys', 'article_id')); }
}
public function home(Article $article, Category $category, Relationship $relation) { public function Faq(Faq $faq, Category $category) {
if (Config::get('database.install') == '%0%') { $faq = $faq->where('id', '1')->first();
return redirect('step1'); $categorys = $category->get();
} return view('themes.default1.client.kb.article-list.faq', compact('categorys', 'faq'));
else }
{
//$categorys = $category->get();
$categorys = $category->get();
// $categorys->setPath('home');
/* direct to view with $article_id */
return view('themes.default1.client.kb.article-list.home', compact('categorys', 'article_id'));
}
}
public function Faq(Faq $faq, Category $category) { /**
$faq = $faq->where('id', '1')->first(); * get the contact page for user
$categorys = $category->get(); * @return response
return view('themes.default1.client.kb.article-list.faq', compact('categorys', 'faq')); */
} public function contact(Category $category, Settings $settings) {
$settings = $settings->whereId('1')->first();
$categorys = $category->get();
return view('themes.default1.client.kb.article-list.contact', compact('settings', 'categorys'));
}
/** /**
* get the contact page for user * send message to the mail adderess that define in the system
* @return response * @return response
*/ */
public function contact(Category $category, Settings $settings) { public function postContact(ContactRequest $request, Contact $contact) {
$settings = $settings->whereId('1')->first(); $this->port();
$categorys = $category->get(); $this->host();
return view('themes.default1.client.kb.article-list.contact', compact('settings', 'categorys')); $this->encryption();
} $this->email();
$this->password();
//return Config::get('mail');
$contact->fill($request->input())->save();
$name = $request->input('name');
//echo $name;
$email = $request->input('email');
//echo $email;
$subject = $request->input('subject');
//echo $subject;
$details = $request->input('message');
//echo $message;
//echo $contact->email;
$mail = Mail::send('themes.default1.client.kb.article-list.contact-details', array('name' => $name, 'email' => $email, 'subject' => $subject, 'details' => $details), function ($message) use ($contact) {
$message->to($contact->email, $contact->name)->subject('Contact');
});
if ($mail) {
return redirect('contact')->with('success', 'Your details send to System');
} else {
return redirect('contact')->with('fails', 'Your details can not send to System');
}
}
/** public function contactDetails() {
* send message to the mail adderess that define in the system return view('themes.default1.client.kb.article-list.contact-details');
* @return response }
*/
public function postContact(ContactRequest $request, Contact $contact) {
$this->port();
$this->host();
$this->encryption();
$this->email();
$this->password();
//return Config::get('mail');
$contact->fill($request->input())->save();
$name = $request->input('name');
//echo $name;
$email = $request->input('email');
//echo $email;
$subject = $request->input('subject');
//echo $subject;
$details = $request->input('message');
//echo $message;
//echo $contact->email;
$mail = Mail::send('themes.default1.client.kb.article-list.contact-details', array('name' => $name, 'email' => $email, 'subject' => $subject, 'details' => $details), function ($message) use ($contact) {
$message->to($contact->email, $contact->name)->subject('Contact');
});
if ($mail) {
return redirect('contact')->with('success', 'Your details send to System');
} else {
return redirect('contact')->with('fails', 'Your details can not send to System');
}
}
public function contactDetails() { /**
return view('themes.default1.client.kb.article-list.contact-details'); * To insert the values to the comment table
} * @param type Article $article
* @param type Request $request
* @param type Comment $comment
* @param type Id $id
* @return type response
*/
public function postComment($slug, Article $article, CommentRequest $request, Comment $comment) {
$article = $article->where('slug', $slug)->first();
$id = $article->id;
$comment->article_id = $id;
if ($comment->fill($request->input())->save()) {
return Redirect::back()->with('success', 'Your comment posted');
} else {
return Redirect::back()->with('fails', 'Sorry not processed');
}
}
/** public function getPage($name, Page $page) {
* To insert the values to the comment table $page = $page->where('slug', $name)->first();
* @param type Article $article //$this->timezone($page->created_at);
* @param type Request $request return view('themes.default1.client.kb.article-list.pages', compact('page'));
* @param type Comment $comment }
* @param type Id $id
* @return type response
*/
public function postComment($slug, Article $article, CommentRequest $request, Comment $comment) {
$article = $article->where('slug',$slug)->first();
$id = $article->id;
$comment->article_id = $id;
if ($comment->fill($request->input())->save()) {
return Redirect::back()->with('success', 'Your comment posted');
} else {
return Redirect::back()->with('fails', 'Sorry not processed');
}
}
public function getPage($name, Page $page) { static function port() {
$page = $page->where('slug', $name)->first(); $setting = Settings::whereId('1')->first();
//$this->timezone($page->created_at); Config::set('mail.port', $setting->port);
return view('themes.default1.client.kb.article-list.pages', compact('page')); }
}
static function port() {
$setting = Settings::whereId('1')->first();
Config::set('mail.port', $setting->port);
}
static function host() {
$setting = Settings::whereId('1')->first();
Config::set('mail.host', $setting->host);
}
static function encryption() {
$setting = Settings::whereId('1')->first();
Config::set(['mail.encryption' => $setting->encryption, 'mail.username' => $setting->email]);
}
static function email() {
$setting = Settings::whereId('1')->first();
Config::set(['mail.from' => ['address' => $setting->email, 'name' => 'asd']]);
//dd(Config::get('mail'));
}
static function password() {
$setting = Settings::whereId('1')->first();
Config::set(['mail.password' => $setting->password, 'mail.sendmail' => $setting->email]);
}
public function getCategoryList(Article $article, Category $category, Relationship $relation) { static function host() {
//$categorys = $category->get(); $setting = Settings::whereId('1')->first();
$categorys = $category->get(); Config::set('mail.host', $setting->host);
// $categorys->setPath('home'); }
/* direct to view with $article_id */
return view('themes.default1.client.kb.article-list.categoryList', compact('categorys', 'article_id'));
} static function encryption() {
$setting = Settings::whereId('1')->first();
Config::set(['mail.encryption' => $setting->encryption, 'mail.username' => $setting->email]);
}
// static function timezone($utc) { static function email() {
// $set = Settings::whereId('1')->first(); $setting = Settings::whereId('1')->first();
// $tz = $set->timezone; Config::set(['mail.from' => ['address' => $setting->email, 'name' => 'asd']]);
// $format = $set->dateformat; //dd(Config::get('mail'));
// //$utc = date('M d Y h:i:s A'); }
// //echo 'UTC : ' . $utc;
// date_default_timezone_set($tz);
// $offset = date('Z', strtotime($utc)); static function password() {
// //print "offset: $offset \n"; $setting = Settings::whereId('1')->first();
// $date = date($format, strtotime($utc) + $offset); Config::set(['mail.password' => $setting->password, 'mail.sendmail' => $setting->email]);
// return $date; }
// //return substr($date, 0, -6);
// } public function getCategoryList(Article $article, Category $category, Relationship $relation) {
//$categorys = $category->get();
$categorys = $category->get();
// $categorys->setPath('home');
/* direct to view with $article_id */
return view('themes.default1.client.kb.article-list.categoryList', compact('categorys', 'article_id'));
}
// static function timezone($utc) {
// $set = Settings::whereId('1')->first();
// $tz = $set->timezone;
// $format = $set->dateformat;
// //$utc = date('M d Y h:i:s A');
// //echo 'UTC : ' . $utc;
// date_default_timezone_set($tz);
// $offset = date('Z', strtotime($utc));
// //print "offset: $offset \n";
// $date = date($format, strtotime($utc) + $offset);
// return $date;
// //return substr($date, 0, -6);
// }
public function clientProfile() { public function clientProfile() {
$user = Auth::user(); $user = Auth::user();
return view('themes.default1.client.kb.article-list.profile', compact('user')); return view('themes.default1.client.kb.article-list.profile', compact('user'));
} }
public function postClientProfile($id, ProfileRequest $request) { public function postClientProfile($id, ProfileRequest $request) {
$user = Auth::user(); $user = Auth::user();
$user->gender = $request->input('gender'); $user->gender = $request->input('gender');
$user->save(); $user->save();
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') { if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
if ($request->input('gender') == 1) { if ($request->input('gender') == 1) {
$name = 'avatar5.png'; $name = 'avatar5.png';
$destinationPath = 'lb-faveo/dist/img'; $destinationPath = 'lb-faveo/dist/img';
$user->profile_pic = $name; $user->profile_pic = $name;
} elseif ($request->input('gender') == 0) { } elseif ($request->input('gender') == 0) {
$name = 'avatar2.png'; $name = 'avatar2.png';
$destinationPath = 'lb-faveo/dist/img'; $destinationPath = 'lb-faveo/dist/img';
$user->profile_pic = $name; $user->profile_pic = $name;
} }
} }
if (Input::file('profile_pic')) { if (Input::file('profile_pic')) {
//$extension = Input::file('profile_pic')->getClientOriginalExtension(); //$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName(); $name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/dist/img'; $destinationPath = 'lb-faveo/dist/img';
$fileName = rand(0000, 9999) . '.' . $name; $fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName; //echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName); Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName; $user->profile_pic = $fileName;
} else { } else {
$user->fill($request->except('profile_pic', 'gender'))->save(); $user->fill($request->except('profile_pic', 'gender'))->save();
return redirect('guest')->with('success', 'Profile Updated sucessfully'); return redirect('guest')->with('success', 'Profile Updated sucessfully');
} }
if ($user->fill($request->except('profile_pic'))->save()) { if ($user->fill($request->except('profile_pic'))->save()) {
return redirect('guest')->with('success', 'Profile Updated sucessfully'); return redirect('guest')->with('success', 'Profile Updated sucessfully');
} }
} }
public function postClientProfilePassword($id, ProfilePassword $request) { public function postClientProfilePassword($id, ProfilePassword $request) {
$user = Auth::user(); $user = Auth::user();
//echo $user->password; //echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password')); $user->password = Hash::make($request->input('new_password'));
$user->save(); $user->save();
return redirect()->back()->with('success', 'Password Updated sucessfully'); return redirect()->back()->with('success', 'Password Updated sucessfully');
} else { } else {
return redirect()->back()->with('fails', 'Password was not Updated'); return redirect()->back()->with('fails', 'Password was not Updated');
} }
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Common; <?php
namespace App\Http\Controllers\Common;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -43,7 +46,6 @@ class SettingsController extends Controller {
SettingsController::password(); SettingsController::password();
} }
/** /**
* get the page to create the footer * get the page to create the footer
* @return response * @return response
@@ -57,61 +59,56 @@ class SettingsController extends Controller {
* @return response * @return response
*/ */
public function list_widget() { public function list_widget() {
return \Datatable::collection(Widgets::where('id','<','7')->get()) return \Datatable::collection(Widgets::where('id', '<', '7')->get())
->searchColumns('name') ->searchColumns('name')
->orderColumns('name', 'title', 'value') ->orderColumns('name', 'title', 'value')
->addColumn('name', function ($model) { ->addColumn('name', function ($model) {
return $model->name; return $model->name;
}) })
->addColumn('title', function ($model) {
->addColumn('title', function ($model) { return $model->title;
return $model->title; })
}) ->addColumn('body', function ($model) {
return $model->value;
->addColumn('body', function ($model) { })
return $model->value; ->addColumn('Actions', function ($model) {
}) return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
<div class="modal fade" id="edit_widget' . $model->id . '">
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#edit_widget'.$model->id .'"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
<div class="modal fade" id="edit_widget'.$model->id .'">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<form action="'. url('edit-widget/'.$model->id) .'" method="POST"> <form action="' . url('edit-widget/' . $model->id) . '" method="POST">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">'.strtoupper($model->name).' </h4> <h4 class="modal-title">' . strtoupper($model->name) . ' </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>'.\Lang::get("lang.title").'</label><br/> <label>' . \Lang::get("lang.title") . '</label><br/>
<input type="text" name="title" value="'.$model->title.'" class="form-control" style="width:100%"> <input type="text" name="title" value="' . $model->title . '" class="form-control" style="width:100%">
</div> </div>
<br/> <br/>
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>'.\Lang::get("lang.content").'</label><br/> <label>' . \Lang::get("lang.content") . '</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content'.$model->id.'">'.$model->value.'</textarea> <textarea name="content" class="form-control" style="width:100%" id="Content' . $model->id . '">' . $model->value . '</textarea>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button>
<input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'"> <input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
</div> </div>
<script> <script>
$(function () { $(function () {
$("#Content'. $model->id .'").wysihtml5(); $("#Content' . $model->id . '").wysihtml5();
}); });
</script> </script>
</form> </form>
</div> </div>
</div> </div>
</div>'; </div>';
}) })
->make();
->make();
} }
/** /**
* Post footer * Post footer
* @param type Footer $footer * @param type Footer $footer
@@ -119,13 +116,13 @@ class SettingsController extends Controller {
* @return type response * @return type response
*/ */
public function edit_widget($id, Widgets $widgets, Request $request) { public function edit_widget($id, Widgets $widgets, Request $request) {
$widget = $widgets->where('id','=',$id)->first(); $widget = $widgets->where('id', '=', $id)->first();
$widget->title = $request->title; $widget->title = $request->title;
$widget->value = $request->content; $widget->value = $request->content;
try{ try {
$widget->save(); $widget->save();
return redirect()->back()->with('success', $widget->name.' Saved Successfully'); return redirect()->back()->with('success', $widget->name . ' Saved Successfully');
} catch(Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
@@ -143,44 +140,42 @@ class SettingsController extends Controller {
* @return response * @return response
*/ */
public function list_social_buttons() { public function list_social_buttons() {
return \Datatable::collection(Widgets::where('id','>','6')->get()) return \Datatable::collection(Widgets::where('id', '>', '6')->get())
->searchColumns('name') ->searchColumns('name')
->orderColumns('name', 'value') ->orderColumns('name', 'value')
->addColumn('name', function ($model) { ->addColumn('name', function ($model) {
return $model->name; return $model->name;
}) })
->addColumn('link', function ($model) {
->addColumn('link', function ($model) { return $model->value;
return $model->value; })
}) ->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
->addColumn('Actions', function ($model) { <div class="modal fade" id="edit_widget' . $model->id . '">
return '<span data-toggle="modal" data-target="#edit_widget'.$model->id .'"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
<div class="modal fade" id="edit_widget'.$model->id .'">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<form action="'. url('edit-widget/'.$model->id) .'" method="POST"> <form action="' . url('edit-widget/' . $model->id) . '" method="POST">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">'.strtoupper($model->name).' </h4> <h4 class="modal-title">' . strtoupper($model->name) . ' </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<br/> <br/>
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>'.\Lang::get("lang.link").'</label><br/> <label>' . \Lang::get("lang.link") . '</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="'.$model->value.'"> <input type="url" name="content" class="form-control" style="width:100%" value="' . $model->value . '">
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button>
<input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'"> <input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
</div> </div>
</form> </form>
</div> </div>
</div> </div>
</div>'; </div>';
}) })
->make(); ->make();
} }
/** /**
@@ -190,14 +185,14 @@ class SettingsController extends Controller {
* @return type response * @return type response
*/ */
public function edit_social_buttons($id, Widgets $widgets, Request $request) { public function edit_social_buttons($id, Widgets $widgets, Request $request) {
$widget = $widgets->where('id','=',$id)->first(); $widget = $widgets->where('id', '=', $id)->first();
$widget->title = $request->title; $widget->title = $request->title;
$widget->value = $request->content; $widget->value = $request->content;
try{ try {
$widget->save(); $widget->save();
return redirect()->back()->with('success', $widget->name.' Saved Successfully'); return redirect()->back()->with('success', $widget->name . ' Saved Successfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
} }
@@ -296,7 +291,7 @@ class SettingsController extends Controller {
$data->name = $request->input('name'); $data->name = $request->input('name');
$data->email = $request->input('email'); $data->email = $request->input('email');
$data->password = Crypt::encrypt($request->input('password')); $data->password = Crypt::encrypt($request->input('password'));
try{ try {
$data->save(); $data->save();
return \Redirect::route('getsmtp')->with('success', 'success'); return \Redirect::route('getsmtp')->with('success', 'success');
} catch (Exception $e) { } catch (Exception $e) {
@@ -343,9 +338,9 @@ class SettingsController extends Controller {
$pass = $request->input('password'); $pass = $request->input('password');
$password = Crypt::encrypt($pass); $password = Crypt::encrypt($pass);
$settings->password = $password; $settings->password = $password;
try{ try {
$settings->save(); $settings->save();
} catch(Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
if (Input::file('logo')) { if (Input::file('logo')) {
@@ -425,8 +420,8 @@ class SettingsController extends Controller {
$activate = "<a href=" . url('plugin/status/' . $model['path']) . ">Deactivate</a>"; $activate = "<a href=" . url('plugin/status/' . $model['path']) . ">Deactivate</a>";
} }
$delete = "<a href= id=delete".$model['path']." data-toggle=modal data-target=#del".$model['path']."><span style='color:red'>Delete</span></a>" $delete = "<a href= id=delete" . $model['path'] . " data-toggle=modal data-target=#del" . $model['path'] . "><span style='color:red'>Delete</span></a>"
. "<div class='modal fade' id=del".$model['path']."> . "<div class='modal fade' id=del" . $model['path'] . ">
<div class='modal-dialog'> <div class='modal-dialog'>
<div class=modal-content> <div class=modal-content>
<div class=modal-header> <div class=modal-header>
@@ -457,7 +452,7 @@ class SettingsController extends Controller {
return ucfirst($model['author']); return ucfirst($model['author']);
}) })
->addColumn('website', function($model) { ->addColumn('website', function($model) {
return "<a href=".$model['website']." target=_blank>".$model['website']."</a>"; return "<a href=" . $model['website'] . " target=_blank>" . $model['website'] . "</a>";
}) })
->addColumn('version', function($model) { ->addColumn('version', function($model) {
return $model['version']; return $model['version'];
@@ -523,7 +518,7 @@ class SettingsController extends Controller {
$lines = file($app, FILE_IGNORE_NEW_LINES); $lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str; $lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines)); file_put_contents($app, implode("\n", $lines));
$plug->create(['name' => $filename, 'path' => $filename,'status'=>1]); $plug->create(['name' => $filename, 'path' => $filename, 'status' => 1]);
return redirect()->back()->with('success', 'Installed SuccessFully'); return redirect()->back()->with('success', 'Installed SuccessFully');
} else { } else {
/** /**

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers; <?php
namespace App\Http\Controllers;
// classes // classes
use Illuminate\Foundation\Bus\DispatchesCommands; use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Error; <?php
namespace App\Http\Controllers\Error;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
@@ -11,11 +14,12 @@ use App\Http\Controllers\Controller;
*/ */
class ErrorController extends Controller { class ErrorController extends Controller {
/** /**
* Display a Error Page of 404. * Display a Error Page of 404.
* @return Response * @return Response
*/ */
public function error404() { public function error404() {
return view('404'); return view('404');
} }
} }

View File

@@ -1,9 +1,10 @@
<?php namespace App\Http\Controllers; <?php
namespace App\Http\Controllers;
use App\Model\helpdesk\Manage\Sla_plan; use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
class HomeController extends Controller { class HomeController extends Controller {
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -31,49 +32,47 @@ class HomeController extends Controller {
* @return Response * @return Response
*/ */
public function index() { public function index() {
// ksjdckjdsnc // ksjdckjdsnc
return view('themes/default1/admin/dashboard'); return view('themes/default1/admin/dashboard');
} }
public function getsmtp() {
public function getsmtp(){ $smtp = \App\Model\helpdesk\Email\Smtp::where('id', '=', '1')->first();
$smtp = \App\Model\helpdesk\Email\Smtp::where('id','=','1')->first(); return $smtp->host;
return $smtp->host;
} }
Public function getdata(){ Public function getdata() {
return \View::make('emails/notifications/agent'); return \View::make('emails/notifications/agent');
} }
public function getreport(){ public function getreport() {
return \View::make('test'); return \View::make('test');
} }
public function pushdata(){ public function pushdata() {
$date2 = strtotime(Date('Y-m-d')); $date2 = strtotime(Date('Y-m-d'));
$date3 = Date('Y-m-d'); $date3 = Date('Y-m-d');
$format = 'Y-m-d'; $format = 'Y-m-d';
$date1 = strtotime(Date($format,strtotime('-1 month'. $date3))); $date1 = strtotime(Date($format, strtotime('-1 month' . $date3)));
$return = ""; $return = "";
$last = ""; $last = "";
for ( $i = $date1; $i <= $date2; $i = $i + 86400 ) { for ($i = $date1; $i <= $date2; $i = $i + 86400) {
$thisDate = date( 'Y-m-d', $i ); $thisDate = date('Y-m-d', $i);
$created = \DB::table('tickets')->select('created_at')->where('created_at','LIKE','%'.$thisDate.'%')->count(); $created = \DB::table('tickets')->select('created_at')->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at','LIKE','%'.$thisDate.'%')->count(); $closed = \DB::table('tickets')->select('closed_at')->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at','LIKE','%'.$thisDate.'%')->count(); $reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened]; $value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
$array = array_map('htmlentities',$value); $array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array)); $json = html_entity_decode(json_encode($array));
$return .= $json.','; $return .= $json . ',';
} }
$last = rtrim($return,','); $last = rtrim($return, ',');
return '['.$last.']';
return '[' . $last . ']';
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Installer\helpdesk; <?php
namespace App\Http\Controllers\Installer\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
@@ -20,6 +23,7 @@ use Redirect;
use Session; use Session;
use View; use View;
use Exception; use Exception;
/** /**
* |======================================================================= * |=======================================================================
* |Class: InstallController * |Class: InstallController
@@ -34,38 +38,41 @@ use Exception;
* *
*/ */
class InstallController extends Controller { class InstallController extends Controller {
/** /**
* Get Licence (step 1) * Get Licence (step 1)
* @return type view * @return type view
*/ */
public function licence() { public function licence() {
// checking if the installation is running for the first time or not // checking if the installation is running for the first time or not
if (Session::get('step5') == 'step5') { // if (Session::get('step5') == 'step5') {
return Redirect::route('account'); // return Redirect::route('account');
} // }
// checking if the installation is running for the first time or not // checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') { if (Config::get('database.install') == '%0%') {
return view('themes/default1/installer/helpdesk/view1'); return view('themes/default1/installer/helpdesk/view1');
} else { } else {
// return 1; // return 1;
return redirect('/auth/login'); return redirect('/auth/login');
} }
} }
/** /**
* Post Licencecheck * Post Licencecheck
* @return type view * @return type view
*/ */
public function licencecheck() { public function licencecheck() {
// checking if the user have accepted the licence agreement // checking if the user have accepted the licence agreement
$accept = (Input::has('accept1')) ? true : false; $accept = (Input::has('accept1')) ? true : false;
if ($accept == 'accept') { if ($accept == 'accept') {
Session::put('step1', 'step1'); Session::put('step1', 'step1');
return Redirect::route('prerequisites'); return Redirect::route('prerequisites');
} else { } else {
return Redirect::route('licence')->with('fails', 'Failed! first accept the licence agreeement'); return Redirect::route('licence')->with('fails', 'Failed! first accept the licence agreeement');
} }
// return 1; // return 1;
} }
/** /**
* Get prerequisites (step 2) * Get prerequisites (step 2)
* *
@@ -73,267 +80,310 @@ class InstallController extends Controller {
* without which the project cannot be executed properly * without which the project cannot be executed properly
* @return type view * @return type view
*/ */
public function prerequisites() { public function prerequisites() {
// checking if the installation is running for the first time or not // checking if the installation is running for the first time or not
if (Session::get('step5') == 'step5') { // if (Session::get('step5') == 'step5') {
return Redirect::route('account'); // return Redirect::route('account');
} // }
// checking if the installation is running for the first time or not // checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') { if (Config::get('database.install') == '%0%') {
if (Session::get('step1') == 'step1') { if (Session::get('step1') == 'step1') {
return View::make('themes/default1/installer/helpdesk/view2'); return View::make('themes/default1/installer/helpdesk/view2');
} else { } else {
return Redirect::route('licence'); return Redirect::route('licence');
} }
} else { } else {
return redirect('/auth/login'); return redirect('/auth/login');
} }
} }
/** /**
* Post Prerequisitescheck * Post Prerequisitescheck
* checking prerequisites * checking prerequisites
* @return type view * @return type view
*/ */
public function prerequisitescheck() { public function prerequisitescheck() {
Session::put('step2', 'step2'); Session::put('step2', 'step2');
return Redirect::route('configuration'); return Redirect::route('configuration');
} }
/**
* Get Localization (step 3) /**
* Requesting user recomended settings for installation * Get Localization (step 3)
* @return type view * Requesting user recomended settings for installation
*/ * @return type view
public function localization() { */
// checking if the installation is running for the first time or not public function localization() {
if (Session::get('step5') == 'step5') { // checking if the installation is running for the first time or not
return Redirect::route('account'); // if (Session::get('step5') == 'step5') {
} // return Redirect::route('account');
// checking if the installation is running for the first time or not // }
if (Config::get('database.install') == '%0%') { // checking if the installation is running for the first time or not
if (Session::get('step2') == 'step2') { if (Config::get('database.install') == '%0%') {
return View::make('themes/default1/installer/helpdesk/view3'); if (Session::get('step2') == 'step2') {
} else { return View::make('themes/default1/installer/helpdesk/view3');
return Redirect::route('prerequisites'); } else {
} return Redirect::route('prerequisites');
} else { }
return redirect('/auth/login'); } else {
} return redirect('/auth/login');
} }
/** }
* Post localizationcheck
* checking prerequisites /**
* @return type view * Post localizationcheck
*/ * checking prerequisites
public function localizationcheck() { * @return type view
Session::put('step3', 'step3'); */
Session::put('language', Input::get('language')); public function localizationcheck() {
Session::put('timezone', Input::get('timezone'));
Session::put('date', Input::get('date')); Session::put('step3', 'step3');
Session::put('datetime', Input::get('datetime'));
return Redirect::route('configuration'); Session::put('language', Input::get('language'));
} Session::put('timezone', Input::get('timezone'));
Session::put('date', Input::get('date'));
Session::put('datetime', Input::get('datetime'));
return Redirect::route('configuration');
}
/** /**
* Get Configuration (step 4) * Get Configuration (step 4)
* checking prerequisites * checking prerequisites
* @return type view * @return type view
*/ */
public function configuration() { public function configuration() {
// checking if the installation is running for the first time or not // checking if the installation is running for the first time or not
if (Session::get('step5') == 'step5') { // if (Session::get('step5') == 'step5') {
return Redirect::route('account'); // return Redirect::route('account');
} // }
// checking if the installation is running for the first time or not // checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') { if (Config::get('database.install') == '%0%') {
if (Session::get('step2') == 'step2') { if (Session::get('step2') == 'step2') {
return View::make('themes/default1/installer/helpdesk/view3'); return View::make('themes/default1/installer/helpdesk/view3');
} else { } else {
return Redirect::route('prerequisites'); return Redirect::route('prerequisites');
} }
} else { } else {
return redirect('/auth/login'); return redirect('/auth/login');
} }
} }
/** /**
* Post configurationcheck * Post configurationcheck
* checking prerequisites * checking prerequisites
* @return type view * @return type view
*/ */
public function configurationcheck() { public function configurationcheck() {
Session::put('step4', 'step4');
Session::put('default', Input::get('default')); Session::put('step4', 'step4');
Session::put('host', Input::get('host'));
Session::put('databasename', Input::get('databasename')); Session::put('default', Input::get('default'));
Session::put('username', Input::get('username')); Session::put('host', Input::get('host'));
Session::put('password', Input::get('password')); Session::put('databasename', Input::get('databasename'));
Session::put('port', Input::get('port')); Session::put('username', Input::get('username'));
return Redirect::route('database'); Session::put('password', Input::get('password'));
} Session::put('port', Input::get('port'));
/**
* postconnection return Redirect::route('database');
* @return type view }
*/
public function postconnection() { /**
error_reporting(E_ALL & ~E_NOTICE); * postconnection
$default = Input::get('default'); * @return type view
$host = Input::get('host'); */
$database = Input::get('databasename'); public function postconnection() {
$dbusername = Input::get('username'); error_reporting(E_ALL & ~E_NOTICE);
$dbpassword = Input::get('password'); $default = Input::get('default');
$port = Input::get('port'); $host = Input::get('host');
// Setting environment values $database = Input::get('databasename');
$_ENV['DB_TYPE'] = $default; $dbusername = Input::get('username');
$_ENV['DB_HOST'] = $host; $dbpassword = Input::get('password');
$_ENV['DB_PORT'] = $port; $port = Input::get('port');
$_ENV['DB_DATABASE'] = $database;
$_ENV['DB_USERNAME'] = $dbusername; // Setting environment values
$_ENV['DB_PASSWORD'] = $dbpassword; $_ENV['DB_TYPE'] = $default;
$config = ''; $_ENV['DB_HOST'] = $host;
foreach ($_ENV as $key => $val) { $_ENV['DB_PORT'] = $port;
$config .= "{$key}={$val}\n"; $_ENV['DB_DATABASE'] = $database;
} $_ENV['DB_USERNAME'] = $dbusername;
// Write environment file $_ENV['DB_PASSWORD'] = $dbpassword;
$fp = fopen(base_path()."/.env", 'w');
fwrite($fp, $config); $config = '';
fclose($fp); foreach ($_ENV as $key => $val) {
return 1; $config .= "{$key}={$val}\n";
} }
// Write environment file
$fp = fopen(base_path() . "/.env", 'w');
fwrite($fp, $config);
fclose($fp);
return 1;
}
/** /**
* Get database * Get database
* checking prerequisites * checking prerequisites
* @return type view * @return type view
*/ */
public function database() { public function database() {
// checking if the installation is running for the first time or not // checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') { if (Config::get('database.install') == '%0%') {
if (Session::get('step4') == 'step4') { if (Session::get('step4') == 'step4') {
return View::make('themes/default1/installer/helpdesk/view4'); return View::make('themes/default1/installer/helpdesk/view4');
} else { } else {
return Redirect::route('configuration'); return Redirect::route('configuration');
} }
} else { } else {
return redirect('/auth/login'); return redirect('/auth/login');
} }
} }
/** /**
* Get account * Get account
* checking prerequisites * checking prerequisites
* @return type view * @return type view
*/ */
public function account() { public function account() {
// checking if the installation is running for the first time or not // checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') { if (Config::get('database.install') == '%0%') {
if (Session::get('step4') == 'step4') { if (Session::get('step4') == 'step4') {
Session::put('step5', 'step5'); Session::put('step5', 'step5');
Session::forget('step1'); Session::forget('step1');
Session::forget('step2'); Session::forget('step2');
Session::forget('step3'); Session::forget('step3');
return View::make('themes/default1/installer/helpdesk/view5'); return View::make('themes/default1/installer/helpdesk/view5');
} else { } else {
return Redirect::route('configuration'); return Redirect::route('configuration');
} }
} else { } else {
return redirect('/auth/login'); return redirect('/auth/login');
} }
} }
/** /**
* Post accountcheck * Post accountcheck
* checking prerequisites * checking prerequisites
* @param type InstallerRequest $request * @param type InstallerRequest $request
* @return type view * @return type view
*/ */
public function accountcheck(InstallerRequest $request) { public function accountcheck(InstallerRequest $request) {
// migrate database
Artisan::call('migrate', array('--force' => true)); // migrate database
Artisan::call('db:seed', array('--force' => true)); Artisan::call('migrate', array('--force' => true));
// create user Artisan::call('db:seed', array('--force' => true));
$firstname = $request->input('firstname');
$lastname = $request->input('Lastname'); // create user
$email = $request->input('email'); $firstname = $request->input('firstname');
$username = $request->input('username'); $lastname = $request->input('Lastname');
$password = $request->input('password'); $email = $request->input('email');
$language = $request->input('language'); $username = $request->input('username');
$timezone = $request->input('timezone'); $password = $request->input('password');
$date = $request->input('date');
$datetime = $request->input('datetime'); $language = $request->input('language');
// $system = System::where('id','=','1')->first(); $timezone = $request->input('timezone');
// $system->time_zone = $timezone; $date = $request->input('date');
// $system->date_time_format = $datetime; $datetime = $request->input('datetime');
// $system->save();
// checking requested timezone for the admin and system
$timezones = Timezones::where('name','=',$timezone)->first(); //\Cache::forever('language', $language);
if($timezones->id == null){
return ['response'=>'fail','reason'=>'Invalid time-zone','status'=>'0']; //\App::setLocale($language);
} // $system = System::where('id','=','1')->first();
// var_dump($datetime); // $system->time_zone = $timezone;
// checking requested date time format for the admin and system // $system->date_time_format = $datetime;
$date_time_format = Date_time_format::where('format','=',$datetime)->first(); // $system->save();
// dd($date_time_format); // checking requested timezone for the admin and system
if($date_time_format->id == null){ $timezones = Timezones::where('name', '=', $timezone)->first();
return ['response'=>'fail','reason'=>'invalid date-time format','status'=>'0']; if ($timezones->id == null) {
} return ['response' => 'fail', 'reason' => 'Invalid time-zone', 'status' => '0'];
// Creating minum settings for system }
$system = new System; // var_dump($datetime);
$system->status = 1; // checking requested date time format for the admin and system
$system->department = 1; $date_time_format = Date_time_format::where('format', '=', $datetime)->first();
$system->date_time_format = $date_time_format->id; // dd($date_time_format);
$system->time_zone = $timezones->id; if ($date_time_format->id == null) {
$system->save(); return ['response' => 'fail', 'reason' => 'invalid date-time format', 'status' => '0'];
// creating an user }
$user = User::create(array(
'first_name' => $firstname, // Creating minum settings for system
'last_name' => $lastname, $system = new System;
'email' => $email, $system->status = 1;
'user_name' => $username, $system->department = 1;
'password' => Hash::make($password), $system->date_time_format = $date_time_format->id;
'assign_group' => 1, $system->time_zone = $timezones->id;
'primary_dpt' => 1, $system->save();
'active' => 1,
'role' => 'admin',
)); // creating an user
// checking if the user have been created $user = User::create(array(
if ($user) { 'first_name' => $firstname,
Session::put('step6', 'step6'); 'last_name' => $lastname,
return Redirect::route('final'); 'email' => $email,
} 'user_name' => $username,
} 'password' => Hash::make($password),
'assign_group' => 1,
'primary_dpt' => 1,
'active' => 1,
'role' => 'admin',
));
// checking if the user have been created
if ($user) {
Session::put('step6', 'step6');
return Redirect::route('final');
}
}
/** /**
* Get finalize * Get finalize
* checking prerequisites * checking prerequisites
* @return type view * @return type view
*/ */
public function finalize() { public function finalize() {
// checking if the installation have been completed or not // checking if the installation have been completed or not
if (Session::get('step6') == 'step6') { if (Session::get('step6') == 'step6') {
$value = '1'; $value = '1';
$install = app_path('../config/database.php'); $install = app_path('../config/database.php');
$datacontent = File::get($install); $datacontent = File::get($install);
$datacontent = str_replace('%0%', $value, $datacontent); $datacontent = str_replace('%0%', $value, $datacontent);
File::put($install, $datacontent); File::put($install, $datacontent);
// setting email settings in route // setting email settings in route
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()"; $smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
$path22 = app_path('Http/routes.php'); $lfmpath = "url('photos').'/'";
$content23 = File::get($path22); $path22 = app_path('Http/routes.php');
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23); $path23 = base_path('config/lfm.php');
File::put($path22, $content23); $content23 = File::get($path22);
try { $content24 = File::get($path23);
return View::make('themes/default1/installer/helpdesk/view6'); $content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
} catch (Exception $e) { $content24 = str_replace("'%url%'", $lfmpath, $content24);
return Redirect::route('npl'); File::put($path22, $content23);
} File::put($path23, $content24);
} else { try {
return redirect('/auth/login'); Session::forget('step1');
} Session::forget('step2');
} Session::forget('step3');
/** Session::forget('step4');
Session::forget('step5');
Session::forget('step6');
return View::make('themes/default1/installer/helpdesk/view6');
} catch (Exception $e) {
return Redirect::route('npl');
}
} else {
return redirect('/auth/login');
}
}
/**
* Post finalcheck * Post finalcheck
* checking prerequisites * checking prerequisites
* @return type view * @return type view
*/ */
public function finalcheck() { public function finalcheck() {
try { try {
return redirect('/auth/login'); return redirect('/auth/login');
} catch (Exception $e) { } catch (Exception $e) {
return redirect('/auth/login'); return redirect('/auth/login');
} }
} }
} }

View File

@@ -1,119 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Phpmailer\PHPMailerautoload;
use Illuminate\Http\Request;
class PhpMailController extends Controller {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index() {
//
}
/**
* Sending emails from the system.
*
* @return Mail
*/
public function sendmail($host = '', $username = '', $password = '', $smtpsecure = '', $port = '', $from = '', $recipants = '', $subject = '', $body = '', $cc = '', $bc = '') {
$mail = new \PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'sujitprasad4567@gmail.com'; // SMTP username
$mail->Password = 'pankajprasad22.'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('sujitprasad4567@gmail.com', 'Mailer');
$mail->addAddress('sada059@gmail.com', 'Joe User'); // Add a recipient
// Name is optional
$mail->addReplyTo('sada059@gmail.com', 'Information');
// Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create() {
//
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store() {
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id) {
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id) {
//
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id) {
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id) {
//
}
}

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http; <?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel; use Illuminate\Foundation\Http\Kernel as HttpKernel;
@@ -9,33 +11,36 @@ use Illuminate\Foundation\Http\Kernel as HttpKernel;
*/ */
class Kernel extends HttpKernel { class Kernel extends HttpKernel {
/** /**
* The application's global HTTP middleware stack. * The application's global HTTP middleware stack.
* *
* @var array * @var array
*/ */
protected $middleware = [ protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode', 'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies', 'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession', 'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession', 'Illuminate\View\Middleware\ShareErrorsFromSession',
//'App\Http\Middleware\VerifyCsrfToken', //'App\Http\Middleware\VerifyCsrfToken',
'App\Http\Middleware\LanguageMiddleware', 'App\Http\Middleware\LanguageMiddleware',
]; ];
/** /**
* The application's route middleware. * The application's route middleware.
* *
* @var array * @var array
*/ */
protected $routeMiddleware = [ protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate', 'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth', 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated', 'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
'roles' => 'App\Http\Middleware\CheckRole', 'roles' => 'App\Http\Middleware\CheckRole',
'role.agent' => 'App\Http\Middleware\CheckRoleAgent', 'role.agent' => 'App\Http\Middleware\CheckRoleAgent',
'role.user' => 'App\Http\Middleware\CheckRoleUser', 'role.user' => 'App\Http\Middleware\CheckRoleUser',
]; 'api' => 'App\Http\Middleware\ApiKey',
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class
];
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Middleware; <?php
namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
@@ -10,40 +13,40 @@ use Illuminate\Contracts\Auth\Guard;
*/ */
class Authenticate { class Authenticate {
/** /**
* The Guard implementation. * The Guard implementation.
* *
* @var Guard * @var Guard
*/ */
protected $auth; protected $auth;
/** /**
* Create a new filter instance. * Create a new filter instance.
* *
* @param Guard $auth * @param Guard $auth
* @return void * @return void
*/ */
public function __construct(Guard $auth) { public function __construct(Guard $auth) {
$this->auth = $auth; $this->auth = $auth;
} }
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) { public function handle($request, Closure $next) {
if ($this->auth->guest()) { if ($this->auth->guest()) {
if ($request->ajax()) { if ($request->ajax()) {
return response('Unauthorized.', 401); return response('Unauthorized.', 401);
} else { } else {
return redirect()->guest('auth/login'); return redirect()->guest('auth/login');
} }
} }
return $next($request); return $next($request);
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Middleware; <?php
namespace App\Http\Middleware;
use Closure; use Closure;
/** /**
@@ -9,19 +12,19 @@ use Closure;
*/ */
class CheckRole { class CheckRole {
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) { public function handle($request, Closure $next) {
if ($request->user()->role == 'admin') { if ($request->user()->role == 'admin') {
return $next($request); return $next($request);
} }
return redirect('guest')->with('fails', 'You are not Autherised'); return redirect('guest')->with('fails', 'You are not Autherised');
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Middleware; <?php
namespace App\Http\Middleware;
use Closure; use Closure;
/** /**
@@ -9,18 +12,18 @@ use Closure;
*/ */
class CheckRoleAgent { class CheckRoleAgent {
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) { public function handle($request, Closure $next) {
if ($request->user()->role == 'agent' || $request->user()->role == 'admin') { if ($request->user()->role == 'agent' || $request->user()->role == 'admin') {
return $next($request); return $next($request);
} }
return redirect('dashboard')->with('fails', 'You are not Autherised'); return redirect('dashboard')->with('fails', 'You are not Autherised');
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Middleware; <?php
namespace App\Http\Middleware;
use Closure; use Closure;
/** /**
@@ -9,18 +12,18 @@ use Closure;
*/ */
class CheckRoleUser { class CheckRoleUser {
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) { public function handle($request, Closure $next) {
if ($request->user()->role == 'user') { if ($request->user()->role == 'user') {
return $next($request); return $next($request);
} }
return redirect('guest')->with('fails', 'You are not Autherised'); return redirect('guest')->with('fails', 'You are not Autherised');
} }
} }

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Middleware; <?php
namespace App\Http\Middleware;
use Cache; use Cache;
use Closure; use Closure;
@@ -11,14 +13,14 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
class LanguageMiddleware implements Middleware { class LanguageMiddleware implements Middleware {
public function handle($request, Closure $next)
{ public function handle($request, Closure $next) {
if (Cache::has('language') AND array_key_exists(Cache::get('language'), Config::get('languages'))) { if (Cache::has('language') AND array_key_exists(Cache::get('language'), Config::get('languages'))) {
App::setLocale(Cache::get('language')); App::setLocale(Cache::get('language'));
} } else { // This is optional as Laravel will automatically set the fallback language if there is none specified
else { // This is optional as Laravel will automatically set the fallback language if there is none specified
App::setLocale(Config::get('app.fallback_locale')); App::setLocale(Config::get('app.fallback_locale'));
} }
return $next($request); return $next($request);
} }
} }

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Middleware; <?php
namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
@@ -6,36 +8,36 @@ use Illuminate\Http\RedirectResponse;
class RedirectIfAuthenticated { class RedirectIfAuthenticated {
/** /**
* The Guard implementation. * The Guard implementation.
* *
* @var Guard * @var Guard
*/ */
protected $auth; protected $auth;
/** /**
* Create a new filter instance. * Create a new filter instance.
* *
* @param Guard $auth * @param Guard $auth
* @return void * @return void
*/ */
public function __construct(Guard $auth) { public function __construct(Guard $auth) {
$this->auth = $auth; $this->auth = $auth;
} }
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) { public function handle($request, Closure $next) {
if ($this->auth->check()) { if ($this->auth->check()) {
return new RedirectResponse(url('dashboard')); return new RedirectResponse(url('dashboard'));
} }
return $next($request); return $next($request);
} }
} }

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Middleware; <?php
namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

View File

@@ -1,9 +1,9 @@
<?php namespace App\Http\Requests; <?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest { abstract class Request extends FormRequest {
//
//
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,35 +12,35 @@ use App\Http\Requests\Request;
*/ */
class AgentRequest extends Request { class AgentRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'user_name' => 'required|unique:users', 'user_name' => 'required|unique:users',
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
'email' => 'required', 'email' => 'required',
'active' => 'required', 'active' => 'required',
// 'account_status' => 'required', // 'account_status' => 'required',
'assign_group' => 'required', 'assign_group' => 'required',
'primary_dpt' => 'required', 'primary_dpt' => 'required',
'agent_tzone' => 'required', 'agent_tzone' => 'required',
// 'phone_number' => 'phone:IN', // 'phone_number' => 'phone:IN',
// 'mobile' => 'phone:IN', // 'mobile' => 'phone:IN',
'team_id' => 'required', 'team_id' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,34 +12,34 @@ use App\Http\Requests\Request;
*/ */
class AgentUpdate extends Request { class AgentUpdate extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
'email' => 'required|email', 'email' => 'required|email',
'active' => 'required', 'active' => 'required',
'role' => 'required', 'role' => 'required',
'assign_group' => 'required', 'assign_group' => 'required',
'primary_dpt' => 'required', 'primary_dpt' => 'required',
'agent_tzone' => 'required', 'agent_tzone' => 'required',
// 'phone_number' => 'phone:IN', // 'phone_number' => 'phone:IN',
// 'mobile' => 'phone:IN', // 'mobile' => 'phone:IN',
'team_id' => 'required', 'team_id' => 'required',
]; ];
} }
} }

View File

@@ -1,27 +1,30 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
class ArticleRequest extends Request { class ArticleRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => 'required', 'name' => 'required',
'description' => 'required', 'description' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class BanRequest extends Request { class BanRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email' => 'required|email', 'email' => 'required|email',
'ban' => 'required', 'ban' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class BanlistRequest extends Request { class BanlistRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email' => 'email', 'email' => 'email',
'ban' => 'required', 'ban' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class CannedRequest extends Request { class CannedRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'title' => 'required', 'title' => 'required',
'message' => 'required', 'message' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class CannedUpdateRequest extends Request { class CannedUpdateRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'title' => 'required', 'title' => 'required',
'message' => 'required', 'message' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class CheckTicket extends Request { class CheckTicket extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email' => 'required|email', 'email' => 'required|email',
'ticket_number' => 'required', 'ticket_number' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/ */
class ClientRequest extends Request { class ClientRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'Name'=>'required', 'Name' => 'required',
'Email'=>'required', 'Email' => 'required',
'Subject'=>'required', 'Subject' => 'required',
'Details'=>'required', 'Details' => 'required',
]; ];
} }
} }

View File

@@ -1,29 +1,32 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
class CommentRequest extends Request { class CommentRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => 'required|max:10', 'name' => 'required|max:10',
'email' => 'required|email', 'email' => 'required|email',
'website' => 'url', 'website' => 'url',
'comment' => 'required|max:60', 'comment' => 'required|max:60',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/ */
class CompanyRequest extends Request { class CompanyRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'company_name' => 'required', 'company_name' => 'required',
'website' => 'url', 'website' => 'url',
'phone' => 'numeric', 'phone' => 'numeric',
'logo' => 'image', 'logo' => 'image',
]; ];
} }
} }

View File

@@ -1,29 +1,32 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
class ContactRequest extends Request { class ContactRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => 'required', 'name' => 'required',
'email' => 'required|email', 'email' => 'required|email',
'subject' => 'required', 'subject' => 'required',
'message' => 'required|max:50', 'message' => 'required|max:50',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,32 +12,32 @@ use App\Http\Requests\Request;
*/ */
class CreateTicketRequest extends Request { class CreateTicketRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email' => 'required|email', 'email' => 'required|email',
'fullname' => 'required|min:3', 'fullname' => 'required|min:3',
'helptopic' => 'required', 'helptopic' => 'required',
// 'dept' => 'required', // 'dept' => 'required',
'sla' => 'required', 'sla' => 'required',
'subject' => 'required|min:5', 'subject' => 'required|min:5',
'body' => 'required|min:20', 'body' => 'required|min:20',
'priority' => 'required', 'priority' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/ */
class DepartmentRequest extends Request { class DepartmentRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => 'required|unique:department', 'name' => 'required|unique:department',
// 'outgoing_email' => 'required', // 'outgoing_email' => 'required',
// 'auto_response_email' => 'required', // 'auto_response_email' => 'required',
// 'group_id' => 'required', // 'group_id' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/ */
class DepartmentUpdate extends Request { class DepartmentUpdate extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
// 'outgoing_email' => 'required', // 'outgoing_email' => 'required',
// 'auto_response_email' => 'required', // 'auto_response_email' => 'required',
// 'group_id' => 'required', // 'group_id' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/ */
class DiagnoRequest extends Request { class DiagnoRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'from' => 'required|email', 'from' => 'required|email',
'to' => 'required|email', 'to' => 'required|email',
'subject' => 'required', 'subject' => 'required',
'message' => 'required', 'message' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,23 +12,23 @@ use App\Http\Requests\Request;
*/ */
class EmailRequest extends Request { class EmailRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,37 +12,37 @@ use App\Http\Requests\Request;
*/ */
class EmailsEditRequest extends Request { class EmailsEditRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email_address' => 'email', 'email_address' => 'email',
'email_name' => 'required', 'email_name' => 'required',
'department' => 'required', // 'department' => 'required',
'priority' => 'required', // 'priority' => 'required',
'help_topic' => 'required', // 'help_topic' => 'required',
// 'imap_config' => 'required', // 'imap_config' => 'required',
'password' => 'required|min:6', 'password' => 'required|min:6',
// 'user_name' => 'required', // 'user_name' => 'required',
// 'sending_host' => 'required', // 'sending_host' => 'required',
// 'sending_port' => 'required', // 'sending_port' => 'required',
//'mailbox_protocol' => 'required' //'mailbox_protocol' => 'required'
'fetching_host' => 'required', 'fetching_host' => 'required',
'fetching_port' => 'required', 'fetching_port' => 'required',
'mailbox_protocol' => 'required', 'mailbox_protocol' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,36 +12,36 @@ use App\Http\Requests\Request;
*/ */
class EmailsRequest extends Request { class EmailsRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email_address' => 'required|email|unique:emails', 'email_address' => 'required|email|unique:emails',
'email_name' => 'required', 'email_name' => 'required',
'department' => 'required', // 'department' => 'required',
'priority' => 'required', // 'priority' => 'required',
'help_topic' => 'required', // 'help_topic' => 'required',
// 'imap_config' => 'required', // 'imap_config' => 'required',
'password' => 'required|min:6', 'password' => 'required|min:6',
// 'user_name' => 'required', // 'user_name' => 'required',
// 'sending_host' => 'required', // 'sending_host' => 'required',
// 'sending_port' => 'required', // 'sending_port' => 'required',
'fetching_host' => 'required', 'fetching_host' => 'required',
'fetching_port' => 'required', 'fetching_port' => 'required',
'mailbox_protocol' => 'required', 'mailbox_protocol' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,28 +12,28 @@ use App\Http\Requests\Request;
*/ */
class FormRequest extends Request { class FormRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'title' => 'required', 'title' => 'required',
'label' => 'required', 'label' => 'required',
'type' => 'required', 'type' => 'required',
'visibility' => 'required', 'visibility' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,24 +12,24 @@ use App\Http\Requests\Request;
*/ */
class GroupRequest extends Request { class GroupRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => 'required|unique:groups', 'name' => 'required|unique:groups',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,30 +12,30 @@ use App\Http\Requests\Request;
*/ */
class HelptopicRequest extends Request { class HelptopicRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'topic' => 'required|unique:help_topic', 'topic' => 'required|unique:help_topic',
// 'parent_topic' => 'required', // 'parent_topic' => 'required',
// 'custom_form' => 'required', // 'custom_form' => 'required',
'department' => 'required', 'department' => 'required',
'priority' => 'required', 'priority' => 'required',
'sla_plan' => 'required', 'sla_plan' => 'required',
// 'auto_assign' => 'required', // 'auto_assign' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,29 +12,29 @@ use App\Http\Requests\Request;
*/ */
class HelptopicUpdate extends Request { class HelptopicUpdate extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
// 'parent_topic' => 'required', // 'parent_topic' => 'required',
// 'custom_form' => 'required', // 'custom_form' => 'required',
'department' => 'required', 'department' => 'required',
'priority' => 'required', 'priority' => 'required',
'sla_plan' => 'required', 'sla_plan' => 'required',
// 'auto_assign' => 'required', // 'auto_assign' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,29 +12,29 @@ use App\Http\Requests\Request;
*/ */
class InstallerRequest extends Request { class InstallerRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'firstname' => 'required|max:20', 'firstname' => 'required|max:20',
'Lastname' => 'required|max:20', 'Lastname' => 'required|max:20',
'email' => 'required|max:50|email', 'email' => 'required|max:50|email',
'username' => 'required|max:50|min:3', 'username' => 'required|max:50|min:3',
'password' => 'required|min:6', 'password' => 'required|min:6',
'confirmpassword' => 'required|same:password', 'confirmpassword' => 'required|same:password',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class LoginRequest extends Request { class LoginRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email' => 'required', 'email' => 'required',
'password' => 'required|min:6', 'password' => 'required|min:6',
]; ];
} }
} }

View File

@@ -1,33 +1,32 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
class MessageRequest extends Request { class MessageRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() public function authorize() {
{ return true;
return true; }
}
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() public function rules() {
{ return [
return [
'message_title' => 'required', 'message_title' => 'required',
'message' => 'required' 'message' => 'required'
];
]; }
}
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/ */
class OrganizationRequest extends Request { class OrganizationRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => 'required|unique:organization', 'name' => 'required|unique:organization',
'website' => 'url', 'website' => 'url',
// 'phone' => 'size:10', // 'phone' => 'size:10',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,26 +12,26 @@ use App\Http\Requests\Request;
*/ */
class OrganizationUpdate extends Request { class OrganizationUpdate extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'website' => 'url', 'website' => 'url',
// 'phone' => 'size:10', // 'phone' => 'size:10',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,26 +12,26 @@ use App\Http\Requests\Request;
*/ */
class ProfilePassword extends Request { class ProfilePassword extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'old_password' => 'required', 'old_password' => 'required',
'new_password' => 'required|min:6', 'new_password' => 'required|min:6',
'confirm_password' => 'required|same:new_password', 'confirm_password' => 'required|same:new_password',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class ProfileRequest extends Request { class ProfileRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'first_name' => 'required', 'first_name' => 'required',
'profile_pic' => 'mimes:png,jpeg', 'profile_pic' => 'mimes:png,jpeg',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/ */
class RegisterRequest extends Request { class RegisterRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email' => 'required|max:50|email|unique:users', 'email' => 'required|max:50|email|unique:users',
'full_name' => 'required', 'full_name' => 'required',
'password' => 'required|min:6', 'password' => 'required|min:6',
'password_confirmation' => 'required|same:password', 'password_confirmation' => 'required|same:password',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class SlaRequest extends Request { class SlaRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => 'required|unique:sla_plan', 'name' => 'required|unique:sla_plan',
'grace_period' => 'required', 'grace_period' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,24 +12,24 @@ use App\Http\Requests\Request;
*/ */
class SlaUpdate extends Request { class SlaUpdate extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'grace_period' => 'required', 'grace_period' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,29 +12,29 @@ use App\Http\Requests\Request;
*/ */
class SmtpRequest extends Request { class SmtpRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'host' => 'required', 'host' => 'required',
'port' => 'required', 'port' => 'required',
'encryption' => 'required', 'encryption' => 'required',
'name' => 'required', 'name' => 'required',
'email' => 'required', 'email' => 'required',
'password' => 'required', 'password' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/ */
class Sys_userRequest extends Request { class Sys_userRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'email' => 'required|unique:users,email', 'email' => 'required|unique:users,email',
'full_name' => 'required', 'full_name' => 'required',
// 'phone' => 'size:10', // 'phone' => 'size:10',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,26 +12,26 @@ use App\Http\Requests\Request;
*/ */
class Sys_userUpdate extends Request { class Sys_userUpdate extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'user_name' => 'required', 'user_name' => 'required',
// 'email' => 'required|email', // 'email' => 'required|email',
// 'phone' => 'size:10', // 'phone' => 'size:10',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,26 +12,26 @@ use App\Http\Requests\Request;
*/ */
class SystemRequest extends Request { class SystemRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => '', 'name' => '',
'url' => 'url', 'url' => 'url',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/ */
class TeamRequest extends Request { class TeamRequest extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
'name' => 'required|unique:teams', 'name' => 'required|unique:teams',
'status' => 'required', 'status' => 'required',
]; ];
} }
} }

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk; <?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
/** /**
@@ -9,23 +12,23 @@ use App\Http\Requests\Request;
*/ */
class TeamUpdate extends Request { class TeamUpdate extends Request {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize() {
return true; return true;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
* @return array * @return array
*/ */
public function rules() { public function rules() {
return [ return [
]; ];
} }
} }

Some files were not shown because too many files have changed in this diff Show More