update v 1.0.7.5
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user