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

View File

@@ -1,13 +1,14 @@
<?php namespace App\Http\Controllers\Admin\helpdesk;
<?php
namespace App\Http\Controllers\Admin\helpdesk;
// controller
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// request
use App\Http\Requests\helpdesk\AgentRequest;
use App\Http\Requests\helpdesk\AgentUpdate;
// model
use App\User;
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\Utility\Timezones;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Email\Emails;
// classes
use DB;
use Mail;
@@ -33,216 +35,222 @@ use Exception;
*/
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.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
SettingsController::smtp();
// checking authentication
$this->middleware('auth');
// checking admin roles
$this->middleware('roles');
}
/**
* Get all agent list page
* @param type User $user
* @return type Response
*/
public function index() {
try {
return view('themes.default1.admin.helpdesk.agent.agents.index');
} catch (Exception $e) {
return view('404');
}
}
/**
* Get all agent list page
* @param type User $user
* @return type Response
*/
public function index() {
try {
return view('themes.default1.admin.helpdesk.agent.agents.index');
} catch (Exception $e) {
return view('404');
}
}
/**
* creating a new agent
* @param type Assign_team_agent $team_assign_agent
* @param type Timezones $timezone
* @param type Groups $group
* @param type Department $department
* @param type Teams $team
* @return type view
*/
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
* @param type Assign_team_agent $team_assign_agent
* @param type Timezones $timezone
* @param type Groups $group
* @param type Department $department
* @param type Teams $team
* @return type view
*/
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]);
}
}
/**
* 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) {
/**
* 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 */
$user->role = 'agent';
$user->fill($request->input())->save();
$password = $this->generateRandomString();
$user->password = Hash::make($password);
$requests = $request->input('team_id');
$id = $user->id;
// insert team
foreach ($requests as $req) {
DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]);
}
/* Succes And Failure condition */
if ($user->save() == true) {
$name = $user->user_name;
$email = $user->email;
$from = $this->company();
// send mail on registration
try{
Mail::send('emails.pass', ['name' => $name, 'password' => $password, 'from' => $from, 'emailadd' => $email], function ($message) use ($email, $name) {
$message->to($email, $name)->subject('[password]');
});
} 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('fails', 'Agent can not Create');
}
}
// dd($this->system_mail());
/**
* Editing a selected agent
* @param type int $id
* @param type User $user
* @param type Assign_team_agent $team_assign_agent
* @param type Timezones $timezone
* @param type Groups $group
* @param type Department $department
* @param type Teams $team
* @return type Response
*/
public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) {
try {
$user = $user->whereId($id)->first();
$team = $team->get();
$teams1 = $team->lists('name', 'id');
$timezones = $timezone->get();
$groups = $group->get();
$departments = $department->get();
$table = $team_assign_agent->where('agent_id', $id)->first();
$teams = $team->lists('id', 'name');
$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'));
} catch (Exception $e) {
return redirect('agents')->with('fail', 'No such file');
}
}
/* Insert to user table */
$user->role = 'agent';
$user->fill($request->input())->save();
$password = $this->generateRandomString();
$user->password = Hash::make($password);
$requests = $request->input('team_id');
$id = $user->id;
// insert team
foreach ($requests as $req) {
// DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]);
}
/* Succes And Failure condition */
if ($user->save() == true) {
$name = $user->user_name;
$email = $user->email;
$system_from = $this->company();
try {
// send mail on registration
$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]);
} catch (Exception $e) {
return redirect('agents')->with('fails', 'Some error occured while sending mail to the agent. Please check email settings and try again');
}
return redirect('agents')->with('success', 'Agent Created sucessfully');
} else {
return redirect('agents')->with('fails', 'Agent can not Create');
}
}
/**
* Update the specified agent in storage.
* @param type int $id
* @param type User $user
* @param type AgentUpdate $request
* @param type Assign_team_agent $team_assign_agent
* @return type Response
*/
public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent) {
/**
* Editing a selected agent
* @param type int $id
* @param type User $user
* @param type Assign_team_agent $team_assign_agent
* @param type Timezones $timezone
* @param type Groups $group
* @param type Department $department
* @param type Teams $team
* @return type Response
*/
public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) {
try {
$user = $user->whereId($id)->first();
$team = $team->get();
$teams1 = $team->lists('name', 'id');
$timezones = $timezone->get();
$groups = $group->get();
$departments = $department->get();
$table = $team_assign_agent->where('agent_id', $id)->first();
$teams = $team->lists('id', 'name');
$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'));
} catch (Exception $e) {
return redirect('agents')->with('fail', 'No such file');
}
}
// storing all the details
$user = $user->whereId($id)->first();
$daylight_save = $request->input('daylight_save');
$limit_access = $request->input('limit_access');
$directory_listing = $request->input('directory_listing');
$vocation_mode = $request->input('vocation_mode');
//==============================================
$table = $team_assign_agent->where('agent_id', $id);
$table->delete();
$requests = $request->input('team_id');
// inserting team details
foreach ($requests as $req) {
DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]);
}
//Todo For success and failure conditions
try {
$user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save();
return redirect('agents')->with('success', 'Agent Updated sucessfully');
} catch (Exception $e) {
return redirect('agents')->with('fails', 'Agent did not update'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Update the specified agent in storage.
* @param type int $id
* @param type User $user
* @param type AgentUpdate $request
* @param type Assign_team_agent $team_assign_agent
* @return type Response
*/
public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent) {
/**
* Remove the specified agent from storage.
* @param type int $id
* @param type User $user
* @param type Assign_team_agent $team_assign_agent
* @return type Response
*/
public function destroy($id, User $user, Assign_team_agent $team_assign_agent) {
/* Becouse of foreign key we delete team_assign_agent first */
error_reporting(E_ALL & ~E_NOTICE);
$team_assign_agent = $team_assign_agent->where('agent_id', $id);
$team_assign_agent->delete();
$user = $user->whereId($id)->first();
try {
$error = 'This staff is related to some tickets';
$user->id;
$user->delete();
throw new \Exception($error);
return redirect('agents')->with('success', 'Agent Deleted sucessfully');
} catch (\Exception $e) {
dd($e->errorInfo);
return redirect('agents')->with('fails', $error);
}
}
// storing all the details
$user = $user->whereId($id)->first();
$daylight_save = $request->input('daylight_save');
$limit_access = $request->input('limit_access');
$directory_listing = $request->input('directory_listing');
$vocation_mode = $request->input('vocation_mode');
//==============================================
$table = $team_assign_agent->where('agent_id', $id);
$table->delete();
$requests = $request->input('team_id');
// inserting team details
foreach ($requests as $req) {
DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]);
}
//Todo For success and failure conditions
try {
$user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save();
return redirect('agents')->with('success', 'Agent Updated sucessfully');
} catch (Exception $e) {
return redirect('agents')->with('fails', 'Agent did not update' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Remove the specified agent from storage.
* @param type int $id
* @param type User $user
* @param type Assign_team_agent $team_assign_agent
* @return type Response
*/
public function destroy($id, User $user, Assign_team_agent $team_assign_agent) {
/* Becouse of foreign key we delete team_assign_agent first */
error_reporting(E_ALL & ~E_NOTICE);
$team_assign_agent = $team_assign_agent->where('agent_id', $id);
$team_assign_agent->delete();
$user = $user->whereId($id)->first();
try {
$error = 'This staff is related to some tickets';
$user->id;
$user->delete();
throw new \Exception($error);
return redirect('agents')->with('success', 'Agent Deleted sucessfully');
} catch (\Exception $e) {
dd($e->errorInfo);
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
* @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;
}
/**
* 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'));
// }
/**
* 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;
}
/**
* 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
use App\Http\Controllers\Controller;
// request
use App\Http\Requests\helpdesk\BanlistRequest;
use App\Http\Requests\helpdesk\BanRequest;
// model
use App\User;
use App\Model\helpdesk\Email\Banlist;
//classes
use Exception;
@@ -22,142 +22,142 @@ use Exception;
*/
class BanlistController 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() {
// checking authentication
$this->middleware('auth');
// checking admin roles
$this->middleware('roles');
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking admin roles
$this->middleware('roles');
}
/**
* Display a listing of the resource.
* @param type Banlist $ban
* @return type Response
*/
public function index() {
try {
$bans = User::where('ban','=',1)->get();
return view('themes.default1.admin.helpdesk.emails.banlist.index', compact('bans'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Display a listing of the resource.
* @param type Banlist $ban
* @return type Response
*/
public function index() {
try {
$bans = User::where('ban', '=', 1)->get();
return view('themes.default1.admin.helpdesk.emails.banlist.index', compact('bans'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.admin.helpdesk.emails.banlist.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.admin.helpdesk.emails.banlist.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
* @param type banlist $ban
* @param type BanRequest $request
* @param type User $user
* @return type Response
*/
public function store(BanRequest $request, User $user) {
// dd($request);
try {
//adding field to user whether it is banned or not
$adban = $request->input('email');
$use = $user->where('email', $adban)->first();
if ($use != null) {
$use->ban = $request->input('ban');
$use->internal_note = $request->input('internal_note');
$use->save();
// $user->create($request->input())->save();
return redirect('banlist')->with('success', 'Email Banned sucessfully');
} else {
$user = new User;
$user->email = $adban;
$user->ban = $request->input('ban');
$user->internal_note = $request->input('internal_note');
$user->save();
return redirect('banlist')->with('success', 'Email Banned sucessfully');
}
} catch (Exception $e) {
return redirect('banlist')->with('fails', 'Email can not Ban');
}
}
/**
* Store a newly created resource in storage.
* @param type banlist $ban
* @param type BanRequest $request
* @param type User $user
* @return type Response
*/
public function store(BanRequest $request, User $user) {
// dd($request);
try {
//adding field to user whether it is banned or not
$adban = $request->input('email');
$use = $user->where('email', $adban)->first();
if ($use != null) {
$use->ban = $request->input('ban');
$use->internal_note = $request->input('internal_note');
$use->save();
// $user->create($request->input())->save();
return redirect('banlist')->with('success', 'Email Banned sucessfully');
} else {
$user = new User;
$user->email = $adban;
$user->ban = $request->input('ban');
$user->internal_note = $request->input('internal_note');
$user->save();
return redirect('banlist')->with('success', 'Email Banned sucessfully');
}
} catch (Exception $e) {
return redirect('banlist')->with('fails', 'Email can not Ban');
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id) {
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id) {
//
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type Banlist $ban
* @return type Response
*/
public function edit($id, User $ban) {
try {
$bans = $ban->whereId($id)->first();
return view('themes.default1.admin.helpdesk.emails.banlist.edit', compact('bans'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type Banlist $ban
* @return type Response
*/
public function edit($id, User $ban) {
try {
$bans = $ban->whereId($id)->first();
return view('themes.default1.admin.helpdesk.emails.banlist.edit', compact('bans'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Banlist $ban
* @param type BanlistRequest $request
* @return type Response
*/
public function update($id, User $ban, BanlistRequest $request) {
try {
$bans = $ban->whereId($id)->first();
$bans->internal_note = $request->input('internal_note');
$bans->ban = $request->input('ban');
// dd($request->input('ban'));
if ($bans->save()) {
return redirect('banlist')->with('success', 'Banned Email Updated sucessfully');
} else {
return redirect('banlist')->with('fails', 'Banned Email not Updated');
}
} catch (Exception $e) {
return redirect('banlist')->with('fails', 'Banned Email not Updated');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Banlist $ban
* @param type BanlistRequest $request
* @return type Response
*/
public function update($id, User $ban, BanlistRequest $request) {
try {
$bans = $ban->whereId($id)->first();
$bans->internal_note = $request->input('internal_note');
$bans->ban = $request->input('ban');
// dd($request->input('ban'));
if ($bans->save()) {
return redirect('banlist')->with('success', 'Banned Email Updated sucessfully');
} else {
return redirect('banlist')->with('fails', 'Banned Email not Updated');
}
} catch (Exception $e) {
return redirect('banlist')->with('fails', 'Banned Email not Updated');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Banlist $ban
* @return type Response
*/
// public function destroy($id, Banlist $ban) {
// $bans = $ban->whereId($id)->first();
// dd($bans);
// /* Success and Falure condition */
// try{
// $bans->delete();
// return redirect('banlist')->with('success', 'Banned Email Deleted sucessfully');
// } catch (Exception $e) {
// return redirect('banlist')->with('fails', 'Banned Email can not Delete'.'<li>'.$e->errorInfo[2].'</li>');
// }
// }
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Banlist $ban
* @return type Response
*/
// public function destroy($id, Banlist $ban) {
// $bans = $ban->whereId($id)->first();
// dd($bans);
// /* Success and Falure condition */
// try{
// $bans->delete();
// return redirect('banlist')->with('success', 'Banned Email Deleted sucessfully');
// } catch (Exception $e) {
// 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
use App\Http\Controllers\Controller;
// request
@@ -29,214 +32,213 @@ use Exception;
*/
class DepartmentController extends Controller {
/**
* Create a new controller instance.
* @return void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Get index page
* @param type Department $department
* @return type Response
*/
public function index(Department $department) {
try {
$departments = $department->get();
return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Get index page
* @param type Department $department
* @return type Response
*/
public function index(Department $department) {
try {
$departments = $department->get();
return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @param type User $user
* @param type Group_assign_department $group_assign_department
* @param type Department $department
* @param type Sla_plan $sla
* @param type Template $template
* @param type Emails $email
* @param type Groups $group
* @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) {
try {
$slas = $sla->get();
$user = $user->where('role', 'agent')->get();
$emails = $email->get();
$templates = $template->get();
$department = $department->get();
$groups = $group->lists('id', 'name');
return view('themes.default1.admin.helpdesk.agent.departments.create', compact('department', 'templates', 'slas', 'user', 'emails', 'groups'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @param type User $user
* @param type Group_assign_department $group_assign_department
* @param type Department $department
* @param type Sla_plan $sla
* @param type Template $template
* @param type Emails $email
* @param type Groups $group
* @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) {
try {
$slas = $sla->get();
$user = $user->where('role', 'agent')->get();
$emails = $email->get();
$templates = $template->get();
$department = $department->get();
$groups = $group->lists('id', 'name');
return view('themes.default1.admin.helpdesk.agent.departments.create', compact('department', 'templates', 'slas', 'user', 'emails', 'groups'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
* @param type Department $department
* @param type DepartmentRequest $request
* @return type Response
*/
public function store(Department $department, DepartmentRequest $request) {
try {
$department->fill($request->except('group_id','manager'))->save();
$requests = $request->input('group_id');
$id = $department->id;
if($request->manager) {
$department->manager = $request->input('manager');
} else {
$department->manager = null;
}
// foreach ($requests as $req) {
// DB::insert('insert into group_assign_department(group_id, department_id) values (?,?)', [$req, $id]);
// }
/* Succes And Failure condition */
/* Check Whether the function Success or Fail */
if ($department->save() == true) {
return redirect('departments')->with('success', 'Department Created sucessfully');
} else {
return redirect('departments')->with('fails', 'Department can not Create');
}
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department can not Create');
}
}
/**
* Store a newly created resource in storage.
* @param type Department $department
* @param type DepartmentRequest $request
* @return type Response
*/
public function store(Department $department, DepartmentRequest $request) {
try {
$department->fill($request->except('group_id', 'manager'))->save();
$requests = $request->input('group_id');
$id = $department->id;
if ($request->manager) {
$department->manager = $request->input('manager');
} else {
$department->manager = null;
}
// foreach ($requests as $req) {
// DB::insert('insert into group_assign_department(group_id, department_id) values (?,?)', [$req, $id]);
// }
/* Succes And Failure condition */
/* Check Whether the function Success or Fail */
if ($department->save() == true) {
return redirect('departments')->with('success', 'Department Created sucessfully');
} else {
return redirect('departments')->with('fails', 'Department can not Create');
}
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department can not Create');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type User $user
* @param type Group_assign_department $group_assign_department
* @param type Template $template
* @param type Teams $team
* @param type Department $department
* @param type Sla_plan $sla
* @param type Emails $email
* @param type Groups $group
* @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) {
try {
$slas = $sla->get();
$user = $user->where('role', 'agent')->get();
$emails = $email->get();
$templates = $template->get();
$departments = $department->whereId($id)->first();
$groups = $group->lists('id', 'name');
$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'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type User $user
* @param type Group_assign_department $group_assign_department
* @param type Template $template
* @param type Teams $team
* @param type Department $department
* @param type Sla_plan $sla
* @param type Emails $email
* @param type Groups $group
* @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) {
try {
$slas = $sla->get();
$user = $user->where('role', 'agent')->get();
$emails = $email->get();
$templates = $template->get();
$departments = $department->whereId($id)->first();
$groups = $group->lists('id', 'name');
$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'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Group_assign_department $group_assign_department
* @param type Department $department
* @param type DepartmentUpdate $request
* @return type Response
*/
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) {
// dd($id);
try {
$table = $group_assign_department->where('department_id', $id);
$table->delete();
$requests = $request->input('group_id');
// foreach ($requests as $req) {
// DB::insert('insert into group_assign_department (group_id, department_id) values (?,?)', [$req, $id]);
// }
$departments = $department->whereId($id)->first();
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Group_assign_department $group_assign_department
* @param type Department $department
* @param type DepartmentUpdate $request
* @return type Response
*/
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) {
// dd($id);
try {
$table = $group_assign_department->where('department_id', $id);
$table->delete();
$requests = $request->input('group_id');
// foreach ($requests as $req) {
// DB::insert('insert into group_assign_department (group_id, department_id) values (?,?)', [$req, $id]);
// }
$departments = $department->whereId($id)->first();
if($request->manager) {
$departments->manager = $request->input('manager');
} else {
$departments->manager = null;
}
$departments->save();
if ($request->manager) {
$departments->manager = $request->input('manager');
} else {
$departments->manager = null;
}
$departments->save();
if ($departments->fill($request->except('group_access','manager'))->save()) {
return redirect('departments')->with('success', 'Department Updated sucessfully');
} else {
return redirect('departments')->with('fails', 'Department not Updated');
}
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department not Updated');
}
}
if ($departments->fill($request->except('group_access', 'manager'))->save()) {
return redirect('departments')->with('success', 'Department Updated sucessfully');
} else {
return redirect('departments')->with('fails', 'Department not Updated');
}
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department not Updated');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Department $department
* @param type Group_assign_department $group_assign_department
* @return type Response
*/
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets) {
// try {
$system = $system->where('id','=','1')->first();
if($system->department == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
} else {
$tickets = DB::table('tickets')->where('dept_id','=',$id)->update(['dept_id' => $system->department]);
if($tickets > 0){
if($tickets > 1){
$text_tickets = "Tickets";
} else {
$text_tickets = "Ticket";
}
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default department</li>';
} else {
$ticket = "";
}
$users = DB::table('users')->where('primary_dpt','=',$id)->update(['primary_dpt' => $system->department]);
if($users > 0){
if($users > 1){
$text_user = "Users";
} else {
$text_user = "User";
}
$user = '<li>'.$users.' '.$text_user.' have been moved to default department</li>';
} else {
$user = "";
}
$emails = DB::table('emails')->where('department','=',$id)->update(['department' => $system->department]);
if($emails > 0){
if($emails > 1){
$text_emails = "Emails";
} else {
$text_emails = "Email";
}
$email = '<li>'.$emails.' System '.$text_emails.' have been moved to default department</li>';
} else {
$email = "";
}
$helptopic = DB::table('help_topic')->where('department','=',$id)->update(['department' => null],['status' => '1']);
if($helptopic > 0){
$helptopic = '<li>The associated helptopic has been deactivated</li>';
} else {
$helptopic = "";
}
$message = $ticket.$user.$email.$helptopic;
/* Becouse of foreign key we delete group_assign_department first */
$group_assign_department = $group_assign_department->where('department_id', $id);
$group_assign_department->delete();
$departments = $department->whereId($id)->first();
/* Check the function is Success or Fail */
if ($departments->delete() == true) {
return redirect('departments')->with('success', 'Department Deleted sucessfully'.$message);
} else {
return redirect('departments')->with('fails', 'Department can not Delete');
}
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Department $department
* @param type Group_assign_department $group_assign_department
* @return type Response
*/
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets) {
// try {
$system = $system->where('id', '=', '1')->first();
if ($system->department == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
} else {
$tickets = DB::table('tickets')->where('dept_id', '=', $id)->update(['dept_id' => $system->department]);
if ($tickets > 0) {
if ($tickets > 1) {
$text_tickets = "Tickets";
} else {
$text_tickets = "Ticket";
}
$ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default department</li>';
} else {
$ticket = "";
}
$users = DB::table('users')->where('primary_dpt', '=', $id)->update(['primary_dpt' => $system->department]);
if ($users > 0) {
if ($users > 1) {
$text_user = "Users";
} else {
$text_user = "User";
}
$user = '<li>' . $users . ' ' . $text_user . ' have been moved to default department</li>';
} else {
$user = "";
}
$emails = DB::table('emails')->where('department', '=', $id)->update(['department' => $system->department]);
if ($emails > 0) {
if ($emails > 1) {
$text_emails = "Emails";
} else {
$text_emails = "Email";
}
$email = '<li>' . $emails . ' System ' . $text_emails . ' have been moved to default department</li>';
} else {
$email = "";
}
$helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']);
if ($helptopic > 0) {
$helptopic = '<li>The associated helptopic has been deactivated</li>';
} else {
$helptopic = "";
}
$message = $ticket . $user . $email . $helptopic;
/* Becouse of foreign key we delete group_assign_department first */
$group_assign_department = $group_assign_department->where('department_id', $id);
$group_assign_department->delete();
$departments = $department->whereId($id)->first();
/* Check the function is Success or Fail */
if ($departments->delete() == true) {
return redirect('departments')->with('success', 'Department Deleted sucessfully' . $message);
} else {
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
use App\Http\Controllers\Controller;
// request
@@ -10,6 +13,7 @@ use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Utility\MailboxProtocol;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Settings\Email;
// classes
use Crypt;
use Exception;
@@ -23,143 +27,187 @@ use Exception;
*/
class EmailsController extends Controller {
/**
* Create a new controller instance.
* @return type
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return type
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Display a listing of the resource.
* @param type Emails $emails
* @return type Response
*/
public function index(Emails $emails) {
try {
$emails = $emails->get();
return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Display a listing of the resource.
* @param type Emails $emails
* @return type Response
*/
public function index(Emails $emails) {
try {
$emails = $emails->get();
return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @param type Department $department
* @param type Help_topic $help
* @param type Priority $priority
* @param type MailboxProtocol $mailbox_protocol
* @return type Response
*/
public function create(Department $department, Help_topic $help, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) {
try {
$departments = $department->get();
$helps = $help->get();
$priority = $priority->get();
$mailbox_protocols = $mailbox_protocol->get();
return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @param type Department $department
* @param type Help_topic $help
* @param type Priority $priority
* @param type MailboxProtocol $mailbox_protocol
* @return type Response
*/
public function create(Department $department, Help_topic $help, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) {
try {
$departments = $department->get();
$helps = $help->get();
$priority = $priority->get();
$mailbox_protocols = $mailbox_protocol->get();
return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
* @param type Emails $email
* @param type EmailsRequest $request
* @return type Response
*/
public function store(Emails $email, EmailsRequest $request) {
try {
$password = $request->input('password');
$encrypted = Crypt::encrypt($password);
$email->password = $encrypted;
if ($email->fill($request->except('password'))->save() == true) {
return redirect('emails')->with('success', 'Email Created sucessfully');
} else {
return redirect('emails')->with('fails', 'Email can not Create');
}
} catch (Exception $e) {
return redirect('emails')->with('fails', 'Email can not Create');
}
}
/**
* Store a newly created resource in storage.
* @param type Emails $email
* @param type EmailsRequest $request
* @return type Response
*/
public function store(Emails $email, EmailsRequest $request) {
try {
$password = $request->input('password');
$encrypted = Crypt::encrypt($password);
$department = $request->input('department');
$priority = $request->input('priority');
$help_topic = $request->input('help_topic');
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id) {
//
}
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic'))->save() == true) {
if ($request->input('department')) {
$email->department = $request->input('department');
} else {
$email->department = null;
}
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();
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type Department $department
* @param type Help_topic $help
* @param type Emails $email
* @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');
}
}
return redirect('emails')->with('success', 'Email Created sucessfully');
} else {
return redirect('emails')->with('fails', 'Email can not Create');
}
} catch (Exception $e) {
return redirect('emails')->with('fails', 'Email can not Create');
}
}
/**
* 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'))->save();
return redirect('emails')->with('success', 'Email Updated sucessfully');
} catch (Exception $e) {
return redirect('emails')->with('fails', 'Email not updated');
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id) {
//
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Emails $email
* @return type Response
*/
public function destroy($id, Emails $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 ');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type Department $department
* @param type Help_topic $help
* @param type Emails $email
* @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.
* @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
use App\Http\Controllers\Controller;
// Model
use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Form\Forms;
use App\Model\helpdesk\Manage\Help_topic;
// Request
use Illuminate\Http\Request;
// Class
use Input;
use Redirect;
@@ -25,21 +24,21 @@ use Exception;
* @author Ladybird <info@ladybirdweb.com>
*/
class FormController extends Controller {
private $fields;
private $fields;
private $forms;
public function __construct(Fields $fields,Forms $forms) {
public function __construct(Fields $fields, Forms $forms) {
$this->fields = $fields;
$this->forms = $forms;
// $this->middleware('auth');
// $this->middleware('auth');
}
/**
* home
* @return type
*/
public function home() {
public function home() {
return view('forms.home');
}
@@ -49,7 +48,7 @@ class FormController extends Controller {
* @return Response
*/
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,70 +60,64 @@ class FormController extends Controller {
}
/**
* Display the specified resource.
* @param int $id
* @return Response
*/
* Display the specified resource.
* @param int $id
* @return Response
*/
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'));
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Forms $forms) {
if(!Input::get('formname')) {
return Redirect::back()->with('fails','Please fill Form name');
public function store(Forms $forms) {
if (!Input::get('formname')) {
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->save();
$count = count(Input::get('name'));
$count = count(Input::get('name'));
$fields = array();
for($i=0; $i<=$count; $i++) {
if(!empty(Input::get('name')[$i])) {
array_push($fields, array(
'forms_id' => $forms->id,
'label' => Input::get('label')[$i],
'name' => Input::get('name')[$i],
'type' => Input::get('type')[$i],
'value' => Input::get('value')[$i],
'required'=>$require[$i],
));
}
}
for ($i = 0; $i <= $count; $i++) {
if (!empty(Input::get('name')[$i])) {
array_push($fields, array(
'forms_id' => $forms->id,
'label' => Input::get('label')[$i],
'name' => Input::get('name')[$i],
'type' => Input::get('type')[$i],
'value' => Input::get('value')[$i],
'required' => $require[$i],
));
}
}
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();
$help_topics = $help_topic->where('custom_form','=',$id)->get();
foreach($help_topics as $help_topic) {
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic) {
$fields = $field->where('forms_id', $id)->get();
$help_topics = $help_topic->where('custom_form', '=', $id)->get();
foreach ($help_topics as $help_topic) {
$help_topic->custom_form = null;
$help_topic->save();
}
foreach($fields as $field) {
foreach ($fields as $field) {
$field->delete();
}
$forms = $forms->where('id',$id)->first();
$forms = $forms->where('id', $id)->first();
$forms->delete();
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
use App\Http\Controllers\Controller;
// requests
@@ -12,6 +15,7 @@ use App\User;
// classes
use Illuminate\Support\Facades\Input;
use Exception;
/**
* GroupController
*
@@ -21,161 +25,162 @@ use Exception;
*/
class GroupController extends Controller {
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Display a listing of the resource.
* @param type Groups $group
* @param type Department $department
* @param type Group_assign_department $group_assign_department
* @return type Response
*/
public function index(Groups $group, Department $department, Group_assign_department $group_assign_department) {
try {
$groups = $group->get();
$departments = $department->lists('id');
return view('themes.default1.admin.helpdesk.agent.groups.index', compact('departments', 'group_assign_department', 'groups'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Display a listing of the resource.
* @param type Groups $group
* @param type Department $department
* @param type Group_assign_department $group_assign_department
* @return type Response
*/
public function index(Groups $group, Department $department, Group_assign_department $group_assign_department) {
try {
$groups = $group->get();
$departments = $department->lists('id');
return view('themes.default1.admin.helpdesk.agent.groups.index', compact('departments', 'group_assign_department', 'groups'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.admin.helpdesk.agent.groups.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.admin.helpdesk.agent.groups.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
* @param type Groups $group
* @param type GroupRequest $request
* @return type Response
*/
public function store(Groups $group, GroupRequest $request) {
try {
/* Check Whether function success or not */
$group->fill($request->input())->save();
return redirect('groups')->with('success', 'Group Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Store a newly created resource in storage.
* @param type Groups $group
* @param type GroupRequest $request
* @return type Response
*/
public function store(Groups $group, GroupRequest $request) {
try {
/* Check Whether function success or not */
$group->fill($request->input())->save();
return redirect('groups')->with('success', 'Group Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('groups')->with('fails', 'Groups can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type Groups $group
* @return type Response
*/
public function edit($id, Groups $group) {
try {
$groups = $group->whereId($id)->first();
return view('themes.default1.admin.helpdesk.agent.groups.edit', compact('groups'));
} catch (Exception $e) {
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type Groups $group
* @return type Response
*/
public function edit($id, Groups $group) {
try {
$groups = $group->whereId($id)->first();
return view('themes.default1.admin.helpdesk.agent.groups.edit', compact('groups'));
} catch (Exception $e) {
return redirect('groups')->with('fails', 'Groups can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Groups $group
* @param type Request $request
* @return type Response
*/
public function update($id, Groups $group, Request $request) {
$var = $group->whereId($id)->first();
//Updating Status
$status = $request->Input('group_status');
$var->group_status = $status;
//Updating can_create_ticket field
$createTicket = $request->Input('can_create_ticket');
$var->can_create_ticket = $createTicket;
//Updating can_edit_ticket field
$editTicket = $request->Input('can_edit_ticket');
$var->can_edit_ticket = $editTicket;
//Updating can_post_ticket field
$postTicket = $request->Input('can_post_ticket');
$var->can_post_ticket = $postTicket;
//Updating can_close_ticket field
$closeTicket = $request->Input('can_close_ticket');
$var->can_close_ticket = $closeTicket;
//Updating can_assign_ticket field
$assignTicket = $request->Input('can_assign_ticket');
$var->can_assign_ticket = $assignTicket;
//Updating can_trasfer_ticket field
$trasferTicket = $request->Input('can_trasfer_ticket');
$var->can_trasfer_ticket = $trasferTicket;
//Updating can_delete_ticket field
$deleteTicket = $request->Input('can_delete_ticket');
$var->can_delete_ticket = $deleteTicket;
//Updating can_ban_email field
$banEmail = $request->Input('can_ban_email');
$var->can_ban_email = $banEmail;
//Updating can_manage_canned field
$manageCanned = $request->Input('can_manage_canned');
$var->can_manage_canned = $manageCanned;
//Updating can_manage_faq field
$manageFaq = $request->Input('can_manage_faq');
$var->can_manage_faq = $manageFaq;
//Updating can_view_agent_stats field
$viewAgentStats = $request->Input('can_view_agent_stats');
$var->can_view_agent_stats = $viewAgentStats;
//Updating department_access field
$departmentAccess = $request->Input('department_access');
$var->department_access = $departmentAccess;
//Updating admin_notes field
$adminNotes = $request->Input('admin_notes');
$var->admin_notes = $adminNotes;
/* Check whether function success or not */
try {
$var->save();
/* redirect to Index page with Success Message */
return redirect('groups')->with('success', 'Group Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Groups $group
* @param type Request $request
* @return type Response
*/
public function update($id, Groups $group, Request $request) {
$var = $group->whereId($id)->first();
//Updating Status
$status = $request->Input('group_status');
$var->group_status = $status;
//Updating can_create_ticket field
$createTicket = $request->Input('can_create_ticket');
$var->can_create_ticket = $createTicket;
//Updating can_edit_ticket field
$editTicket = $request->Input('can_edit_ticket');
$var->can_edit_ticket = $editTicket;
//Updating can_post_ticket field
$postTicket = $request->Input('can_post_ticket');
$var->can_post_ticket = $postTicket;
//Updating can_close_ticket field
$closeTicket = $request->Input('can_close_ticket');
$var->can_close_ticket = $closeTicket;
//Updating can_assign_ticket field
$assignTicket = $request->Input('can_assign_ticket');
$var->can_assign_ticket = $assignTicket;
//Updating can_trasfer_ticket field
$trasferTicket = $request->Input('can_trasfer_ticket');
$var->can_trasfer_ticket = $trasferTicket;
//Updating can_delete_ticket field
$deleteTicket = $request->Input('can_delete_ticket');
$var->can_delete_ticket = $deleteTicket;
//Updating can_ban_email field
$banEmail = $request->Input('can_ban_email');
$var->can_ban_email = $banEmail;
//Updating can_manage_canned field
$manageCanned = $request->Input('can_manage_canned');
$var->can_manage_canned = $manageCanned;
//Updating can_manage_faq field
$manageFaq = $request->Input('can_manage_faq');
$var->can_manage_faq = $manageFaq;
//Updating can_view_agent_stats field
$viewAgentStats = $request->Input('can_view_agent_stats');
$var->can_view_agent_stats = $viewAgentStats;
//Updating department_access field
$departmentAccess = $request->Input('department_access');
$var->department_access = $departmentAccess;
//Updating admin_notes field
$adminNotes = $request->Input('admin_notes');
$var->admin_notes = $adminNotes;
/* Check whether function success or not */
try {
$var->save();
/* redirect to Index page with Success Message */
return redirect('groups')->with('success', 'Group Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
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
use App\Http\Controllers\Controller;
// requests
@@ -26,201 +29,202 @@ use Exception;
*/
class HelptopicController extends Controller {
/**
* Create a new controller instance.
* @return type vodi
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return type vodi
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Display a listing of the resource.
* @param type Help_topic $topic
* @return type Response
*/
public function index(Help_topic $topic) {
try {
$topics = $topic->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.index', compact('topics'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Display a listing of the resource.
* @param type Help_topic $topic
* @return type Response
*/
public function index(Help_topic $topic) {
try {
$topics = $topic->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.index', compact('topics'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @param type Priority $priority
* @param type Department $department
* @param type Help_topic $topic
* @param type Form_name $form
* @param type Agents $agent
* @param type Sla_plan $sla
* @return type Response
*/
/*
================================================
| Route to Create view file passing Model Values
| 1.Department Model
| 2.Help_topic Model
| 3.Agents Model
| 4.Sla_plan Model
| 5.Forms Model
================================================
*/
public function create(Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, User $agent, Sla_plan $sla) {
try {
$departments = $department->get();
$topics = $topic->get();
$forms = $form->get();
$agents = $agent->where('role','=','agent')->get();
$slas = $sla->get();
$priority = $priority->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @param type Priority $priority
* @param type Department $department
* @param type Help_topic $topic
* @param type Form_name $form
* @param type Agents $agent
* @param type Sla_plan $sla
* @return type Response
*/
/*
================================================
| Route to Create view file passing Model Values
| 1.Department Model
| 2.Help_topic Model
| 3.Agents Model
| 4.Sla_plan Model
| 5.Forms Model
================================================
*/
public function create(Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, User $agent, Sla_plan $sla) {
try {
$departments = $department->get();
$topics = $topic->get();
$forms = $form->get();
$agents = $agent->where('role', '=', 'agent')->get();
$slas = $sla->get();
$priority = $priority->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
* @param type Help_topic $topic
* @param type HelptopicRequest $request
* @return type Response
*/
public function store(Help_topic $topic, HelptopicRequest $request) {
try {
if($request->custom_form){
$custom_form = $request->custom_form;
} else {
$custom_form = null;
}
if($request->auto_assign){
$auto_assign = $request->auto_assign;
} else {
$auto_assign = null;
}
/* Check whether function success or not */
$topic->fill($request->except('custom_form','auto_assign'))->save();
// $topics->fill($request->except('custom_form','auto_assign'))->save();
/* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('helptopic')->with('fails', 'Helptopic can not Create'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Store a newly created resource in storage.
* @param type Help_topic $topic
* @param type HelptopicRequest $request
* @return type Response
*/
public function store(Help_topic $topic, HelptopicRequest $request) {
try {
if ($request->custom_form) {
$custom_form = $request->custom_form;
} else {
$custom_form = null;
}
if ($request->auto_assign) {
$auto_assign = $request->auto_assign;
} else {
$auto_assign = null;
}
/* Check whether function success or not */
$topic->fill($request->except('custom_form', 'auto_assign'))->save();
// $topics->fill($request->except('custom_form','auto_assign'))->save();
/* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('helptopic')->with('fails', 'Helptopic can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Show the form for editing the specified resource.
* @param type $id
* @param type Priority $priority
* @param type Department $department
* @param type Help_topic $topic
* @param type Form_name $form
* @param type Agents $agent
* @param type Sla_plan $sla
* @return type Response
*/
public function edit($id, Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, Sla_plan $sla) {
try {
$agents = User::where('role','=','agent')->get();
$departments = $department->get();
$topics = $topic->whereId($id)->first();
$forms = $form->get();
$slas = $sla->get();
$priority = $priority->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) {
return redirect('helptopic')->with('fails', '<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Show the form for editing the specified resource.
* @param type $id
* @param type Priority $priority
* @param type Department $department
* @param type Help_topic $topic
* @param type Form_name $form
* @param type Agents $agent
* @param type Sla_plan $sla
* @return type Response
*/
public function edit($id, Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, Sla_plan $sla) {
try {
$agents = User::where('role', '=', 'agent')->get();
$departments = $department->get();
$topics = $topic->whereId($id)->first();
$forms = $form->get();
$slas = $sla->get();
$priority = $priority->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) {
return redirect('helptopic')->with('fails', '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Update the specified resource in storage.
* @param type $id
* @param type Help_topic $topic
* @param type HelptopicUpdate $request
* @return type Response
*/
public function update($id, Help_topic $topic, HelptopicUpdate $request) {
// dd($request);
try {
$topics = $topic->whereId($id)->first();
if($request->custom_form){
$custom_form = $request->custom_form;
} else {
$custom_form = null;
}
if($request->auto_assign){
$auto_assign = $request->auto_assign;
} else {
$auto_assign = null;
}
/* Check whether function success or not */
$topics->fill($request->except('custom_form','auto_assign'))->save();
$topics->custom_form = $custom_form;
$topics->auto_assign = $auto_assign;
$topics->save();
/* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('helptopic')->with('fails', 'Helptopic can not Update'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Update the specified resource in storage.
* @param type $id
* @param type Help_topic $topic
* @param type HelptopicUpdate $request
* @return type Response
*/
public function update($id, Help_topic $topic, HelptopicUpdate $request) {
// dd($request);
try {
$topics = $topic->whereId($id)->first();
if ($request->custom_form) {
$custom_form = $request->custom_form;
} else {
$custom_form = null;
}
if ($request->auto_assign) {
$auto_assign = $request->auto_assign;
} else {
$auto_assign = null;
}
/* Check whether function success or not */
$topics->fill($request->except('custom_form', 'auto_assign'))->save();
$topics->custom_form = $custom_form;
$topics->auto_assign = $auto_assign;
$topics->save();
/* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('helptopic')->with('fails', 'Helptopic can not Update' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Help_topic $topic
* @return type Response
*/
public function destroy($id, Help_topic $topic, Ticket $ticket_setting) {
$ticket_settings = $ticket_setting->where('id','=','1')->first();
if($ticket_settings->help_topic == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
} else {
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Help_topic $topic
* @return type Response
*/
public function destroy($id, Help_topic $topic, Ticket $ticket_setting) {
$ticket_settings = $ticket_setting->where('id', '=', '1')->first();
if ($ticket_settings->help_topic == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
} 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 > 1){
$text_tickets = "Tickets";
} else {
$text_tickets = "Ticket";
}
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default Help Topic</li>';
} else {
$ticket = "";
}
if ($tickets > 0) {
if ($tickets > 1) {
$text_tickets = "Tickets";
} else {
$text_tickets = "Ticket";
}
$ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default Help Topic</li>';
} else {
$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 > 1){
$text_emails = "Emails";
} else {
$text_emails = "Email";
}
$email = '<li>'.$emails.' System '.$text_emails.' have been moved to default Help Topic</li>';
} else {
$email = "";
}
if ($emails > 0) {
if ($emails > 1) {
$text_emails = "Emails";
} else {
$text_emails = "Email";
}
$email = '<li>' . $emails . ' System ' . $text_emails . ' have been moved to default Help Topic</li>';
} else {
$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 {
/**
* Create a new controller instance.
* @return void
*/
public function __construct() {
$this->middleware('auth');
}
/**
* Create a new controller instance.
* @return void
*/
public function __construct() {
$this->middleware('auth');
}
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index() {
return view('themes/default1/admin/dashboard');
}
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index() {
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
use App\Http\Controllers\Controller;
// requests
@@ -43,156 +46,142 @@ class LanguageController extends Controller {
* @return type response
*/
public function switchLanguage($lang) {
//if(Cache::has('language'))
//{
// return Cache::get('language');
//} else return 'false';
// Cache::put('language',$)
$path = '../resources/lang';// Path to check available language packages
if(array_key_exists($lang, Config::get('languages')) && in_array($lang, scandir($path))) {
// dd(array_key_exists($lang, Config::get('languages')));
// app()->setLocale($lang);
//if(Cache::has('language'))
//{
// return Cache::get('language');
//} else return 'false';
// Cache::put('language',$)
$path = '../resources/lang'; // Path to check available language packages
if (array_key_exists($lang, Config::get('languages')) && in_array($lang, scandir($path))) {
// dd(array_key_exists($lang, Config::get('languages')));
// app()->setLocale($lang);
Cache::forever('language', $lang);
// dd(Cache::get('language'));
// dd()
} else {
return Redirect::back()->with('fails', Lang::get("lang.language-error"));
}
return Redirect::back();
Cache::forever('language', $lang);
// dd(Cache::get('language'));
// dd()
} else {
return Redirect::back()->with('fails', Lang::get("lang.language-error"));
}
return Redirect::back();
}
/**
*Shows language page
*@return type response
* Shows language page
* @return type response
*/
public function index(){
public function index() {
return view('themes.default1.admin.helpdesk.language.index');
}
/**
*Shows Language upload form
*@return type response
* Shows Language upload form
* @return type response
*/
public function getForm(){
public function getForm() {
return view('themes.default1.admin.helpdesk.language.create');
}
/**
*Provide language datatable to language page
*@return type
* Provide language datatable to language page
* @return type
*/
public function getLanguages()
{
public function getLanguages() {
$path = '../resources/lang';
$values = scandir($path); //Extracts names of directories present in lang directory
$values = array_slice($values, 2); // skips array element $value[0] = '.' & $value[1] = '..'
return \Datatable::collection(new Collection($values))
->addColumn('language', function($model){
return Config::get('languages.'.$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>"; } else return "<span style='color:red'>".Lang::trans("lang.inactive")."</span>";
})
->addColumn('Action', function($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>
<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 {
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>";
}
})
->searchColumns('language','id')
->make();
->addColumn('language', function($model) {
return Config::get('languages.' . $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>";
} else
return "<span style='color:red'>" . Lang::trans("lang.inactive") . "</span>";
})
->addColumn('Action', function($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>
<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 {
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>";
}
})
->searchColumns('language', 'id')
->make();
}
/**
*handle language file uploading
*@return response
* handle language file uploading
* @return response
*/
public function postForm() {
// getting all of the post data
$file = array(
'File' => Input::file('File'),
'language-name' => Input::input('language-name'),
'iso-code' => Input::input('iso-code')
);
'File' => Input::file('File'),
'language-name' => Input::input('language-name'),
'iso-code' => Input::input('iso-code')
);
// setting up rules
$rules = array(
'File' => 'required|mimes:zip|max:30000',
'language-name' => 'required',
'iso-code' => 'required|max:2'
); // and for max size
$rules = array(
'File' => 'required|mimes:zip|max:30000',
'language-name' => 'required',
'iso-code' => 'required|max:2'
); // and for max size
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
// send back to the page with the input data and errors
return Redirect::back()->withInput()->withErrors($validator);
} else {
//Checking if package already exists or not in lang folder
$path = '../resources/lang';
if (in_array(strtolower(Input::get('iso-code')), scandir($path))) {
//sending back with error message
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();
} 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
Session::flash('fails', Lang::get('lang.iso-code-error'));
return Redirect::back()->withInput();
} else {
// checking file is valid.
if (Input::file('File')->isValid()) {
$name = Input::file('File')->getClientOriginalName(); //uploaded file's original name
$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($destinationPath);
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
$directories = File::directories($extractpath);
//$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
//$success2 = File::delete($destinationPath.'/'.$name);
if($success){
if ($success) {
//sending back with error message
Session::flash('fails', Lang::get('lang.zipp-error'));
Session::flash('link2',"http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages");
return Redirect::back()->withInput();
}
Session::flash('link2', "http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages");
return Redirect::back()->withInput();
}
} else {
// sending back with success message
Session::flash('success', Lang::get("lang.upload-success"));
Session::flash('link',"change-language/".strtolower(Input::get('iso-code')));
return Redirect::route('LanguageController');
// sending back with success message
Session::flash('success', Lang::get("lang.upload-success"));
Session::flash('link', "change-language/" . strtolower(Input::get('iso-code')));
return Redirect::route('LanguageController');
}
} else {
// sending back with error message.
@@ -204,8 +193,8 @@ class LanguageController extends Controller {
}
/**
*allow user to download language template file
*@return type
* allow user to download language template file
* @return type
*/
Public function download() {
return response()->download('../public/downloads/en.zip');
@@ -216,23 +205,24 @@ class LanguageController extends Controller {
* @param type $lang
* @return type response
*/
public function deleteLanguage($lang){
if($lang !== App::getLocale()){
$deletePath = '../resources/lang/'.$lang; //define file path to delete
public function deleteLanguage($lang) {
if ($lang !== App::getLocale()) {
$deletePath = '../resources/lang/' . $lang; //define file path to delete
$success = File::deleteDirectory($deletePath); //remove extracted folder and it's subfolder from lang
if($success) {
if ($success) {
//sending back with success message
Session::flash('success', Lang::get('lang.delete-success'));
return Redirect::back();
return Redirect::back();
} else {
//sending back with error message
Session::flash('fails', Lang::get('lang.lang-doesnot-exist'));
return Redirect::back();
return Redirect::back();
}
} else {
//sending back with error message
Session::flash('fails', Lang::get('lang.active-lang-error'));
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
use App\Http\Controllers\Controller;
// requests
@@ -21,103 +24,104 @@ use Exception;
*/
class ProfileController extends Controller {
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Get profile page
* @return type Response
*/
public function getProfile() {
try {
$user = Auth::user();
if ($user) {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} else {
return redirect('404');
}
} catch (Exception $e) {
return redirect('404');
}
}
/**
* Get profile page
* @return type Response
*/
public function getProfile() {
try {
$user = Auth::user();
if ($user) {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} else {
return redirect('404');
}
} catch (Exception $e) {
return redirect('404');
}
}
/**
* Get profile Edit page
* @return type Response
*/
public function getProfileedit() {
try {
$user = Auth::user();
if ($user) {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} else {
return redirect('404');
}
} catch (Exception $e) {
return redirect('404');
}
}
/**
* Get profile Edit page
* @return type Response
*/
public function getProfileedit() {
try {
$user = Auth::user();
if ($user) {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} else {
return redirect('404');
}
} catch (Exception $e) {
return redirect('404');
}
}
/**
* Post profile page
* @param type int $id
* @param type ProfileRequest $request
* @return type Response
*/
public function postProfile($id, ProfileRequest $request) {
$user = Auth::user();
$user->gender = $request->input('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/profilepic';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/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/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('guest')->with('success', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return redirect('guest')->with('success', 'Profile Updated sucessfully');
}
}
/**
* Post profile page
* @param type int $id
* @param type ProfileRequest $request
* @return type Response
*/
public function postProfile($id, ProfileRequest $request) {
$user = Auth::user();
$user->gender = $request->input('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/profilepic';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/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/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('guest')->with('success', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
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
use App\Http\Controllers\Controller;
// requests
@@ -27,7 +30,6 @@ use App\Model\helpdesk\Utility\Time_format;
use Illuminate\Http\Request;
use Input;
use Exception;
use DB;
/**
* SettingsController
@@ -38,415 +40,428 @@ use DB;
*/
class SettingsController extends Controller {
/**
* Create a new controller instance.
* @return void
*/
public function __construct() {
// $this->smtp();
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return void
*/
public function __construct() {
// $this->smtp();
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Main Settings Page
* @return type view
*/
/**
* Main Settings Page
* @return type view
*/
public function settings() {
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'));
}
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');
}
public function RatingDelete($slug) {
DB::table('settings_ratings')->whereSlug($slug)->delete();
return redirect()->back()->with('success', 'Successfully Deleted');
}
/**
* @param int $id
* @return Response
* @param $compant instance of company table
*
* 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]);
}
}
return view('themes.default1.admin.helpdesk.setting');
}
/**
* 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>');
}
}
/**
* @param int $id
* @return Response
* @param $compant instance of company table
*
* 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]);
}
}
/**
* get the form for System setting page
* @param type System $system
* @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]);
}
}
/**
* 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>');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type System $system
* @param type SystemRequest $request
* @return type Response
*/
public function postsystem($id, System $system, SystemRequest $request) {
try {
// dd($request);
/* fetch the values of system request */
$systems = $system->whereId('1')->first();
/* fill the values to coompany table */
/* Check whether function success or not */
$systems->fill($request->input())->save();
/* redirect to Index page with Success Message */
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>');
}
}
/**
* get the form for System setting page
* @param type System $system
* @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]);
}
}
/**
* get the form for Ticket setting page
* @param type Ticket $ticket
* @param type Sla_plan $sla
* @param type Help_topic $topic
* @param type Priority $priority
* @return type Response
*/
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) {
try {
/* fetch the values of ticket from ticket table */
$tickets = $ticket->whereId('1')->first();
/* Fetch the values from SLA Plan table */
$slas = $sla->get();
/* Fetch the values from Help_topic table */
$topics = $topic->get();
/* Direct to Ticket Settings Page */
return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type System $system
* @param type SystemRequest $request
* @return type Response
*/
public function postsystem($id, System $system, SystemRequest $request) {
try {
// dd($request);
/* fetch the values of system request */
$systems = $system->whereId('1')->first();
/* fill the values to coompany table */
/* Check whether function success or not */
$systems->fill($request->input())->save();
/* redirect to Index page with Success Message */
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.
* @param type int $id
* @param type Ticket $ticket
* @param type Request $request
* @return type Response
*/
public function postticket($id, Ticket $ticket, Request $request) {
try {
/* 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 Ticket setting page
* @param type Ticket $ticket
* @param type Sla_plan $sla
* @param type Help_topic $topic
* @param type Priority $priority
* @return type Response
*/
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) {
try {
/* fetch the values of ticket from ticket table */
$tickets = $ticket->whereId('1')->first();
/* Fetch the values from SLA Plan table */
$slas = $sla->get();
/* Fetch the values from Help_topic table */
$topics = $topic->get();
/* Direct to Ticket Settings Page */
return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* 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 Ticket $ticket
* @param type Request $request
* @return type Response
*/
public function postticket($id, Ticket $ticket, Request $request) {
try {
/* 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');
$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.
* @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 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]);
}
}
/**
* 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();
/**
* 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
// return view('themes.default1.admin.helpdesk.settings.access', compact('accesses'));
// } catch (Exception $e) {
// return view('404');
// }
// }
// return view('themes.default1.admin.helpdesk.settings.access', compact('accesses'));
// } catch (Exception $e) {
// return view('404');
// }
// }
/**
* Update the specified resource in storage.
* @param type Access $access
* @param type Request $request
* @return type Response
*/
// public function postaccess(Access $access, Request $request) {
// try {
// /* fetch the values of access request */
// $accesses = $access->whereId('1')->first();
// /* fill the values to access table */
// $accesses->fill($request->except('password_reset', 'bind_agent_ip', 'reg_require', 'quick_access'))->save();
// /* insert checkbox value to DB */
// $accesses->password_reset = $request->input('password_reset');
// $accesses->bind_agent_ip = $request->input('bind_agent_ip');
// $accesses->reg_require = $request->input('reg_require');
// $accesses->quick_access = $request->input('quick_access');
// /* Check whether function success or not */
// if ($accesses->save() == true) {
// /* redirect to Index page with Success Message */
// return redirect('getaccess')->with('success', 'Access Updated Successfully');
// } else {
// /* redirect to Index page with Fails Message */
// return redirect('getaccess')->with('fails', 'Access can not Updated');
// }
// } catch (Exception $e) {
// /* redirect to Index page with Fails Message */
// return redirect('getaccess')->with('fails', 'Access can not Updated');
// }
// }
/**
* Update the specified resource in storage.
* @param type Access $access
* @param type Request $request
* @return type Response
*/
// public function postaccess(Access $access, Request $request) {
// try {
// /* fetch the values of access request */
// $accesses = $access->whereId('1')->first();
// /* fill the values to access table */
// $accesses->fill($request->except('password_reset', 'bind_agent_ip', 'reg_require', 'quick_access'))->save();
// /* insert checkbox value to DB */
// $accesses->password_reset = $request->input('password_reset');
// $accesses->bind_agent_ip = $request->input('bind_agent_ip');
// $accesses->reg_require = $request->input('reg_require');
// $accesses->quick_access = $request->input('quick_access');
// /* Check whether function success or not */
// if ($accesses->save() == true) {
// /* redirect to Index page with Success Message */
// return redirect('getaccess')->with('success', 'Access Updated Successfully');
// } else {
// /* redirect to Index page with Fails Message */
// return redirect('getaccess')->with('fails', 'Access can not Updated');
// }
// } catch (Exception $e) {
// /* redirect to Index page with Fails Message */
// return redirect('getaccess')->with('fails', 'Access can not Updated');
// }
// }
/**
* get the form for Responder setting page
* @param type Responder $responder
* @return type Response
*/
public function getresponder(Responder $responder) {
try {
/* fetch the values of responder from responder table */
$responders = $responder->whereId('1')->first();
/* Direct to Responder Settings Page */
return view('themes.default1.admin.helpdesk.settings.responder', compact('responders'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* get the form for Responder setting page
* @param type Responder $responder
* @return type Response
*/
public function getresponder(Responder $responder) {
try {
/* fetch the values of responder from responder table */
$responders = $responder->whereId('1')->first();
/* Direct to Responder Settings Page */
return view('themes.default1.admin.helpdesk.settings.responder', compact('responders'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Update the specified resource in storage.
* @param type Responder $responder
* @param type Request $request
* @return type
*/
public function postresponder(Responder $responder, Request $request) {
try {
/* fetch the values of responder request */
$responders = $responder->whereId('1')->first();
/* insert Checkbox value to DB */
$responders->new_ticket = $request->input('new_ticket');
$responders->agent_new_ticket = $request->input('agent_new_ticket');
$responders->submitter = $request->input('submitter');
$responders->participants = $request->input('participants');
$responders->overlimit = $request->input('overlimit');
/* fill the values to coompany table */
/* Check whether function success or not */
$responders->save();
/* redirect to Index page with Success Message */
return redirect('getresponder')->with('success', 'Responder Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getresponder')->with('fails', 'Responder can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Update the specified resource in storage.
* @param type Responder $responder
* @param type Request $request
* @return type
*/
public function postresponder(Responder $responder, Request $request) {
try {
/* fetch the values of responder request */
$responders = $responder->whereId('1')->first();
/* insert Checkbox value to DB */
$responders->new_ticket = $request->input('new_ticket');
$responders->agent_new_ticket = $request->input('agent_new_ticket');
$responders->submitter = $request->input('submitter');
$responders->participants = $request->input('participants');
$responders->overlimit = $request->input('overlimit');
/* fill the values to coompany table */
/* Check whether function success or not */
$responders->save();
/* redirect to Index page with Success Message */
return redirect('getresponder')->with('success', 'Responder Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getresponder')->with('fails', 'Responder can not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* get the form for Alert setting page
* @param type Alert $alert
* @return type Response
*/
public function getalert(Alert $alert) {
try {
/* fetch the values of alert from alert table */
$alerts = $alert->whereId('1')->first();
/* Direct to Alert Settings Page */
return view('themes.default1.admin.helpdesk.settings.alert', compact('alerts'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* get the form for Alert setting page
* @param type Alert $alert
* @return type Response
*/
public function getalert(Alert $alert) {
try {
/* fetch the values of alert from alert table */
$alerts = $alert->whereId('1')->first();
/* Direct to Alert Settings Page */
return view('themes.default1.admin.helpdesk.settings.alert', compact('alerts'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Update the specified resource in storage.
* @param type $id
* @param type Alert $alert
* @param type Request $request
* @return type Response
*/
public function postalert($id, Alert $alert, Request $request) {
try {
/* fetch the values of alert request */
$alerts = $alert->whereId('1')->first();
/* Insert Checkbox to DB */
$alerts->assignment_status = $request->input('assignment_status');
$alerts->ticket_status = $request->input('ticket_status');
$alerts->overdue_department_member = $request->input('overdue_department_member');
$alerts->sql_error = $request->input('sql_error');
$alerts->excessive_failure = $request->input('excessive_failure');
$alerts->overdue_status = $request->input('overdue_status');
$alerts->overdue_assigned_agent = $request->input('overdue_assigned_agent');
$alerts->overdue_department_manager = $request->input('overdue_department_manager');
$alerts->internal_status = $request->input('internal_status');
$alerts->internal_last_responder = $request->input('internal_last_responder');
$alerts->internal_assigned_agent = $request->input('internal_assigned_agent');
$alerts->internal_department_manager = $request->input('internal_department_manager');
$alerts->assignment_assigned_agent = $request->input('assignment_assigned_agent');
$alerts->assignment_team_leader = $request->input('assignment_team_leader');
$alerts->assignment_team_member = $request->input('assignment_team_member');
$alerts->system_error = $request->input('system_error');
$alerts->transfer_department_member = $request->input('transfer_department_member');
$alerts->transfer_department_manager = $request->input('transfer_department_manager');
$alerts->transfer_assigned_agent = $request->input('transfer_assigned_agent');
$alerts->transfer_status = $request->input('transfer_status');
$alerts->message_organization_accmanager = $request->input('message_organization_accmanager');
$alerts->message_department_manager = $request->input('message_department_manager');
$alerts->message_assigned_agent = $request->input('message_assigned_agent');
$alerts->message_last_responder = $request->input('message_last_responder');
$alerts->message_status = $request->input('message_status');
$alerts->ticket_organization_accmanager = $request->input('ticket_organization_accmanager');
$alerts->ticket_department_manager = $request->input('ticket_department_manager');
$alerts->ticket_department_member = $request->input('ticket_department_member');
$alerts->ticket_admin_email = $request->input('ticket_admin_email');
/**
* Update the specified resource in storage.
* @param type $id
* @param type Alert $alert
* @param type Request $request
* @return type Response
*/
public function postalert($id, Alert $alert, Request $request) {
try {
/* fetch the values of alert request */
$alerts = $alert->whereId('1')->first();
/* Insert Checkbox to DB */
$alerts->assignment_status = $request->input('assignment_status');
$alerts->ticket_status = $request->input('ticket_status');
$alerts->overdue_department_member = $request->input('overdue_department_member');
$alerts->sql_error = $request->input('sql_error');
$alerts->excessive_failure = $request->input('excessive_failure');
$alerts->overdue_status = $request->input('overdue_status');
$alerts->overdue_assigned_agent = $request->input('overdue_assigned_agent');
$alerts->overdue_department_manager = $request->input('overdue_department_manager');
$alerts->internal_status = $request->input('internal_status');
$alerts->internal_last_responder = $request->input('internal_last_responder');
$alerts->internal_assigned_agent = $request->input('internal_assigned_agent');
$alerts->internal_department_manager = $request->input('internal_department_manager');
$alerts->assignment_assigned_agent = $request->input('assignment_assigned_agent');
$alerts->assignment_team_leader = $request->input('assignment_team_leader');
$alerts->assignment_team_member = $request->input('assignment_team_member');
$alerts->system_error = $request->input('system_error');
$alerts->transfer_department_member = $request->input('transfer_department_member');
$alerts->transfer_department_manager = $request->input('transfer_department_manager');
$alerts->transfer_assigned_agent = $request->input('transfer_assigned_agent');
$alerts->transfer_status = $request->input('transfer_status');
$alerts->message_organization_accmanager = $request->input('message_organization_accmanager');
$alerts->message_department_manager = $request->input('message_department_manager');
$alerts->message_assigned_agent = $request->input('message_assigned_agent');
$alerts->message_last_responder = $request->input('message_last_responder');
$alerts->message_status = $request->input('message_status');
$alerts->ticket_organization_accmanager = $request->input('ticket_organization_accmanager');
$alerts->ticket_department_manager = $request->input('ticket_department_manager');
$alerts->ticket_department_member = $request->input('ticket_department_member');
$alerts->ticket_admin_email = $request->input('ticket_admin_email');
if($request->input('system_error') == null){
$str = '%0%';
$path = app_path('../config/app.php');
$content = \File::get($path);
$content = str_replace('%1%', $str, $content);
\File::put($path, $content);
} else {
$str = '%1%';
$path = app_path('../config/app.php');
$content = \File::get($path);
$content = str_replace('%0%', $str, $content);
\File::put($path, $content);
}
/* fill the values to coompany table */
/* Check whether function success or not */
$alerts->save();
/* redirect to Index page with Success Message */
return redirect('getalert')->with('success', 'Alert Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getalert')->with('fails', 'Alert can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
}
}
if ($request->input('system_error') == null) {
$str = '%0%';
$path = app_path('../config/app.php');
$content = \File::get($path);
$content = str_replace('%1%', $str, $content);
\File::put($path, $content);
} else {
$str = '%1%';
$path = app_path('../config/app.php');
$content = \File::get($path);
$content = str_replace('%0%', $str, $content);
\File::put($path, $content);
}
/* fill the values to coompany table */
/* Check whether function success or not */
$alerts->save();
/* redirect to Index page with Success Message */
return redirect('getalert')->with('success', 'Alert Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
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
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\SlaRequest;
use App\Http\Requests\helpdesk\SlaUpdate;
// models
use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Settings\Ticket;
//classes
use DB;
use Exception;
@@ -24,163 +23,163 @@ use Exception;
*/
class SlaController extends Controller {
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Display a listing of the resource.
* @param type Sla_plan $sla
* @return type Response
*/
public function index(Sla_plan $sla) {
try {
/* Declare a Variable $slas to store all Values From Sla_plan Table */
$slas = $sla->get();
/* Listing the values From Sla_plan Table */
return view('themes.default1.admin.helpdesk.manage.sla.index', compact('slas'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Display a listing of the resource.
* @param type Sla_plan $sla
* @return type Response
*/
public function index(Sla_plan $sla) {
try {
/* Declare a Variable $slas to store all Values From Sla_plan Table */
$slas = $sla->get();
/* Listing the values From Sla_plan Table */
return view('themes.default1.admin.helpdesk.manage.sla.index', compact('slas'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function create() {
try {
/* Direct to Create Page */
return view('themes.default1.admin.helpdesk.manage.sla.create');
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function create() {
try {
/* Direct to Create Page */
return view('themes.default1.admin.helpdesk.manage.sla.create');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Store a newly created resource in storage.
* @param type Sla_plan $sla
* @param type SlaRequest $request
* @return type Response
*/
public function store(Sla_plan $sla, SlaRequest $request) {
try {
/* Fill the request values to Sla_plan Table */
/* Check whether function success or not */
$sla->fill($request->input())->save();
/* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('sla')->with('fails', 'SLA Plan can not Create'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Store a newly created resource in storage.
* @param type Sla_plan $sla
* @param type SlaRequest $request
* @return type Response
*/
public function store(Sla_plan $sla, SlaRequest $request) {
try {
/* Fill the request values to Sla_plan Table */
/* Check whether function success or not */
$sla->fill($request->input())->save();
/* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('sla')->with('fails', 'SLA Plan can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type Sla_plan $sla
* @return type Response
*/
public function edit($id, Sla_plan $sla) {
try {
/* Direct to edit page along values of perticular field using Id */
$slas = $sla->whereId($id)->first();
$slas->get();
return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type Sla_plan $sla
* @return type Response
*/
public function edit($id, Sla_plan $sla) {
try {
/* Direct to edit page along values of perticular field using Id */
$slas = $sla->whereId($id)->first();
$slas->get();
return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Sla_plan $sla
* @param type SlaUpdate $request
* @return type Response
*/
public function update($id, Sla_plan $sla, SlaUpdate $request) {
try {
/* Fill values to selected field using Id except Check box */
$slas = $sla->whereId($id)->first();
$slas->fill($request->except('transient', 'ticket_overdue'))->save();
/* Update transient checkox field */
$slas->transient = $request->input('transient');
/* Update ticket_overdue checkox field */
$slas->ticket_overdue = $request->input('ticket_overdue');
/* Check whether function success or not */
$slas->save();
/* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('sla')->with('fails', 'SLA Plan can not Update'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Sla_plan $sla
* @param type SlaUpdate $request
* @return type Response
*/
public function update($id, Sla_plan $sla, SlaUpdate $request) {
try {
/* Fill values to selected field using Id except Check box */
$slas = $sla->whereId($id)->first();
$slas->fill($request->except('transient', 'ticket_overdue'))->save();
/* Update transient checkox field */
$slas->transient = $request->input('transient');
/* Update ticket_overdue checkox field */
$slas->ticket_overdue = $request->input('ticket_overdue');
/* Check whether function success or not */
$slas->save();
/* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('sla')->with('fails', 'SLA Plan can not Update' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Sla_plan $sla
* @return type Response
*/
public function destroy($id, Sla_plan $sla) {
$default_sla = Ticket::where('id','=','1')->first();
if($default_sla->sla == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
} else {
$tickets = DB::table('tickets')->where('sla','=',$id)->update(['sla' => $default_sla->sla]);
if($tickets > 0) {
if($tickets > 1) {
$text_tickets = "Tickets";
} else {
$text_tickets = "Ticket";
}
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default SLA</li>';
} else {
$ticket = "";
}
$dept = DB::table('department')->where('sla','=',$id)->update(['sla' => $default_sla->sla]);
if($dept > 0){
if($dept > 1){
$text_dept = "Emails";
} else {
$text_dept = "Email";
}
$dept = '<li>Associated department have been moved to default SLA</li>';
} else {
$dept = "";
}
$topic = DB::table('help_topic')->where('sla_plan','=',$id)->update(['sla_plan' => $default_sla->sla]);
if($topic > 0){
if($topic > 1){
$text_topic = "Emails";
} else {
$text_topic = "Email";
}
$topic = '<li>Associated Help Topic have been moved to default SLA</li>';
} else {
$topic = "";
}
$message = $ticket.$dept.$topic;
/* Delete a perticular field from the database by delete() using Id */
$slas = $sla->whereId($id)->first();
/* Check whether function success or not */
try{
$slas->delete();
/* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Deleted Successfully'.$message);
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('sla')->with('fails', 'SLA Plan can not Delete'.'<li>'.$e->errorInfo[2].'</li>');
}
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type Sla_plan $sla
* @return type Response
*/
public function destroy($id, Sla_plan $sla) {
$default_sla = Ticket::where('id', '=', '1')->first();
if ($default_sla->sla == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
} else {
$tickets = DB::table('tickets')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]);
if ($tickets > 0) {
if ($tickets > 1) {
$text_tickets = "Tickets";
} else {
$text_tickets = "Ticket";
}
$ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default SLA</li>';
} else {
$ticket = "";
}
$dept = DB::table('department')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]);
if ($dept > 0) {
if ($dept > 1) {
$text_dept = "Emails";
} else {
$text_dept = "Email";
}
$dept = '<li>Associated department have been moved to default SLA</li>';
} else {
$dept = "";
}
$topic = DB::table('help_topic')->where('sla_plan', '=', $id)->update(['sla_plan' => $default_sla->sla]);
if ($topic > 0) {
if ($topic > 1) {
$text_topic = "Emails";
} else {
$text_topic = "Email";
}
$topic = '<li>Associated Help Topic have been moved to default SLA</li>';
} else {
$topic = "";
}
$message = $ticket . $dept . $topic;
/* Delete a perticular field from the database by delete() using Id */
$slas = $sla->whereId($id)->first();
/* Check whether function success or not */
try {
$slas->delete();
/* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Deleted Successfully' . $message);
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
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
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\TeamRequest;
use App\Http\Requests\helpdesk\TeamUpdate;
// models
use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Agent\Teams;
use App\User;
// classes
use DB;
use Exception;
@@ -25,145 +24,146 @@ use Exception;
*/
class TeamController extends Controller {
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
/**
* get Index page
* @param type Teams $team
* @param type Assign_team_agent $assign_team_agent
* @return type Response
*/
public function index(Teams $team, Assign_team_agent $assign_team_agent) {
try {
$teams = $team->get();
/* find out the Number of Members in the Team */
$id = $teams->lists('id');
$assign_team_agent = $assign_team_agent->get();
return view('themes.default1.admin.helpdesk.agent.teams.index', compact('assign_team_agent', 'teams'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* get Index page
* @param type Teams $team
* @param type Assign_team_agent $assign_team_agent
* @return type Response
*/
public function index(Teams $team, Assign_team_agent $assign_team_agent) {
try {
$teams = $team->get();
/* find out the Number of Members in the Team */
$id = $teams->lists('id');
$assign_team_agent = $assign_team_agent->get();
return view('themes.default1.admin.helpdesk.agent.teams.index', compact('assign_team_agent', 'teams'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Show the form for creating a new resource.
* @param type User $user
* @return type Response
*/
public function create(User $user) {
try {
$user = $user->get();
return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Show the form for creating a new resource.
* @param type User $user
* @return type Response
*/
public function create(User $user) {
try {
$user = $user->get();
return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Store a newly created resource in storage.
* @param type Teams $team
* @param type TeamRequest $request
* @return type Response
*/
public function store(Teams $team, TeamRequest $request) {
if($request->team_lead){
$team_lead = $request->team_lead;
} else {
$team_lead = null;
}
$team->team_lead = $team_lead;
try {
/* Check whether function success or not */
$team->fill($request->except('team_lead'))->save();
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('teams')->with('fails', 'Teams can not Create'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Store a newly created resource in storage.
* @param type Teams $team
* @param type TeamRequest $request
* @return type Response
*/
public function store(Teams $team, TeamRequest $request) {
/**
* Show the form for editing the specified resource.
* @param type $id
* @param type User $user
* @param type Assign_team_agent $assign_team_agent
* @param type Teams $team
* @return type Response
*/
public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team) {
try {
$user = $user->whereId($id)->first();
$teams = $team->whereId($id)->first();
$agent_team = $assign_team_agent->where('team_id', $id)->get();
$agent_id = $agent_team->lists('agent_id', 'agent_id');
return view('themes.default1.admin.helpdesk.agent.teams.edit', compact('agent_id', 'user', 'teams', 'allagents'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
if ($request->team_lead) {
$team_lead = $request->team_lead;
} else {
$team_lead = null;
}
$team->team_lead = $team_lead;
try {
/* Check whether function success or not */
$team->fill($request->except('team_lead'))->save();
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('teams')->with('fails', 'Teams can not Create' . '<li>' . $e->errorInfo[2] . '</li>');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Teams $team
* @param type TeamUpdate $request
* @return type Response
*/
public function update($id, Teams $team, TeamUpdate $request) {
$teams = $team->whereId($id)->first();
//updating check box
if($request->team_lead){
$team_lead = $request->team_lead;
} else {
$team_lead = null;
}
$teams->team_lead = $team_lead;
$teams->save();
/**
* Show the form for editing the specified resource.
* @param type $id
* @param type User $user
* @param type Assign_team_agent $assign_team_agent
* @param type Teams $team
* @return type Response
*/
public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team) {
try {
$user = $user->whereId($id)->first();
$teams = $team->whereId($id)->first();
$agent_team = $assign_team_agent->where('team_id', $id)->get();
$agent_id = $agent_team->lists('agent_id', 'agent_id');
return view('themes.default1.admin.helpdesk.agent.teams.edit', compact('agent_id', 'user', 'teams', 'allagents'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
$alert = $request->input('assign_alert');
$teams->assign_alert = $alert;
$teams->save(); //saving check box
//updating whole field
/* Check whether function success or not */
try {
$teams->fill($request->except('team_lead'))->save();
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('teams')->with('fails', 'Teams can not Update'.'<li>'.$e->errorInfo[2].'</li>');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Teams $team
* @param type TeamUpdate $request
* @return type Response
*/
public function update($id, Teams $team, TeamUpdate $request) {
$teams = $team->whereId($id)->first();
//updating check box
if ($request->team_lead) {
$team_lead = $request->team_lead;
} else {
$team_lead = null;
}
$teams->team_lead = $team_lead;
$teams->save();
$alert = $request->input('assign_alert');
$teams->assign_alert = $alert;
$teams->save(); //saving check box
//updating whole field
/* Check whether function success or not */
try {
$teams->fill($request->except('team_lead'))->save();
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
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
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// requests
use App\Http\Requests\helpdesk\TemplateRequest;
use App\Http\Requests\helpdesk\TemplateUdate;
@@ -24,230 +28,260 @@ use Input;
*/
class TemplateController extends Controller {
/**
* Create a new controller instance.
* @return type void
*/
public function __construct() {
SettingsController::smtp();
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Create a new controller instance.
* @return type void
*/
public function __construct(PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
SettingsController::smtp();
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Display a listing of the resource.
* @param type Template $template
* @return type Response
*/
public function index(Template $template) {
try {
$templates = $template->get();
return view('themes.default1.admin.helpdesk.emails.template.index', compact('templates'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Display a listing of the resource.
* @param type Template $template
* @return type Response
*/
public function index(Template $template) {
try {
$templates = $template->get();
return view('themes.default1.admin.helpdesk.emails.template.index', compact('templates'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @param type Languages $language
* @param type Template $template
* @return type Response
*/
public function create(Languages $language, Template $template) {
try {
$templates = $template->get();
$languages = $language->get();
return view('themes.default1.admin.helpdesk.emails.template.create', compact('languages', 'templates'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @param type Languages $language
* @param type Template $template
* @return type Response
*/
public function create(Languages $language, Template $template) {
try {
$templates = $template->get();
$languages = $language->get();
return view('themes.default1.admin.helpdesk.emails.template.create', compact('languages', 'templates'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
* @param type Template $template
* @param type TemplateRequest $request
* @return type Response
*/
public function store(Template $template, TemplateRequest $request) {
try {
/* Check whether function success or not */
if ($template->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('template')->with('success', 'Teams Created Successfully');
} else {
/* redirect to Index page with Fails Message */
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'));
/**
* Store a newly created resource in storage.
* @param type Template $template
* @param type TemplateRequest $request
* @return type Response
*/
public function store(Template $template, TemplateRequest $request) {
try {
/* Check whether function success or not */
if ($template->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('template')->with('success', 'Teams Created Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('template')->with('fails', 'Teams can not Create');
}
else {
$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;
} 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 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
// $mydir = dirname( __FILE__ )."/html/images";
// if(!is_dir($mydir)){
// mkdir("html/images");
// }
// Move all images files
// Move all images files
if (!file_exists($filename)) {
mkdir($filename, 0777);
}
$files = array_filter(scandir($directory . 'default'));
foreach ($files as $file) {
if ($file === '.' or $file === '..')
continue;
if (!is_dir($file)) {
// $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file);
$destination = $directory . $fname . '/';
copy($directory . 'default/' . $file, $destination . $file);
}
}
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));
return \Redirect::back()->with('success', 'Successfully updated');
}
public function deletetemplate($template, $path) {
$directory = str_replace('-', '/', $path);
$dir = $directory . $template;
$status = \DB::table('settings_email')->first();
if ($template == 'default' or $template == $status->template) {
return \Redirect::back()->with('fails', 'You cannot delete a default or active directory!');
}
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
unlink($dir . "/" . $object);
}
}
rmdir($dir);
} else {
rmdir($dir);
}
return \Redirect::back()->with('success', 'Successfully Deleted');
}
public function activateset($setname) {
\DB::table('settings_email')->update(array('template' => $setname));
return \Redirect::back()->with('success', 'You have Successfully Activated this Set');
}
public function edit($id, Template $template, Languages $language) {
try {
$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');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Template $template
* @param type TemplateUdate $request
* @return type Response
*/
public function update($id, Template $template, TemplateUdate $request) {
try {
//TODO validation
$templates = $template->whereId($id)->first();
/* Check whether function success or not */
if ($templates->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
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');
}
if(!file_exists($filename)) {
mkdir($filename,0777);
}
$files = array_filter(scandir($directory.'default'));
foreach($files as $file){
if ($file === '.' or $file === '..') continue;
if(!is_dir($file)) {
// $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file);
$destination = $directory.$fname.'/';
copy($directory.'default/'.$file, $destination.$file);
}
}
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));
return \Redirect::back()->with('success', 'Successfully updated');
}
public function edit($id, Template $template, Languages $language) {
try {
$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');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type Template $template
* @param type TemplateUdate $request
* @return type Response
*/
public function update($id, Template $template, TemplateUdate $request) {
try {
//TODO validation
$templates = $template->whereId($id)->first();
/* Check whether function success or not */
if ($templates->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
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 !');
}
$mail = Mail::send('themes.default1.admin.helpdesk.emails.template.connection', array('link' => url('getmail'), 'username' => $email), function ($message) use ($email) {
$message->to($email)->subject('Checking the connection');
});
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
use App\Http\Controllers\Controller;
// models
use App\Model\helpdesk\Priority;
use App\Model\helpdesk\Ticket_thread;
// classes
use Exception;
/**
* ThreadController
*
@@ -18,22 +19,23 @@ use Exception;
*/
class ThreadController extends Controller {
/**
* get the values from ticket_thread Table and direct to view page
* @param type Ticket_thread $thread
* @param type Priority $priority
* @return type Response
*/
public function getTickets(Ticket_thread $thread, Priority $priority) {
try {
/* get the values of Ticket_thread from Ticket_thread Table */
$threads = $thread->get();
/* get the values of priority from Priority Table */
$priorities = $priority->get();
/* Direct to view page */
return view('themes.default1.admin.helpdesk.tickets.ticket', compact('threads', 'priorities'));
} catch (Exception $e) {
return view('404');
}
}
/**
* get the values from ticket_thread Table and direct to view page
* @param type Ticket_thread $thread
* @param type Priority $priority
* @return type Response
*/
public function getTickets(Ticket_thread $thread, Priority $priority) {
try {
/* get the values of Ticket_thread from Ticket_thread Table */
$threads = $thread->get();
/* get the values of priority from Priority Table */
$priorities = $priority->get();
/* Direct to view page */
return view('themes.default1.admin.helpdesk.tickets.ticket', compact('threads', 'priorities'));
} catch (Exception $e) {
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
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\CannedRequest;
use App\Http\Requests\helpdesk\CannedUpdateRequest;
// model
use App\Model\helpdesk\Agent_panel\Canned;
use App\User;
// classes
use Exception;
@@ -25,129 +24,129 @@ use Exception;
*/
class CannedController 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() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
$this->middleware('role.agent');
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
$this->middleware('role.agent');
}
/**
* Display a listing of the Canned Responses.
* @return type View
*/
public function index() {
return view('themes.default1.agent.helpdesk.canned.index');
}
/**
* Display a listing of the Canned Responses.
* @return type View
*/
public function index() {
return view('themes.default1.agent.helpdesk.canned.index');
}
/**
* Show the form for creating a new Canned Response
* @return type View
*/
public function create() {
return view('themes.default1.agent.helpdesk.canned.create');
}
/**
* Show the form for creating a new Canned Response
* @return type View
*/
public function create() {
return view('themes.default1.agent.helpdesk.canned.create');
}
/**
* Store a newly created Canned Response.
* @param type CannedRequest $request
* @param type Canned $canned
* @return type Redirect
*/
public function store(CannedRequest $request, Canned $canned) {
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
$canned->message = $request->input('message');
try {
// saving inputs
$canned->save();
return redirect()->route('canned.list')->with('success','Added Successfully');
} catch (Exception $e) {
return redirect()->route('canned.list')->with('fails',$e->errorInfo[2]);
}
}
/**
* Store a newly created Canned Response.
* @param type CannedRequest $request
* @param type Canned $canned
* @return type Redirect
*/
public function store(CannedRequest $request, Canned $canned) {
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
$canned->message = $request->input('message');
try {
// saving inputs
$canned->save();
return redirect()->route('canned.list')->with('success', 'Added Successfully');
} catch (Exception $e) {
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
}
}
/**
* Show the form for editing the Canned Response.
* @param type $id
* @param type Canned $canned
* @return type View
*/
public function edit($id, Canned $canned) {
// fetching requested canned response
$canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id','=',$id)->first();
return view('themes.default1.agent.helpdesk.canned.edit',compact('canned'));
}
/**
* Show the form for editing the Canned Response.
* @param type $id
* @param type Canned $canned
* @return type View
*/
public function edit($id, Canned $canned) {
// fetching requested canned response
$canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id', '=', $id)->first();
return view('themes.default1.agent.helpdesk.canned.edit', compact('canned'));
}
/**
* Update the Canned Response in database.
* @param type $id
* @param type CannedUpdateRequest $request
* @param type Canned $canned
* @return type Redirect
*/
public function update($id, CannedUpdateRequest $request, Canned $canned) {
/* select the field where id = $id(request Id) */
$canned = $canned->where('id','=',$id)->where('user_id', '=', \Auth::user()->id)->first();
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
$canned->message = $request->input('message');
try {
// saving inputs
$canned->save();
return redirect()->route('canned.list')->with('success','Updated Successfully');
} catch (Exception $e) {
return redirect()->route('canned.list')->with('fails',$e->errorInfo[2]);
}
}
/**
* Update the Canned Response in database.
* @param type $id
* @param type CannedUpdateRequest $request
* @param type Canned $canned
* @return type Redirect
*/
public function update($id, CannedUpdateRequest $request, Canned $canned) {
/* select the field where id = $id(request Id) */
$canned = $canned->where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
// fetching all the requested inputs
$canned->user_id = \Auth::user()->id;
$canned->title = $request->input('title');
$canned->message = $request->input('message');
try {
// saving inputs
$canned->save();
return redirect()->route('canned.list')->with('success', 'Updated Successfully');
} catch (Exception $e) {
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
}
}
/**
* Delete the Canned Response from storage.
* @param type $id
* @param type Canned $canned
* @return type Redirect
*/
public function destroy($id, Canned $canned) {
/* select the field where id = $id(request Id) */
$canned = $canned->whereId($id)->first();
/* delete the selected field */
/* Check whether function success or not */
try {
$canned->delete();
/* redirect to Index page with Success Message */
return redirect()->route('canned.list')->with('success', 'User Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
}
}
/**
* Delete the Canned Response from storage.
* @param type $id
* @param type Canned $canned
* @return type Redirect
*/
public function destroy($id, Canned $canned) {
/* select the field where id = $id(request Id) */
$canned = $canned->whereId($id)->first();
/* delete the selected field */
/* Check whether function success or not */
try {
$canned->delete();
/* redirect to Index page with Success Message */
return redirect()->route('canned.list')->with('success', 'User Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
}
}
/**
* Fetch Canned Response in the ticket detail page.
* @param type $id
* @return type json
*/
public function get_canned($id) {
// checking for the canned response with requested value
if($id != "zzz") {
// fetching canned response
$canned = Canned::where('id','=',$id)->where('user_id','=',\Auth::user()->id)->first();
$msg = $canned->message;
} else {
$msg = "";
}
// returning the canned response in JSON format
return \Response::json($msg);
}
/**
* Fetch Canned Response in the ticket detail page.
* @param type $id
* @return type json
*/
public function get_canned($id) {
// checking for the canned response with requested value
if ($id != "zzz") {
// fetching canned response
$canned = Canned::where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
$msg = $canned->message;
} else {
$msg = "";
}
// returning the canned response in JSON format
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
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;
@@ -25,81 +25,78 @@ use Exception;
*/
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() {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking for authentication
$this->middleware('auth');
$this->middleware('auth');
// checking if the role is agent
$this->middleware('role.agent');
}
$this->middleware('role.agent');
}
/**
* Get the dashboard page
* @return type view
*/
public function index() {
// if(Auth::user()->role == "user"){
// return \Redirect::route('home');
// }
/**
* Get the dashboard page
* @return type view
*/
public function index() {
// if(Auth::user()->role == "user"){
// return \Redirect::route('home');
// }
try {
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
} 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
* @return type Json
*/
public function ChartData($date111 = "",$date122 = "")
{
$date11 = strtotime($date122);
$date12 = strtotime($date111);
if($date11 && $date12){
$date2 = $date12;
$date1 = $date11;
} else {
public function ChartData($date111 = "", $date122 = "") {
$date11 = strtotime($date122);
$date12 = strtotime($date111);
if ($date11 && $date12) {
$date2 = $date12;
$date1 = $date11;
} else {
// generating current date
$date2 = strtotime(Date('Y-m-d'));
$date3 = Date('Y-m-d');
$format = 'Y-m-d';
// generating a date range of 1 month
$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,',');
$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 . ']';
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('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'),
// DB::raw('count(*) as totaltickets'))
// ->groupBy('month')
// ->orderBy('month', 'asc')
// ->get();
// return $ticketlist;
}

View File

@@ -1,8 +1,10 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController;
// models
use App\User;
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_Thread;
use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Ticket;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Utility\MailboxProtocol;
use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Ticket\Tickets;
// classes
use PhpImap\Mailbox as ImapMailbox;
use PhpImap\IncomingMail;
use PhpImap\IncomingMailAttachment;
use ForceUTF8\Encoding;
use \ForceUTF8\Encoding;
use App;
use DB;
use Crypt;
@@ -28,9 +30,7 @@ use Schedule;
use File;
use Artisan;
use Exception;
use Phpmailer\PHPMailerautoload;
//$root = realpath($_SERVER["DOCUMENT_ROOT"]);
//include_once($root.'\vendor\phpmailer\phpmailer\PHPMailerautoload.php');
/**
* MailController
*
@@ -40,211 +40,218 @@ use Phpmailer\PHPMailerautoload;
*/
class MailController extends Controller {
/**
* constructor
* Create a new controller instance.
* @param type TicketController $TicketController
*/
public function __construct(TicketController $TicketController) {
$this->TicketController = $TicketController;
}
/**
* constructor
* Create a new controller instance.
* @param type TicketController $TicketController
*/
public function __construct(TicketController $TicketController) {
$this->TicketController = $TicketController;
}
/**
* Reademails
* @return type
*/
public function readmails(Emails $emails, Email $settings_email, System $system)
{
// $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)){
$subject = $mail->subject;
} else {
$subject = "No Subject";
}
// dd($subject);
$fromname = $mail->fromName;
$fromaddress = $mail->fromAddress;
$ticket_source = Ticket_source::where('name','=','email')->first();
$source = $ticket_source->id;
$phone = "";
$priority = $get_helptopic->priority;
// Ticket_Priority::where('')
/**
* Reademails
* @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;
$assign = $get_helptopic->auto_assign;
$form_data = null;
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data);
// dd($result);
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) {
$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 ($priority == null) {
$priority = $ticket->first()->priority;
}
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();
if ($dept == null) {
$dept = $system->first()->department;
}
if ($helptopic == null) {
$helptopic = $ticket->first()->help_topic;
}
// dd($dept);
$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)) {
$subject = $mail->subject;
} else {
$subject = "No Subject";
}
// dd($subject);
$fromname = $mail->fromName;
$fromaddress = $mail->fromAddress;
$ticket_source = Ticket_source::where('name', '=', 'email')->first();
$source = $ticket_source->id;
$phone = "";
$assign = $get_helptopic->auto_assign;
$form_data = null;
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data);
// dd($result);
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) {
$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 {
$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);
}
$body = Encoding::fixUTF8($body);
$thread = Ticket_Thread::where('id','=',$thread_id)->first();
$thread->body = $this->separate_reply($body) ;
$thread->save();
}
}
}
}
}
}
}
$body = Encoding::fixUTF8($body);
$thread = Ticket_Thread::where('id', '=', $thread_id)->first();
$thread->body = $this->separate_reply($body);
$thread->save();
}
}
}
}
}
}
}
/**
* separate reply
* @param type $body
* @return type string
*/
public function separate_reply($body) {
$body2 = explode('---Reply above this line---', $body);
$body3 = $body2[0];
return $body3;
}
/**
* separate reply
* @param type $body
* @return type string
*/
public function separate_reply($body) {
$body2 = explode('---Reply above this line---', $body);
$body3 = $body2[0];
return $body3;
}
/**
* Decode Imap text
* @param type $str
* @return type string
*/
public function decode_imap_text($str) {
$result = '';
$decode_header = imap_mime_header_decode($str);
foreach ($decode_header AS $obj) {
$result .= htmlspecialchars(rtrim($obj->text, "\t"));
}
return $result;
}
/**
* Decode Imap text
* @param type $str
* @return type string
*/
public function decode_imap_text($str) {
$result = '';
$decode_header = imap_mime_header_decode($str);
foreach ($decode_header AS $obj) {
$result .= htmlspecialchars(rtrim($obj->text, "\t"));
}
return $result;
}
/**
* fetch_attachments
* @return type
*/
public function fetch_attachments(){
$uploads = Upload::all();
foreach($uploads as $attachment) {
$image = @imagecreatefromstring($attachment->file);
ob_start();
imagejpeg($image, null, 80);
$data = ob_get_contents();
ob_end_clean();
$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>';
}
}
/**
* fetch_attachments
* @return type
*/
public function fetch_attachments() {
$uploads = Upload::all();
foreach ($uploads as $attachment) {
$image = @imagecreatefromstring($attachment->file);
ob_start();
imagejpeg($image, null, 80);
$data = ob_get_contents();
ob_end_clean();
$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>';
}
}
/**
* function to load data
* @param type $id
* @return type file
*/
public function get_data($id){
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id','=',$id)->get();
foreach($attachments as $attachment)
{
header('Content-type: application/'.$attachment->type.'');
header('Content-Disposition: inline; filename='.$attachment->name.'');
header('Content-Transfer-Encoding: binary');
echo $attachment->file;
}
}
/**
* function to load data
* @param type $id
* @return type file
*/
public function get_data($id) {
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
foreach ($attachments as $attachment) {
header('Content-type: application/' . $attachment->type . '');
header('Content-Disposition: inline; filename=' . $attachment->name . '');
header('Content-Transfer-Encoding: binary');
echo $attachment->file;
}
}
}

View File

@@ -1,8 +1,9 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// Model
use App\User;
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\Utility\Log_notification;
use App\Model\helpdesk\settings\Email;
// classes
use Exception;
@@ -24,138 +24,138 @@ use Exception;
*/
class NotificationController extends Controller {
/**
* This function is for sending daily report/notification about the system
**/
public function send_notification() {
//fetching email settings
$email = Email::where('id','=','1')->first();
// checking if the daily notification is enabled or not
if($email->notification_cron == 1){
// checking if current date is equal to the last entered daily notification log
$notification = Log_notification::where('log','=','NOT-1')->orderBy('id','DESC')->first();
$date = explode(" " , $notification->created_at);
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);
}
}
}
/**
* This function is for sending daily report/notification about the system
* */
public function send_notification() {
//fetching email settings
$email = Email::where('id', '=', '1')->first();
// checking if the daily notification is enabled or not
if ($email->notification_cron == 1) {
// checking if current date is equal to the last entered daily notification log
$notification = Log_notification::where('log', '=', 'NOT-1')->orderBy('id', 'DESC')->first();
$date = explode(" ", $notification->created_at);
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);
}
}
}
/**
* Admin Notification/Report
* @param company
* @return mail
**/
public function send_notification_to_admin($company) {
// get all admin users
$users = User::where('role','=','admin')->get();
foreach ($users as $user) {
// Send notification details to admin
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\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 ');
});
}
}
/**
* Admin Notification/Report
* @param company
* @return mail
* */
public function send_notification_to_admin($company) {
// get all admin users
$users = User::where('role', '=', 'admin')->get();
foreach ($users as $user) {
// Send notification details to admin
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\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
* @return mail
**/
public function send_notification_to_manager($company) {
// get all department managers
$depts = Department::all();
foreach ($depts as $dept) {
if(isset($dept->manager)) {
$dept_name = $dept->name;
$users = User::where('id','=',$dept->manager)->get();
foreach ($users as $user) {
// Send notification details to manager of a department
$email = $user->email;
$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.');
});
}
}
}
}
/**
* Department Manager Notification/Report
* @return mail
* */
public function send_notification_to_manager($company) {
// get all department managers
$depts = Department::all();
foreach ($depts as $dept) {
if (isset($dept->manager)) {
$dept_name = $dept->name;
$users = User::where('id', '=', $dept->manager)->get();
foreach ($users as $user) {
// Send notification details to manager of a department
$email = $user->email;
$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
* @return mail
**/
public function send_notification_to_team_lead($company) {
// get all Team leads
$teams = Teams::all();
foreach ($teams as $team) {
if(isset($team->team_lead)) {
$team_name = $team->name;
$users = User::where('id','=',$team->team_lead)->get();
foreach ($users as $user) {
// 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);
});
}
}
}
}
/**
* Team Lead Notification/Report
* @return mail
* */
public function send_notification_to_team_lead($company) {
// get all Team leads
$teams = Teams::all();
foreach ($teams as $team) {
if (isset($team->team_lead)) {
$team_name = $team->name;
$users = User::where('id', '=', $team->team_lead)->get();
foreach ($users as $user) {
// 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);
});
}
}
}
}
/**
* Agent Notification/Report
* @return mail
**/
public function send_notification_to_agent($company) {
// get all agents users
$users = User::where('role','=','agent')->get();
foreach ($users as $user) {
// Send notification details to all the agents
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_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');
});
}
}
/**
* Agent Notification/Report
* @return mail
* */
public function send_notification_to_agent($company) {
// get all agents users
$users = User::where('role', '=', 'agent')->get();
foreach ($users as $user) {
// Send notification details to all the agents
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_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');
});
}
}
/**
* Fetching company name
* @return type variable
*/
public function company() {
// 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;
}
/**
* Fetching company name
* @return type variable
*/
public function company() {
// 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');
// });
// }
}
// // 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
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\OrganizationRequest;
/* include organization model */
use App\Http\Requests\helpdesk\OrganizationUpdate;
// models
/* Define OrganizationRequest to validate the create form */
use App\Model\helpdesk\Agent_panel\Organization;
@@ -27,73 +28,73 @@ use Exception;
*/
class OrganizationController 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() {
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking for authentication
$this->middleware('auth');
$this->middleware('auth');
// checking if the role is agent
$this->middleware('role.agent');
}
$this->middleware('role.agent');
}
/**
* Display a listing of the resource.
* @param type Organization $org
* @return type Response
*/
public function index() {
try {
/* get all values of table organization */
return view('themes.default1.agent.helpdesk.organization.index');
} catch (Exception $e) {
return view('404');
}
}
/**
* Display a listing of the resource.
* @param type Organization $org
* @return type Response
*/
public function index() {
try {
/* get all values of table organization */
return view('themes.default1.agent.helpdesk.organization.index');
} catch (Exception $e) {
return view('404');
}
}
/**
* This function is used to display the list of Organizations
* @return datatable
*/
public function org_list() {
// chumper datable package call to display Advance datatable
return \Datatable::collection(Organization::all())
/* searchable name */
->searchColumns('name')
/* order by name and website */
->orderColumns('name', 'website')
/* column name */
->addColumn('name', function ($model) {
// return $model->name;
if(strlen($model->name) > 20) {
$orgname = substr($model->name, 0, 25);
$orgname = substr($orgname, 0, strrpos($orgname, ' ')).' ...';
} else {
$orgname = $model->name;
}
return $orgname;
})
/* column website */
->addColumn('website', function ($model) {
$website = $model->website;
return $website;
})
/* column phone number */
->addColumn('phone', function ($model) {
$phone = $model->phone;
return $phone;
})
/* column action buttons */
->addColumn('Actions', function ($model) {
// displaying action buttons
// 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>
<div class="modal fade" id="deletearticle'.$model->id .'">
/**
* This function is used to display the list of Organizations
* @return datatable
*/
public function org_list() {
// chumper datable package call to display Advance datatable
return \Datatable::collection(Organization::all())
/* searchable name */
->searchColumns('name')
/* order by name and website */
->orderColumns('name', 'website')
/* column name */
->addColumn('name', function ($model) {
// return $model->name;
if (strlen($model->name) > 20) {
$orgname = substr($model->name, 0, 25);
$orgname = substr($orgname, 0, strrpos($orgname, ' ')) . ' ...';
} else {
$orgname = $model->name;
}
return $orgname;
})
/* column website */
->addColumn('website', function ($model) {
$website = $model->website;
return $website;
})
/* column phone number */
->addColumn('phone', function ($model) {
$phone = $model->phone;
return $phone;
})
/* column action buttons */
->addColumn('Actions', function ($model) {
// displaying action buttons
// 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>
<div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -101,154 +102,154 @@ class OrganizationController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->user_name.'
' . $model->user_name . '
</div>
<div class="modal-footer">
<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><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>';
})
->make();
}
})
->make();
}
/**
* Show the form for creating a new organization.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.organization.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new organization.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.organization.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created organization in storage.
* @param type Organization $org
* @param type OrganizationRequest $request
* @return type Redirect
*/
public function store(Organization $org, OrganizationRequest $request) {
try {
/* Insert the all input request to organization table */
/* Check whether function success or not */
if ($org->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Created Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create');
}
}
/**
* Store a newly created organization in storage.
* @param type Organization $org
* @param type OrganizationRequest $request
* @return type Redirect
*/
public function store(Organization $org, OrganizationRequest $request) {
try {
/* Insert the all input request to organization table */
/* Check whether function success or not */
if ($org->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Created Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Create');
}
}
/**
* Display the specified organization.
* @param type $id
* @param type Organization $org
* @return type view
*/
public function show($id, Organization $org) {
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* To view page */
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Display the specified organization.
* @param type $id
* @param type Organization $org
* @return type view
*/
public function show($id, Organization $org) {
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* To view page */
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Show the form for editing the specified organization.
* @param type $id
* @param type Organization $org
* @return type view
*/
public function edit($id, Organization $org) {
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* To view page */
return view('themes.default1.agent.helpdesk.organization.edit', compact('orgs'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified organization.
* @param type $id
* @param type Organization $org
* @return type view
*/
public function edit($id, Organization $org) {
try {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* To view page */
return view('themes.default1.agent.helpdesk.organization.edit', compact('orgs'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Update the specified organization in storage.
* @param type $id
* @param type Organization $org
* @param type OrganizationUpdate $request
* @return type Redirect
*/
public function update($id, Organization $org, OrganizationUpdate $request) {
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* update the organization table */
/* Check whether function success or not */
try {
if ($orgs->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Update');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]);
}
}
/**
* Update the specified organization in storage.
* @param type $id
* @param type Organization $org
* @param type OrganizationUpdate $request
* @return type Redirect
*/
public function update($id, Organization $org, OrganizationUpdate $request) {
/**
* Delete a specified organization from storage.
* @param type int $id
* @return type Redirect
*/
public function destroy($id, Organization $org, User_org $user_org) {
/* select the field by id */
$orgs = $org->whereId($id)->first();
$user_orgs = $user_org->where('org_id','=',$id)->get();
foreach ($user_orgs as $user_org) {
$user_org->delete();
}
/* Delete the field selected from the table */
/* Check whether function success or not */
try {
$orgs->delete();
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]);
}
}
/* select the field by id */
$orgs = $org->whereId($id)->first();
/* update the organization table */
/* Check whether function success or not */
try {
if ($orgs->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', 'Organization can not Update');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]);
}
}
/**
* Soring an organization head
* @param type $id
* @return type boolean
*/
public function Head_Org($id){
// get the user to make organization head
$head_user = \Input::get('user');
// get an instance of the selected organization
$org_head = Organization::where('id','=',$id)->first();
$org_head->head = $head_user;
// save the user to organization head
$org_head->save();
return 1;
}
/**
* Delete a specified organization from storage.
* @param type int $id
* @return type Redirect
*/
public function destroy($id, Organization $org, User_org $user_org) {
/* select the field by id */
$orgs = $org->whereId($id)->first();
$user_orgs = $user_org->where('org_id', '=', $id)->get();
foreach ($user_orgs as $user_org) {
$user_org->delete();
}
/* Delete the field selected from the table */
/* Check whether function success or not */
try {
$orgs->delete();
/* redirect to Index page with Success Message */
return redirect('organizations')->with('success', 'Organization Deleted Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('organizations')->with('fails', $e->errorInfo[2]);
}
}
/**
* Soring an organization head
* @param type $id
* @return type boolean
*/
public function Head_Org($id) {
// get the user to make organization head
$head_user = \Input::get('user');
// get an instance of the selected organization
$org_head = Organization::where('id', '=', $id)->first();
$org_head->head = $head_user;
// save the user to organization head
$org_head->save();
return 1;
}
}

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Agent\helpdesk;
<?php
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController;
@@ -36,64 +39,64 @@ use PDF;
*/
class Ticket2Controller extends Controller {
/**
* Create a new controller instance.
* @return type response
*/
public function __construct() {
SettingsController::smtp();
$this->middleware('auth');
}
/**
* Create a new controller instance.
* @return type response
*/
public function __construct() {
SettingsController::smtp();
$this->middleware('auth');
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptopen($id) {
$dept = Department::where('name','=',$id)->first();
if(Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.open',compact('id'));
} else {
return redirect()->back()->with('fails','Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.open',compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptopen($id) {
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptclose($id) {
$dept = Department::where('name','=',$id)->first();
if(Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.closed',compact('id'));
} else {
return redirect()->back()->with('fails','Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.closed',compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptclose($id) {
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptinprogress($id) {
$dept = Department::where('name','=',$id)->first();
if(Auth::user()->role == 'agent') {
if(Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress',compact('id'));
} else {
return redirect()->back()->with('fails','Unauthorised!');
}
} else {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress',compact('id'));
}
}
/**
* Show the Inbox ticket list page
* @return type response
*/
public function deptinprogress($id) {
$dept = Department::where('name', '=', $id)->first();
if (Auth::user()->role == 'agent') {
if (Auth::user()->dept_id == $dept->id) {
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
} else {
return redirect()->back()->with('fails', 'Unauthorised!');
}
} else {
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
use App\Http\Controllers\Controller;
// requests
/* Include Sys_user Model */
use App\Http\Requests\helpdesk\ProfilePassword;
@@ -11,12 +13,10 @@ use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\Sys_userRequest;
/* include guest_note model */
use App\Http\Requests\helpdesk\Sys_userUpdate;
// models
use App\Model\helpdesk\Agent_panel\Organization;
use App\Model\helpdesk\Agent_panel\User_org;
use App\User;
// classes
use Auth;
use Hash;
@@ -34,350 +34,350 @@ use Exception;
*/
class UserController 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() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
$this->middleware('role.agent');
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
$this->middleware('role.agent');
}
/**
* Display all list of the users.
* @param type User $user
* @return type view
*/
public function index() {
try {
/* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index');
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Display all list of the users.
* @param type User $user
* @return type view
*/
public function index() {
try {
/* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* This function is used to display the list of users using chumper datatables
* @return datatable
*/
public function user_list() {
// displaying list of users with chumper datatables
return \Datatable::collection(User::where('role','!=','admin')->where('role','!=','agent')->get())
/* searchable column username */
->searchColumns('user_name')
/* order column username and email */
->orderColumns('user_name', 'email')
/* column username */
->addColumn('user_name', function ($model) {
if(strlen($model->user_name) > 20) {
$username = substr($model->user_name, 0, 30);
$username = substr($username, 0, strrpos($username, ' ')).' ...';
} else {
$username = $model->user_name;
}
return $username;
})
/* column email */
->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})
/* column phone */
->addColumn('phone', function ($model) {
$phone = "";
if($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
}
$mobile = "";
if($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone ."&nbsp;&nbsp;&nbsp;". $mobile;
return $phone;
})
/* column account status */
->addColumn('status', function ($model) {
$status = $model->active;
if($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})
/* column ban status */
->addColumn('ban', function ($model) {
$status = $model->ban;
if($status == 1) {
$stat = '<button class="btn btn-danger btn-xs">Banned</button>';
} else {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
}
return $stat;
})
/* column last login date */
->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})
/* column actions */
->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>';
})
->make();
}
/**
* This function is used to display the list of users using chumper datatables
* @return datatable
*/
public function user_list() {
// displaying list of users with chumper datatables
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
/* searchable column username */
->searchColumns('user_name')
/* order column username and email */
->orderColumns('user_name', 'email')
/* column username */
->addColumn('user_name', function ($model) {
if (strlen($model->user_name) > 20) {
$username = substr($model->user_name, 0, 30);
$username = substr($username, 0, strrpos($username, ' ')) . ' ...';
} else {
$username = $model->user_name;
}
return $username;
})
/* column email */
->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})
/* column phone */
->addColumn('phone', function ($model) {
$phone = "";
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
}
$mobile = "";
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . "&nbsp;&nbsp;&nbsp;" . $mobile;
return $phone;
})
/* column account status */
->addColumn('status', function ($model) {
$status = $model->active;
if ($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})
/* column ban status */
->addColumn('ban', function ($model) {
$status = $model->ban;
if ($status == 1) {
$stat = '<button class="btn btn-danger btn-xs">Banned</button>';
} else {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
}
return $stat;
})
/* column last login date */
->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})
/* column actions */
->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>';
})
->make();
}
/**
* Show the form for creating a new users.
* @return type view
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Show the form for creating a new users.
* @return type view
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Store a newly created users in storage.
* @param type User $user
* @param type Sys_userRequest $request
* @return type redirect
*/
public function store(User $user, Sys_userRequest $request) {
/* insert the input request to sys_user table */
/* Check whether function success or not */
$user->email = $request->input('email');
$user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile');
$user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number');
$user->active = $request->input('active');
$user->internal_note = $request->input('internal_note');
$user->role = 'user';
try {
$user->save();
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', $e->errorInfo[2]);
}
}
/**
* Store a newly created users in storage.
* @param type User $user
* @param type Sys_userRequest $request
* @return type redirect
*/
public function store(User $user, Sys_userRequest $request) {
/* insert the input request to sys_user table */
/* Check whether function success or not */
$user->email = $request->input('email');
$user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile');
$user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number');
$user->active = $request->input('active');
$user->internal_note = $request->input('internal_note');
$user->role = 'user';
try {
$user->save();
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', $e->errorInfo[2]);
}
}
/**
* Display the specified users.
* @param type int $id
* @param type User $user
* @return type view
*/
public function show($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Display the specified users.
* @param type int $id
* @param type User $user
* @return type view
*/
public function show($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function edit($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function edit($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Update the specified user in storage.
* @param type int $id
* @param type User $user
* @param type Sys_userUpdate $request
* @return type Response
*/
public function update($id, User $user, Sys_userUpdate $request) {
/**
* Update the specified user in storage.
* @param type int $id
* @param type User $user
* @param type Sys_userUpdate $request
* @return type Response
*/
public function update($id, User $user, Sys_userUpdate $request) {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* Update the value by selected field */
/* Check whether function success or not */
try{
$users->fill($request->input())->save();
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* Update the value by selected field */
/* Check whether function success or not */
try {
$users->fill($request->input())->save();
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully');
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* get agent profile page
* @return type view
*/
public function getProfile() {
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* get agent profile page
* @return type view
*/
public function getProfile() {
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* get profile edit page
* @return type view
*/
public function getProfileedit() {
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* get profile edit page
* @return type view
*/
public function getProfileedit() {
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* post profile edit
* @param type int $id
* @param type ProfileRequest $request
* @return type Redirect
*/
public function postProfileedit(ProfileRequest $request) {
// geet authenticated user details
$user = Auth::user();
$user->gender = $request->input('gender');
$user->save();
// checking availability of agent profile ppicture
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;
}
}
// checking if the post system includes agent profile picture upload
if (Input::file('profile_pic')) {
// fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path
$destinationPath = 'lb-faveo/media/profilepic';
// adding a random value to profile picture filename
$fileName = rand(0000, 9999) . '.' . $name;
// moving the picture to a destination folder
Input::file('profile_pic')->move($destinationPath, $fileName);
// saving filename to database
$user->profile_pic = $fileName;
} else {
try{
$user->fill($request->except('profile_pic', 'gender'))->save();
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
} catch (Exception $e){
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');
}
}
/**
* post profile edit
* @param type int $id
* @param type ProfileRequest $request
* @return type Redirect
*/
public function postProfileedit(ProfileRequest $request) {
// geet authenticated user details
$user = Auth::user();
$user->gender = $request->input('gender');
$user->save();
// checking availability of agent profile ppicture
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;
}
}
// checking if the post system includes agent profile picture upload
if (Input::file('profile_pic')) {
// fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path
$destinationPath = 'lb-faveo/media/profilepic';
// adding a random value to profile picture filename
$fileName = rand(0000, 9999) . '.' . $name;
// moving the picture to a destination folder
Input::file('profile_pic')->move($destinationPath, $fileName);
// saving filename to database
$user->profile_pic = $fileName;
} else {
try {
$user->fill($request->except('profile_pic', 'gender'))->save();
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
} catch (Exception $e) {
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');
}
}
/**
* Post profile password
* @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
* @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');
}
}
/**
* Assigning an user to an organization
* @param type $id
* @return type boolean
*/
public function UserAssignOrg($id) {
$org = Input::get('org');
$user_org = new User_org;
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* Assigning an user to an organization
* @param type $id
* @return type boolean
*/
public function UserAssignOrg($id) {
$org = Input::get('org');
$user_org = new User_org;
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* creating an organization in user profile page via modal popup
* @param type $id
* @return type
*/
public function User_Create_Org($id) {
// 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();
/**
* creating an organization in user profile page via modal popup
* @param type $id
* @return type
*/
public function User_Create_Org($id) {
// 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;
}
}
}
$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
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\kb\SettingsController;
use App\Http\Controllers\Client\kb\UserController;
use App\Http\Controllers\Agent\helpdesk\TicketController;
// Requests
use App\Http\Requests\kb\ArticleRequest;
use App\Http\Requests\kb\ArticleUpdate;
// Models
use App\Model\kb\Article;
use App\Model\kb\Category;
use App\Model\kb\Relationship;
use App\Model\kb\Settings;
use App\Model\kb\Comment;
// Classes
use Auth;
use Chumper\Datatable\Table;
@@ -36,52 +35,52 @@ use Exception;
*/
class ArticleController 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() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
SettingsController::language();
}
public function test() {
//$table = $this->setDatatable();
return view('themes.default1.agent.kb.article.test');
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
SettingsController::language();
}
/**
* Fetching all the list of articles in a chumper datatable format
* @return type void
*/
public function getData() {
// returns chumper datatable
return Datatable::collection(Article::All())
/* searcable column name */
->searchColumns('name')
/* order column name and description */
->orderColumns('name', 'description')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column action */
->addColumn('Actions', function ($model) {
/* 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>
<div class="modal fade" id="deletearticle'.$model->id .'">
public function test() {
//$table = $this->setDatatable();
return view('themes.default1.agent.kb.article.test');
}
/**
* Fetching all the list of articles in a chumper datatable format
* @return type void
*/
public function getData() {
// returns chumper datatable
return Datatable::collection(Article::All())
/* searcable column name */
->searchColumns('name')
/* order column name and description */
->orderColumns('name', 'description')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column action */
->addColumn('Actions', function ($model) {
/* 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>
<div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -89,188 +88,192 @@ class ArticleController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->name.'
' . $model->name . '
</div>
<div class="modal-footer">
<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><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>';
})
->make();
}
})
->make();
}
/**
* List of Articles
* @return type view
*/
public function index() {
/* show article list */
try{
return view('themes.default1.agent.kb.article.index');
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* List of Articles
* @return type view
*/
public function index() {
/* show article list */
try {
return view('themes.default1.agent.kb.article.index');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Creating a Article
* @param type Category $category
* @return type view
*/
public function create(Category $category) {
/* get the attributes of the category */
$category = $category->lists('id', 'name');
/* get the create page */
try{
return view('themes.default1.agent.kb.article.create', compact('category'));
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Creating a Article
* @param type Category $category
* @return type view
*/
public function create(Category $category) {
/* get the attributes of the category */
$category = $category->lists('id', 'name');
/* get the create page */
try {
return view('themes.default1.agent.kb.article.create', compact('category'));
} catch (Exception $e) {
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
$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>');
}
}
/**
* 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';
/**
* 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) {
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$article->slug = $slug;
$article->publish_time = $publishTime;
$article->fill($request->except('created_at', 'slug'))->save();
// creating article category relationship
$requests = $request->input('category_id');
$id = $article->id;
$aid = $article->where('id', $slug)->first();
$id = $aid->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>');
}
}
/* 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]);
}
}
/**
* 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]);
}
}
/**
* Update an Artile by id
* @param type Integer $id
* @param type Article $article
* @param type Relationship $relation
* @param type ArticleRequest $request
* @return Response
*/
public function update($slug, Article $article, Relationship $relation, ArticleUpdate $request) {
$aid = $article->where('id', $slug)->first();
$id = $aid->id;
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
$article->slug = $slug;
/* get the attribute of relation table where id==$id */
$relation = $relation->where('article_id', $id);
$relation->delete();
/* get the request of the current articles */
$article = $article->whereId($id)->first();
$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>');
}
}
/**
* Update an Artile by id
* @param type Integer $id
* @param type Article $article
* @param type Relationship $relation
* @param type ArticleRequest $request
* @return Response
*/
public function update($slug, Article $article, Relationship $relation, ArticleUpdate $request) {
$aid = $article->where('id', $slug)->first();
$publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
/**
* Delete an Agent by id
* @param type $id
* @param type Article $article
* @return Response
*/
public function destroy($slug, Article $article, Relationship $relation, Comment $comment) {
/* delete the selected article from the table */
$article = $article->where('slug',$slug)->first(); //get the selected article via id
$id = $article->id;
$comments = $comment->where('article_id',$id)->get();
if($comments) {
foreach($comments as $comment)
$comment->delete();
$id = $aid->id;
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
$article->slug = $slug;
/* get the attribute of relation table where id==$id */
$relation = $relation->where('article_id', $id);
$relation->delete();
/* get the request of the current articles */
$article = $article->whereId($id)->first();
$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]);
}
/* update the value to the table */
try {
$article->fill($request->all())->save();
$article->slug = $slug;
$article->publish_time = $publishTime;
$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
* @param type $id
* @param type Article $article
* @return Response
*/
public function destroy($slug, Article $article, Relationship $relation, Comment $comment) {
/* delete the selected article from the table */
$article = $article->where('slug', $slug)->first(); //get the selected article via id
$id = $article->id;
$comments = $comment->where('article_id', $id)->get();
if ($comments) {
foreach ($comments as $comment)
$comment->delete();
}
// deleting relationship
$relation = $relation->where('article_id', $id)->first();
if($relation) {
$relation->delete();
}
if($article) {
if ($article->delete()) {//true:redirect to index page with success message
return Redirect::back()->with('success', 'Article Deleted Successfully');
} else { //redirect to index page with fails message
return Redirect::back()->with('fails', 'Article Not Deleted');
}
} else {
return Redirect::back()->with('fails', 'Article can Not Deleted');
}
}
$relation = $relation->where('article_id', $id)->first();
if ($relation) {
$relation->delete();
}
if ($article) {
if ($article->delete()) {//true:redirect to index page with success message
return Redirect::back()->with('success', 'Article Deleted Successfully');
} else { //redirect to index page with fails message
return Redirect::back()->with('fails', 'Article Not Deleted');
}
} else {
return Redirect::back()->with('fails', 'Article can Not Deleted');
}
}
/**
* user time zone
* fetching timezone
* @param type $utc
* @return type
*/
static function usertimezone($utc) {
$user = Auth::user();
$tz = $user->timezone;
$set = Settings::whereId('1')->first();
$format = $set->dateformat;
//$utc = date('M d Y h:i:s A');
date_default_timezone_set($tz);
$offset = date('Z', strtotime($utc));
$date = date($format, strtotime($utc) + $offset);
echo $date;
}
/**
* user time zone
* fetching timezone
* @param type $utc
* @return type
*/
static function usertimezone($utc) {
$user = Auth::user();
$tz = $user->timezone;
$set = Settings::whereId('1')->first();
$format = $set->dateformat;
//$utc = date('M d Y h:i:s A');
date_default_timezone_set($tz);
$offset = date('Z', strtotime($utc));
$date = date($format, strtotime($utc) + $offset);
echo $date;
}
}

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Controllers\Agent\kb;
<?php
namespace App\Http\Controllers\Agent\kb;
// Controllers
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\Agent\kb\SettingsController;
use App\Http\Controllers\Agent\helpdesk\TicketController;
// Requests
use App\Http\Requests\kb\CategoryRequest;
use App\Http\Requests\kb\CategoryUpdate;
// Model
use App\Model\kb\Category;
use App\Model\kb\Relationship;
// Classes
use Datatable;
use Redirect;
@@ -30,61 +29,61 @@ use Exception;
*/
class CategoryController 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() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
SettingsController::language();
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
SettingsController::language();
}
/**
* Indexing all Category
* @param type Category $category
* @return Response
*/
public function index() {
/* get the view of index of the catogorys with all attributes
of category model */
try{
return view('themes.default1.agent.kb.category.index');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* Indexing all Category
* @param type Category $category
* @return Response
*/
public function index() {
/* get the view of index of the catogorys with all attributes
of category model */
try {
return view('themes.default1.agent.kb.category.index');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* fetching category list in chumper datatables
* @return type chumper datatable
*/
public function getData() {
/* fetching chumper datatables */
return Datatable::collection(Category::All())
/* search column name */
->searchColumns('name')
/* order column name and description */
->orderColumns('name', 'description')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->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>
/**
* fetching category list in chumper datatables
* @return type chumper datatable
*/
public function getData() {
/* fetching chumper datatables */
return Datatable::collection(Category::All())
/* search column name */
->searchColumns('name')
/* order column name and description */
->orderColumns('name', 'description')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->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>
<div class="modal fade" id="deletecategory' . $model->slug . '">
<div class="modal-dialog">
<div class="modal-content">
@@ -93,7 +92,7 @@ class CategoryController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->name.'
' . $model->name . '
</div>
<div class="modal-footer">
<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>';
})
->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
* @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]);
}
}
/**
* To store the selected category
* @param type Category $category
* @param type CategoryRequest $request
* @return type Redirect
*/
public function store(Category $category, CategoryRequest $request) {
/* Get the whole request from the form and insert into table via model */
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$category->slug = $slug;
// send success message to index page
try {
$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
* @param type Category $category
* @param type CategoryRequest $request
* @return type Redirect
*/
public function store(Category $category, CategoryRequest $request) {
/* Get the whole request from the form and insert into table via model */
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$category->slug = $slug;
// send success message to index page
try{
$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>');
}
}
/**
* Show the form for editing the specified category.
* @param type $slug
* @param type Category $category
* @return type view
*/
public function edit($slug, Category $category) {
// fetch the category
$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'));
}
/**
* Show the form for editing the specified category.
* @param type $slug
* @param type Category $category
* @return type view
*/
public function edit($slug, Category $category) {
// fetch the category
$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'));
}
/**
* Update the specified Category in storage.
* @param type $slug
* @param type Category $category
* @param type CategoryUpdate $request
* @return type redirect
*/
public function update($slug, Category $category, CategoryUpdate $request) {
/**
* Update the specified Category in storage.
* @param type $slug
* @param type Category $category
* @param type CategoryUpdate $request
* @return type redirect
*/
public function update($slug, Category $category, CategoryUpdate $request) {
/* Edit the selected category via id */
$category = $category->where('id', $slug)->first();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
$category->slug = $slug;
/* update the values at the table via model according with the 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();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
// dd($slug);
$category->slug = $slug;
/* update the values at the table via model according with the 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>');
}
}
/**
* Remove the specified category from storage.
* @param type $id
* @param type Category $category
* @param type Relationship $relation
* @return type Redirect
*/
public function destroy($id, Category $category, Relationship $relation) {
/**
* Remove the specified category from storage.
* @param type $id
* @param type Category $category
* @param type Relationship $relation
* @return type Redirect
*/
public function destroy($id, Category $category, Relationship $relation) {
$relation = $relation->where('category_id', $id)->first();
if($relation != null){
return Redirect::back()->with('fails', 'Category Not Deleted');
}
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>');
}
}
}
$relation = $relation->where('category_id', $id)->first();
if ($relation != null) {
return Redirect::back()->with('fails', 'Category Not Deleted');
} 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
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\Agent\kb\SettingsController;
use App\Http\Controllers\Agent\helpdesk\TicketController;
// request
use App\Http\Requests\kb\PageRequest;
use App\Http\Requests\kb\PageUpdate;
use Illuminate\Http\Request;
// Model
use App\Model\kb\Page;
// classes
use Datatable;
use Exception;
@@ -29,61 +28,61 @@ use Exception;
*/
class PageController 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(Page $page) {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
$this->page = $page;
SettingsController::language();
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct(Page $page) {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
$this->page = $page;
SettingsController::language();
}
/**
* Display the list of pages
* @return type
*/
public function index() {
$pages = $this->page->paginate(3);
$pages->setPath('page');
try{
return view('themes.default1.agent.kb.pages.index', compact('pages'));
} catch(Exception $e) {
return redirect()->back()->with('fails',$e->errorInfo[2]);
}
}
/**
* Display the list of pages
* @return type
*/
public function index() {
$pages = $this->page->paginate(3);
$pages->setPath('page');
try {
return view('themes.default1.agent.kb.pages.index', compact('pages'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* fetching pages list in chumper datatables
* @return type
*/
public function getData() {
/* fetching chumper datatables */
return Datatable::collection(Page::All())
/* search column name */
->searchColumns('name')
/* order column name, description and created */
->orderColumns('name', 'description', 'created')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->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>
/**
* fetching pages list in chumper datatables
* @return type
*/
public function getData() {
/* fetching chumper datatables */
return Datatable::collection(Page::All())
/* search column name */
->searchColumns('name')
/* order column name, description and created */
->orderColumns('name', 'description', 'created')
/* add column name */
->addColumn('name', function ($model) {
return $model->name;
})
/* add column Created */
->addColumn('Created', function ($model) {
$t = $model->created_at;
return TicketController::usertimezone($t);
})
/* add column Actions */
/* there are action buttons and modal popup to delete a data column */
->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>
<div class="modal fade" id="deletepage' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
@@ -92,7 +91,7 @@ class PageController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->name.'
' . $model->name . '
</div>
<div class="modal-footer">
<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>';
})
->make();
}
})
->make();
}
/**
* Show the form for creating a new resource.
* @return type view
*/
public function create() {
return view('themes.default1.agent.kb.pages.create');
}
/**
* Show the form for creating a new resource.
* @return type view
*/
public function create() {
return view('themes.default1.agent.kb.pages.create');
}
/**
* To insert a value to the table Page
* @param type Request $request
* @return type
*/
public function store(PageRequest $request) {
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$this->page->slug = $slug;
try{
$this->page->fill($request->except('slug'))->save();
return redirect('page')->with('success','Page created successfully');
} catch(Exception $e) {
return redirect('page')->with('fails',$e->errorInfo[2]);
}
}
/**
* To insert a value to the table Page
* @param type Request $request
* @return type
*/
public function store(PageRequest $request) {
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$this->page->slug = $slug;
try {
$this->page->fill($request->except('slug'))->save();
return redirect('page')->with('success', 'Page created successfully');
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To edit a page
* @param type $slug
* @return type view
*/
public function edit($slug) {
try{
$page = $this->page->where('slug', $slug)->first();
return view('themes.default1.agent.kb.pages.edit', compact('page'));
} catch (Exception $e) {
return redirect('page')->with('fails',$e->errorInfo[2]);
}
}
/**
* To edit a page
* @param type $slug
* @return type view
*/
public function edit($slug) {
try {
$page = $this->page->where('slug', $slug)->first();
return view('themes.default1.agent.kb.pages.edit', compact('page'));
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To update a page
* @param type $slug
* @param type PageUpdate $request
* @return type redirect
*/
public function update($slug, PageUpdate $request) {
// get pages with respect to slug
$pages = $this->page->where('slug', $slug)->first();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$this->page->slug = $slug;
try{
$pages->fill($request->all())->save();
$pages->slug = $slug;
$pages->save();
return redirect('page')->with('success', 'Your Page Updated Successfully');
} catch(Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To update a page
* @param type $slug
* @param type PageUpdate $request
* @return type redirect
*/
public function update($slug, PageUpdate $request) {
// get pages with respect to slug
$pages = $this->page->where('slug', $slug)->first();
$sl = $request->input('slug');
$slug = str_slug($sl, "-");
$this->page->slug = $slug;
try {
$pages->fill($request->all())->save();
$pages->slug = $slug;
$pages->save();
return redirect('page')->with('success', 'Your Page Updated Successfully');
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To Delete a Page
* @param type $id
* @return type redirect
*/
public function destroy($id) {
try{
// get the page to be deleted
$page = $this->page->whereId($id)->first();
$page->delete();
return redirect('page')->with('success', 'Page Deleted Successfully');
} catch (Exception $e) {
return redirect('page')->with('fails', $e->errorInfo[2]);
}
}
/**
* To Delete a Page
* @param type $id
* @return type redirect
*/
public function destroy($id) {
try {
// get the page to be deleted
$page = $this->page->whereId($id)->first();
$page->delete();
return redirect('page')->with('success', 'Page Deleted Successfully');
} catch (Exception $e) {
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
use App\Http\Controllers\Agent\kb\ArticleController;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Controller;
// Request
use App\Http\Requests\kb\FooterRequest;
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\SocialRequest;
use Illuminate\Http\Request;
// Model
use App\Model\kb\Comment;
use App\Model\kb\Faq;
@@ -22,7 +22,6 @@ use App\Model\kb\Side2;
use App\Model\kb\Social;
use App\Model\helpdesk\Utility\Timezones;
use App\Model\helpdesk\Utility\Date_format;
// Classes
use Auth;
use Config;
@@ -42,244 +41,241 @@ use Exception;
*/
class SettingsController 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() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
$this->language();
}
/**
* Create a new controller instance.
* constructor to check
* 1. authentication
* 2. user roles
* 3. roles must be agent
* @return void
*/
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking roles
$this->middleware('roles');
$this->language();
}
/**
* to get the settings page
* @return response
* @package default
*/
public function settings(Settings $settings, Timezones $time, Date_format $date) {
/* get the setting where the id == 1 */
$settings = $settings->whereId('1')->first();
$time = $time->get();
//$date = $date->get();
return view('themes.default1.agent.kb.settings.settings', compact('date', 'settings', 'time'));
}
/**
* to get the settings page
* @return response
* @package default
*/
public function settings(Settings $settings, Timezones $time, Date_format $date) {
/* get the setting where the id == 1 */
$settings = $settings->whereId('1')->first();
$time = $time->get();
//$date = $date->get();
return view('themes.default1.agent.kb.settings.settings', compact('date', 'settings', 'time'));
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function postSettings($id, Settings $settings, SettingsRequests $request) {
try
{
/* fetch the values of company request */
$settings = $settings->whereId('1')->first();
if (Input::file('logo')) {
$name = Input::file('logo')->getClientOriginalName();
$destinationPath = 'lb-faveo/dist/image';
$fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName;
Input::file('logo')->move($destinationPath, $fileName);
$settings->logo = $fileName;
//$thDestinationPath = 'dist/th';
Image::make($destinationPath . '/' . $fileName, array(
'width' => 300,
'height' => 300,
'grayscale' => false,
))->save('lb-faveo/dist/image/' . $fileName);
}
if (Input::file('background')) {
$name = Input::file('background')->getClientOriginalName();
$destinationPath = 'lb-faveo/dist/image';
$fileName = rand(0000, 9999) . '.' . $name;
echo $fileName;
Input::file('background')->move($destinationPath, $fileName);
$settings->background = $fileName;
//$thDestinationPath = 'dist/th';
Image::make($destinationPath . '/' . $fileName, array(
'width' => 300,
'height' => 300,
'grayscale' => false,
))->save('lb-faveo/dist/image/' . $fileName);
}
/* Check whether function success or not */
if ($settings->fill($request->except('logo', 'background'))->save() == true) {
/* redirect to Index page with Success Message */
return redirect('settings')->with('success', 'Settings Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('settings')->with('fails', 'Settings can not Updated');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('settings')->with('fails', 'Settings can not Updated');
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function postSettings($id, Settings $settings, SettingsRequests $request) {
try {
/* fetch the values of company request */
$settings = $settings->whereId('1')->first();
if (Input::file('logo')) {
$name = Input::file('logo')->getClientOriginalName();
$destinationPath = 'lb-faveo/dist/image';
$fileName = rand(0000, 9999) . '.' . $name;
//echo $fileName;
Input::file('logo')->move($destinationPath, $fileName);
$settings->logo = $fileName;
//$thDestinationPath = 'dist/th';
Image::make($destinationPath . '/' . $fileName, array(
'width' => 300,
'height' => 300,
'grayscale' => false,
))->save('lb-faveo/dist/image/' . $fileName);
}
if (Input::file('background')) {
$name = Input::file('background')->getClientOriginalName();
$destinationPath = 'lb-faveo/dist/image';
$fileName = rand(0000, 9999) . '.' . $name;
echo $fileName;
Input::file('background')->move($destinationPath, $fileName);
$settings->background = $fileName;
//$thDestinationPath = 'dist/th';
Image::make($destinationPath . '/' . $fileName, array(
'width' => 300,
'height' => 300,
'grayscale' => false,
))->save('lb-faveo/dist/image/' . $fileName);
}
/* Check whether function success or not */
if ($settings->fill($request->except('logo', 'background'))->save() == true) {
/* redirect to Index page with Success Message */
return redirect('settings')->with('success', 'Settings Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('settings')->with('fails', 'Settings can not Updated');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
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
* @param type Comment $comment
* @return Response
*/
public function comment(Comment $comment) {
return view('themes.default1.agent.kb.settings.comment');
}
/**
* getdata
* @return type
*/
public function getData() {
return \Datatable::collection(Comment::All())
->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
* @return type
*/
public function getData() {
return \Datatable::collection(Comment::All())
->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();
}
/**
* Admin can publish the comment
* @param type $id
* @param type Comment $comment
* @return bool
*/
public function publish($id, Comment $comment) {
$comment = $comment->whereId($id)->first();
$comment->status = 1;
if ($comment->save()) {
return redirect('comment')->with('success', $comment->name . '-' . 'Comment Published');
} else {
return redirect('comment')->with('fails', 'Can not Process');
}
}
/**
* Admin can publish the comment
* @param type $id
* @param type Comment $comment
* @return bool
*/
public function publish($id, Comment $comment) {
$comment = $comment->whereId($id)->first();
$comment->status = 1;
if ($comment->save()) {
return redirect('comment')->with('success', $comment->name . '-' . 'Comment Published');
} else {
return redirect('comment')->with('fails', 'Can not Process');
}
}
/**
* delete the comment
* @param type $id
* @param type Comment $comment
* @return type
*/
public function delete($id, Comment $comment) {
$comment = $comment->whereId($id)->first();
if ($comment->delete()) {
return redirect('comment')->with('success', $comment->name . "'s!" . 'Comment Deleted');
} else {
return redirect('comment')->with('fails', 'Can not Process');
}
}
/**
* delete the comment
* @param type $id
* @param type Comment $comment
* @return type
*/
public function delete($id, Comment $comment) {
$comment = $comment->whereId($id)->first();
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
* @return type view
*/
public function getProfile() {
$time = Timezone::all();
$user = Auth::user();
return view('themes.default1.agent.kb.settings.profile', compact('user', 'time'));
}
/**
* get profile page
* @return type view
*/
public function getProfile() {
$time = Timezone::all();
$user = Auth::user();
return view('themes.default1.agent.kb.settings.profile', compact('user', 'time'));
}
/**
* Post profile page
* @param type ProfileRequest $request
* @return type redirect
*/
public function postProfile(ProfileRequest $request) {
$user = Auth::user();
$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
* @param type ProfileRequest $request
* @return type redirect
*/
public function postProfile(ProfileRequest $request) {
$user = Auth::user();
$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 password
* @param type $id
* @param type ProfilePassword $request
* @return type redirect
*/
public function postProfilePassword($id, ProfilePassword $request) {
$user = Auth::user();
//echo $user->password;
/**
* post profile password
* @param type $id
* @param type ProfilePassword $request
* @return type redirect
*/
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'));
$user->save();
return redirect('profile')->with('success2', 'Password Updated sucessfully');
} else {
return redirect('profile')->with('fails2', 'Old password Wrong');
}
}
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
$user->password = Hash::make($request->input('new_password'));
$user->save();
return redirect('profile')->with('success2', 'Password Updated sucessfully');
} else {
return redirect('profile')->with('fails2', 'Old password Wrong');
}
}
/**
* 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');
}
/**
* 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\User;
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\Sla_plan;
use App\Model\helpdesk\Utility\Priority;
@@ -86,7 +86,7 @@ class ApiController extends Controller {
$team = new Teams();
$this->team = $team;
$setting = new Settings();
$setting = new System();
$this->setting = $setting;
$helptopic = new Help_topic();
@@ -150,6 +150,7 @@ class ApiController extends Controller {
/**
* return ticket details
*/
//dd($response);
$result = $this->thread->where('id', $response)->first();
//$result = $this->attach($result->id,$file);
return response()->json(compact('result'));
@@ -259,7 +260,7 @@ class ApiController extends Controller {
*/
public function OpenedTickets() {
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'));
} catch (\Exception $e) {
$error = $e->getMessage();
@@ -278,7 +279,7 @@ class ApiController extends Controller {
*/
public function UnassignedTickets() {
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'));
} catch (\Exception $e) {
$error = $e->getMessage();
@@ -316,7 +317,7 @@ class ApiController extends Controller {
*/
public function GetAgents() {
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'));
} catch (Exception $e) {
$error = $e->getMessage();
@@ -505,8 +506,9 @@ class ApiController extends Controller {
}
$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);
//dd($result);
return response()->json(compact('result'));
} catch (Exception $ex) {
$error = $e->getMessage();
@@ -579,6 +581,7 @@ class ApiController extends Controller {
public function GenerateApiKey() {
try {
$set = $this->setting->where('id', '1')->first();
//dd($set);
if ($set->api_enable == 1) {
$key = str_random(32);
$set->api_key = $key;
@@ -675,6 +678,7 @@ class ApiController extends Controller {
return response()->json(compact('error'));
}
}
/**
* Getting the tickets
* @return type json
@@ -694,12 +698,11 @@ class ApiController extends Controller {
return response()->json(compact('error'));
}
}
/**
* Fetching the Inbox details
* @return type json
*/
public function Inbox() {
try {
$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'));
}
}
/**
* Create internal note
* @return type json
@@ -742,7 +746,7 @@ class ApiController extends Controller {
}
$userid = $this->request->input('userid');
$ticketid = $this->request->input('ticketid');
$body = $this->request->input('body');
$thread = $this->thread->create(['ticket_id' => $ticketid, 'user_id' => $userid, 'is_internal' => 1, 'body' => $body]);
return response()->json(compact('thread'));
@@ -753,7 +757,5 @@ class ApiController extends Controller {
return response()->json(compact('error', 'file', 'line'));
}
}
}

View File

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

View File

@@ -56,28 +56,28 @@ class TestController extends Controller {
}
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 = [
'ticket_ID' => '81',
'ticket_ID' => '13',
'ReplyContent' => 'reply for the ticket id',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg',
'attachments' => [
[
'name' => 'ladybird',
'size' => '26398',
'type' => 'png',
'file' => $file,
],
[
'name' => 'ladybird',
'size' => '26398',
'type' => 'png',
'file' => $file,
]
],
// 'attachments' => [
// [
// 'name' => 'ladybird',
// 'size' => '26398',
// 'type' => 'png',
// 'file' => $file,
// ],
// [
// 'name' => 'ladybird',
// 'size' => '26398',
// 'type' => 'png',
// 'file' => $file,
// ]
// ],
];
$data = http_build_query($data, '', '&');
@@ -90,10 +90,10 @@ class TestController extends Controller {
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 = [
'user_id' => '1',
'user_id' => 1,
'subject' => 'Api create via faveo api',
'body' => 'Test me when call api',
'helptopic' => '1',
@@ -101,24 +101,22 @@ class TestController extends Controller {
'priority' => '1',
'headers' => [0 => 'vijaycodename47@gmail.com'],
'dept' => '1',
'assignto' => '0',
'source' => 'api',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg',
/** if attachment */
'attachments' => [
[
'name' => 'ladybird',
'size' => '26398',
'type' => 'png',
'file' => $file,
],
[
'name' => 'ladybird',
'size' => '26398',
'type' => 'png',
'file' => $file,
]
],
/** if attachment */
// 'attachments' => [
// [
// 'name' => 'ladybird',
// 'size' => '26398',
// 'type' => 'png',
// 'file' => $file,
// ],
// [
// 'name' => 'ladybird',
// 'size' => '26398',
// 'type' => 'png',
// 'file' => $file,
// ]
// ],
];
$data = http_build_query($data, '', '&');
@@ -162,7 +160,7 @@ class TestController extends Controller {
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();
$respose = $_this->CallGetApi($url);
return $respose;
@@ -170,12 +168,12 @@ class TestController extends Controller {
public function EditTicket() {
$data = [
'ticket_id' => '81',
'ticket_id' => '13',
'subject' => 'Api editing ticket via faveo api',
'sla_plan' => '2',
'help_topic' => '2',
'ticket_source' => '2',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg',
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
'ticket_priority' => '2',
];
@@ -188,8 +186,8 @@ class TestController extends Controller {
public function DeleteTicket() {
$data = [
'ticket_id' => [],
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
'ticket_id' => [11],
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
];
$data = http_build_query($data, '', '&');
@@ -200,35 +198,35 @@ class TestController extends Controller {
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
@@ -236,9 +234,9 @@ class TestController extends Controller {
public function AssignTicket() {
$data = [
'ticket_id' => '8',
'user' => 'vijay.sebastian@ladybird.com',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
'ticket_id' => 1,
'user' => 'vijay.sebastian@ladybirdweb.com',
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
];
$data = http_build_query($data, '', '&');
$url = $this->server . "helpdesk/assign?token=" . \Config::get('app.token');
@@ -250,7 +248,7 @@ class TestController extends Controller {
public function GetCustomers() {
$search = [
'search' => 'vij',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
];
$data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/customers?token=" . \Config::get('app.token');
@@ -263,7 +261,7 @@ class TestController extends Controller {
public function GetCustomer() {
$search = [
'user_id' => '1',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
];
$data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/customer?token=" . \Config::get('app.token');
@@ -276,7 +274,7 @@ class TestController extends Controller {
public function GetSearch() {
$search = [
'search' => 'api',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
];
$data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/ticket-search?token=" . \Config::get('app.token');
@@ -288,8 +286,8 @@ class TestController extends Controller {
public function TicketThreads() {
$search = [
'id' => '8',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
'id' => '1',
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
];
$data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/ticket-thread?token=" . \Config::get('app.token');
@@ -301,8 +299,8 @@ class TestController extends Controller {
public function Url() {
$search = [
'url' => 'http://localhost/FaveoHELPDESK+KBLatests',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
'url' => 'http://localhost/Faveo-HelpDesk-My-Branch/public/',
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
];
$data = http_build_query($search, '', '&');
$url = $this->server . "helpdesk/url?token=" . \Config::get('app.token');
@@ -313,21 +311,21 @@ class TestController extends Controller {
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
@@ -341,32 +339,32 @@ class TestController extends Controller {
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
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();
$respose = $_this->CallGetApi($url);
return $respose;
}
public function InternalNote() {
$data = [
'ticketid' => '23',
'userid' => 1,
'body' => 'Testing the api internal note',
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
];
$data = http_build_query($data, '', '&');
$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\Settings\System;
use App\Model\helpdesk\Settings\Alert;
use Hash;
/**
* -----------------------------------------------------------------------------
@@ -31,7 +32,6 @@ use App\Model\helpdesk\Settings\Alert;
*
*
*/
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 = '') {
try {
$max_number = Tickets::whereRaw('id = (select max(`id`) from tickets)')->first();
//dd($max_number);
if ($max_number == null) {
$ticket_number = "AAAA-9999-9999999";
} else {
@@ -56,6 +57,7 @@ class TicketController extends Controller {
}
$ticket = new Tickets;
$ticket->ticket_number = $this->ticket_number($ticket_number);
//dd($this->ticket_number($ticket_number));
$ticket->user_id = $user_id;
$ticket->dept_id = $dept;
$ticket->help_topic_id = $helptopic;
@@ -65,6 +67,7 @@ class TicketController extends Controller {
$ticket->priority_id = $priority;
$ticket->source = $source;
$ticket->save();
//dd($ticket);
$ticket_number = $ticket->ticket_number;
$id = $ticket->id;
if ($form_data != null) {
@@ -93,6 +96,7 @@ class TicketController extends Controller {
}
return $thread;
} catch (\Exception $e) {
dd($e);
return $e->getMessage();
}
}
@@ -170,6 +174,7 @@ class TicketController extends Controller {
*/
public function ticket_number($ticket_number) {
try {
//dd($ticket_number);
$number = $ticket_number;
$number = explode('-', $number);
$number1 = $number[0];
@@ -193,6 +198,7 @@ class TicketController extends Controller {
$number = implode('-', $array);
return $number;
} catch (\Exception $e) {
dd($e);
return $e->getMessage();
}
}
@@ -373,15 +379,24 @@ class TicketController extends Controller {
public function assign($id) {
try {
$UserEmail = Input::get('user');
//dd($id);
//dd($UserEmail);
// $UserEmail = 'sujitprasad12@yahoo.in';
$user = User::where('email', '=', $UserEmail)->first();
if (!$user) {
return ['error' => 'No agent not found'];
}
$user_id = $user->id;
$ticket = Tickets::where('id', '=', $id)->first();
if (!$ticket) {
return ['error' => 'No ticket not found'];
}
$ticket_number = $ticket->ticket_number;
$ticket->assigned_to = $user_id;
$ticket->save();
$ticket_thread = Ticket_Thread::where('ticket_id', '=', $id)->first();
if (!$ticket_thread) {
return ['error' => 'No thread not found'];
}
$ticket_subject = $ticket_thread->title;
$thread = New Ticket_Thread;
$thread->ticket_id = $ticket->id;
@@ -497,6 +512,7 @@ class TicketController extends Controller {
return $e->getMessage();
}
}
/**
* Create Attachment
* @param type $thread

View File

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

View File

@@ -1,14 +1,15 @@
<?php namespace App\Http\Controllers\Auth;
<?php
namespace App\Http\Controllers\Auth;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// requests
use App\Http\Requests\helpdesk\LoginRequest;
use App\Http\Requests\helpdesk\RegisterRequest;
use App\User;
// classes
use Hash;
use Illuminate\Contracts\Auth\Guard;
@@ -18,7 +19,6 @@ use Mail;
use Auth;
use Exception;
/**
* ---------------------------------------------------
* AuthController
@@ -33,131 +33,137 @@ use Exception;
*/
class AuthController extends Controller {
use AuthenticatesAndRegistersUsers;
/* 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';
use AuthenticatesAndRegistersUsers;
/* to redirect after login */
/**
* Create a new authentication controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\Registrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar) {
SettingsController::smtp();
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
// if auth is agent
protected $redirectTo = '/dashboard';
// if auth is user
protected $redirectToUser = '/profile';
/* Direct After Logout */
protected $redirectAfterLogout = '/';
protected $loginPath = '/auth/login';
/**
* Get the form for registration
* @return type Response
*/
public function getRegister() {
// Event for login
\Event::fire(new \App\Events\FormRegisterEvent());
if(Auth::user()) {
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');
}
}
/**
* Create a new authentication controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\Registrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar, PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
SettingsController::smtp();
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
/**
* Post registration form
* @param type User $user
* @param type RegisterRequest $request
* @return type Response
*/
public function postRegister(User $user, RegisterRequest $request) {
// Event for login
\Event::fire(new \App\Events\LoginEvent($request));
/**
* Get the form for registration
* @return type Response
*/
public function getRegister() {
// Event for login
\Event::fire(new \App\Events\FormRegisterEvent());
if (Auth::user()) {
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;
$name = $request->input('full_name');
$user->user_name = $name;
$user->email = $request->input('email');
// $user->first_name = $request->input('first_name');
// $user->last_nmae = $request->input('last_nmae');
// $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');
});
return redirect('home')->with('success', 'Activate Your Account ! Click on Link that send to your mail');
}
/**
* 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');
}
}
/**
* Post registration form
* @param type User $user
* @param type RegisterRequest $request
* @return type Response
*/
public function postRegister(User $user, RegisterRequest $request) {
// Event for login
\Event::fire(new \App\Events\LoginEvent($request));
/**
* 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');
}
}
$password = Hash::make($request->input('password'));
$user->password = $password;
$name = $request->input('full_name');
$user->user_name = $name;
$user->email = $request->input('email');
// $user->first_name = $request->input('first_name');
// $user->last_nmae = $request->input('last_nmae');
// $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');
// });
/**
* Post of login page
* @param type LoginRequest $request
* @return type Response
*/
public function postLogin(LoginRequest $request) {
$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)]);
return redirect('home')->with('success', 'Activate Your Account ! Click on Link that send to your mail');
}
/**
* 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');
}
}
/**
* 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
$loginAttempts = 1;
$usernameinput = $request->input('email');
$password = $request->input('password');
$password = $request->input('password');
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
// If session has login attempts, retrieve attempts counter and attempts time
if (\Session::has('loginAttempts')) {
$loginAttempts = \Session::get('loginAttempts');
$loginAttemptTime = \Session::get('loginAttemptTime');
// $credentials = $request->only('email', 'password');
$usernameinput = $request->input('email');
$password = $request->input('password');
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
$usernameinput = $request->input('email');
$password = $request->input('password');
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
// If attempts > 3 and time < 10 minutes
if ($loginAttempts > 4 && (time() - $loginAttemptTime <= 600)) {
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
\Session::put('loginAttempts', $loginAttempts + 1);
if ($this->auth->attempt([$field => $usernameinput, 'password' => $password], $request->has('remember'))) {
if(Auth::user()->role == 'user') {
return \Redirect::route('/');
} else {
return redirect()->intended($this->redirectPath());
}
}
return redirect($this->loginPath())
->withInput($request->only('email', 'remember'))
->withErrors([
'email' => $this->getFailedLoginMessage(),
'password' => $this->getFailedLoginMessage(),
]);
if (Auth::user()->role == 'user') {
return \Redirect::route('/');
} else {
return redirect()->intended($this->redirectPath());
}
}
return redirect($this->loginPath())
->withInput($request->only('email', 'remember'))
->withErrors([
'email' => $this->getFailedLoginMessage(),
'password' => $this->getFailedLoginMessage(),
]);
// Increment login attempts
}
}
/**
* Get Failed login message
* @return type string
*/
protected function getFailedLoginMessage() {
return 'This Field do not match our records.';
}
/**
* Get Failed login message
* @return type string
*/
protected function getFailedLoginMessage() {
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
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// request
use Illuminate\Http\Request;
// model
use App\User;
// classes
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\PasswordBroker;
@@ -25,31 +26,61 @@ use Exception;
*/
class PasswordController extends Controller {
use ResetsPasswords;
use ResetsPasswords;
/**
* Create a new password controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
* @return void
*/
public function __construct(Guard $auth, PasswordBroker $passwords) {
$this->auth = $auth;
$this->passwords = $passwords;
$this->middleware('guest');
SettingsController::smtp();
}
/**
* Create a new password controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
* @return void
*/
public function __construct(Guard $auth, PasswordBroker $passwords, PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
$this->auth = $auth;
$this->passwords = $passwords;
$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.
*
* @return Response
*/
public function getEmail() {
return view('auth.password');
}
/**
* Display the form to request a password reset link.
*
* @return Response
*/
public function postEmail(Request $request) {
$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
use App\Http\Controllers\Controller;
// requests
@@ -37,81 +40,81 @@ use Redirect;
*/
class UserController 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');
// $this->middleware('roles');
}
/**
* 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');
// $this->middleware('roles');
}
/**
* Display a listing of the resource.
* @param type User $user
* @return type Response
*/
public function index() {
try {
/* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index');
} catch (Exception $e) {
return view('404');
}
}
/**
* Display a listing of the resource.
* @param type User $user
* @return type Response
*/
public function index() {
try {
/* get all values in Sys_user */
return view('themes.default1.agent.helpdesk.user.index');
} catch (Exception $e) {
return view('404');
}
}
/**
* This function is used to display the list of users
* @return datatable
*/
public function user_list() {
return \Datatable::collection(User::where('role','!=','admin')->where('role','!=','agent')->get())
->searchColumns('user_name')
->orderColumns('user_name', 'email')
->addColumn('user_name', function ($model) {
return $model->user_name;
})
->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})
->addColumn('phone', function ($model) {
$phone = "";
if($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
}
$mobile = "";
if($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone ."&nbsp;&nbsp;&nbsp;". $mobile;
return $phone;
})
->addColumn('status', function ($model) {
$status = $model->active;
if($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})
->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})
->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 '<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>
<div class="modal fade" id="deletearticle'.$model->id .'">
/**
* This function is used to display the list of users
* @return datatable
*/
public function user_list() {
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
->searchColumns('user_name')
->orderColumns('user_name', 'email')
->addColumn('user_name', function ($model) {
return $model->user_name;
})
->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})
->addColumn('phone', function ($model) {
$phone = "";
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
}
$mobile = "";
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . "&nbsp;&nbsp;&nbsp;" . $mobile;
return $phone;
})
->addColumn('status', function ($model) {
$status = $model->active;
if ($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})
->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})
->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 '<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>
<div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -119,270 +122,271 @@ class UserController extends Controller {
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
'.$model->user_name.'
' . $model->user_name . '
</div>
<div class="modal-footer">
<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><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>';
})
->make();
}
})
->make();
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for creating a new resource.
* @return type Response
*/
public function create() {
try {
return view('themes.default1.agent.helpdesk.user.create');
} catch (Exception $e) {
return view('404');
}
}
/**
* Store a newly created resource in storage.
* @param type User $user
* @param type Sys_userRequest $request
* @return type Response
*/
public function store(User $user, Sys_userRequest $request) {
try {
/* insert the input request to sys_user table */
/* Check whether function success or not */
$user->email = $request->input('email');
$user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile');
$user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number');
$user->active = $request->input('active');
$user->internal_note = $request->input('internal_note');
$user->role = 'user';
if ($user->save() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Create');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Create');
}
}
/**
* Store a newly created resource in storage.
* @param type User $user
* @param type Sys_userRequest $request
* @return type Response
*/
public function store(User $user, Sys_userRequest $request) {
try {
/* insert the input request to sys_user table */
/* Check whether function success or not */
$user->email = $request->input('email');
$user->user_name = $request->input('full_name');
$user->mobile = $request->input('mobile');
$user->ext = $request->input('ext');
$user->phone_number = $request->input('phone_number');
$user->active = $request->input('active');
$user->internal_note = $request->input('internal_note');
$user->role = 'user';
if ($user->save() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Created Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Create');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Create');
}
}
/**
* Display the specified resource.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function show($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Display the specified resource.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function show($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function edit($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Show the form for editing the specified resource.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function edit($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
} catch (Exception $e) {
return view('404');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type User $user
* @param type Sys_userUpdate $request
* @return type Response
*/
public function update($id, User $user, Sys_userUpdate $request) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* Update the value by selected field */
/* Check whether function success or not */
if ($users->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Update');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Update');
}
}
/**
* Update the specified resource in storage.
* @param type int $id
* @param type User $user
* @param type Sys_userUpdate $request
* @return type Response
*/
public function update($id, User $user, Sys_userUpdate $request) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* Update the value by selected field */
/* Check whether function success or not */
if ($users->fill($request->input())->save() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Updated Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Update');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Update');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function destroy($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* delete the selected field */
/* Check whether function success or not */
if ($users->delete() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Deleted Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Delete');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Delete');
}
}
/**
* Remove the specified resource from storage.
* @param type int $id
* @param type User $user
* @return type Response
*/
public function destroy($id, User $user) {
try {
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
/* delete the selected field */
/* Check whether function success or not */
if ($users->delete() == true) {
/* redirect to Index page with Success Message */
return redirect('user')->with('success', 'User Deleted Successfully');
} else {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Delete');
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('user')->with('fails', 'User can not Delete');
}
}
/**
* get profile page
* @return type Response
*/
public function getProfile() {
$user = Auth::user();
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
}
/**
* get profile page
* @return type Response
*/
public function getProfile() {
$user = Auth::user();
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
}
/**
* get profile edit page
* @return type Response
*/
public function getProfileedit() {
$user = Auth::user();
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
}
/**
* get profile edit page
* @return type Response
*/
public function getProfileedit() {
$user = Auth::user();
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
}
/**
* post profile page
* @param type int $id
* @param type ProfileRequest $request
* @return type Response
*/
public function postProfileedit(ProfileRequest $request) {
$user = Auth::user();
$user->gender = $request->input('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/profilepic';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/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/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::route('profile')->with('success', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
}
}
/**
* post profile page
* @param type int $id
* @param type ProfileRequest $request
* @return type Response
*/
public function postProfileedit(ProfileRequest $request) {
$user = Auth::user();
$user->gender = $request->input('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/profilepic';
$user->profile_pic = $name;
} elseif ($request->input('gender') == 0) {
$name = 'avatar2.png';
$destinationPath = 'lb-faveo/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/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::route('profile')->with('success', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
}
}
/**
* Post profile password
* @param type int $id
* @param type ProfilePassword $request
* @return type Response
*/
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'));
$user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} else {
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
}
}
/**
* Post profile password
* @param type int $id
* @param type ProfilePassword $request
* @return type Response
*/
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'));
$user->save();
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
} else {
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
}
}
/**
* User Assign Org
* @param type $id
* @return type boolean
*/
public function UserAssignOrg($id) {
$org = Input::get('org');
$user_org = new User_org;
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* User Assign Org
* @param type $id
* @return type boolean
*/
public function UserAssignOrg($id) {
$org = Input::get('org');
$user_org = new User_org;
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
}
/**
* user create organisation
* @return type value
*/
public function User_Create_Org($id) {
/**
* user create organisation
* @return type value
*/
public function User_Create_Org($id) {
if(Input::get('website')!=null) {
// checking website
$check = Organization::where('website','=',Input::get('website'))->first();
} else {
$check = null;
}
if (Input::get('website') != null) {
// checking website
$check = Organization::where('website', '=', Input::get('website'))->first();
} else {
$check = null;
}
// checking name
$check2 = Organization::where('name','=',Input::get('name'))->first();
// checking name
$check2 = Organization::where('name', '=', Input::get('name'))->first();
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 {
$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();
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 {
$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();
$user_org = new User_org;
$user_org->org_id = $org->id;
$user_org->user_id = $id;
$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
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Common\SettingsController;
// requests
use Illuminate\Http\Request;
use App\Http\Requests\helpdesk\CreateTicketRequest;
use App\Http\Requests\helpdesk\TicketRequest;
use App\Http\Requests\helpdesk\TicketEditRequest;
// models
use App\Model\helpdesk\Email\Banlist;
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\Agent\Department;
use App\User;
// classes
use Auth;
use Hash;
@@ -42,55 +41,54 @@ use Exception;
*/
class ClientTicketController extends Controller {
/**
* Create a new controller instance.
* @return type response
*/
public function __construct() {
SettingsController::smtp();
// $this->middleware('auth');
// $this->middleware('role.user');
}
/**
* Create a new controller instance.
* @return type response
*/
public function __construct() {
SettingsController::smtp();
// $this->middleware('auth');
// $this->middleware('role.user');
}
/**
* Get Checked ticket
* @param type Tickets $ticket
* @param type User $user
* @return type response
*/
public function getCheckTicket(Tickets $ticket, User $user) {
return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket'));
}
/**
* Get Checked ticket
* @param type Tickets $ticket
* @param type User $user
* @return type response
*/
public function getCheckTicket(Tickets $ticket, User $user) {
return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket'));
}
/**
* reply
* @param type $value
* @return type view
*/
public function reply($id, Request $request) {
$comment = $request->input('comment');
if($comment != null) {
$tickets = Tickets::where('id','=',$id)->first();
$tickets->closed_at = null;
$tickets->closed = 0;
$tickets->reopened_at = date('Y-m-d H:i:s');
$tickets->reopened = 1;
$threads = new Ticket_Thread;
$threads->user_id = Auth::user()->id;
$threads->ticket_id = $tickets->id;
$threads->poster = "client";
$threads->body = $comment;
try {
$threads->save();
$tickets->save();
return \Redirect::back()->with('success1','Successfully replied');
} catch(Exception $e) {
return \Redirect::back()->with('fails1',$e->errorInfo[2]);
}
} else {
return \Redirect::back()->with('fails1','Please fill some data!');
}
}
/**
* reply
* @param type $value
* @return type view
*/
public function reply($id, Request $request) {
$comment = $request->input('comment');
if ($comment != null) {
$tickets = Tickets::where('id', '=', $id)->first();
$tickets->closed_at = null;
$tickets->closed = 0;
$tickets->reopened_at = date('Y-m-d H:i:s');
$tickets->reopened = 1;
$threads = new Ticket_Thread;
$threads->user_id = Auth::user()->id;
$threads->ticket_id = $tickets->id;
$threads->poster = "client";
$threads->body = $comment;
try {
$threads->save();
$tickets->save();
return \Redirect::back()->with('success1', 'Successfully replied');
} catch (Exception $e) {
return \Redirect::back()->with('fails1', $e->errorInfo[2]);
}
} else {
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
use App\Http\Controllers\Controller;
// models
use App\Model\helpdesk\Email\Emails;
// classes
use Exception;
@@ -17,28 +17,26 @@ use Exception;
* @author Ladybird <info@ladybirdweb.com>
*/
class OuthouseController extends Controller {
/**
/**
* post port
*
* @return string
*/
public static function port()
{
$port = Emails::where('id','=','1')->first();
$portvalue = $port->option_value;
public static function port() {
$port = Emails::where('id', '=', '1')->first();
$portvalue = $port->option_value;
return $portvalue;
}
/**
* post host
*
* @return string
*/
public static function host()
{
$host=Option::where('option_name','=','host')->first();
$hostvalue=$host->option_value;
public static function host() {
$host = Option::where('option_name', '=', 'host')->first();
$hostvalue = $host->option_value;
return $hostvalue;
}
@@ -47,10 +45,9 @@ class OuthouseController extends Controller {
*
* @return string
*/
public static function username()
{
$username=Option::where('option_name','=','username')->first();
$uservalue=$username->option_value;
public static function username() {
$username = Option::where('option_name', '=', 'username')->first();
$uservalue = $username->option_value;
return $uservalue;
}
@@ -60,10 +57,9 @@ class OuthouseController extends Controller {
*
* @return string
*/
public static function password()
{
$password=Option::where('option_name','=','password')->first();
$passvalue=$password->option_value;
public static function password() {
$password = Option::where('option_name', '=', 'password')->first();
$passvalue = $password->option_value;
return $passvalue;
}
@@ -73,10 +69,9 @@ class OuthouseController extends Controller {
*
* @return string
*/
public static function encryption()
{
$encryption=Option::where('option_name','=','encryption')->first();
$encryptvalue=$encryption->option_value;
public static function encryption() {
$encryption = Option::where('option_name', '=', 'encryption')->first();
$encryptvalue = $encryption->option_value;
return $encryptvalue;
}

View File

@@ -1,14 +1,14 @@
<?php namespace App\Http\Controllers\Client\helpdesk;
<?php
namespace App\Http\Controllers\Client\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Agent\helpdesk\TicketController;
use App\Http\Controllers\Common\SettingsController;
// requests
use Illuminate\Http\Request;
use App\Http\Requests\helpdesk\ClientRequest;
// models
use App\Model\helpdesk\Form\Forms;
use App\Model\helpdesk\Manage\Help_topic;
@@ -22,7 +22,6 @@ use App\Model\helpdesk\Ticket\Ticket_source;
use App\User;
use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Form\Form_value;
// classes
use Form;
use Input;
@@ -43,152 +42,148 @@ use Exception;
*/
class FormController extends Controller {
/**
* Create a new controller instance.
* Constructor to check
* @return void
*/
public function __construct(TicketController $TicketController) {
// mail smtp settings
SettingsController::smtp();
// creating a TicketController instance
$this->TicketController = $TicketController;
}
/**
* Create a new controller instance.
* Constructor to check
* @return void
*/
public function __construct(TicketController $TicketController) {
// mail smtp settings
SettingsController::smtp();
// creating a TicketController instance
$this->TicketController = $TicketController;
}
/**
* getform
* @param type Help_topic $topic
* @return type
*/
public function getForm(Help_topic $topic) {
if(\Config::get('database.install') == '%0%') {
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
* @param type Help_topic $topic
* @return type
*/
public function getForm(Help_topic $topic) {
if (\Config::get('database.install') == '%0%') {
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');
}
}
/**
* This Function to post the form for the ticket
* @param type Form_name $name
* @param type Form_details $details
* @return type string
*/
public function postForm($id, Help_topic $topic) {
// dd($id);
if($id != 0 ){
$helptopic = $topic->where('id', '=', $id)->first();
$custom_form = $helptopic->custom_form;
$values = Fields::where('forms_id', '=', $custom_form)->get();
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;
}
}
/**
* This Function to post the form for the ticket
* @param type Form_name $name
* @param type Form_details $details
* @return type string
*/
public function postForm($id, Help_topic $topic) {
// dd($id);
if ($id != 0) {
$helptopic = $topic->where('id', '=', $id)->first();
$custom_form = $helptopic->custom_form;
$values = Fields::where('forms_id', '=', $custom_form)->get();
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;
}
}
/**
* Posted form
* @param type Request $request
* @param type User $user
*/
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source) {
$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');
$phone = $request->input('Phone');
$email = $request->input('Email');
$subject = $request->input('Subject');
$details = $request->input('Details');
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token');
$System = System::where('id','=',1)->first();
$departments = Department::where('id','=',$System->department)->first();
$department = $departments->id;
$name = $request->input('Name');
$phone = $request->input('Phone');
$email = $request->input('Email');
$subject = $request->input('Subject');
$details = $request->input('Details');
$status = $ticket_settings->first()->status;
$helptopic = $ticket_settings->first()->help_topic;
$sla = $ticket_settings->first()->sla;
$priority = $ticket_settings->first()->priority;
$source = $ticket_source->where('name','=','web')->first();
$System = System::where('id', '=', 1)->first();
$departments = Department::where('id', '=', $System->department)->first();
$department = $departments->id;
$collaborator = null;
$assignto = null;
$status = $ticket_settings->first()->status;
$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)) {
return Redirect::route('guest.getform')->with('success','Ticket Created Successfully');
}
}
$collaborator = null;
$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
* @param type $value
* @return type view
*/
public function post_ticket_reply($id, Request $request) {
$comment = $request->input('comment');
if ($comment != null) {
$tickets = Tickets::where('id', '=', $id)->first();
$threads = new Ticket_Thread;
$tickets->closed_at = null;
$tickets->closed = 0;
$tickets->reopened_at = date('Y-m-d H:i:s');
$tickets->reopened = 1;
$threads->user_id = $tickets->user_id;
$threads->ticket_id = $tickets->id;
$threads->poster = "client";
$threads->body = $comment;
try {
$threads->save();
$tickets->save();
return \Redirect::back()->with('success1', 'Successfully replied');
} catch (Exception $e) {
return \Redirect::back()->with('fails1', $e->errorInfo[2]);
}
} else {
return \Redirect::back()->with('fails1', 'Please fill some data!');
}
}
/**
* reply
* @param type $value
* @return type view
*/
public function post_ticket_reply($id, Request $request) {
$comment = $request->input('comment');
if($comment != null) {
$tickets = Tickets::where('id','=',$id)->first();
$threads = new Ticket_Thread;
$tickets->closed_at = null;
$tickets->closed = 0;
$tickets->reopened_at = date('Y-m-d H:i:s');
$tickets->reopened = 1;
$threads->user_id = $tickets->user_id;
$threads->ticket_id = $tickets->id;
$threads->poster = "client";
$threads->body = $comment;
try {
$threads->save();
$tickets->save();
return \Redirect::back()->with('success1','Successfully replied');
} catch(Exception $e) {
return \Redirect::back()->with('fails1',$e->errorInfo[2]);
}
} else {
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
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Common\PhpMailController;
// requests
use App\Http\Requests\helpdesk\CheckTicket;
use App\Http\Requests\helpdesk\ProfilePassword;
use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\TicketRequest;
// models
use App\Model\helpdesk\Manage\Help_topic;
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\System;
use App\User;
// classes
use Auth;
use Hash;
@@ -33,256 +33,255 @@ use Exception;
*/
class GuestController extends Controller {
/**
* Create a new controller instance.
* @return type void
*/
/**
* Create a new controller instance.
* @return type void
*/
public function __construct(PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
SettingsController::smtp();
// checking authentication
$this->middleware('auth');
}
public function __construct() {
SettingsController::smtp();
// checking authentication
$this->middleware('auth');
}
/**
* Get profile
* @return type Response
*/
public function getProfile() {
$user = Auth::user();
return view('themes.default1.client.helpdesk.profile', compact('user'));
}
/**
* Get profile
* @return type Response
*/
public function getProfile() {
$user = Auth::user();
return view('themes.default1.client.helpdesk.profile', compact('user'));
}
/**
* Save profile data
* @param type $id
* @param type ProfileRequest $request
* @return type Response
*/
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
* @param type $id
* @param type ProfileRequest $request
* @return type Response
*/
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');
}
}
/**
* Get Ticket page
* @param type Help_topic $topic
* @return type Response
*/
public function getTicket(Help_topic $topic) {
$topics = $topic->get();
return view('themes.default1.client.helpdesk.tickets.form', compact('topics'));
}
/**
* Get Ticket page
* @param type Help_topic $topic
* @return type Response
*/
public function getTicket(Help_topic $topic) {
$topics = $topic->get();
return view('themes.default1.client.helpdesk.tickets.form', compact('topics'));
}
/**
* getform
* @param type Help_topic $topic
* @return type
*/
public function getForm(Help_topic $topic) {
if(\Config::get('database.install') == '%0%') {
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
* @param type Help_topic $topic
* @return type
*/
public function getForm(Help_topic $topic) {
if (\Config::get('database.install') == '%0%') {
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');
}
}
/**
* Get my ticket
* @param type Tickets $tickets
* @param type Ticket_Thread $thread
* @param type User $user
* @return type Response
*/
public function getMyticket() {
return view('themes.default1.client.helpdesk.mytickets');
}
/**
* Get my ticket
* @param type Tickets $tickets
* @param type Ticket_Thread $thread
* @param type User $user
* @return type Response
*/
public function getMyticket() {
return view('themes.default1.client.helpdesk.mytickets');
}
/**
* Get ticket-thread
* @param type Ticket_Thread $thread
* @param type Tickets $tickets
* @param type User $user
* @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'));
}
/**
* Get ticket-thread
* @param type Ticket_Thread $thread
* @param type Tickets $tickets
* @param type User $user
* @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
* @param type $id
* @param type ProfilePassword $request
* @return type Response
*/
public function postProfilePassword(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'));
try{
$user->save();
return redirect()->back()->with('success2', 'Password Updated sucessfully');
} catch (Exception $e) {
return redirect()->back()->with('fails2', $e->errorInfo[2]);
}
} else {
return redirect()->back()->with('fails2', 'Password was not Updated. Incorrect old password');
}
}
/**
* Ticekt reply
* @param type Ticket_Thread $thread
* @param type TicketRequest $request
* @return type Response
*/
public function reply(Ticket_Thread $thread, TicketRequest $request) {
$thread->ticket_id = $request->input('ticket_ID');
$thread->title = $request->input('To');
$thread->user_id = Auth::user()->id;
$thread->body = $request->input('ReplyContent');
$thread->poster = 'user';
$thread->save();
$ticket_id = $request->input('ticket_ID');
$tickets = Tickets::where('id', '=', $ticket_id)->first();
$thread = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first();
return Redirect("thread/" . $ticket_id);
}
/**
* Get Checked ticket
* @param type Tickets $ticket
* @param type User $user
* @return type response
*/
public function getCheckTicket(Tickets $ticket, User $user) {
return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket'));
}
/**
* Post Check ticket
* @param type CheckTicket $request
* @param type User $user
* @param type Tickets $ticket
* @param type Ticket_Thread $thread
* @return type Response
*/
public function PostCheckTicket() {
$Email = \Input::get('email');
$Ticket_number = \Input::get('ticket_number');
$ticket = Tickets::where('ticket_number', '=', $Ticket_number)->first();
if($ticket == null) {
return \Redirect::route('form')->with('fails', 'There is no such Ticket Number');
} else {
$userId = $ticket->user_id;
$user = User::where('id', '=', $userId)->first();
if($user->role == 'user') {
$username = $user->user_name;
} else {
$username = $user->first_name." ".$user->last_name;
}
if($user->email != $Email) {
return \Redirect::route('form')->with('fails', "Email didn't match with Ticket Number");
} else {
$code = $ticket->id;
$code = \Crypt::encrypt($code);
$company = $this->company();
\Mail::send('emails.check_ticket',
array('link'=>\URL::route('check_ticket',$code),'user'=>$username, 'from'=>$company),
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');
}
}
}
/**
* 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'));
}
/**
* ticket Edit
* @return
*/
public function ticketEdit() {
}
/**
* Post porfile password
* @param type $id
* @param type ProfilePassword $request
* @return type Response
*/
public function postProfilePassword(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'));
try {
$user->save();
return redirect()->back()->with('success2', 'Password Updated sucessfully');
} catch (Exception $e) {
return redirect()->back()->with('fails2', $e->errorInfo[2]);
}
} else {
return redirect()->back()->with('fails2', 'Password was not Updated. Incorrect old password');
}
}
/**
* Ticekt reply
* @param type Ticket_Thread $thread
* @param type TicketRequest $request
* @return type Response
*/
public function reply(Ticket_Thread $thread, TicketRequest $request) {
$thread->ticket_id = $request->input('ticket_ID');
$thread->title = $request->input('To');
$thread->user_id = Auth::user()->id;
$thread->body = $request->input('ReplyContent');
$thread->poster = 'user';
$thread->save();
$ticket_id = $request->input('ticket_ID');
$tickets = Tickets::where('id', '=', $ticket_id)->first();
$thread = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first();
return Redirect("thread/" . $ticket_id);
}
/**
* Get Checked ticket
* @param type Tickets $ticket
* @param type User $user
* @return type response
*/
public function getCheckTicket(Tickets $ticket, User $user) {
return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket'));
}
/**
* Post Check ticket
* @param type CheckTicket $request
* @param type User $user
* @param type Tickets $ticket
* @param type Ticket_Thread $thread
* @return type Response
*/
public function PostCheckTicket() {
$Email = \Input::get('email');
$Ticket_number = \Input::get('ticket_number');
$ticket = Tickets::where('ticket_number', '=', $Ticket_number)->first();
if ($ticket == null) {
return \Redirect::route('form')->with('fails', 'There is no such Ticket Number');
} else {
$userId = $ticket->user_id;
$user = User::where('id', '=', $userId)->first();
if ($user->role == 'user') {
$username = $user->user_name;
} else {
$username = $user->first_name . " " . $user->last_name;
}
if ($user->email != $Email) {
return \Redirect::route('form')->with('fails', "Email didn't match with Ticket Number");
} else {
$code = $ticket->id;
$code = \Crypt::encrypt($code);
$company = $this->company();
$this->PhpMailController->sendmail(
$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)]
);
return \Redirect::back()
->with('success', 'We have sent you a link by Email. Please click on that link to view ticket');
}
}
}
/**
* 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
* @param type Tickets $ticket
* @return type
*/
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
* @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;
}
/**
* get company
* @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;
}
}

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Client\helpdesk;
<?php
namespace App\Http\Controllers\Client\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// models
@@ -17,26 +20,27 @@ use Exception;
*/
class WelcomepageController extends Controller {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function get(System $note) {
if(Config::get('database.install')=='%0%') {
return Redirect::route('licence');
}
$notes = $note->get();
foreach ($notes as $note) {
$content = $note->content;
}
return view('themes.default1.client.guest-user.guest', compact('heading', 'content'));
}
/**
* Display a listing of the resource.
*
* @return Response
*/
public function get(System $note) {
if (Config::get('database.install') == '%0%') {
return Redirect::route('licence');
}
$notes = $note->get();
foreach ($notes as $note) {
$content = $note->content;
}
return view('themes.default1.client.guest-user.guest', compact('heading', 'content'));
}
public function index() {
if(Config::get('database.install')=='%0%') {
return Redirect::route('licence');
}
public function index() {
if (Config::get('database.install') == '%0%') {
return Redirect::route('licence');
}
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\Requests\kb\CommentRequest;
@@ -9,7 +11,7 @@ use App\Model\kb\Article;
use App\Model\kb\Category;
use App\Model\kb\Comment;
use App\Model\kb\Contact;
use App\Model\kb\Faq;
use App\Model\kb\Faq;
use App\Model\kb\Page;
use App\Model\kb\Relationship;
use App\Model\kb\Settings;
@@ -24,275 +26,281 @@ use Exception;
class UserController extends Controller {
public function __construct() {
//$this->middleware('auth');
//SettingsController::language();
// $this->port();
// $this->host();
// $this->password();
// $this->encryption();
// $this->email();
}
public function __construct() {
//$this->middleware('auth');
//SettingsController::language();
// $this->port();
// $this->host();
// $this->password();
// $this->encryption();
// $this->email();
}
/**
* @param
* @return response
* @package default
*/
public function getArticle(Article $article, Category $category, Settings $settings) {
$settings = $settings->first();
$pagination = $settings->pagination;
// $article = $article->where('status', '1');
// $article = $article->where('type', '1');
$article = $article->paginate($pagination);
/**
* @param
* @return response
* @package default
*/
public function getArticle(Article $article, Category $category, Settings $settings) {
$settings = $settings->first();
$pagination = $settings->pagination;
// $article = $article->where('status', '1');
// $article = $article->where('type', '1');
$article = $article->paginate($pagination);
// dd($article);
$article->setPath('article-list');
$categorys = $category->get();
// $time = $this->timezone($utc);
return view('themes.default1.client.kb.article-list.articles', compact('time', 'categorys', 'article'));
}
$article->setPath('article-list');
$categorys = $category->get();
// $time = $this->timezone($utc);
return view('themes.default1.client.kb.article-list.articles', compact('time', 'categorys', 'article'));
}
/**
* Get excerpt from string
*
* @param String $str String to get an excerpt from
* @param Integer $startPos Position int string to start excerpt from
* @param Integer $maxLength Maximum length the excerpt may be
* @return String excerpt
*/
static function getExcerpt($str, $startPos = 0, $maxLength = 50) {
if (strlen($str) > $maxLength) {
$excerpt = substr($str, $startPos, $maxLength - 3);
$lastSpace = strrpos($excerpt, ' ');
$excerpt = substr($excerpt, 0, $lastSpace);
$excerpt .= '...';
} else {
$excerpt = $str;
}
/**
* Get excerpt from string
*
* @param String $str String to get an excerpt from
* @param Integer $startPos Position int string to start excerpt from
* @param Integer $maxLength Maximum length the excerpt may be
* @return String excerpt
*/
static function getExcerpt($str, $startPos = 0, $maxLength = 50) {
if (strlen($str) > $maxLength) {
$excerpt = substr($str, $startPos, $maxLength - 3);
$lastSpace = strrpos($excerpt, ' ');
$excerpt = substr($excerpt, 0, $lastSpace);
$excerpt .= '...';
} else {
$excerpt = $str;
}
return $excerpt;
}
return $excerpt;
}
public function search(SearchRequest $request, Category $category, Article $article, Settings $settings) {
$settings = $settings->first();
$pagination = $settings->pagination;
$search = $request->input('s');
$result = $article->search($search)->paginate($pagination);
$result->setPath('search');
//dd($result);
$categorys = $category->get();
return view('themes.default1.client.kb.article-list.search', compact('categorys', 'result'));
}
public function search(SearchRequest $request, Category $category, Article $article, Settings $settings) {
$settings = $settings->first();
$pagination = $settings->pagination;
$search = $request->input('s');
$result = $article->search($search)->paginate($pagination);
$result->setPath('search');
//dd($result);
$categorys = $category->get();
return view('themes.default1.client.kb.article-list.search', compact('categorys', 'result'));
}
/**
* to show the seleted article
* @return response
*/
public function show($slug, Article $article, Category $category) {
//ArticleController::timezone();
$arti = $article->where('slug', $slug)->where('status','1')->where('type','1')->first();
// dd($arti);
//$categorys = $category->get();
//$avatar->get('vijaycodename47@gmail.com');
return view('themes.default1.client.kb.article-list.show', compact('arti'));
}
/**
* to show the seleted article
* @return response
*/
public function show($slug, Article $article, Category $category) {
//ArticleController::timezone();
$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');
}
}
public function getCategory($slug, Article $article, Category $category, Relationship $relation) {
/* get the article_id where category_id == current category */
$catid = $category->where('slug', $slug)->first();
$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) {
/* get the article_id where category_id == current category */
$catid = $category->where('slug', $slug)->first();
$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 home(Article $article, Category $category, Relationship $relation) {
if (Config::get('database.install') == '%0%') {
return redirect('step1');
}
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 home(Article $article, Category $category, Relationship $relation) {
if (Config::get('database.install') == '%0%') {
return redirect('step1');
} 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();
$categorys = $category->get();
return view('themes.default1.client.kb.article-list.faq', compact('categorys', 'faq'));
}
public function Faq(Faq $faq, Category $category) {
$faq = $faq->where('id', '1')->first();
$categorys = $category->get();
return view('themes.default1.client.kb.article-list.faq', compact('categorys', 'faq'));
}
/**
* get the contact page for user
* @return response
*/
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
* @return response
*/
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'));
}
/**
* send message to the mail adderess that define in the system
* @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');
}
}
/**
* send message to the mail adderess that define in the system
* @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');
}
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');
}
}
/**
* 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) {
$page = $page->where('slug', $name)->first();
//$this->timezone($page->created_at);
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 getPage($name, Page $page) {
$page = $page->where('slug', $name)->first();
//$this->timezone($page->created_at);
return view('themes.default1.client.kb.article-list.pages', compact('page'));
}
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 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 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);
static function encryption() {
$setting = Settings::whereId('1')->first();
Config::set(['mail.encryption' => $setting->encryption, 'mail.username' => $setting->email]);
}
// $offset = date('Z', strtotime($utc));
// //print "offset: $offset \n";
// $date = date($format, strtotime($utc) + $offset);
// return $date;
// //return substr($date, 0, -6);
// }
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) {
//$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() {
$user = Auth::user();
return view('themes.default1.client.kb.article-list.profile', compact('user'));
}
$user = Auth::user();
return view('themes.default1.client.kb.article-list.profile', compact('user'));
}
public function postClientProfile($id, ProfileRequest $request) {
$user = Auth::user();
$user->gender = $request->input('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/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('guest')->with('success', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return redirect('guest')->with('success', 'Profile Updated sucessfully');
}
}
$user = Auth::user();
$user->gender = $request->input('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/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('guest')->with('success', 'Profile Updated sucessfully');
}
if ($user->fill($request->except('profile_pic'))->save()) {
return redirect('guest')->with('success', 'Profile Updated sucessfully');
}
}
public function postClientProfilePassword($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'));
$user->save();
return redirect()->back()->with('success', 'Password Updated sucessfully');
} else {
return redirect()->back()->with('fails', 'Password was not Updated');
}
}
$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()->back()->with('success', 'Password Updated sucessfully');
} else {
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
use App\Http\Controllers\Controller;
// requests
@@ -43,7 +46,6 @@ class SettingsController extends Controller {
SettingsController::password();
}
/**
* get the page to create the footer
* @return response
@@ -57,61 +59,56 @@ class SettingsController extends Controller {
* @return response
*/
public function list_widget() {
return \Datatable::collection(Widgets::where('id','<','7')->get())
->searchColumns('name')
->orderColumns('name', 'title', 'value')
->addColumn('name', function ($model) {
return $model->name;
})
->addColumn('title', function ($model) {
return $model->title;
})
->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 .'">
return \Datatable::collection(Widgets::where('id', '<', '7')->get())
->searchColumns('name')
->orderColumns('name', 'title', 'value')
->addColumn('name', function ($model) {
return $model->name;
})
->addColumn('title', function ($model) {
return $model->title;
})
->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 . '">
<div class="modal-dialog">
<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">
<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 class="modal-body">
<div class="form-group" style="width:100%">
<label>'.\Lang::get("lang.title").'</label><br/>
<input type="text" name="title" value="'.$model->title.'" class="form-control" style="width:100%">
<label>' . \Lang::get("lang.title") . '</label><br/>
<input type="text" name="title" value="' . $model->title . '" class="form-control" style="width:100%">
</div>
<br/>
<div class="form-group" style="width:100%">
<label>'.\Lang::get("lang.content").'</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content'.$model->id.'">'.$model->value.'</textarea>
<label>' . \Lang::get("lang.content") . '</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content' . $model->id . '">' . $model->value . '</textarea>
</div>
</div>
<div class="modal-footer">
<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').'">
<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') . '">
</div>
<script>
$(function () {
$("#Content'. $model->id .'").wysihtml5();
$("#Content' . $model->id . '").wysihtml5();
});
</script>
</form>
</div>
</div>
</div>';
})
->make();
})
->make();
}
/**
* Post footer
* @param type Footer $footer
@@ -119,14 +116,14 @@ class SettingsController extends Controller {
* @return type response
*/
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->value = $request->content;
try{
try {
$widget->save();
return redirect()->back()->with('success', $widget->name.' Saved Successfully');
} catch(Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
return redirect()->back()->with('success', $widget->name . ' Saved Successfully');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
@@ -143,44 +140,42 @@ class SettingsController extends Controller {
* @return response
*/
public function list_social_buttons() {
return \Datatable::collection(Widgets::where('id','>','6')->get())
->searchColumns('name')
->orderColumns('name', 'value')
->addColumn('name', function ($model) {
return $model->name;
})
->addColumn('link', 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 .'">
return \Datatable::collection(Widgets::where('id', '>', '6')->get())
->searchColumns('name')
->orderColumns('name', 'value')
->addColumn('name', function ($model) {
return $model->name;
})
->addColumn('link', 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 . '">
<div class="modal-dialog">
<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">
<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 class="modal-body">
<br/>
<div class="form-group" style="width:100%">
<label>'.\Lang::get("lang.link").'</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="'.$model->value.'">
<label>' . \Lang::get("lang.link") . '</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="' . $model->value . '">
</div>
</div>
<div class="modal-footer">
<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').'">
<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') . '">
</div>
</form>
</div>
</div>
</div>';
})
->make();
})
->make();
}
/**
@@ -190,14 +185,14 @@ class SettingsController extends Controller {
* @return type response
*/
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->value = $request->content;
try{
try {
$widget->save();
return redirect()->back()->with('success', $widget->name.' Saved Successfully');
return redirect()->back()->with('success', $widget->name . ' Saved Successfully');
} 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->email = $request->input('email');
$data->password = Crypt::encrypt($request->input('password'));
try{
try {
$data->save();
return \Redirect::route('getsmtp')->with('success', 'success');
} catch (Exception $e) {
@@ -343,9 +338,9 @@ class SettingsController extends Controller {
$pass = $request->input('password');
$password = Crypt::encrypt($pass);
$settings->password = $password;
try{
try {
$settings->save();
} catch(Exception $e) {
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
if (Input::file('logo')) {
@@ -357,7 +352,7 @@ class SettingsController extends Controller {
$settings->save();
}
try {
$settings->fill($request->except('logo', 'password'))->save();
$settings->fill($request->except('logo', 'password'))->save();
return redirect()->back()->with('success', 'Settings updated Successfully');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
@@ -425,8 +420,8 @@ class SettingsController extends Controller {
$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>"
. "<div class='modal fade' id=del".$model['path'].">
$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-dialog'>
<div class=modal-content>
<div class=modal-header>
@@ -457,7 +452,7 @@ class SettingsController extends Controller {
return ucfirst($model['author']);
})
->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) {
return $model['version'];
@@ -523,7 +518,7 @@ class SettingsController extends Controller {
$lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str;
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');
} else {
/**

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers;
<?php
namespace App\Http\Controllers;
// classes
use Illuminate\Foundation\Bus\DispatchesCommands;
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
use App\Http\Controllers\Controller;
@@ -11,11 +14,12 @@ use App\Http\Controllers\Controller;
*/
class ErrorController extends Controller {
/**
* Display a Error Page of 404.
* @return Response
*/
public function error404() {
return view('404');
}
/**
* Display a Error Page of 404.
* @return Response
*/
public function error404() {
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\Ticket\Tickets;
class HomeController extends Controller {
/*
|--------------------------------------------------------------------------
@@ -31,49 +32,47 @@ class HomeController extends Controller {
* @return Response
*/
public function index() {
// ksjdckjdsnc
// ksjdckjdsnc
return view('themes/default1/admin/dashboard');
}
public function getsmtp(){
$smtp = \App\Model\helpdesk\Email\Smtp::where('id','=','1')->first();
return $smtp->host;
public function getsmtp() {
$smtp = \App\Model\helpdesk\Email\Smtp::where('id', '=', '1')->first();
return $smtp->host;
}
Public function getdata(){
return \View::make('emails/notifications/agent');
Public function getdata() {
return \View::make('emails/notifications/agent');
}
public function getreport(){
return \View::make('test');
public function getreport() {
return \View::make('test');
}
public function pushdata(){
$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,',');
public function pushdata() {
return '['.$last.']';
$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 . ']';
}
}

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers\Installer\helpdesk;
<?php
namespace App\Http\Controllers\Installer\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// requests
@@ -20,6 +23,7 @@ use Redirect;
use Session;
use View;
use Exception;
/**
* |=======================================================================
* |Class: InstallController
@@ -34,38 +38,41 @@ use Exception;
*
*/
class InstallController extends Controller {
/**
* Get Licence (step 1)
* @return type view
*/
public function licence() {
// checking if the installation is running for the first time or not
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%') {
return view('themes/default1/installer/helpdesk/view1');
} else {
// return 1;
return redirect('/auth/login');
}
}
public function licence() {
// checking if the installation is running for the first time or not
// 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%') {
return view('themes/default1/installer/helpdesk/view1');
} else {
// return 1;
return redirect('/auth/login');
}
}
/**
* Post Licencecheck
* @return type view
*/
public function licencecheck() {
// checking if the user have accepted the licence agreement
$accept = (Input::has('accept1')) ? true : false;
if ($accept == 'accept') {
Session::put('step1', 'step1');
return Redirect::route('prerequisites');
} else {
return Redirect::route('licence')->with('fails', 'Failed! first accept the licence agreeement');
}
// return 1;
}
public function licencecheck() {
// checking if the user have accepted the licence agreement
$accept = (Input::has('accept1')) ? true : false;
if ($accept == 'accept') {
Session::put('step1', 'step1');
return Redirect::route('prerequisites');
} else {
return Redirect::route('licence')->with('fails', 'Failed! first accept the licence agreeement');
}
// return 1;
}
/**
* Get prerequisites (step 2)
*
@@ -73,267 +80,310 @@ class InstallController extends Controller {
* without which the project cannot be executed properly
* @return type view
*/
public function prerequisites() {
// checking if the installation is running for the first time or not
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%') {
if (Session::get('step1') == 'step1') {
return View::make('themes/default1/installer/helpdesk/view2');
} else {
return Redirect::route('licence');
}
} else {
return redirect('/auth/login');
}
}
public function prerequisites() {
// checking if the installation is running for the first time or not
// 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%') {
if (Session::get('step1') == 'step1') {
return View::make('themes/default1/installer/helpdesk/view2');
} else {
return Redirect::route('licence');
}
} else {
return redirect('/auth/login');
}
}
/**
* Post Prerequisitescheck
* checking prerequisites
* @return type view
*/
public function prerequisitescheck() {
Session::put('step2', 'step2');
return Redirect::route('configuration');
}
/**
* Get Localization (step 3)
* Requesting user recomended settings for installation
* @return type view
*/
public function localization() {
// checking if the installation is running for the first time or not
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%') {
if (Session::get('step2') == 'step2') {
return View::make('themes/default1/installer/helpdesk/view3');
} else {
return Redirect::route('prerequisites');
}
} else {
return redirect('/auth/login');
}
}
/**
* Post localizationcheck
* checking prerequisites
* @return type view
*/
public function localizationcheck() {
Session::put('step3', 'step3');
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');
}
public function prerequisitescheck() {
Session::put('step2', 'step2');
return Redirect::route('configuration');
}
/**
* Get Localization (step 3)
* Requesting user recomended settings for installation
* @return type view
*/
public function localization() {
// checking if the installation is running for the first time or not
// 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%') {
if (Session::get('step2') == 'step2') {
return View::make('themes/default1/installer/helpdesk/view3');
} else {
return Redirect::route('prerequisites');
}
} else {
return redirect('/auth/login');
}
}
/**
* Post localizationcheck
* checking prerequisites
* @return type view
*/
public function localizationcheck() {
Session::put('step3', 'step3');
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)
* checking prerequisites
* @return type view
*/
public function configuration() {
// checking if the installation is running for the first time or not
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%') {
if (Session::get('step2') == 'step2') {
return View::make('themes/default1/installer/helpdesk/view3');
} else {
return Redirect::route('prerequisites');
}
} else {
return redirect('/auth/login');
}
}
public function configuration() {
// checking if the installation is running for the first time or not
// 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%') {
if (Session::get('step2') == 'step2') {
return View::make('themes/default1/installer/helpdesk/view3');
} else {
return Redirect::route('prerequisites');
}
} else {
return redirect('/auth/login');
}
}
/**
* Post configurationcheck
* checking prerequisites
* @return type view
*/
public function configurationcheck() {
Session::put('step4', 'step4');
Session::put('default', Input::get('default'));
Session::put('host', Input::get('host'));
Session::put('databasename', Input::get('databasename'));
Session::put('username', Input::get('username'));
Session::put('password', Input::get('password'));
Session::put('port', Input::get('port'));
return Redirect::route('database');
}
/**
* postconnection
* @return type view
*/
public function postconnection() {
error_reporting(E_ALL & ~E_NOTICE);
$default = Input::get('default');
$host = Input::get('host');
$database = Input::get('databasename');
$dbusername = Input::get('username');
$dbpassword = Input::get('password');
$port = Input::get('port');
// Setting environment values
$_ENV['DB_TYPE'] = $default;
$_ENV['DB_HOST'] = $host;
$_ENV['DB_PORT'] = $port;
$_ENV['DB_DATABASE'] = $database;
$_ENV['DB_USERNAME'] = $dbusername;
$_ENV['DB_PASSWORD'] = $dbpassword;
$config = '';
foreach ($_ENV as $key => $val) {
$config .= "{$key}={$val}\n";
}
// Write environment file
$fp = fopen(base_path()."/.env", 'w');
fwrite($fp, $config);
fclose($fp);
return 1;
}
public function configurationcheck() {
Session::put('step4', 'step4');
Session::put('default', Input::get('default'));
Session::put('host', Input::get('host'));
Session::put('databasename', Input::get('databasename'));
Session::put('username', Input::get('username'));
Session::put('password', Input::get('password'));
Session::put('port', Input::get('port'));
return Redirect::route('database');
}
/**
* postconnection
* @return type view
*/
public function postconnection() {
error_reporting(E_ALL & ~E_NOTICE);
$default = Input::get('default');
$host = Input::get('host');
$database = Input::get('databasename');
$dbusername = Input::get('username');
$dbpassword = Input::get('password');
$port = Input::get('port');
// Setting environment values
$_ENV['DB_TYPE'] = $default;
$_ENV['DB_HOST'] = $host;
$_ENV['DB_PORT'] = $port;
$_ENV['DB_DATABASE'] = $database;
$_ENV['DB_USERNAME'] = $dbusername;
$_ENV['DB_PASSWORD'] = $dbpassword;
$config = '';
foreach ($_ENV as $key => $val) {
$config .= "{$key}={$val}\n";
}
// Write environment file
$fp = fopen(base_path() . "/.env", 'w');
fwrite($fp, $config);
fclose($fp);
return 1;
}
/**
* Get database
* checking prerequisites
* @return type view
*/
public function database() {
// checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') {
if (Session::get('step4') == 'step4') {
return View::make('themes/default1/installer/helpdesk/view4');
} else {
return Redirect::route('configuration');
}
} else {
return redirect('/auth/login');
}
}
public function database() {
// checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') {
if (Session::get('step4') == 'step4') {
return View::make('themes/default1/installer/helpdesk/view4');
} else {
return Redirect::route('configuration');
}
} else {
return redirect('/auth/login');
}
}
/**
* Get account
* checking prerequisites
* @return type view
*/
public function account() {
// checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') {
if (Session::get('step4') == 'step4') {
Session::put('step5', 'step5');
Session::forget('step1');
Session::forget('step2');
Session::forget('step3');
return View::make('themes/default1/installer/helpdesk/view5');
} else {
return Redirect::route('configuration');
}
} else {
return redirect('/auth/login');
}
}
public function account() {
// checking if the installation is running for the first time or not
if (Config::get('database.install') == '%0%') {
if (Session::get('step4') == 'step4') {
Session::put('step5', 'step5');
Session::forget('step1');
Session::forget('step2');
Session::forget('step3');
return View::make('themes/default1/installer/helpdesk/view5');
} else {
return Redirect::route('configuration');
}
} else {
return redirect('/auth/login');
}
}
/**
* Post accountcheck
* checking prerequisites
* @param type InstallerRequest $request
* @return type view
*/
public function accountcheck(InstallerRequest $request) {
// migrate database
Artisan::call('migrate', array('--force' => true));
Artisan::call('db:seed', array('--force' => true));
// create user
$firstname = $request->input('firstname');
$lastname = $request->input('Lastname');
$email = $request->input('email');
$username = $request->input('username');
$password = $request->input('password');
$language = $request->input('language');
$timezone = $request->input('timezone');
$date = $request->input('date');
$datetime = $request->input('datetime');
// $system = System::where('id','=','1')->first();
// $system->time_zone = $timezone;
// $system->date_time_format = $datetime;
// $system->save();
// checking requested timezone for the admin and system
$timezones = Timezones::where('name','=',$timezone)->first();
if($timezones->id == null){
return ['response'=>'fail','reason'=>'Invalid time-zone','status'=>'0'];
}
// var_dump($datetime);
// checking requested date time format for the admin and system
$date_time_format = Date_time_format::where('format','=',$datetime)->first();
// dd($date_time_format);
if($date_time_format->id == null){
return ['response'=>'fail','reason'=>'invalid date-time format','status'=>'0'];
}
// Creating minum settings for system
$system = new System;
$system->status = 1;
$system->department = 1;
$system->date_time_format = $date_time_format->id;
$system->time_zone = $timezones->id;
$system->save();
// creating an user
$user = User::create(array(
'first_name' => $firstname,
'last_name' => $lastname,
'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');
}
}
public function accountcheck(InstallerRequest $request) {
// migrate database
Artisan::call('migrate', array('--force' => true));
Artisan::call('db:seed', array('--force' => true));
// create user
$firstname = $request->input('firstname');
$lastname = $request->input('Lastname');
$email = $request->input('email');
$username = $request->input('username');
$password = $request->input('password');
$language = $request->input('language');
$timezone = $request->input('timezone');
$date = $request->input('date');
$datetime = $request->input('datetime');
//\Cache::forever('language', $language);
//\App::setLocale($language);
// $system = System::where('id','=','1')->first();
// $system->time_zone = $timezone;
// $system->date_time_format = $datetime;
// $system->save();
// checking requested timezone for the admin and system
$timezones = Timezones::where('name', '=', $timezone)->first();
if ($timezones->id == null) {
return ['response' => 'fail', 'reason' => 'Invalid time-zone', 'status' => '0'];
}
// var_dump($datetime);
// checking requested date time format for the admin and system
$date_time_format = Date_time_format::where('format', '=', $datetime)->first();
// dd($date_time_format);
if ($date_time_format->id == null) {
return ['response' => 'fail', 'reason' => 'invalid date-time format', 'status' => '0'];
}
// Creating minum settings for system
$system = new System;
$system->status = 1;
$system->department = 1;
$system->date_time_format = $date_time_format->id;
$system->time_zone = $timezones->id;
$system->save();
// creating an user
$user = User::create(array(
'first_name' => $firstname,
'last_name' => $lastname,
'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
* checking prerequisites
* @return type view
*/
public function finalize() {
// checking if the installation have been completed or not
if (Session::get('step6') == 'step6') {
$value = '1';
$install = app_path('../config/database.php');
$datacontent = File::get($install);
$datacontent = str_replace('%0%', $value, $datacontent);
File::put($install, $datacontent);
// setting email settings in route
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
$path22 = app_path('Http/routes.php');
$content23 = File::get($path22);
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
File::put($path22, $content23);
try {
return View::make('themes/default1/installer/helpdesk/view6');
} catch (Exception $e) {
return Redirect::route('npl');
}
} else {
return redirect('/auth/login');
}
}
/**
public function finalize() {
// checking if the installation have been completed or not
if (Session::get('step6') == 'step6') {
$value = '1';
$install = app_path('../config/database.php');
$datacontent = File::get($install);
$datacontent = str_replace('%0%', $value, $datacontent);
File::put($install, $datacontent);
// setting email settings in route
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
$lfmpath = "url('photos').'/'";
$path22 = app_path('Http/routes.php');
$path23 = base_path('config/lfm.php');
$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);
try {
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
* checking prerequisites
* @return type view
*/
public function finalcheck() {
try {
return redirect('/auth/login');
} catch (Exception $e) {
return redirect('/auth/login');
}
}
public function finalcheck() {
try {
return redirect('/auth/login');
} catch (Exception $e) {
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;
@@ -9,33 +11,36 @@ use Illuminate\Foundation\Http\Kernel as HttpKernel;
*/
class Kernel extends HttpKernel {
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
//'App\Http\Middleware\VerifyCsrfToken',
'App\Http\Middleware\LanguageMiddleware',
];
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
//'App\Http\Middleware\VerifyCsrfToken',
'App\Http\Middleware\LanguageMiddleware',
];
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
'roles' => 'App\Http\Middleware\CheckRole',
'role.agent' => 'App\Http\Middleware\CheckRoleAgent',
'role.user' => 'App\Http\Middleware\CheckRoleUser',
];
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
'roles' => 'App\Http\Middleware\CheckRole',
'role.agent' => 'App\Http\Middleware\CheckRoleAgent',
'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 Illuminate\Contracts\Auth\Guard;
@@ -10,40 +13,40 @@ use Illuminate\Contracts\Auth\Guard;
*/
class Authenticate {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth) {
$this->auth = $auth;
}
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth) {
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
}
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
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;
/**
@@ -9,19 +12,19 @@ use Closure;
*/
class CheckRole {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($request->user()->role == 'admin') {
return $next($request);
}
return redirect('guest')->with('fails', 'You are not Autherised');
}
if ($request->user()->role == 'admin') {
return $next($request);
}
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;
/**
@@ -9,18 +12,18 @@ use Closure;
*/
class CheckRoleAgent {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($request->user()->role == 'agent' || $request->user()->role == 'admin') {
return $next($request);
}
return redirect('dashboard')->with('fails', 'You are not Autherised');
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($request->user()->role == 'agent' || $request->user()->role == 'admin') {
return $next($request);
}
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;
/**
@@ -9,18 +12,18 @@ use Closure;
*/
class CheckRoleUser {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($request->user()->role == 'user') {
return $next($request);
}
return redirect('guest')->with('fails', 'You are not Autherised');
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($request->user()->role == 'user') {
return $next($request);
}
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 Closure;
@@ -11,14 +13,14 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Session;
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'))) {
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'));
}
return $next($request);
}
}
}

View File

@@ -1,4 +1,6 @@
<?php namespace App\Http\Middleware;
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
@@ -6,36 +8,36 @@ use Illuminate\Http\RedirectResponse;
class RedirectIfAuthenticated {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth) {
$this->auth = $auth;
}
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth) {
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($this->auth->check()) {
return new RedirectResponse(url('dashboard'));
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next) {
if ($this->auth->check()) {
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 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;
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;
/**
@@ -9,35 +12,35 @@ use App\Http\Requests\Request;
*/
class AgentRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'user_name' => 'required|unique:users',
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required',
'active' => 'required',
// 'account_status' => 'required',
'assign_group' => 'required',
'primary_dpt' => 'required',
'agent_tzone' => 'required',
// 'phone_number' => 'phone:IN',
// 'mobile' => 'phone:IN',
'team_id' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'user_name' => 'required|unique:users',
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required',
'active' => 'required',
// 'account_status' => 'required',
'assign_group' => 'required',
'primary_dpt' => 'required',
'agent_tzone' => 'required',
// 'phone_number' => 'phone:IN',
// 'mobile' => 'phone:IN',
'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;
/**
@@ -9,34 +12,34 @@ use App\Http\Requests\Request;
*/
class AgentUpdate extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email',
'active' => 'required',
'role' => 'required',
'assign_group' => 'required',
'primary_dpt' => 'required',
'agent_tzone' => 'required',
// 'phone_number' => 'phone:IN',
// 'mobile' => 'phone:IN',
'team_id' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email',
'active' => 'required',
'role' => 'required',
'assign_group' => 'required',
'primary_dpt' => 'required',
'agent_tzone' => 'required',
// 'phone_number' => 'phone:IN',
// 'mobile' => 'phone:IN',
'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;
class ArticleRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required',
'description' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => '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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class BanRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required|email',
'ban' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required|email',
'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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class BanlistRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'email',
'ban' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'email',
'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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class CannedRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'title' => 'required',
'message' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'title' => '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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class CannedUpdateRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'title' => 'required',
'message' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'title' => '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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class CheckTicket extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required|email',
'ticket_number' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required|email',
'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;
/**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/
class ClientRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'Name'=>'required',
'Email'=>'required',
'Subject'=>'required',
'Details'=>'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'Name' => 'required',
'Email' => 'required',
'Subject' => '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;
class CommentRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|max:10',
'email' => 'required|email',
'website' => 'url',
'comment' => 'required|max:60',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|max:10',
'email' => 'required|email',
'website' => 'url',
'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;
/**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/
class CompanyRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'company_name' => 'required',
'website' => 'url',
'phone' => 'numeric',
'logo' => 'image',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'company_name' => 'required',
'website' => 'url',
'phone' => 'numeric',
'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;
class ContactRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required',
'email' => 'required|email',
'subject' => 'required',
'message' => 'required|max:50',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required',
'email' => 'required|email',
'subject' => 'required',
'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;
/**
@@ -9,32 +12,32 @@ use App\Http\Requests\Request;
*/
class CreateTicketRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required|email',
'fullname' => 'required|min:3',
'helptopic' => 'required',
// 'dept' => 'required',
'sla' => 'required',
'subject' => 'required|min:5',
'body' => 'required|min:20',
'priority' => 'required',
];
}
'email' => 'required|email',
'fullname' => 'required|min:3',
'helptopic' => 'required',
// 'dept' => 'required',
'sla' => 'required',
'subject' => 'required|min:5',
'body' => 'required|min:20',
'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;
/**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/
class DepartmentRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|unique:department',
// 'outgoing_email' => 'required',
// 'auto_response_email' => 'required',
// 'group_id' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|unique:department',
// 'outgoing_email' => 'required',
// 'auto_response_email' => '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;
/**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/
class DepartmentUpdate extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
// 'outgoing_email' => 'required',
// 'auto_response_email' => 'required',
// 'group_id' => 'required',
];
}
// 'outgoing_email' => 'required',
// 'auto_response_email' => '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;
/**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/
class DiagnoRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'from' => 'required|email',
'to' => 'required|email',
'subject' => 'required',
'message' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'from' => 'required|email',
'to' => 'required|email',
'subject' => '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;
/**
@@ -9,23 +12,23 @@ use App\Http\Requests\Request;
*/
class EmailRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
];
}
}

View File

@@ -1,4 +1,7 @@
<?php namespace App\Http\Requests\helpdesk;
<?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request;
/**
@@ -9,37 +12,37 @@ use App\Http\Requests\Request;
*/
class EmailsEditRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email_address' => 'email',
'email_name' => 'required',
'department' => 'required',
'priority' => 'required',
'help_topic' => 'required',
// 'imap_config' => 'required',
'password' => 'required|min:6',
// 'user_name' => 'required',
// 'sending_host' => 'required',
// 'sending_port' => 'required',
//'mailbox_protocol' => 'required'
'fetching_host' => 'required',
'fetching_port' => 'required',
'mailbox_protocol' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email_address' => 'email',
'email_name' => 'required',
// 'department' => 'required',
// 'priority' => 'required',
// 'help_topic' => 'required',
// 'imap_config' => 'required',
'password' => 'required|min:6',
// 'user_name' => 'required',
// 'sending_host' => 'required',
// 'sending_port' => 'required',
//'mailbox_protocol' => 'required'
'fetching_host' => 'required',
'fetching_port' => '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;
/**
@@ -9,36 +12,36 @@ use App\Http\Requests\Request;
*/
class EmailsRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email_address' => 'required|email|unique:emails',
'email_name' => 'required',
'department' => 'required',
'priority' => 'required',
'help_topic' => 'required',
// 'imap_config' => 'required',
'password' => 'required|min:6',
// 'user_name' => 'required',
// 'sending_host' => 'required',
// 'sending_port' => 'required',
'fetching_host' => 'required',
'fetching_port' => 'required',
'mailbox_protocol' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email_address' => 'required|email|unique:emails',
'email_name' => 'required',
// 'department' => 'required',
// 'priority' => 'required',
// 'help_topic' => 'required',
// 'imap_config' => 'required',
'password' => 'required|min:6',
// 'user_name' => 'required',
// 'sending_host' => 'required',
// 'sending_port' => 'required',
'fetching_host' => 'required',
'fetching_port' => '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;
/**
@@ -9,28 +12,28 @@ use App\Http\Requests\Request;
*/
class FormRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'title' => 'required',
'label' => 'required',
'type' => 'required',
'visibility' => 'required',
];
}
'title' => 'required',
'label' => 'required',
'type' => '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;
/**
@@ -9,24 +12,24 @@ use App\Http\Requests\Request;
*/
class GroupRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|unique:groups',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'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;
/**
@@ -9,30 +12,30 @@ use App\Http\Requests\Request;
*/
class HelptopicRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'topic' => 'required|unique:help_topic',
// 'parent_topic' => 'required',
// 'custom_form' => 'required',
'department' => 'required',
'priority' => 'required',
'sla_plan' => 'required',
// 'auto_assign' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'topic' => 'required|unique:help_topic',
// 'parent_topic' => 'required',
// 'custom_form' => 'required',
'department' => 'required',
'priority' => 'required',
'sla_plan' => '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;
/**
@@ -9,29 +12,29 @@ use App\Http\Requests\Request;
*/
class HelptopicUpdate extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
// 'parent_topic' => 'required',
// 'custom_form' => 'required',
'department' => 'required',
'priority' => 'required',
'sla_plan' => 'required',
// 'auto_assign' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
// 'parent_topic' => 'required',
// 'custom_form' => 'required',
'department' => 'required',
'priority' => 'required',
'sla_plan' => '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;
/**
@@ -9,29 +12,29 @@ use App\Http\Requests\Request;
*/
class InstallerRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'firstname' => 'required|max:20',
'Lastname' => 'required|max:20',
'email' => 'required|max:50|email',
'username' => 'required|max:50|min:3',
'password' => 'required|min:6',
'confirmpassword' => 'required|same:password',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'firstname' => 'required|max:20',
'Lastname' => 'required|max:20',
'email' => 'required|max:50|email',
'username' => 'required|max:50|min:3',
'password' => 'required|min:6',
'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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class LoginRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required',
'password' => 'required|min:6',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required',
'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;
class MessageRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'message_title' => 'required',
'message' => 'required'
];
}
'message_title' => '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;
/**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/
class OrganizationRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|unique:organization',
'website' => 'url',
// 'phone' => 'size:10',
];
}
'name' => 'required|unique:organization',
'website' => 'url',
// '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;
/**
@@ -9,26 +12,26 @@ use App\Http\Requests\Request;
*/
class OrganizationUpdate extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'website' => 'url',
// 'phone' => 'size:10',
];
}
'website' => 'url',
// '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;
/**
@@ -9,26 +12,26 @@ use App\Http\Requests\Request;
*/
class ProfilePassword extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'old_password' => 'required',
'new_password' => 'required|min:6',
'confirm_password' => 'required|same:new_password',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'old_password' => 'required',
'new_password' => 'required|min:6',
'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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class ProfileRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'first_name' => 'required',
'profile_pic' => 'mimes:png,jpeg',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'first_name' => 'required',
'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;
/**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/
class RegisterRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required|max:50|email|unique:users',
'full_name' => 'required',
'password' => 'required|min:6',
'password_confirmation' => 'required|same:password',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required|max:50|email|unique:users',
'full_name' => 'required',
'password' => 'required|min:6',
'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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class SlaRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|unique:sla_plan',
'grace_period' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|unique:sla_plan',
'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;
/**
@@ -9,24 +12,24 @@ use App\Http\Requests\Request;
*/
class SlaUpdate extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'grace_period' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'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;
/**
@@ -9,29 +12,29 @@ use App\Http\Requests\Request;
*/
class SmtpRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'host' => 'required',
'port' => 'required',
'encryption' => 'required',
'name' => 'required',
'email' => 'required',
'password' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'host' => 'required',
'port' => 'required',
'encryption' => 'required',
'name' => 'required',
'email' => '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;
/**
@@ -9,27 +12,27 @@ use App\Http\Requests\Request;
*/
class Sys_userRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'email' => 'required|unique:users,email',
'full_name' => 'required',
// 'phone' => 'size:10',
];
}
'email' => 'required|unique:users,email',
'full_name' => 'required',
// '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;
/**
@@ -9,26 +12,26 @@ use App\Http\Requests\Request;
*/
class Sys_userUpdate extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'user_name' => 'required',
// 'email' => 'required|email',
// 'phone' => 'size:10',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'user_name' => 'required',
// 'email' => 'required|email',
// '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;
/**
@@ -9,26 +12,26 @@ use App\Http\Requests\Request;
*/
class SystemRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => '',
'url' => 'url',
];
}
'name' => '',
'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;
/**
@@ -9,25 +12,25 @@ use App\Http\Requests\Request;
*/
class TeamRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|unique:teams',
'status' => 'required',
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'name' => 'required|unique:teams',
'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;
/**
@@ -9,23 +12,23 @@ use App\Http\Requests\Request;
*/
class TeamUpdate extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
];
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
];
}
}

View File

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

View File

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

View File

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

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