update v 1.0.7.5

This commit is contained in:
Sujit Prasad
2016-06-13 20:41:55 +05:30
parent aa9786d829
commit 283d97e3ea
5078 changed files with 339851 additions and 175995 deletions

View File

@@ -13,12 +13,15 @@ use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Agent\Groups;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Utility\CountryCode;
use App\Model\helpdesk\Utility\Timezones;
use App\User;
// classes
use DB;
use Exception;
use GeoIP;
use Hash;
use Lang;
/**
* AgentController
@@ -72,7 +75,7 @@ class AgentController extends Controller
*
* @return type view
*/
public function create(Timezones $timezone, Groups $group, Department $department, Teams $team_all)
public function create(Timezones $timezone, Groups $group, Department $department, Teams $team_all, CountryCode $code)
{
try {
// gte all the teams
@@ -84,9 +87,11 @@ class AgentController extends Controller
// get all department
$departments = $department->get();
// list all the teams in a single variable
$teams = $team->lists('id', 'name');
$teams = $team->lists('id', 'name')->toArray();
$location = GeoIP::getLocation('');
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
// returns to the page with all the variables and their datas
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team'));
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) {
// returns if try fails with exception meaagse
return redirect()->back()->with('fails', $e->getMessage());
@@ -104,13 +109,24 @@ class AgentController extends Controller
*/
public function store(User $user, AgentRequest $request)
{
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
return redirect()->back()->with(['fails2' => Lang::get('lang.country-code-required-error'), 'country_code' => 1])->withInput();
} else {
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
if (!count($code)) {
return redirect()->back()->with(['fails2' => Lang::get('lang.incorrect-country-code-error'), 'country_code' => 1])->withInput();
}
}
// fixing the user role to agent
$user->fill($request->input())->save();
$user->fill($request->except(['group', 'primary_department', 'agent_time_zone']))->save();
$user->assign_group = $request->group;
$user->primary_dpt = $request->primary_department;
$user->agent_tzone = $request->agent_time_zone;
// generate password and has immediately to store
$password = $this->generateRandomString();
$user->password = Hash::make($password);
// fetching all the team details checked for this user
$requests = $request->input('team_id');
$requests = $request->input('team');
// get user id of the inserted user detail
$id = $user->id;
// insert team
@@ -128,13 +144,13 @@ class AgentController extends Controller
$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) {
// returns if try fails
return redirect('agents')->with('fails', 'Some error occurred while sending mail to the agent. Please check email settings and try again');
return redirect('agents')->with('warning', Lang::get('lang.agent_send_mail_error_on_agent_creation'));
}
// returns for the success case
return redirect('agents')->with('success', 'Agent Created sucessfully');
return redirect('agents')->with('success', Lang::get('lang.agent_creation_success'));
} else {
// returns if fails
return redirect('agents')->with('fails', 'Agent can not Create');
return redirect('agents')->with('fails', Lang::get('lang.failed_to_create_agent'));
}
}
@@ -151,9 +167,11 @@ class AgentController extends Controller
*
* @return type Response
*/
public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team)
public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team, CountryCode $code)
{
try {
$location = GeoIP::getLocation('');
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
$user = $user->whereId($id)->first();
$team = $team->get();
$teams1 = $team->lists('name', 'id');
@@ -161,12 +179,12 @@ class AgentController extends Controller
$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');
$teams = $team->lists('id', 'name')->toArray();
$assign = $team_assign_agent->where('agent_id', $id)->lists('team_id')->toArray();
return view('themes.default1.admin.helpdesk.agent.agents.edit', compact('teams', 'assign', 'table', 'teams1', 'selectedTeams', 'user', 'timezones', 'groups', 'departments', 'team', 'exp', 'counted'));
return view('themes.default1.admin.helpdesk.agent.agents.edit', compact('teams', 'assign', 'table', 'teams1', 'selectedTeams', 'user', 'timezones', 'groups', 'departments', 'team', 'exp', 'counted'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) {
return redirect('agents')->with('fail', 'No such file');
return redirect('agents')->with('fail', Lang::get('lang.failed_to_edit_agent'));
}
}
@@ -182,7 +200,14 @@ class AgentController extends Controller
*/
public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent)
{
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
return redirect()->back()->with(['fails2' => Lang::get('lang.country-code-required-error'), 'country_code' => 1])->withInput();
} else {
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
if (!count($code)) {
return redirect()->back()->with(['fails2' => Lang::get('lang.incorrect-country-code-error'), 'country_code' => 1])->withInput();
}
}
// storing all the details
$user = $user->whereId($id)->first();
$daylight_save = $request->input('daylight_save');
@@ -192,18 +217,25 @@ class AgentController extends Controller
//==============================================
$table = $team_assign_agent->where('agent_id', $id);
$table->delete();
$requests = $request->input('team_id');
$requests = $request->input('team');
// 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 {
if ($request->input('country_code') != '' or $request->input('country_code') != null) {
$user->country_code = $request->input('country_code');
}
$user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save();
$user->assign_group = $request->group;
$user->primary_dpt = $request->primary_department;
$user->agent_tzone = $request->agent_time_zone;
$user->save();
return redirect('agents')->with('success', 'Agent Updated sucessfully');
return redirect('agents')->with('success', Lang::get('lang.agent_updated_sucessfully'));
} catch (Exception $e) {
return redirect('agents')->with('fails', 'Agent did not update'.'<li>'.$e->errorInfo[2].'</li>');
return redirect('agents')->with('fails', Lang::get('lang.unable_to_update_agent').'<li>'.$e->errorInfo[2].'</li>');
}
}
@@ -226,12 +258,12 @@ class AgentController extends Controller
$team_assign_agent->delete();
$user = $user->whereId($id)->first();
try {
$error = 'This staff is related to some tickets';
$error = Lang::get('lang.this_staff_is_related_to_some_tickets');
$user->id;
$user->delete();
throw new \Exception($error);
return redirect('agents')->with('success', 'Agent Deleted sucessfully');
return redirect('agents')->with('success', Lang::get('lang.agent_deleted_sucessfully'));
} catch (\Exception $e) {
return redirect('agents')->with('fails', $error);
}

View File

@@ -12,6 +12,7 @@ use App\Model\helpdesk\Email\Banlist;
use App\User;
//classes
use Exception;
use Lang;
/**
* BanlistController
@@ -50,7 +51,7 @@ class BanlistController extends Controller
return view('themes.default1.admin.helpdesk.emails.banlist.index', compact('bans'));
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -64,7 +65,7 @@ class BanlistController extends Controller
try {
return view('themes.default1.admin.helpdesk.emails.banlist.create');
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -88,7 +89,7 @@ class BanlistController extends Controller
$use->internal_note = $request->input('internal_note');
$use->save();
// $user->create($request->input())->save();
return redirect('banlist')->with('success', 'Email Banned sucessfully');
return redirect('banlist')->with('success', Lang::get('lang.email_banned_sucessfully'));
} else {
$user = new User();
$user->email = $adban;
@@ -96,10 +97,10 @@ class BanlistController extends Controller
$user->internal_note = $request->input('internal_note');
$user->save();
return redirect('banlist')->with('success', 'Email Banned sucessfully');
return redirect('banlist')->with('success', Lang::get('lang.email_banned_sucessfully'));
}
} catch (Exception $e) {
return redirect('banlist')->with('fails', 'Email can not Ban');
return redirect('banlist')->with('fails', Lang::get('lang.email_can_not_ban'));
}
}
@@ -118,7 +119,7 @@ class BanlistController extends Controller
return view('themes.default1.admin.helpdesk.emails.banlist.edit', compact('bans'));
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -138,12 +139,33 @@ class BanlistController extends Controller
$bans->internal_note = $request->input('internal_note');
$bans->ban = $request->input('ban');
if ($bans->save()) {
return redirect('banlist')->with('success', 'Banned Email Updated sucessfully');
return redirect('banlist')->with('success', Lang::get('lang.banned_email_updated_sucessfully'));
} else {
return redirect('banlist')->with('fails', 'Banned Email not Updated');
return redirect('banlist')->with('fails', Lang::get('lang.banned_email_not_updated'));
}
} catch (Exception $e) {
return redirect('banlist')->with('fails', 'Banned Email not Updated');
return redirect('banlist')->with('fails', Lang::get('lang.banned_email_not_updated'));
}
}
/**
* delete the banned users.
*
* @param type $id
* @param \App\User $ban
*
* @return type view
*/
public function delete($id, User $ban)
{
try {
$ban_user = $ban->where('id', '=', $id)->first();
$ban_user->ban = 0;
$ban_user->save();
return redirect('banlist')->with('success', Lang::get('lang.banned_removed_sucessfully'));
} catch (Exception $ex) {
return redirect('banlist')->with('fails', $ex->getMessage());
}
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Http\Controllers\Admin\helpdesk;
use App\Http\Controllers\Controller;
use App\Http\Requests\helpdesk\WorkflowCloseRequest;
use App\Model\helpdesk\Workflow\WorkflowClose;
use Lang;
/**
* |=================================================
* | CloseWrokflowController
* |=================================================
* In this controller the functionalities fo close ticket workflow defined.
*/
class CloseWrokflowController extends Controller
{
private $security;
public function __construct(WorkflowClose $security)
{
$this->security = $security;
}
/**
* get the workflow settings page.
*
* @param \App\Model\helpdesk\Workflow\WorkflowClose $securitys
*
* @return type view
*/
public function index(WorkflowClose $securitys)
{
try {
$security = $securitys->whereId('1')->first();
return view('themes.default1.admin.helpdesk.settings.close-workflow.index', compact('security'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
/**
* updating the workflow settings for closing ticket.
*
* @param type $id
* @param \App\Http\Requests\helpdesk\WorkflowCloseRequest $request
*
* @return type redirect
*/
public function update($id, WorkflowCloseRequest $request)
{
try {
$security = new WorkflowClose();
$securitys = $security->whereId($id)->first();
$securitys->days = $request->input('days');
$securitys->condition = $request->input('condition');
$securitys->send_email = $request->input('send_email');
$securitys->status = $request->input('status');
$securitys->save();
return \Redirect::back()->with('success', Lang::get('lang.successfully_saved_your_settings'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
}

View File

@@ -22,6 +22,7 @@ use App\User;
// classes
use DB;
use Exception;
use Lang;
/**
* DepartmentController.
@@ -76,7 +77,7 @@ class DepartmentController extends Controller
{
try {
$slas = $sla->get();
$user = $user->where('role', 'agent')->get();
$user = $user->where('role', 'agent2')->get();
$emails = $email->get();
$templates = $template->get();
$department = $department->get();
@@ -84,7 +85,7 @@ class DepartmentController extends Controller
return view('themes.default1.admin.helpdesk.agent.departments.create', compact('department', 'templates', 'slas', 'user', 'emails', 'groups'));
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -99,7 +100,12 @@ class DepartmentController extends Controller
public function store(Department $department, DepartmentRequest $request)
{
try {
$department->fill($request->except('group_id', 'manager'))->save();
$department->fill($request->except('group_id', 'manager', 'sla'))->save();
if ($request->sla) {
$department->sla = $request->input('sla');
} else {
$department->sla = null;
}
$requests = $request->input('group_id');
$id = $department->id;
if ($request->manager) {
@@ -107,18 +113,15 @@ class DepartmentController extends Controller
} 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');
return redirect('departments')->with('success', Lang::get('lang.department_created_sucessfully'));
} else {
return redirect('departments')->with('fails', 'Department can not Create');
return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department'));
}
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department can not Create');
return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department'));
}
}
@@ -140,17 +143,21 @@ class DepartmentController extends Controller
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 {
$sys_department = \DB::table('settings_system')
->select('department')
->where('id', '=', 1)
->first();
$slas = $sla->get();
$user = $user->where('role', 'agent')->get();
$user = $user->where('primary_dpt', $id)->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'));
return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'groups', 'sys_department'));
} catch (Exception $e) {
return view('404');
return redirect('departments')->with('fails', $e->getMessage());
}
}
@@ -168,6 +175,7 @@ class DepartmentController extends Controller
{
// dd($id);
try {
$table = $group_assign_department->where('department_id', $id);
$table->delete();
$requests = $request->input('group_id');
@@ -182,14 +190,25 @@ class DepartmentController extends Controller
$departments->manager = null;
}
$departments->save();
if ($departments->fill($request->except('group_access', 'manager'))->save()) {
return redirect('departments')->with('success', 'Department Updated sucessfully');
if ($request->sla) {
$departments->sla = $request->input('sla');
$departments->save();
} else {
return redirect('departments')->with('fails', 'Department not Updated');
$departments->sla = null;
$departments->save();
}
if ($request->input('sys_department') == 'on') {
DB::table('settings_system')
->where('id', 1)
->update(['department' => $id]);
}
if ($departments->fill($request->except('group_access', 'manager', 'sla'))->save()) {
return redirect('departments')->with('success', Lang::get('lang.department_updated_sucessfully'));
} else {
return redirect('departments')->with('fails', Lang::get('lang.department_not_updated'));
}
} catch (Exception $e) {
return redirect('departments')->with('fails', 'Department not Updated');
return redirect('departments')->with('fails', Lang::get('lang.department_not_updated'));
}
}
@@ -207,7 +226,7 @@ class DepartmentController extends Controller
// try {
$system = $system->where('id', '=', '1')->first();
if ($system->department == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
} else {
$tickets = DB::table('tickets')->where('dept_id', '=', $id)->update(['dept_id' => $system->department]);
if ($tickets > 0) {
@@ -216,7 +235,7 @@ class DepartmentController extends Controller
} else {
$text_tickets = 'Ticket';
}
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default department</li>';
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_department').'</li>';
} else {
$ticket = '';
}
@@ -227,7 +246,7 @@ class DepartmentController extends Controller
} else {
$text_user = 'User';
}
$user = '<li>'.$users.' '.$text_user.' have been moved to default department</li>';
$user = '<li>'.$users.' '.$text_user.Lang::get('lang.have_been_moved_to_default_department').'</li>';
} else {
$user = '';
}
@@ -238,13 +257,13 @@ class DepartmentController extends Controller
} else {
$text_emails = 'Email';
}
$email = '<li>'.$emails.' System '.$text_emails.' have been moved to default department</li>';
$email = '<li>'.$emails.' System '.$text_emails.Lang::get('lang.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>';
$helptopic = '<li>'.Lang::get('lang.the_associated_helptopic_has_been_deactivated').'</li>';
} else {
$helptopic = '';
}
@@ -255,9 +274,9 @@ class DepartmentController extends Controller
$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);
return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully').$message);
} else {
return redirect('departments')->with('fails', 'Department can not Delete');
return redirect('departments')->with('fails', Lang::get('lang.department_can_not_delete'));
}
}
}

View File

@@ -18,6 +18,7 @@ use Crypt;
// classes
use Exception;
use Illuminate\Http\Request;
use Lang;
/**
* ======================================
@@ -27,15 +28,14 @@ use Illuminate\Http\Request;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class EmailsController extends Controller
{
class EmailsController extends Controller {
/**
* Defining constructor variables.
*
* @return type
*/
public function __construct()
{
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
@@ -47,8 +47,7 @@ class EmailsController extends Controller
*
* @return type view
*/
public function index(Emails $email)
{
public function index(Emails $email) {
try {
// fetch all the emails from emails table
$emails = $email->get();
@@ -69,8 +68,7 @@ class EmailsController extends Controller
*
* @return type Response
*/
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
{
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol) {
try {
// fetch all the departments from the department table
$departments = $department->get();
@@ -95,18 +93,16 @@ class EmailsController extends Controller
*
* @return int
*/
public function validatingEmailSettings(Request $request)
{
public function validatingEmailSettings(Request $request) {
$validator = \Validator::make(
[
'email_address' => $request->email_address,
'email_name' => $request->email_name,
'password' => $request->password,
],
[
[
'email_address' => $request->input('email_address'),
'email_name' => $request->input('email_name'),
'password' => $request->input('password'),
], [
'email_address' => 'required|email|unique:emails',
'email_name' => 'required',
'password' => 'required',
'email_name' => 'required',
'password' => 'required',
]
);
if ($validator->fails()) {
@@ -119,32 +115,31 @@ class EmailsController extends Controller
return $return_data;
}
if ($request->validate == 'on') {
if ($request->input('imap_validate') == 'on') {
$validate = '/validate-cert';
} else {
} elseif (!$request->input('imap_validate')) {
$validate = '/novalidate-cert';
}
if ($request->fetching_status == 'on') {
if ($request->input('fetching_status') == 'on') {
$imap_check = $this->getImapStream($request, $validate);
if ($imap_check[0] == 0) {
return 'Incoming email connection failed';
return Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
}
$need_to_check_imap = 1;
} else {
$imap_check = 0;
$need_to_check_imap = 0;
}
if ($request->sending_status == 'on') {
if ($request->input('sending_status') == 'on') {
$smtp_check = $this->getSmtp($request);
if ($smtp_check == 0) {
return 'Outgoing email connection failed';
return Lang::get('lang.outgoing_email_connection_failed');
}
$need_to_check_smtp = 1;
} else {
$smtp_check = 0;
$need_to_check_smtp = 0;
}
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
if ($imap_check != 0 && $smtp_check != 0) {
$this->store($request, $imap_check[1]);
@@ -178,55 +173,69 @@ class EmailsController extends Controller
*
* @return type Redirect
*/
public function store($request, $imap_check)
{
// dd($request);
public function store($request, $imap_check) {
$email = new Emails();
try {
// getConnection($request->input('email_name'), $request->input('email_address'), $request->input('email_address'))
// saving all the fields to the database
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save() == true) {
if ($request->fetching_status == 'on') {
$email->fetching_status = 1;
} else {
$email->fetching_status = 0;
}
if ($request->sending_status == 'on') {
$email->sending_status = 1;
} else {
$email->sending_status = 0;
}
if ($request->auto_response == 'on') {
$email->auto_response = 1;
} else {
$email->auto_response = 0;
}
if ($imap_check !== null) {
$email->fetching_encryption = $imap_check;
} else {
$email->fetching_encryption = $request->fetching_encryption;
}
// fetching department value
$email->department = $this->departmentValue($request->input('department'));
// fetching priority value
$email->priority = $this->priorityValue($request->input('priority'));
// fetching helptopic value
$email->help_topic = $this->helpTopicValue($request->input('help_topic'));
// inserting the encrypted value of password
$email->password = Crypt::encrypt($request->input('password'));
$email->save(); // run save
// Creating a default system email as the first email is inserted to the system
$email_settings = Email::where('id', '=', '1')->first();
$email_settings->sys_email = $email->id;
$email_settings->save();
// returns success message for successful email creation
// return redirect('emails')->with('success', 'Email Created sucessfully');
return 1;
} else {
// returns fail message for unsuccessful save execution
// return redirect('emails')->with('fails', 'Email can not Create');
return 0;
// if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save() == true) {
$email->email_address = $request->email_address;
$email->email_name = $request->email_name;
$email->fetching_host = $request->fetching_host;
$email->fetching_port = $request->fetching_port;
$email->fetching_protocol = $request->fetching_protocol;
$email->sending_host = $request->sending_host;
$email->sending_port = $request->sending_port;
$email->sending_protocol = $request->sending_protocol;
$email->sending_encryption = $request->sending_encryption;
if ($request->smtp_validate == 'on') {
$email->smtp_validate = $request->smtp_validate;
}
if ($request->input('password')) {
$email->password = Crypt::encrypt($request->input('password'));
}
if ($request->input('fetching_status') == 'on') {
$email->fetching_status = 1;
} else {
$email->fetching_status = 0;
}
if ($request->input('sending_status') == 'on') {
$email->sending_status = 1;
} else {
$email->sending_status = 0;
}
if ($request->input('auto_response') == 'on') {
$email->auto_response = 1;
} else {
$email->auto_response = 0;
}
if ($imap_check !== null) {
$email->fetching_encryption = $imap_check;
} else {
$email->fetching_encryption = $request->input('fetching_encryption');
}
// fetching department value
$email->department = $this->departmentValue($request->input('department'));
// fetching priority value
$email->priority = $this->priorityValue($request->input('priority'));
// fetching helptopic value
$email->help_topic = $this->helpTopicValue($request->input('help_topic'));
// inserting the encrypted value of password
$email->password = Crypt::encrypt($request->input('password'));
$email->save(); // run save
// Creating a default system email as the first email is inserted to the system
$email_settings = Email::where('id', '=', '1')->first();
$email_settings->sys_email = $email->id;
$email_settings->save();
// returns success message for successful email creation
// return redirect('emails')->with('success', 'Email Created sucessfully');
return 1;
// } else {
// returns fail message for unsuccessful save execution
// return redirect('emails')->with('fails', 'Email can not Create');
// return 0;
// }
} catch (Exception $e) {
// returns if try fails
// return redirect()->back()->with('fails', $e->getMessage());
@@ -246,13 +255,16 @@ class EmailsController extends Controller
*
* @return type Response
*/
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
{
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol) {
try {
$sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first();
// dd($sys_email);
// fetch the selected emails
$emails = $email->whereId($id)->first();
// get all the departments
$departments = $department->get();
//get count of emails
$count = $email->count();
// get all the helptopic
$helps = $help->get();
// get all the priority
@@ -260,7 +272,7 @@ class EmailsController extends Controller
// get all the mailbox protocols
$mailbox_protocols = $mailbox_protocol->get();
// return if the execution is succeeded
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails'));
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails', 'sys_email'))->with('count', $count);
} catch (Exception $e) {
// return if try fails
return redirect()->back()->with('fails', $e->getMessage());
@@ -274,18 +286,16 @@ class EmailsController extends Controller
*
* @return int
*/
public function validatingEmailSettingsUpdate($id, Request $request)
{
public function validatingEmailSettingsUpdate($id, Request $request) {
$validator = \Validator::make(
[
'email_address' => $request->email_address,
'email_name' => $request->email_name,
'password' => $request->password,
],
[
[
'email_address' => $request->input('email_address'),
'email_name' => $request->input('email_name'),
'password' => $request->input('password'),
], [
'email_address' => 'email',
'email_name' => 'required',
'password' => 'required',
'email_name' => 'required',
'password' => 'required',
]
);
if ($validator->fails()) {
@@ -299,32 +309,31 @@ class EmailsController extends Controller
return $return_data;
}
// return $request;
if ($request->validate == 'on') {
if ($request->input('imap_validate') == 'on') {
$validate = '/validate-cert';
} else {
} elseif (!$request->input('imap_validate')) {
$validate = '/novalidate-cert';
}
if ($request->fetching_status == 'on') {
if ($request->input('fetching_status') == 'on') {
$imap_check = $this->getImapStream($request, $validate);
if ($imap_check[0] == 0) {
return 'Incoming email connection failed';
return Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
}
$need_to_check_imap = 1;
} else {
$imap_check = 0;
$need_to_check_imap = 0;
}
if ($request->sending_status == 'on') {
if ($request->input('sending_status') == 'on') {
$smtp_check = $this->getSmtp($request);
if ($smtp_check == 0) {
return 'Outgoing email connection failed';
return Lang::get('lang.outgoing_email_connection_failed');
}
$need_to_check_smtp = 1;
} else {
$smtp_check = 0;
$need_to_check_smtp = 0;
}
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
if ($imap_check != 0 && $smtp_check != 0) {
$this->update($id, $request, $imap_check[1]);
@@ -359,36 +368,45 @@ class EmailsController extends Controller
*
* @return type Response
*/
public function update($id, $request, $imap_check)
{
// try {
// dd($id);
// dd($request);
// dd($imap_check);
public function update($id, $request, $imap_check) {
try {
// fetch the selected emails
$emails = Emails::whereId($id)->first();
// insert all the requested parameters with except
$emails->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save();
if ($request->fetching_status == 'on') {
$emails->fetching_status = 1;
} else {
$emails->fetching_status = 0;
}
if ($request->sending_status == 'on') {
$emails->sending_status = 1;
} else {
$emails->sending_status = 0;
}
if ($request->auto_response == 'on') {
$emails->auto_response = 1;
} else {
$emails->auto_response = 0;
}
if ($imap_check !== null) {
$emails->fetching_encryption = $imap_check;
} else {
$emails->fetching_encryption = $request->fetching_encryption;
}
$emails->email_address = $request->email_address;
$emails->email_name = $request->email_name;
$emails->fetching_host = $request->fetching_host;
$emails->fetching_port = $request->fetching_port;
$emails->fetching_protocol = $request->fetching_protocol;
$emails->sending_host = $request->sending_host;
$emails->sending_port = $request->sending_port;
$emails->sending_protocol = $request->sending_protocol;
$emails->sending_encryption = $request->sending_encryption;
if ($request->smtp_validate == 'on') {
$emails->smtp_validate = $request->smtp_validate;
}
if ($request->input('fetching_status') == 'on') {
$emails->fetching_status = 1;
} else {
$emails->fetching_status = 0;
}
if ($request->input('sending_status') == 'on') {
$emails->sending_status = 1;
} else {
$emails->sending_status = 0;
}
if ($request->input('auto_response') == 'on') {
$emails->auto_response = 1;
} else {
$emails->auto_response = 0;
}
if ($imap_check !== null) {
$emails->fetching_encryption = $imap_check;
} else {
$emails->fetching_encryption = $request->fetching_encryption;
}
$emails->password = Crypt::encrypt($request->input('password'));
// dd($email->fetching_encryption);
// fetching department value
$emails->department = $this->departmentValue($request->input('department'));
@@ -397,14 +415,25 @@ class EmailsController extends Controller
// fetching helptopic value
$emails->help_topic = $this->helpTopicValue($request->input('help_topic'));
// inserting the encrypted value of password
$emails->password = Crypt::encrypt($request->input('password'));
$emails->save();
// $emails->password = Crypt::encrypt($request->input('password'));
$emails->save();
//dd($request->sys_email);
if($request->sys_email == 'on') {
$system = \DB::table('settings_email')
->where('id', '=', 1)
->update(['sys_email' => $id]);
} elseif ($request->input('count') <= 1 && $request->sys_email == null) {
$system = \DB::table('settings_email')
->where('id', '=', 1)
->update(['sys_email' => null]);
}
// returns success message for successful email update
$return = 1;
// } catch (Exception $e) {
// // returns if try fails
// $return = $e->getMessage();
// }
} catch (Exception $e) {
// // returns if try fails
$return = $e->getMessage();
}
return $return;
}
@@ -416,14 +445,13 @@ class EmailsController extends Controller
*
* @return type Redirect
*/
public function destroy($id, Emails $email)
{
public function destroy($id, Emails $email) {
// fetching the details on the basis of the $id passed to the function
$default_system_email = Email::where('id', '=', '1')->first();
if ($default_system_email->sys_email) {
// checking if the default system email is the passed email
if ($id == $default_system_email->sys_email) {
return redirect('emails')->with('fails', 'You cannot delete system default Email');
return redirect('emails')->with('fails', Lang::get('lang.you_cannot_delete_system_default_email'));
}
}
try {
@@ -431,9 +459,9 @@ class EmailsController extends Controller
$emails = $email->whereId($id)->first();
// checking if deleting the email is success or if it's carrying any dependencies
if ($emails->delete() == true) {
return redirect('emails')->with('success', 'Email Deleted sucessfully');
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
} else {
return redirect('emails')->with('fails', 'Email can not Delete ');
return redirect('emails')->with('fails', Lang::get('lang.email_can_not_delete'));
}
} catch (Exception $e) {
// returns if the try fails
@@ -448,28 +476,26 @@ class EmailsController extends Controller
*
* @return type int
*/
public function getImapStream($request, $validate)
{
public function getImapStream($request, $validate) {
$fetching_status = $request->input('fetching_status');
$username = $request->input('email_address');
$password = $request->input('password');
$protocol_id = $request->input('mailbox_protocol');
$fetching_protocol = '/'.$request->input('fetching_protocol');
$fetching_encryption = '/'.$request->input('fetching_encryption');
$fetching_protocol = '/' . $request->input('fetching_protocol');
$fetching_encryption = '/' . $request->input('fetching_encryption');
if ($fetching_encryption == '/none') {
$fetching_encryption2 = '/novalidate-cert';
$mailbox_protocol = $fetching_encryption2;
$host = $request->input('fetching_host');
$port = $request->input('fetching_port');
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.'}INBOX';
$mailbox = '{' . $host . ':' . $port . $mailbox_protocol . '}INBOX';
} else {
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
$mailbox_protocol = $fetching_protocol . $fetching_encryption;
$host = $request->input('fetching_host');
$port = $request->input('fetching_port');
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.$validate.'}INBOX';
$mailbox_protocol = $fetching_encryption.$validate;
$mailbox = '{' . $host . ':' . $port . $mailbox_protocol . $validate . '}INBOX';
$mailbox_protocol = $fetching_encryption . $validate;
}
try {
$imap_stream = imap_open($mailbox, $username, $password);
} catch (\Exception $ex) {
@@ -492,8 +518,7 @@ class EmailsController extends Controller
*
* @return type int
*/
public function checkImapStream($imap_stream)
{
public function checkImapStream($imap_stream) {
$check_imap_stream = imap_check($imap_stream);
if ($check_imap_stream) {
$imap_stream = 1;
@@ -511,22 +536,43 @@ class EmailsController extends Controller
*
* @return int
*/
public function getSmtp($request)
{
public function getSmtp($request) {
$sending_status = $request->input('sending_status');
$mail = new \PHPMailer();
$mail->isSMTP();
$mail->Host = $request->input('sending_host');
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $request->input('email_address');
$mail->Password = $request->input('password');
$mail->SMTPSecure = $request->input('sending_encryption');
$mail->Port = $request->input('sending_port');
if ($mail->smtpConnect() == true) {
$mail->smtpClose();
// cheking for the sending protocol
if ($request->input('sending_protocol') == 'smtp') {
$mail = new \PHPMailer();
$mail->isSMTP();
$mail->Host = $request->input('sending_host'); // Specify main and backup SMTP servers
//$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $request->input('email_address'); // SMTP username
$mail->Password = $request->input('password'); // SMTP password
$mail->SMTPSecure = $request->input('sending_encryption'); // Enable TLS encryption, `ssl` also accepted
$mail->Port = $request->input('sending_port'); // TCP port to connect to
if (!$request->input('smtp_validate')) {
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
],
];
if ($mail->smtpConnect($mail->SMTPOptions) == true) {
$mail->smtpClose();
$return = 1;
} else {
$return = 0;
}
} else {
if ($mail->smtpConnect()) {
$mail->smtpClose();
$return = 1;
} else {
$return = 0;
}
}
} elseif ($request->input('sending_protocol') == 'mail') {
$return = 1;
} else {
$return = 0;
}
return $return;
@@ -539,8 +585,7 @@ class EmailsController extends Controller
*
* @return type string or null
*/
public function departmentValue($dept)
{
public function departmentValue($dept) {
if ($dept) {
$email_department = $dept;
} else {
@@ -557,8 +602,7 @@ class EmailsController extends Controller
*
* @return type string or null
*/
public function priorityValue($priority)
{
public function priorityValue($priority) {
if ($priority) {
$email_priority = $priority;
} else {
@@ -575,8 +619,7 @@ class EmailsController extends Controller
*
* @return type string or null
*/
public function helpTopicValue($help_topic)
{
public function helpTopicValue($help_topic) {
if ($help_topic) {
$email_help_topic = $help_topic;
} else {
@@ -585,4 +628,5 @@ class EmailsController extends Controller
return $email_help_topic;
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Admin\helpdesk;
// controller
use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Controller;
// request
use Exception;
use Lang;
use File;
/**
* ErrorAndDebuggingController
*
* @author Ladybird <info@ladybirdweb.com>
*/
class ErrorAndDebuggingController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
// $this->smtp();
$this->middleware('auth');
$this->middleware('roles');
}
/**
* function to show error and debugging setting page
* @param void
* @return response
*/
public function showSettings()
{
$debug = \Config::get('app.debug');
$bugsnag = \Config::get('app.bugsnag_reporting');
return view('themes.default1.admin.helpdesk.settings.error-and-logs.error-debug')->with(['debug'=> $debug, 'bugsnag' => $bugsnag]);
}
/**
* funtion to update error and debugging settings
* @param void
* @return
*/
public function postSettings()
{
try{
$debug = \Config::get('app.debug');
$debug = ($debug) ? 'true' : 'false';
$bugsnag_debug = \Config::get('app.bugsnag_reporting');
$bugsnag_debug = ($bugsnag_debug) ? 'true' : 'false';
if ($debug != \Input::get('debug') || $bugsnag_debug != \Input::get('bugsnag')) {
// dd($request->input());
$debug_new = base_path()
.DIRECTORY_SEPARATOR.
'config'
.DIRECTORY_SEPARATOR.
'app.php';
$datacontent = File::get($debug_new);
$datacontent = str_replace("'debug' => ".$debug,
"'debug' => ".\Input::get('debug'),
$datacontent);
File::put($debug_new, $datacontent);
// dd($request->input());
$bugsnag_debug_new = base_path()
.DIRECTORY_SEPARATOR.
'config'
.DIRECTORY_SEPARATOR.
'app.php';
$datacontent2 = File::get($bugsnag_debug_new);
$datacontent2 = str_replace("'bugsnag_reporting' => ".$bugsnag_debug,
"'bugsnag_reporting' => ".\Input::get('bugsnag'),
$datacontent2);
File::put($bugsnag_debug_new, $datacontent2);
return redirect()->back()->with('success',
Lang::get('lang.error-debug-settings-saved-message'));
} else {
return redirect()->back()->with('fails',
Lang::get('lang.error-debug-settings-error-message'));
}
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* function to show error log table page
* @param void
* @return response view
*/
public function showErrorLogs()
{
return view('themes.default1.admin.helpdesk.settings.error-and-logs.log-table');
}
}

View File

@@ -12,6 +12,7 @@ use App\Model\helpdesk\Manage\Help_topic;
use Illuminate\Http\Request;
// Class
use Input;
use Lang;
use Redirect;
/**
@@ -29,7 +30,7 @@ class FormController extends Controller
{
$this->fields = $fields;
$this->forms = $forms;
// $this->middleware('auth');
$this->middleware('auth');
}
/**
@@ -51,21 +52,29 @@ class FormController extends Controller
*/
public function index(Forms $forms)
{
return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms'));
try {
return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* Show the form for creating a new resource.
* create a new form.
*
* @return Response
*/
public function create()
{
return view('themes.default1.admin.helpdesk.manage.form.form');
try {
return view('themes.default1.admin.helpdesk.manage.form.form');
} catch (Exception $ex) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* Display the specified resource.
* Show a new form.
*
* @param int $id
*
@@ -73,18 +82,22 @@ class FormController extends Controller
*/
public function show($id)
{
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('id'));
try {
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('id'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* Store a newly created resource in storage.
* Store a new form.
*
* @return Response
*/
public function store(Forms $forms)
{
if (!Input::get('formname')) {
return Redirect::back()->with('fails', 'Please fill Form name');
return Redirect::back()->with('fails', Lang::get('lang.please_fill_form_name'));
}
$required = Input::get('required');
$count = count($required);
@@ -112,9 +125,19 @@ class FormController extends Controller
}
Fields::insert($fields);
return Redirect::back()->with('success', 'Successfully created Form');
return Redirect::back()->with('success', Lang::get('lang.successfully_created_form'));
}
/**
* Delete Form.
*
* @param type $id
* @param \App\Model\helpdesk\Form\Forms $forms
* @param type $field
* @param type $help_topic
*
* @return type redirect
*/
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic)
{
$fields = $field->where('forms_id', $id)->get();
@@ -129,6 +152,6 @@ class FormController extends Controller
$forms = $forms->where('id', $id)->first();
$forms->delete();
return redirect()->back()->with('success', 'Deleted Successfully');
return redirect()->back()->with('success', Lang::get('lang.form_deleted_successfully'));
}
}

View File

@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Admin\helpdesk;
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\GroupRequest;
use App\Http\Requests\helpdesk\GroupUpdateRequest;
use App\Model\helpdesk\Agent\Department;
// models
use App\Model\helpdesk\Agent\Group_assign_department;
@@ -15,6 +16,7 @@ use Exception;
// classes
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Lang;
/**
* GroupController.
@@ -51,7 +53,7 @@ class GroupController extends Controller
return view('themes.default1.admin.helpdesk.agent.groups.index', compact('departments', 'group_assign_department', 'groups'));
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', Lang::get('lang.failed_to_load_the_page'));
}
}
@@ -65,7 +67,7 @@ class GroupController extends Controller
try {
return view('themes.default1.admin.helpdesk.agent.groups.create');
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', Lang::get('lang.failed_to_load_the_page'));
}
}
@@ -83,10 +85,10 @@ class GroupController extends Controller
/* Check Whether function success or not */
$group->fill($request->input())->save();
return redirect('groups')->with('success', 'Group Created Successfully');
return redirect('groups')->with('success', Lang::get('lang.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>');
return redirect('groups')->with('fails', Lang::get('lang.group_can_not_create').'<li>'.$e->getMessage().'</li>');
}
}
@@ -105,7 +107,7 @@ class GroupController extends Controller
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>');
return redirect('groups')->with('fails', Lang::get('lang.group_can_not_update').'<li>'.$e->getMessage().'</li>');
}
}
@@ -118,56 +120,59 @@ class GroupController extends Controller
*
* @return type Response
*/
public function update($id, Groups $group, Request $request)
public function update($id, Groups $group, GroupUpdateRequest $request)
{
// Database instannce to the current id
$var = $group->whereId($id)->first();
// Updating Name
$var->name = $request->input('name');
//Updating Status
$status = $request->Input('group_status');
$status = $request->input('group_status');
$var->group_status = $status;
//Updating can_create_ticket field
$createTicket = $request->Input('can_create_ticket');
$createTicket = $request->input('can_create_ticket');
$var->can_create_ticket = $createTicket;
//Updating can_edit_ticket field
$editTicket = $request->Input('can_edit_ticket');
$editTicket = $request->input('can_edit_ticket');
$var->can_edit_ticket = $editTicket;
//Updating can_post_ticket field
$postTicket = $request->Input('can_post_ticket');
$postTicket = $request->input('can_post_ticket');
$var->can_post_ticket = $postTicket;
//Updating can_close_ticket field
$closeTicket = $request->Input('can_close_ticket');
$closeTicket = $request->input('can_close_ticket');
$var->can_close_ticket = $closeTicket;
//Updating can_assign_ticket field
$assignTicket = $request->Input('can_assign_ticket');
$assignTicket = $request->input('can_assign_ticket');
$var->can_assign_ticket = $assignTicket;
//Updating can_delete_ticket field
$deleteTicket = $request->Input('can_delete_ticket');
$deleteTicket = $request->input('can_delete_ticket');
$var->can_delete_ticket = $deleteTicket;
//Updating can_ban_email field
$banEmail = $request->Input('can_ban_email');
$banEmail = $request->input('can_ban_email');
$var->can_ban_email = $banEmail;
//Updating can_manage_canned field
$manageCanned = $request->Input('can_manage_canned');
$manageCanned = $request->input('can_manage_canned');
$var->can_manage_canned = $manageCanned;
//Updating can_manage_faq field
$manageFaq = $request->Input('can_manage_faq');
$manageFaq = $request->input('can_manage_faq');
$var->can_manage_faq = $manageFaq;
//Updating can_view_agent_stats field
$viewAgentStats = $request->Input('can_view_agent_stats');
$viewAgentStats = $request->input('can_view_agent_stats');
$var->can_view_agent_stats = $viewAgentStats;
//Updating department_access field
$departmentAccess = $request->Input('department_access');
$departmentAccess = $request->input('department_access');
$var->department_access = $departmentAccess;
//Updating admin_notes field
$adminNotes = $request->Input('admin_notes');
$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');
return redirect('groups')->with('success', Lang::get('lang.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>');
return redirect('groups')->with('fails', Lang::get('lang.group_can_not_update').'<li>'.$e->getMessage().'</li>');
}
}
@@ -184,9 +189,9 @@ class GroupController extends Controller
{
$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>';
$user = '<li>'.Lang::get('lang.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);
return redirect('groups')->with('fails', Lang('lang.group_cannot_delete').$user);
}
$group_assign_department->where('group_id', $id)->delete();
$groups = $group->whereId($id)->first();
@@ -194,10 +199,10 @@ class GroupController extends Controller
try {
$groups->delete();
/* redirect to Index page with Success Message */
return redirect('groups')->with('success', 'Group Deleted Successfully');
return redirect('groups')->with('success', Lang::get('lang.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>');
return redirect('groups')->with('fails', Lang::get('lang.group_cannot_delete').'<li>'.$e->getMessage().'</li>');
}
}
}

View File

@@ -19,6 +19,7 @@ use App\User;
// classes
use DB;
use Exception;
use Lang;
/**
* HelptopicController.
@@ -52,7 +53,7 @@ class HelptopicController extends Controller
return view('themes.default1.admin.helpdesk.manage.helptopic.index', compact('topics'));
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -90,7 +91,7 @@ class HelptopicController extends Controller
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -119,10 +120,10 @@ class HelptopicController extends Controller
$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');
return redirect('helptopic')->with('success', Lang::get('lang.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>');
return redirect('helptopic')->with('fails', Lang::get('lang.helptopic_can_not_create').'<li>'.$e->getMessage().'</li>');
}
}
@@ -148,10 +149,13 @@ class HelptopicController extends Controller
$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'));
$sys_help_topic = \DB::table('settings_ticket')
->select('help_topic')
->where('id', '=', 1)->first();
return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas', 'sys_help_topic'));
} catch (Exception $e) {
return redirect('helptopic')->with('fails', '<li>'.$e->errorInfo[2].'</li>');
return redirect('helptopic')->with('fails', '<li>'.$e->getMessage().'</li>');
}
}
@@ -166,7 +170,6 @@ class HelptopicController extends Controller
*/
public function update($id, Help_topic $topic, HelptopicUpdate $request)
{
// dd($request);
try {
$topics = $topic->whereId($id)->first();
if ($request->custom_form) {
@@ -184,11 +187,16 @@ class HelptopicController extends Controller
$topics->custom_form = $custom_form;
$topics->auto_assign = $auto_assign;
$topics->save();
if ($request->input('sys_help_tpoic') == 'on') {
\DB::table('settings_ticket')
->where('id', '=', 1)
->update(['help_topic' => $id]);
}
/* redirect to Index page with Success Message */
return redirect('helptopic')->with('success', 'Helptopic Updated Successfully');
return redirect('helptopic')->with('success', Lang::get('lang.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>');
return redirect('helptopic')->with('fails', Lang::get('lang.helptopic_can_not_update').'<li>'.$e->getMessage().'</li>');
}
}
@@ -204,45 +212,40 @@ class HelptopicController extends Controller
{
$ticket_settings = $ticket_setting->where('id', '=', '1')->first();
if ($ticket_settings->help_topic == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
} else {
$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>';
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.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]);
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>';
$email = '<li>'.$emails.' System '.$text_emails.Lang::get('lang.have_been_moved_to_default_help_topic').' </li>';
} else {
$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);
return redirect('helptopic')->with('success', Lang::get('lang.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>');
return redirect('helptopic')->with('fails', Lang::get('lang.helptopic_can_not_update').'<li>'.$e->getMessage().'</li>');
}
}
}

View File

@@ -0,0 +1,121 @@
<?php
namespace App\Http\Controllers\Admin\helpdesk;
// Controller
use App\Http\Controllers\Controller;
// Model
use App\Http\Requests\helpdesk\SecurityRequest;
use App\Model\helpdesk\Settings\Security;
// Request
use Illuminate\Http\Request;
// Class
use Input;
use Lang;
use Redirect;
/**
* FormController
* This controller is used to CRUD Custom Security.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class SecurityController extends Controller
{
private $security;
public function __construct(Security $security)
{
$this->security = $security;
}
/**
* list of securitys.
*
* @param type Security $securitys
*
* @return Response
*/
public function index(Security $securitys)
{
try {
$security = $securitys->whereId('1')->first();
return view('themes.default1.admin.helpdesk.settings.security.index', compact('security'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
/**
* Create security setting.
*
* @return Response
*/
public function create()
{
return view('themes.default1.admin.helpdesk.setting.security.security');
}
/**
* Show security.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
return view('themes.default1.admin.helpdesk.setting.security.preview', compact('id'));
}
/**
* Update security details.
*
* @return Response
*/
public function update($id, SecurityRequest $request)
{
try {
$security = new Security();
$securitys = $security->whereId($id)->first();
$securitys->lockout_message = $request->input('lockout_message');
$securitys->backlist_offender = $request->input('backlist_offender');
$securitys->backlist_threshold = $request->input('backlist_threshold');
$securitys->lockout_period = $request->input('lockout_period');
$securitys->days_to_keep_logs = $request->input('days_to_keep_logs');
$securitys->save();
return Redirect::back()->with('success', Lang::get('lang.security_settings_saved_successfully'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
/**
* Delete security details.
*
* @param type $id
* @param \App\Model\helpdesk\Settings\Security $securitys
* @param type $field
* @param \App\Http\Controllers\Admin\helpdesk\Help_topic $help_topic
*
* @return type redirect
*/
public function delete($id, Security $securitys, Fields $field, Help_topic $help_topic)
{
$fields = $field->where('securitys_id', $id)->get();
$help_topics = $help_topic->where('custom_security', '=', $id)->get();
foreach ($help_topics as $help_topic) {
$help_topic->custom_security = null;
$help_topic->save();
}
foreach ($fields as $field) {
$field->delete();
}
$securitys = $securitys->where('id', $id)->first();
$securitys->delete();
return redirect()->back()->with('success', 'Deleted Successfully');
}
}

View File

@@ -7,6 +7,8 @@ use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\CompanyRequest;
use App\Http\Requests\helpdesk\EmailRequest;
use App\Http\Requests\helpdesk\RatingUpdateRequest;
use App\Http\Requests\helpdesk\StatusRequest;
use App\Http\Requests\helpdesk\SystemRequest;
// models
use App\Model\helpdesk\Agent\Department;
@@ -14,7 +16,8 @@ use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Email\Template;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Settings\Access;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Ratings\Rating;
use App\Model\helpdesk\Settings\Alert;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email;
@@ -26,9 +29,11 @@ use App\Model\helpdesk\Utility\Date_format;
use App\Model\helpdesk\Utility\Date_time_format;
use App\Model\helpdesk\Utility\Time_format;
use App\Model\helpdesk\Utility\Timezones;
use DateTime;
// classes
use DB;
use Exception;
use File;
use Illuminate\Http\Request;
use Input;
use Lang;
@@ -52,16 +57,6 @@ class SettingsController extends Controller
$this->middleware('roles');
}
/**
* Main Settings Page.
*
* @return type view
*/
public function settings()
{
return view('themes.default1.admin.helpdesk.setting');
}
/**
* @param int $id
* @param $compant instance of company table
@@ -109,10 +104,10 @@ class SettingsController extends Controller
try {
$companys->fill($request->except('logo'))->save();
/* redirect to Index page with Success Message */
return redirect('getcompany')->with('success', 'Company Updated Successfully');
return redirect('getcompany')->with('success', Lang::get('lang.company_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getcompany')->with('fails', 'Company can not Updated'.'<li>'.$e->getMessage().'</li>');
return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated').'<li>'.$e->getMessage().'</li>');
}
}
@@ -158,6 +153,9 @@ class SettingsController extends Controller
$departments = $department->get();
/* Fetch the values from Timezones table */
$timezones = $timezone->get();
//$debug = \Config::get('app.debug');
//dd($value);
/* Direct to System Settings Page */
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time'));
} catch (Exception $e) {
@@ -184,10 +182,13 @@ class SettingsController extends Controller
/* 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');
// dd($datacontent);
//\Config::set('app.debug', $request->input('debug'));
return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getsystem')->with('fails', 'System can not Updated'.'<li>'.$e->getMessage().'</li>');
return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated').'<br>'.$e->getMessage());
}
}
@@ -245,10 +246,10 @@ class SettingsController extends Controller
/* Check whether function success or not */
$tickets->save();
/* redirect to Index page with Success Message */
return redirect('getticket')->with('success', 'Ticket Updated Successfully');
return redirect('getticket')->with('success', Lang::get('lang.ticket_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getticket')->with('fails', 'Ticket can not Updated'.'<li>'.$e->getMessage().'</li>');
return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated').'<li>'.$e->getMessage().'</li>');
}
}
@@ -303,10 +304,10 @@ class SettingsController extends Controller
/* Check whether function success or not */
$emails->save();
/* redirect to Index page with Success Message */
return redirect('getemail')->with('success', 'Email Updated Successfully');
return redirect('getemail')->with('success', Lang::get('lang.email_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getemail')->with('fails', 'Email can not Updated'.'<li>'.$e->getMessage().'</li>');
return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated').'<li>'.$e->getMessage().'</li>');
}
}
@@ -322,16 +323,15 @@ class SettingsController extends Controller
public function getSchedular(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();
/* 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();
return view('themes.default1.admin.helpdesk.settings.crone', compact('emails', 'templates', 'emails1'));
// } catch {
// }
}
@@ -368,57 +368,6 @@ class SettingsController extends Controller
}
}
/**
* 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');
// }
// }
/**
* 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.
*
@@ -461,10 +410,10 @@ class SettingsController extends Controller
/* Check whether function success or not */
$responders->save();
/* redirect to Index page with Success Message */
return redirect('getresponder')->with('success', 'Responder Updated Successfully');
return redirect('getresponder')->with('success', Lang::get('lang.auto_response_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getresponder')->with('fails', 'Responder can not Updated'.'<li>'.$e->getMessage().'</li>');
return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated').'<li>'.$e->getMessage().'</li>');
}
}
@@ -549,52 +498,13 @@ class SettingsController extends Controller
/* Check whether function success or not */
$alerts->save();
/* redirect to Index page with Success Message */
return redirect('getalert')->with('success', 'Alert Updated Successfully');
return redirect('getalert')->with('success', Lang::get('lang.alert_&_notices_updated_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('getalert')->with('fails', 'Alert can not Updated'.'<li>'.$e->getMessage().'</li>');
return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated').'<li>'.$e->getMessage().'</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(['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');
}
/**
* Generate Api key.
*
@@ -606,4 +516,297 @@ class SettingsController extends Controller
return $key;
}
/**
* Main Settings Page.
*
* @return type view
*/
public function settings()
{
return view('themes.default1.admin.helpdesk.setting');
}
/**
* @param int $id
* @param $compant instance of company table
*
* get the form for company setting page
*
* @return Response
*/
public function getStatuses()
{
try {
/* fetch the values of company from company table */
$statuss = \DB::table('ticket_status')->get();
/* Direct to Company Settings Page */
return view('themes.default1.admin.helpdesk.settings.status', compact('statuss'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* @param int $id
* @param $compant instance of company table
*
* get the form for company setting page
*
* @return Response
*/
public function getEditStatuses($id)
{
try {
/* fetch the values of company from company table */
$status = \DB::table('ticket_status')->where('id', '=', $id)->first();
/* Direct to Company Settings Page */
return view('themes.default1.admin.helpdesk.settings.status-edit', compact('status'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* @param int $id
* @param $compant instance of company table
*
* get the form for company setting page
*
* @return Response
*/
public function editStatuses($id, StatusRequest $request)
{
try {
/* fetch the values of company from company table */
$statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first();
$statuss->name = $request->input('name');
$statuss->icon_class = $request->input('icon_class');
$statuss->email_user = $request->input('email_user');
$statuss->sort = $request->input('sort');
$delete = $request->input('deleted');
if ($delete == 'yes') {
$statuss->state = 'delete';
} else {
$statuss->state = $request->input('state');
}
$statuss->sort = $request->input('sort');
$statuss->save();
/* Direct to Company Settings Page */
return redirect()->back()->with('success', Lang::get('lang.status_has_been_updated_successfully'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* create a status.
*
* @param \App\Model\helpdesk\Ticket\Ticket_Status $statuss
* @param \App\Http\Requests\helpdesk\StatusRequest $request
*
* @return type redirect
*/
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request)
{
try {
/* fetch the values of company from company table */
$statuss->name = $request->input('name');
$statuss->icon_class = $request->input('icon_class');
$statuss->email_user = $request->input('email_user');
$statuss->sort = $request->input('sort');
$delete = $request->input('delete');
if ($delete == 'yes') {
$statuss->state = 'deleted';
} else {
$statuss->state = $request->input('state');
}
$statuss->sort = $request->input('sort');
$statuss->save();
/* Direct to Company Settings Page */
return redirect()->back()->with('success', Lang::get('lang.status_has_been_created_successfully'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
/**
* delete a status.
*
* @param type $id
*
* @return type redirect
*/
public function deleteStatuses($id)
{
try {
if ($id > 5) {
/* fetch the values of company from company table */
\App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->delete();
/* Direct to Company Settings Page */
return redirect()->back()->with('success', Lang::get('lang.status_has_been_deleted'));
} else {
return redirect()->back()->with('failed', Lang::get('lang.you_cannot_delete_this_status'));
}
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
/**
* get the page of notification settings.
*
* @return type view
*/
public function notificationSettings()
{
return view('themes.default1.admin.helpdesk.settings.notification');
}
/**
* delete a notification.
*
* @return type redirect
*/
public function deleteReadNoti()
{
$markasread = UserNotification::where('is_read', '=', 1)->get();
foreach ($markasread as $mark) {
$mark->delete();
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
}
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_read_notifications'));
}
/**
* delete a notification log.
*
* @return type redirect
*/
public function deleteNotificationLog()
{
$days = Input::get('no_of_days');
if ($days == null) {
return redirect()->back()->with('fails', 'Please enter valid no of days');
}
$date = new DateTime();
$date->modify($days.' day');
$formatted_date = $date->format('Y-m-d H:i:s');
$markasread = UserNotification::where('created_at', '<=', $formatted_date)->get();
foreach ($markasread as $mark) {
$mark->delete();
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
}
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_notification_records_since').$days.' days.');
}
/**
* To display the list of ratings in the system.
*
* @return type View
*/
public function RatingSettings()
{
try {
$ratings = Rating::orderBy('display_order', 'asc')->get();
return view('themes.default1.admin.helpdesk.settings.ratings', compact('ratings'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
/**
* edit a rating.
*
* @param type $id
*
* @return type view
*/
public function editRatingSettings($id)
{
try {
$rating = Rating::whereId($id)->first();
return view('themes.default1.admin.helpdesk.settings.edit-ratings', compact('rating'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
/**
* To store rating data.
*
* @return type Redirect
*/
public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request)
{
try {
$rating = $ratings->whereId($id)->first();
$rating->name = $request->input('name');
$rating->display_order = $request->input('display_order');
$rating->allow_modification = $request->input('allow_modification');
$rating->rating_scale = $request->input('rating_scale');
// $rating->rating_area = $request->input('rating_area');
$rating->restrict = $request->input('restrict');
$rating->save();
return redirect()->back()->with('success', Lang::get('lang.ratings_updated_successfully'));
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
/**
* get the create rating page.
*
* @return type redirect
*/
public function createRating()
{
try {
return view('themes.default1.admin.helpdesk.settings.create-ratings');
} catch (Exception $ex) {
return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created').'<li>'.$ex->getMessage().'</li>');
}
}
/**
* store a rating value.
*
* @param \App\Model\helpdesk\Ratings\Rating $rating
* @param \App\Model\helpdesk\Ratings\RatingRef $ratingrefs
* @param \App\Http\Requests\helpdesk\RatingRequest $request
*
* @return type redirect
*/
public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request)
{
$rating->name = $request->input('name');
$rating->display_order = $request->input('display_order');
$rating->allow_modification = $request->input('allow_modification');
$rating->rating_scale = $request->input('rating_scale');
$rating->rating_area = $request->input('rating_area');
$rating->restrict = $request->input('restrict');
$rating->save();
$ratingrefs->rating_id = $rating->id;
$ratingrefs->save();
return redirect()->back()->with('success', Lang::get('lang.successfully_created_this_rating'));
}
/**
* To delete a type of rating.
*
* @return type Redirect
*/
public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs)
{
$ratingrefs->where('rating_id', '=', $slug)->delete();
Rating::whereId($slug)->delete();
return redirect()->back()->with('success', Lang::get('lang.rating_deleted_successfully'));
}
}

View File

@@ -0,0 +1,743 @@
<?php
namespace App\Http\Controllers\Admin\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\CompanyRequest;
use App\Http\Requests\helpdesk\EmailRequest;
use App\Http\Requests\helpdesk\SystemRequest;
// models
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Email\Template;
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Settings\Access;
use App\Model\helpdesk\Settings\Alert;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Settings\Responder;
use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Ticket;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Utility\Date_format;
use App\Model\helpdesk\Utility\Date_time_format;
use App\Model\helpdesk\Utility\Time_format;
use App\Model\helpdesk\Utility\Timezones;
use DateTime;
// classes
use DB;
use Exception;
use Illuminate\Http\Request;
use Input;
use Lang;
/**
* SettingsController.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class SettingsController2 extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
// $this->smtp();
$this->middleware('auth');
$this->middleware('roles');
}
/**
* Main Settings Page.
*
* @return type view
*/
public function settings()
{
return view('themes.default1.admin.helpdesk.setting');
}
public function notificationSettings()
{
return view('themes.default1.admin.helpdesk.settings.notification');
}
public function deleteReadNoti()
{
$markasread = UserNotification::where('is_read', '=', 1)->get();
foreach ($markasread as $mark) {
$mark->delete();
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
}
return redirect()->back()->with('success', 'You have deleted all the read notifications');
}
public function deleteNotificationLog()
{
$days = Input::get('no_of_days');
$date = new DateTime();
$date->modify($days.' day');
$formatted_date = $date->format('Y-m-d H:i:s');
$markasread = DB::table('user_notification')->where('created_at', '<=', $formatted_date)->get();
foreach ($markasread as $mark) {
$mark->delete();
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
}
return redirect()->back()->with('success', 'You have deleted all the notification records since '.$days.' days.');
}
/**
* @param int $id
* @param $compant instance of company table
*
* get the form for company setting page
*
* @return Response
*/
public function getStatuses()
{
try {
/* fetch the values of company from company table */
$statuss = \DB::table('ticket_status')->get();
/* Direct to Company Settings Page */
return view('themes.default1.admin.helpdesk.settings.status', compact('statuss'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* @param int $id
* @param $compant instance of company table
*
* get the form for company setting page
*
* @return Response
*/
public function editStatuses($id)
{
try {
/* fetch the values of company from company table */
$statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first();
$statuss->name = Input::get('name');
$statuss->icon_class = Input::get('icon_class');
$statuss->email_user = Input::get('email_user');
$statuss->sort = Input::get('sort');
$delete = Input::get('delete');
if ($delete == 'yes') {
$statuss->state = 'delete';
} else {
$statuss->state = Input::get('state');
}
$statuss->sort = Input::get('sort');
$statuss->save();
/* Direct to Company Settings Page */
return redirect()->back()->with('success', 'Status has been updated!');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss)
{
// try {
/* fetch the values of company from company table */
$statuss->name = Input::get('name');
$statuss->icon_class = Input::get('icon_class');
$statuss->email_user = Input::get('email_user');
$statuss->sort = Input::get('sort');
$delete = Input::get('delete');
if ($delete == 'yes') {
$statuss->state = 'delete';
} else {
$statuss->state = Input::get('state');
}
$statuss->sort = Input::get('sort');
$statuss->save();
/* Direct to Company Settings Page */
return redirect()->back()->with('success', 'Status has been created!');
// } catch (Exception $ex) {
// return redirect()->back()->with('fails', $ex->errorInfo[2]);
// }
}
public function deleteStatuses($id)
{
try {
if ($id > 5) {
/* fetch the values of company from company table */
\App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->delete();
/* Direct to Company Settings Page */
return redirect()->back()->with('success', 'Status has been deleted');
} else {
return redirect()->back()->with('failed', 'You cannot delete this status');
}
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
}
/**
* @param int $id
* @param $compant instance of company table
*
* get the form for company setting page
*
* @return Response
*/
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->getMessage());
}
}
/**
* 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->getMessage().'</li>');
}
}
/**
* function to delete system logo.
*
* @return type string
*/
public function deleteLogo()
{
$path = $_GET['data1']; //get file path of logo image
if (!unlink($path)) {
return 'false';
} else {
$companys = Company::where('id', '=', 1)->first();
$companys->logo = null;
$companys->use_logo = '0';
$companys->save();
return 'true';
}
// return $res;
}
/**
* 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->getMessage());
}
}
/**
* 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->getMessage().'</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->getMessage());
}
}
/**
* 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->getMessage().'</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->getMessage());
}
}
/**
* 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->getMessage().'</li>');
}
}
/**
* get the form for cron job setting page.
*
* @param type Email $email
* @param type Template $template
* @param type Emails $email1
*
* @return type Response
*/
public function getSchedular(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();
return view('themes.default1.admin.helpdesk.settings.crone', compact('emails', 'templates', 'emails1'));
// } catch {
// }
}
/**
* Update the specified resource in storage for cron job.
*
* @param type Email $email
* @param type EmailRequest $request
*
* @return type Response
*/
public function postSchedular(Email $email, Template $template, Emails $email1, Request $request)
{
// dd($request);
try {
/* fetch the values of email request */
$emails = $email->whereId('1')->first();
if ($request->email_fetching) {
$emails->email_fetching = $request->email_fetching;
} else {
$emails->email_fetching = 0;
}
if ($request->notification_cron) {
$emails->notification_cron = $request->notification_cron;
} else {
$emails->notification_cron = 0;
}
$emails->save();
/* redirect to Index page with Success Message */
return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error').'<li>'.$e->getMessage().'</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');
// }
// }
/**
* 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->getMessage());
}
}
/**
* 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->getMessage().'</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->getMessage());
}
}
/**
* 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->getMessage().'</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(['rating_name' => $name, 'publish' => $publish, 'modify' => $modify]);
return redirect()->back()->with('success', 'Successfully updated');
}
public function createRating()
{
$name = Input::get('rating_name');
$publish = Input::get('publish');
$modify = Input::get('modify');
DB::table('settings_ratings')->insert(['rating_name' => $name, 'publish' => $publish, 'modify' => $modify]);
return redirect()->back()->with('success', 'Successfully created this rating');
}
/**
* 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');
}
/**
* Generate Api key.
*
* @return type json
*/
public function generateApiKey()
{
$key = str_random(32);
return $key;
}
}

View File

@@ -13,6 +13,7 @@ use App\Model\helpdesk\Settings\Ticket;
//classes
use DB;
use Exception;
use Lang;
/**
* SlaController.
@@ -47,7 +48,7 @@ class SlaController extends Controller
/* 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]);
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -62,7 +63,7 @@ class SlaController extends Controller
/* Direct to Create Page */
return view('themes.default1.admin.helpdesk.manage.sla.create');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -81,10 +82,10 @@ class SlaController extends Controller
/* 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');
return redirect('sla')->with('success', Lang::get('lang.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>');
return redirect('sla')->with('fails', Lang::get('lang.sla_plan_can_not_create').'<li>'.$e->getMessage().'</li>');
}
}
@@ -96,16 +97,16 @@ class SlaController extends Controller
*
* @return type Response
*/
public function edit($id, Sla_plan $sla)
public function edit($id)
{
try {
/* Direct to edit page along values of perticular field using Id */
$slas = $sla->whereId($id)->first();
$slas = Sla_plan::whereId($id)->first();
$slas->get();
return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas'));
$sla = \DB::table('settings_ticket')->select('sla')->where('id', '=', 1)->first();
return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas','sla'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -118,11 +119,11 @@ class SlaController extends Controller
*
* @return type Response
*/
public function update($id, Sla_plan $sla, SlaUpdate $request)
public function update($id, SlaUpdate $request)
{
try {
/* Fill values to selected field using Id except Check box */
$slas = $sla->whereId($id)->first();
$slas = Sla_plan::whereId($id)->first();
$slas->fill($request->except('transient', 'ticket_overdue'))->save();
/* Update transient checkox field */
$slas->transient = $request->input('transient');
@@ -131,10 +132,15 @@ class SlaController extends Controller
/* Check whether function success or not */
$slas->save();
/* redirect to Index page with Success Message */
return redirect('sla')->with('success', 'SLA Plan Updated Successfully');
if ($request->input('sys_sla') == 'on') {
\DB::table('settings_ticket')
->where('id', '=', 1)
->update(['sla' => $id]);
}
return redirect('sla')->with('success', Lang::get('lang.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>');
return redirect('sla')->with('fails', Lang::get('lang.sla_plan_can_not_update').'<li>'.$e->getMessage().'</li>');
}
}
@@ -146,11 +152,11 @@ class SlaController extends Controller
*
* @return type Response
*/
public function destroy($id, Sla_plan $sla)
public function destroy($id)
{
$default_sla = Ticket::where('id', '=', '1')->first();
if ($default_sla->sla == $id) {
return redirect('departments')->with('fails', 'You cannot delete default department');
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
} else {
$tickets = DB::table('tickets')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]);
if ($tickets > 0) {
@@ -159,7 +165,7 @@ class SlaController extends Controller
} else {
$text_tickets = 'Ticket';
}
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default SLA</li>';
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_sla').'</li>';
} else {
$ticket = '';
}
@@ -170,7 +176,7 @@ class SlaController extends Controller
} else {
$text_dept = 'Email';
}
$dept = '<li>Associated department have been moved to default SLA</li>';
$dept = '<li>'.Lang::get('lang.associated_department_have_been_moved_to_default_sla').'</li>';
} else {
$dept = '';
}
@@ -181,21 +187,21 @@ class SlaController extends Controller
} else {
$text_topic = 'Email';
}
$topic = '<li>Associated Help Topic have been moved to default SLA</li>';
$topic = '<li>'.Lang::get('lang.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();
$slas = Sla_plan::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);
return redirect('sla')->with('success', Lang::get('lang.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>');
return redirect('sla')->with('fails', Lang::get('lang.sla_plan_can_not_delete').'<li>'.$e->getMessage().'</li>');
}
}
}

View File

@@ -14,6 +14,7 @@ use App\User;
// classes
use DB;
use Exception;
use Lang;
/**
* TeamController.
@@ -51,7 +52,7 @@ class TeamController extends Controller
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]);
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -69,7 +70,7 @@ class TeamController extends Controller
return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -93,10 +94,10 @@ class TeamController extends Controller
/* 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');
return redirect('teams')->with('success', Lang::get('lang.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>');
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_create').'<li>'.$e->getMessage().'</li>');
}
}
@@ -120,7 +121,7 @@ class TeamController extends Controller
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]);
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -153,10 +154,10 @@ class TeamController extends Controller
try {
$teams->fill($request->except('team_lead'))->save();
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Updated Successfully');
return redirect('teams')->with('success', Lang::get('lang.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>');
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_update').'<li>'.$e->getMessage().'</li>');
}
}
@@ -178,10 +179,10 @@ class TeamController extends Controller
/* Check whether function success or not */
$teams->delete();
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', 'Teams Deleted Successfully');
return redirect('teams')->with('success', Lang::get('lang.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>');
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_delete').'<li>'.$e->getMessage().'</li>');
}
}
}

View File

@@ -4,9 +4,9 @@ namespace App\Http\Controllers\Admin\helpdesk;
// controllers
use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\DiagnosRequest;
use App\Http\Requests\helpdesk\TemplateRequest;
use App\Http\Requests\helpdesk\TemplateUdate;
// models
@@ -17,24 +17,22 @@ use App\Model\helpdesk\Utility\Languages;
use Exception;
use Illuminate\Http\Request;
use Input;
use Mail;
use Lang;
/**
* TemplateController.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class TemplateController extends Controller
{
class TemplateController extends Controller {
/**
* Create a new controller instance.
*
* @return type void
*/
public function __construct(PhpMailController $PhpMailController)
{
public function __construct(PhpMailController $PhpMailController) {
$this->PhpMailController = $PhpMailController;
SettingsController::smtp();
$this->middleware('auth');
$this->middleware('roles');
}
@@ -46,14 +44,13 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function index(Template $template)
{
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');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -65,8 +62,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function create(Languages $language, Template $template)
{
public function create(Languages $language, Template $template) {
try {
$templates = $template->get();
$languages = $language->get();
@@ -85,8 +81,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function store(Template $template, TemplateRequest $request)
{
public function store(Template $template, TemplateRequest $request) {
try {
/* Check whether function success or not */
if ($template->fill($request->input())->save() == true) {
@@ -109,8 +104,7 @@ class TemplateController extends Controller
*
* @return Response
*/
public function show($id)
{
public function show($id) {
//
}
@@ -123,41 +117,37 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function listdirectories()
{
$path = \Config::get('view.paths')[0].'/emails/';
public function listdirectories() {
$path = \Config::get('view.paths')[0] . '/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)
{
public function listtemplates($template, $path) {
$paths = str_replace('-', '/', $path);
$directory2 = $paths.$template;
$directory2 = $paths . $template;
$templates = scandir($directory2);
$directory = str_replace('/', '-', $directory2.'/');
$directory = str_replace('/', '-', $directory2 . '/');
return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates', 'directory'));
}
public function readtemplate($template, $path)
{
public function readtemplate($template, $path) {
$directory = str_replace('-', '/', $path);
$handle = fopen($directory.$template, 'r');
$contents = fread($handle, filesize($directory.$template));
$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()
{
public function createtemplate() {
$directory = '../resources/views/emails/';
$fname = Input::get('folder_name');
$filename = $directory.$fname;
$filename = $directory . $fname;
// images folder creation using php
// $mydir = dirname( __FILE__ )."/html/images";
@@ -169,7 +159,7 @@ class TemplateController extends Controller
if (!file_exists($filename)) {
mkdir($filename, 0777);
}
$files = array_filter(scandir($directory.'default'));
$files = array_filter(scandir($directory . 'default'));
foreach ($files as $file) {
if ($file === '.' or $file === '..') {
@@ -177,29 +167,27 @@ class TemplateController extends Controller
}
if (!is_dir($file)) {
// $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file);
$destination = $directory.$fname.'/';
$destination = $directory . $fname . '/';
copy($directory.'default/'.$file, $destination.$file);
copy($directory . 'default/' . $file, $destination . $file);
}
}
return \Redirect::back()->with('success', 'Successfully copied');
}
public function writetemplate($template, $path)
{
public function writetemplate($template, $path) {
$directory = str_replace('-', '/', $path);
$b = Input::get('templatedata');
file_put_contents($directory.$template, print_r($b, true));
file_put_contents($directory . $template, print_r($b, true));
return \Redirect::back()->with('success', 'Successfully updated');
}
public function deletetemplate($template, $path)
{
public function deletetemplate($template, $path) {
$directory = str_replace('-', '/', $path);
$dir = $directory.$template;
$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!');
@@ -208,7 +196,7 @@ class TemplateController extends Controller
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != '.' && $object != '..') {
unlink($dir.'/'.$object);
unlink($dir . '/' . $object);
}
}
rmdir($dir);
@@ -219,15 +207,13 @@ class TemplateController extends Controller
return \Redirect::back()->with('success', 'Successfully Deleted');
}
public function activateset($setname)
{
public function activateset($setname) {
\DB::table('settings_email')->update(['template' => $setname]);
return \Redirect::back()->with('success', 'You have Successfully Activated this Set');
}
public function edit($id, Template $template, Languages $language)
{
public function edit($id, Template $template, Languages $language) {
try {
$templates = $template->whereId($id)->first();
$languages = $language->get();
@@ -247,8 +233,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function update($id, Template $template, TemplateUdate $request)
{
public function update($id, Template $template, TemplateUdate $request) {
try {
//TODO validation
$templates = $template->whereId($id)->first();
@@ -274,8 +259,7 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function destroy($id, Template $template)
{
public function destroy($id, Template $template) {
try {
$templates = $template->whereId($id)->first();
/* Check whether function success or not */
@@ -299,14 +283,13 @@ class TemplateController extends Controller
*
* @return type Response
*/
public function formDiagno(Emails $email)
{
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');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -317,19 +300,56 @@ class TemplateController extends Controller
*
* @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 = $this->PhpMailController->mailfrom('1', '0'), $to = ['email' => $email], $message = ['subject' => 'Checking the connection', 'scenario' => 'error-report', 'content' => 'Email Received Successfully'], $template_variables = ['system_error' => 'Email Received Successfully']);
if ($mail == null) {
return redirect('getdiagno')->with('fails', 'Please check your E-mail settings. Unable to send mails');
} else {
return redirect('getdiagno')->with('success', 'Please check your mail. An E-mail has been sent to your E-mail address');
public function postDiagno(DiagnosRequest $request) {
try {
$email_details = Emails::where('id', '=', $request->from)->first();
if ($email_details->sending_protocol == 'mail') {
$mail = new \PHPMailer(); // defaults to using php "mail()"
$mail->IsSendmail(); // telling the class to use SendMail transport
$mail->SetFrom($email_details->email_address, $email_details->email_name); // sender details
$address = $request->to; // receiver email
$mail->AddAddress($address);
$mail->Subject = $request->subject; // subject of the email
$body = $request->message; // body of the email
$mail->MsgHTML($body);
if (!$mail->Send()) {
$return = Lang::get('lang.mailer_error') . ': ' . $mail->ErrorInfo;
} else {
$return = Lang::get('lang.message_has_been_sent');
}
} elseif ($email_details->sending_protocol == 'smtp') {
$mail = new \PHPMailer();
$mail->isSMTP(); // Set mailer to use SMTP
if ($email_details->smtp_validate == '1') {
$mail->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
],
];
}
$mail->Host = $email_details->sending_host; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $email_details->email_address; // SMTP username
$mail->Password = \Crypt::decrypt($email_details->password); // SMTP password
$mail->SMTPSecure = $email_details->sending_encryption; // Enable TLS encryption, `ssl` also accepted
$mail->Port = $email_details->sending_port; // TCP port to connect to
$mail->setFrom($email_details->email_address, $email_details->email_name);
$mail->addAddress($request->to, ''); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $request->subject;
$mail->Body = utf8_decode($request->message);
if (!$mail->send()) {
$return = Lang::get('lang.mailer_error') . ': ' . $mail->ErrorInfo;
} else {
$return = Lang::get('lang.message_has_been_sent');
}
}
return redirect()->back()->with('success', $return);
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
}

View File

@@ -24,6 +24,7 @@ use Datatable;
//classes
use Exception;
use Illuminate\Http\Request;
use Lang;
/**
* WorkflowController
@@ -60,7 +61,7 @@ class WorkflowController extends Controller
try {
return view('themes.default1.admin.helpdesk.manage.workflow.index');
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -143,18 +144,14 @@ class WorkflowController extends Controller
*/
public function create(Emails $emails)
{
// dd($emails);
foreach ($emails->lists('email_address', 'id') as $key => $email) {
$email_data["E-$key"] = $email;
}
// dd($email_data);
// dd($emails->lists('email_address' , 'id'));
$emails = $email_data;
try {
// $emails = $emails->get();
return view('themes.default1.admin.helpdesk.manage.workflow.create', compact('emails'));
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -167,10 +164,9 @@ class WorkflowController extends Controller
*/
public function store(WorkflowCreateRequest $request)
{
//dd($request);
try {
// store a new workflow credentials in to the system
$workflow_name = new WorkflowName();
$workflow_name = new WorkflowName;
$workflow_name->name = $request->name;
$workflow_name->status = $request->status;
$workflow_name->order = $request->execution_order;
@@ -198,7 +194,7 @@ class WorkflowController extends Controller
$workflow_action->save();
}
return redirect('workflow')->with('success', 'Workflow Created Successfully');
return redirect('workflow')->with('success', Lang::get('lang.workflow_created_successfully'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
@@ -222,7 +218,7 @@ class WorkflowController extends Controller
return view('themes.default1.admin.helpdesk.manage.workflow.edit', compact('id', 'workflow', 'emails', 'workflow_rules', 'workflow_actions'));
} catch (Exception $e) {
return view('404');
return redirect()->back()->with('fails', $e->getMessage());
}
}
@@ -269,7 +265,7 @@ class WorkflowController extends Controller
$workflow_action->save();
}
return redirect('workflow')->with('success', 'Workflow Updated Successfully');
return redirect('workflow')->with('success', Lang::get('lang.workflow_updated_successfully'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
@@ -288,7 +284,7 @@ class WorkflowController extends Controller
$workflow_rules = WorkflowRules::where('workflow_id', '=', $id)->delete();
$workflow = WorkflowName::whereId($id)->delete();
return redirect('workflow')->with('success', 'Workflow Deleted Successfully');
return redirect('workflow')->with('success', Lang::get('lang.workflow_deleted_successfully'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}