Apply fixes from StyleCI

This commit is contained in:
Manish Verma
2016-12-13 13:14:54 +00:00
committed by StyleCI Bot
parent 857d3004eb
commit 88f3df2180
161 changed files with 4729 additions and 3879 deletions

View File

@@ -3,49 +3,44 @@
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Controller;
// requests
/* Include Sys_user Model */
use App\Http\Requests\helpdesk\ProfilePassword;
/* For validation include Sys_userRequest in create */
use App\Http\Requests\helpdesk\ProfileRequest;
/* For validation include Sys_userUpdate in update */
use App\Http\Requests\helpdesk\Sys_userRequest;
/* include guest_note model */
use App\Http\Requests\helpdesk\Sys_userUpdate;
use App\Http\Requests\helpdesk\OtpVerifyRequest;
// change password request
use App\Http\Requests\helpdesk\ChangepasswordRequest;
/* For validation include Sys_userRequest in create */
use App\Http\Requests\helpdesk\OtpVerifyRequest;
/* For validation include Sys_userUpdate in update */
use App\Http\Requests\helpdesk\ProfilePassword;
/* include guest_note model */
use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\Sys_userRequest;
// change password request
use App\Http\Requests\helpdesk\Sys_userUpdate;
// models
use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Agent_panel\Organization;
use App\Model\helpdesk\Agent_panel\User_org;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Utility\CountryCode;
use App\Model\helpdesk\Utility\Otp;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\User;
// classes
use Auth;
use DateTime;
use DB;
use Exception;
use GeoIP;
use Hash;
use Illuminate\Http\Request;
use Input;
use Lang;
use Redirect;
use Illuminate\Http\Request;
use DateTime;
use DB;
/**
* UserController
@@ -53,8 +48,8 @@ use DB;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class UserController extends Controller {
class UserController extends Controller
{
/**
* Create a new controller instance.
* constructor to check
@@ -64,7 +59,8 @@ class UserController extends Controller {
*
* @return void
*/
public function __construct(PhpMailController $PhpMailController) {
public function __construct(PhpMailController $PhpMailController)
{
$this->PhpMailController = $PhpMailController;
// checking authentication
$this->middleware('auth');
@@ -79,7 +75,8 @@ class UserController extends Controller {
*
* @return type view
*/
public function index() {
public function index()
{
try {
/* get all values in Sys_user */
@@ -93,13 +90,15 @@ class UserController extends Controller {
Lang::get('lang.role'),
Lang::get('lang.action')) // these are the column headings to be shown
->noScript();
return view('themes.default1.agent.helpdesk.user.index',compact('table'));
return view('themes.default1.agent.helpdesk.user.index', compact('table'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
}
public function deletedUser() {
public function deletedUser()
{
try {
// dd('here');
/* get all values in Sys_user */
@@ -109,30 +108,20 @@ class UserController extends Controller {
}
}
/**
* This function is used to display the list of users using chumper datatables.
*
* @return datatable
*/
public function user_list(Request $request) {
$type = $request->input('profiletype');
if($type=="active"){
$users=User::where('role', "!=", "admin")->where('is_delete','=',0)->get();
}
else{
$users=User::where('role', "!=", "admin")->where('is_delete','=',1)->get();
}
public function user_list(Request $request)
{
$type = $request->input('profiletype');
if ($type == 'active') {
$users = User::where('role', '!=', 'admin')->where('is_delete', '=', 0)->get();
} else {
$users = User::where('role', '!=', 'admin')->where('is_delete', '=', 1)->get();
}
// displaying list of users with chumper datatables
// return \Datatable::collection(User::where('role', "!=", "admin")->get())
@@ -144,7 +133,7 @@ else{
/* column username */
->addColumn('user_name', function ($model) {
if ($model->first_name) {
$string = strip_tags($model->first_name . ' ' . $model->last_name);
$string = strip_tags($model->first_name.' '.$model->last_name);
} else {
$string = strip_tags($model->user_name);
}
@@ -154,11 +143,12 @@ else{
} else {
$stringCut = $string;
}
return "<a href='" . route('user.show', $model->id) . "' title='".$string."''>".$stringCut."</a>";
return "<a href='".route('user.show', $model->id)."' title='".$string."''>".$stringCut.'</a>';
})
/* column email */
->addColumn('email', function ($model) {
$email = "<a href='" . route('user.show', $model->id) . "'>" . $model->email . '</a>';
$email = "<a href='".route('user.show', $model->id)."'>".$model->email.'</a>';
return $email;
})
@@ -166,13 +156,13 @@ else{
->addColumn('phone', function ($model) {
$phone = '';
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
$phone = $model->ext.' '.$model->phone_number;
}
$mobile = '';
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . '&nbsp;&nbsp;&nbsp;' . $mobile;
$phone = $phone.'&nbsp;&nbsp;&nbsp;'.$mobile;
return $phone;
})
@@ -207,46 +197,42 @@ else{
/* column Role */
->addColumn('role', function ($model) {
$role = $model->role;
return $role;
})
/* column actions */
->addColumn('Actions', function ($model) {
if($model->is_delete==0){
return '<a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp; <a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
if ($model->is_delete == 0) {
return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a>&nbsp; <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
} else {
if (Auth::user()->role == 'admin') {
// @if(Auth::user()->role == 'admin')
return '<a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
}
if (Auth::user()->role == 'agent') {
// @if(Auth::user()->role == 'admin')
if ($model->role == 'user') {
return '<a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
}
}
}
else{
if(Auth::user()->role == 'admin'){
// @if(Auth::user()->role == 'admin')
return '<a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
}
if(Auth::user()->role == 'agent'){
// @if(Auth::user()->role == 'admin')
if($model->role=="user"){
return '<a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
}
}
}
})
->make();
}
public function restoreUser($id)
public function restoreUser($id)
{
// dd($id);
// $delete_all = Input::get('delete_all');
$users = User::where('id', '=', $id)->first();
$users->is_delete=0;
$users->active=1;
$users->ban=0;
$users->is_delete = 0;
$users->active = 1;
$users->ban = 0;
$users->save();
return redirect('user')->with('success', Lang::get('lang.user_restore_successfully'));
return redirect('user')->with('success', Lang::get('lang.user_restore_successfully'));
}
/**
@@ -254,13 +240,15 @@ else{
*
* @return type view
*/
public function create(CountryCode $code) {
public function create(CountryCode $code)
{
try {
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
$location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
$org = Organization::lists('name', 'id')->toArray();
return view('themes.default1.agent.helpdesk.user.create', compact('org', 'settings', 'email_mandatory'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
@@ -275,7 +263,8 @@ else{
*
* @return type redirect
*/
public function store(User $user, Sys_userRequest $request) {
public function store(User $user, Sys_userRequest $request)
{
/* insert the input request to sys_user table */
/* Check whether function success or not */
if ($request->input('email') != '') {
@@ -310,9 +299,9 @@ else{
}
// save user credentails
if ($user->save() == true) {
if ($request->input('org_id') != "") {
if ($request->input('org_id') != '') {
$orgid = $request->input('org_id');
$this->storeUserOrgRelation($user->id, $orgid);
$this->storeUserOrgRelation($user->id, $orgid);
}
// fetch user credentails to send mail
$name = $user->first_name;
@@ -332,6 +321,7 @@ else{
if (($request->input('active') == '0' || $request->input('active') == 0) || ($email_mandatory->status == '0') || $email_mandatory->status == 0) {
\Event::fire(new \App\Events\LoginEvent($request));
}
return redirect('user')->with('success', Lang::get('lang.User-Created-Successfully'));
}
// $user->save();
@@ -344,17 +334,18 @@ else{
}
/**
* Random Password Genetor for users
* Random Password Genetor for users.
*
* @param type int $id
* @param type User $user
*
* @return type view
*/
public function randomPassword() {
public function randomPassword()
{
try {
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*(){}[]';
$pass = array(); //remember to declare $pass as an array
$pass = []; //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 10; $i++) {
$n = rand(0, $alphaLength);
@@ -369,14 +360,15 @@ else{
}
/**
* Random Password Genetor for users
* Random Password Genetor for users.
*
* @param type int $id
* @param type User $user
*
* @return type view
*/
public function randomPostPassword($id, ChangepasswordRequest $request) {
public function randomPostPassword($id, ChangepasswordRequest $request)
{
try {
$changepassword = $request->change_password;
$user = User::whereId($id)->first();
@@ -391,24 +383,25 @@ else{
return redirect('user')->with('success', Lang::get('lang.password_change_successfully'));
} catch (Exception $e) {
return redirect('user')->with('fails', $e->getMessage());
}
}
/**
*
* @param type $id
* @param type $id
* @param Request $request
*
* @return type
*/
public function changeRoleAdmin($id, Request $request) {
public function changeRoleAdmin($id, Request $request)
{
try {
$user = User::whereId($id)->first();
$user->role = 'admin';
$user->assign_group = $request->group;
$user->primary_dpt = $request->primary_department;
$user->save();
return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
} catch (Exception $e) {
/* redirect to Index page with Fails Message */
@@ -417,14 +410,14 @@ else{
}
/**
*
* @param type $id
* @param type $id
* @param Request $request
*
* @return type
*/
public function changeRoleAgent($id, Request $request) {
public function changeRoleAgent($id, Request $request)
{
try {
$user = User::whereId($id)->first();
$user->role = 'agent';
$user->assign_group = $request->group;
@@ -439,22 +432,22 @@ else{
}
/**
*
* @param type $id
*
* @return type
*/
public function changeRoleUser($id) {
public function changeRoleUser($id)
{
try {
$ticket = Tickets::where('assigned_to', '=', $id)->where('status', '=', '1')->get();
if ($ticket) {
$ticket = Tickets::where('assigned_to', '=', $id)->update(array("assigned_to" => NULL));
$ticket = Tickets::where('assigned_to', '=', $id)->update(['assigned_to' => null]);
}
$user = User::whereId($id)->first();
$user->role = 'user';
$user->assign_group = NULL;
$user->primary_dpt = NULL;
$user->remember_token = NULL;
$user->assign_group = null;
$user->primary_dpt = null;
$user->remember_token = null;
$user->save();
return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
@@ -466,32 +459,28 @@ else{
}
/**
*
* @param type $id
*
* @return type
*/
public function deleteAgent($id)
{
// try {
$delete_all = Input::get('delete_all');
$delete_all = Input::get('delete_all');
$users = User::where('id', '=', $id)->first();
if ($users->role == 'user') {
if ($users->role == 'user') {
$users = User::where('id', '=', $id)->first();
$users->is_delete = 1;
$users->active = 0;
$users->ban = 1;
$users->save();
$users = User::where('id', '=', $id)->first();
$users->is_delete=1;
$users->active=0;
$users->ban=1;
$users->save();
return redirect('user')->with('success', Lang::get('lang.user_delete_successfully'));
}
return redirect('user')->with('success', Lang::get('lang.user_delete_successfully'));
}
// }
if ($users->role == 'agent') {
if ($delete_all == null) {
$UserEmail = Input::get('assign_to');
@@ -524,68 +513,62 @@ else{
// Assign_team_agent::where('agent_id', '=', $id)->update(['agent_id' => $assign_to[1]]);
$tickets = Tickets::where('assigned_to', '=', $id)->get();
foreach ($tickets as $ticket ) {
# code...
foreach ($tickets as $ticket) {
// code...
$ticket->assigned_to = $assign_to[1];
$user_detail = User::where('id', '=', $assign_to[1])->first();
$assignee = $user_detail->first_name . ' ' . $user_detail->last_name;
$ticket_number = $ticket->ticket_number;
$ticket->save();
$user_detail = User::where('id', '=', $assign_to[1])->first();
$assignee = $user_detail->first_name.' '.$user_detail->last_name;
$ticket_number = $ticket->ticket_number;
$ticket->save();
$thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id;
$thread->is_internal = 1;
$thread->body = 'This Ticket has been assigned to ' . $assignee;
$thread->save();
}
$thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id;
$thread->is_internal = 1;
$thread->body = 'This Ticket has been assigned to '.$assignee;
$thread->save();
}
$user = User::find($id);
$users->is_delete=1;
$users->active=0;
$users->ban=1;
$users->is_delete = 1;
$users->active = 0;
$users->ban = 1;
$users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully_and_ticket_assign_to_another_agent'));
}
// if (User_org::where('user_id', '=', $id)) {
// DB::table('user_assign_organization')->where('user_id', '=', $id)->delete();
// }
$user = User::find($id);
$users->is_delete=1;
$users->active=0;
$users->ban=1;
$users->save();
$users->is_delete = 1;
$users->active = 0;
$users->ban = 1;
$users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
} elseif ($delete_all == 1) {
if ($delete_all) {
// dd('here');
if ($delete_all) {
// dd('here');
$tickets = Tickets::where('assigned_to', '=', $id)->get();
// dd($tickets);
foreach ($tickets as $ticket ) {
$ticket->assigned_to = NULL;
$ticket_number = $ticket->ticket_number;
$ticket->save();
foreach ($tickets as $ticket) {
$ticket->assigned_to = null;
$ticket_number = $ticket->ticket_number;
$ticket->save();
$thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id;
$thread->is_internal = 1;
$thread->body = 'This Ticket has been unassigned ';
$thread->save();
}
$thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id;
$thread->is_internal = 1;
$thread->body = 'This Ticket has been unassigned ';
$thread->save();
}
// $users = User::where('id', '=', $id)->get();
$user = User::find($id);
$users->is_delete=1;
$users->active=0;
$users->is_delete = 1;
$users->active = 0;
$users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
@@ -593,8 +576,8 @@ foreach ($tickets as $ticket ) {
// Assign_team_agent::where('agent_id', '=', $id)->delete();
// User_org::where('user_id', '=', $id)->delete();
$user = User::find($id);
$users->is_delete=1;
$users->active=0;
$users->is_delete = 1;
$users->active = 0;
$users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
@@ -616,10 +599,11 @@ foreach ($tickets as $ticket ) {
*
* @return type view
*/
public function show($id) {
public function show($id)
{
try {
$users = User::where('id','=', $id)->first();
if (count($users)>0) {
$users = User::where('id', '=', $id)->first();
if (count($users) > 0) {
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} else {
return redirect()->back()->with('fails', Lang::get('lang.user-not-found'));
@@ -637,10 +621,10 @@ foreach ($tickets as $ticket ) {
*
* @return type Response
*/
public function edit($id, CountryCode $code) {
public function edit($id, CountryCode $code)
{
try {
// dd('here');
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
@@ -652,12 +636,12 @@ foreach ($tickets as $ticket ) {
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
$orgs = Organization::all();
// dd($org);
$organization_id=User_org::where('user_id','=',$id)->lists('org_id')->first();
$organization_id = User_org::where('user_id', '=', $id)->lists('org_id')->first();
// $org_name=Organization::where('id','=',$org_id)->lists('name')->first();
// dd($org_name);
return view('themes.default1.agent.helpdesk.user.edit', compact('users', 'orgs', '$settings', '$email_mandatory','organization_id'))->with('phonecode', $phonecode->phonecode);
return view('themes.default1.agent.helpdesk.user.edit', compact('users', 'orgs', '$settings', '$email_mandatory', 'organization_id'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
@@ -672,8 +656,8 @@ foreach ($tickets as $ticket ) {
*
* @return type Response
*/
public function update($id, Sys_userUpdate $request) {
public function update($id, Sys_userUpdate $request)
{
$user = new User();
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
@@ -693,10 +677,10 @@ foreach ($tickets as $ticket ) {
$users->mobile = ($request->input('mobile') == '') ? null : $request->input('mobile');
$users->fill($request->except('mobile'));
$users->save();
if ($request->input('org_id') != "") {
if ($request->input('org_id') != '') {
$orgid = $request->input('org_id');
$this->storeUserOrgRelation($id, $orgid);
$this->storeUserOrgRelation($id, $orgid);
}
/* redirect to Index page with Success Message */
return redirect('user')->with('success', Lang::get('lang.User-profile-Updated-Successfully'));
@@ -711,7 +695,8 @@ foreach ($tickets as $ticket ) {
*
* @return type view
*/
public function getProfile() {
public function getProfile()
{
$user = Auth::user();
try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
@@ -725,7 +710,8 @@ foreach ($tickets as $ticket ) {
*
* @return type view
*/
public function getProfileedit(CountryCode $code) {
public function getProfileedit(CountryCode $code)
{
$user = Auth::user();
$location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
@@ -734,7 +720,7 @@ foreach ($tickets as $ticket ) {
try {
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'))
->with(['phonecode' => $phonecode->phonecode,
'verify' => $status]);
'verify' => $status, ]);
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
@@ -748,7 +734,8 @@ foreach ($tickets as $ticket ) {
*
* @return type Redirect
*/
public function postProfileedit(ProfileRequest $request) {
public function postProfileedit(ProfileRequest $request)
{
try {
// geet authenticated user details
$user = Auth::user();
@@ -758,14 +745,14 @@ foreach ($tickets as $ticket ) {
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
if (!count($code)) {
return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput();
}
}
$user->country_code = $request->country_code;
}
$user->fill($request->except('profile_pic', 'mobile'));
$user->gender = $request->input('gender');
$user->save();
if (Input::file('profile_pic')) {
// fetching picture name
// fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path
$destinationPath = 'uploads/profilepic';
@@ -782,11 +769,10 @@ foreach ($tickets as $ticket ) {
$user->mobile = null;
}
if ($user->save()) {
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
} else {
return Redirect::route('profile')->with('fails', Lang::get('lang.Profile-Updated-sucessfully'));
}
} catch (Exception $e) {
return Redirect::route('profile')->with('fails', $e->getMessage());
}
@@ -826,49 +812,50 @@ foreach ($tickets as $ticket ) {
*
* @return type boolean
*/
public function UserAssignOrg($id) {
public function UserAssignOrg($id)
{
$org_name = Input::get('org');
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = new User_org();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = new User_org();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
} else {
return 0;
return 1;
} else {
return 0;
}
} else {
return 2;
} else {
return 2;
}
}
}
public function UsereditAssignOrg($id)
{
$org_name = Input::get('org');
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = User_org::where('user_id', '=', $id)->first();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
public function UsereditAssignOrg($id)
{
$org_name = Input::get('org');
return 1;
} else {
return 0;
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = User_org::where('user_id', '=', $id)->first();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
} else {
return 0;
}
} else {
return 2;
} else {
return 2;
}
}
}
public function orgAssignUser($id) {
public function orgAssignUser($id)
{
$org = Input::get('org');
$user_org = new User_org();
$user_org->org_id = $id;
@@ -878,7 +865,8 @@ if ($org_name) {
return 1;
}
public function removeUserOrg($id) {
public function removeUserOrg($id)
{
$user_org = User_org::where('org_id', '=', $id)->first();
$user_org->delete();
@@ -892,7 +880,8 @@ if ($org_name) {
*
* @return type
*/
public function User_Create_Org($id) {
public function User_Create_Org($id)
{
// checking if the entered value for website is available in database
if (Input::get('website') != null) {
// checking website
@@ -935,7 +924,8 @@ if ($org_name) {
*
* @return string
*/
public function generateRandomString($length = 10) {
public function generateRandomString($length = 10)
{
// list of supported characters
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// character length checked
@@ -950,7 +940,8 @@ if ($org_name) {
return $randomString;
}
public function storeUserOrgRelation($userid, $orgid) {
public function storeUserOrgRelation($userid, $orgid)
{
$org_relations = new User_org();
$org_relation = $org_relations->where('user_id', $userid)->first();
if ($org_relation) {
@@ -958,11 +949,12 @@ if ($org_name) {
}
$org_relations->create([
'user_id' => $userid,
'org_id' => $orgid,
'org_id' => $orgid,
]);
}
public function getExportUser() {
public function getExportUser()
{
try {
return view('themes.default1.agent.helpdesk.user.export');
} catch (Exception $ex) {
@@ -970,30 +962,34 @@ if ($org_name) {
}
}
public function exportUser(Request $request) {
public function exportUser(Request $request)
{
try {
$date = $request->input('date');
$date = str_replace(' ', '', $date);
$date_array = explode(':', $date);
$first = $date_array[0] . " 00:00:00";
$second = $date_array[1] . " 23:59:59";
$first = $date_array[0].' 00:00:00';
$second = $date_array[1].' 23:59:59';
$first_date = $this->convertDate($first);
$second_date = $this->convertDate($second);
$users = $this->getUsers($first_date, $second_date);
$excel_controller = new \App\Http\Controllers\Common\ExcelController();
$filename = "users" . $date;
$filename = 'users'.$date;
$excel_controller->export($filename, $users);
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
}
}
public function convertDate($date) {
public function convertDate($date)
{
$converted_date = date('Y-m-d H:i:s', strtotime($date));
return $converted_date;
}
public function getUsers($first, $last) {
public function getUsers($first, $last)
{
$user = new User();
$users = $user->leftJoin('user_assign_organization', 'users.id', '=', 'user_assign_organization.user_id')
->leftJoin('organization', 'user_assign_organization.org_id', '=', 'organization.id')
@@ -1003,37 +999,42 @@ if ($org_name) {
->select('users.user_name as Username', 'users.email as Email', 'users.first_name as Fisrtname', 'users.last_name as Lastname', 'organization.name as Organization')
->get()
->toArray();
return $users;
}
public function resendOTP(OtpVerifyRequest $request) {
public function resendOTP(OtpVerifyRequest $request)
{
if (\Schema::hasTable('sms')) {
$sms = DB::table('sms')->get();
if (count($sms) > 0) {
\Event::fire(new \App\Events\LoginEvent($request));
return 1;
}
} else {
return "Plugin has not been setup successfully.";
return 'Plugin has not been setup successfully.';
}
}
public function verifyOTP() {
public function verifyOTP()
{
// dd(Input::all());
// $user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))->first();
$otp = Otp::select('otp', 'updated_at')->where('user_id', '=', Input::get('u_id'))
->first();
if ($otp != null) {
$otp_length = strlen(Input::get('otp'));
if (($otp_length == 6 && !preg_match("/[a-z]/i", Input::get('otp')))) {
if (($otp_length == 6 && !preg_match('/[a-z]/i', Input::get('otp')))) {
$otp2 = Hash::make(Input::get('otp'));
$date1 = date_format($otp->updated_at, "Y-m-d h:i:sa");
$date2 = date("Y-m-d h:i:sa");
$date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
$date2 = date('Y-m-d h:i:sa');
$time1 = new DateTime($date2);
$time2 = new DateTime($date1);
$interval = $time1->diff($time2);
if ($interval->i > 10 || $interval->h > 0) {
$message = Lang::get('lang.otp-expired');
return $message;
} else {
if (Hash::check(Input::get('otp'), $otp->otp)) {
@@ -1045,26 +1046,27 @@ if ($org_name) {
return 1;
} else {
$message = Lang::get('lang.otp-not-matched');
return $message;
}
}
} else {
$message = Lang::get('lang.otp-invalid');
return $message;
}
} else {
$message = Lang::get('lang.otp-not-matched');
return $message;
}
}
/**
*/
public function getAgentDetails()
{
$users = User::where('role', '<>', 'user')->where('active', '=', 1)->get();
foreach ($users as $user) {
echo "<option value='user_$user->id'>".$user->name().'</option>';
echo "<option value='user_$user->id'>".$user->name().'</option>';
}
}
}