diff --git a/app/Http/Controllers/Admin/helpdesk/LanguageController.php b/app/Http/Controllers/Admin/helpdesk/LanguageController.php index 8eb174a22..91802568c 100644 --- a/app/Http/Controllers/Admin/helpdesk/LanguageController.php +++ b/app/Http/Controllers/Admin/helpdesk/LanguageController.php @@ -122,79 +122,84 @@ class LanguageController extends Controller */ public function postForm() { - // getting all of the post data - $file = [ - 'File' => Input::file('File'), - 'language-name' => Input::input('language-name'), - 'iso-code' => Input::input('iso-code'), - ]; + try { + // getting all of the post data + $file = [ + 'File' => Input::file('File'), + 'language-name' => Input::input('language-name'), + 'iso-code' => Input::input('iso-code'), + ]; - // setting up rules - $rules = [ - 'File' => 'required|mimes:zip|max:30000', - 'language-name' => 'required', - 'iso-code' => 'required|max:2', - ]; // and for max size - // doing the validation, passing post data, rules and the messages - $validator = Validator::make($file, $rules); - if ($validator->fails()) { + // setting up rules + $rules = [ + 'File' => 'required|mimes:zip|max:30000', + 'language-name' => 'required', + 'iso-code' => 'required|max:2', + ]; // and for max size + // doing the validation, passing post data, rules and the messages + $validator = Validator::make($file, $rules); + if ($validator->fails()) { - // send back to the page with the input data and errors - return Redirect::back()->withInput()->withErrors($validator); - } else { - - //Checking if package already exists or not in lang folder - $path = base_path('resources/lang'); - if (in_array(strtolower(Input::get('iso-code')), scandir($path))) { - - //sending back with error message - Session::flash('fails', Lang::get('lang.package_exist')); - Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code'))); - - return Redirect::back()->withInput(); - } elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))) {//Checking Valid ISO code form Languages.php - //sending back with error message - Session::flash('fails', Lang::get('lang.iso-code-error')); - - return Redirect::back()->withInput(); + // send back to the page with the input data and errors + return Redirect::back()->withInput()->withErrors($validator); } else { - // checking file is valid. - if (Input::file('File')->isValid()) { - $name = Input::file('File')->getClientOriginalName(); //uploaded file's original name - $destinationPath = base_path('public/uploads/'); // defining uploading path - $extractpath = base_path('resources/lang').'/'.strtolower(Input::get('iso-code')); //defining extracting path - mkdir($extractpath); //creating directroy for extracting uploadd file - //mkdir($destinationPath); - Input::file('File')->move($destinationPath, $name); // uploading file to given path - \Zipper::make($destinationPath.'/'.$name)->extractTo($extractpath); //extracting file to give path - //check if Zip extract foldercontains any subfolder - $directories = File::directories($extractpath); - //$directories = glob($extractpath. '/*' , GLOB_ONLYDIR); - if (!empty($directories)) { //if extract folder contains subfolder - $success = File::deleteDirectory($extractpath); //remove extracted folder and it's subfolder from lang - //$success2 = File::delete($destinationPath.'/'.$name); - if ($success) { - //sending back with error message - Session::flash('fails', Lang::get('lang.zipp-error')); - Session::flash('link2', 'http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages'); + //Checking if package already exists or not in lang folder + $path = base_path('resources/lang'); + if (in_array(strtolower(Input::get('iso-code')), scandir($path))) { - return Redirect::back()->withInput(); + //sending back with error message + Session::flash('fails', Lang::get('lang.package_exist')); + Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code'))); + + return Redirect::back()->withInput(); + } elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))) {//Checking Valid ISO code form Languages.php + //sending back with error message + Session::flash('fails', Lang::get('lang.iso-code-error')); + + return Redirect::back()->withInput(); + } else { + + // checking file is valid. + if (Input::file('File')->isValid()) { + $name = Input::file('File')->getClientOriginalName(); //uploaded file's original name + $destinationPath = base_path('public/uploads/'); // defining uploading path + $extractpath = base_path('resources/lang').'/'.strtolower(Input::get('iso-code')); //defining extracting path + mkdir($extractpath); //creating directroy for extracting uploadd file + //mkdir($destinationPath); + Input::file('File')->move($destinationPath, $name); // uploading file to given path + \Zipper::make($destinationPath.'/'.$name)->extractTo($extractpath); //extracting file to give path + //check if Zip extract foldercontains any subfolder + $directories = File::directories($extractpath); + //$directories = glob($extractpath. '/*' , GLOB_ONLYDIR); + if (!empty($directories)) { //if extract folder contains subfolder + $success = File::deleteDirectory($extractpath); //remove extracted folder and it's subfolder from lang + //$success2 = File::delete($destinationPath.'/'.$name); + if ($success) { + //sending back with error message + Session::flash('fails', Lang::get('lang.zipp-error')); + Session::flash('link2', 'http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages'); + + return Redirect::back()->withInput(); + } + } else { + // sending back with success message + Session::flash('success', Lang::get('lang.upload-success')); + Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code'))); + + return Redirect::route('LanguageController'); } } else { - // sending back with success message - Session::flash('success', Lang::get('lang.upload-success')); - Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code'))); + // sending back with error message. + Session::flash('fails', Lang::get('lang.file-error')); - return Redirect::route('LanguageController'); + return Redirect::route('form'); } - } else { - // sending back with error message. - Session::flash('fails', Lang::get('lang.file-error')); - - return Redirect::route('form'); } } + } catch (\Exception $e) { + Session::flash('fails', $e->getMessage()); + Redirect::back()->withInput(); } } diff --git a/app/Http/Controllers/Agent/helpdesk/UserController.php b/app/Http/Controllers/Agent/helpdesk/UserController.php index 9ba440655..8dd0b7715 100644 --- a/app/Http/Controllers/Agent/helpdesk/UserController.php +++ b/app/Http/Controllers/Agent/helpdesk/UserController.php @@ -41,6 +41,7 @@ use Illuminate\Http\Request; use Input; use Lang; use Redirect; +use Datatables; /** * UserController @@ -85,7 +86,6 @@ class UserController extends Controller Lang::get('lang.email'), Lang::get('lang.phone'), Lang::get('lang.status'), - Lang::get('lang.ban'), Lang::get('lang.last_login'), Lang::get('lang.role'), Lang::get('lang.action')) // these are the column headings to be shown @@ -116,21 +116,42 @@ class UserController extends Controller public function user_list(Request $request) { $type = $request->input('profiletype'); + $search = $request->input('searchTerm'); - if ($type == 'active') { - $users = User::where('role', '!=', 'admin')->where('is_delete', '=', 0)->get(); + if ($type === 'agents') { + $users = User::where('role', '=', 'agent')->where('is_delete', '=', 0); + } elseif ($type === 'users') { + $users = User::where('role', '=', 'user')->where('is_delete', '=', 0); + } elseif ($type === 'active') { + $users = User::where('role', '!=', 'admin')->where('active', '=', 1); + } elseif ($type === 'inactive') { + $users = User::where('role', '!=', 'admin')->where('active', '=', 0); + } elseif ($type === 'deleted') { + $users = User::where('role', '!=', 'admin')->where('is_delete', '=', 1); + } elseif ($type === 'banned') { + $users = User::where('role', '!=', 'admin')->where('ban', '=', 1); } else { - $users = User::where('role', '!=', 'admin')->where('is_delete', '=', 1)->get(); + $users = User::where('role', '!=', 'admin')->where('is_delete', '=', 0); } + + $users = $users->select('user_name', 'email', 'mobile', 'active', 'updated_at', 'role', 'id', 'last_name', 'country_code', 'phone_number'); + if ($search !== '') { + $users = $users->where(function($query) use ($search){ + $query->where('user_name', 'LIKE', '%'.$search.'%'); + $query->orWhere('email', 'LIKE', '%'.$search.'%'); + $query->orWhere('first_name', 'LIKE', '%'.$search.'%'); + $query->orWhere('last_name', 'LIKE', '%'.$search.'%'); + $query->orWhere('mobile', 'LIKE', '%'.$search.'%'); + $query->orWhere('updated_at', 'LIKE', '%'.$search.'%'); + $query->orWhere('country_code', 'LIKE', '%'.$search.'%'); + }); + } // displaying list of users with chumper datatables // return \Datatable::collection(User::where('role', "!=", "admin")->get()) - return \Datatable::collection($users) - /* searchable column username and email */ - ->searchColumns('user_name', 'email', 'phone') - /* order column username and email */ - ->orderColumns('user_name', 'email') + return \Datatables::of($users) /* column username */ + ->removeColumn('id', 'last_name', 'country_code', 'phone_number') ->addColumn('user_name', function ($model) { if ($model->first_name) { $string = strip_tags($model->first_name.' '.$model->last_name); @@ -153,7 +174,7 @@ class UserController extends Controller return $email; }) /* column phone */ - ->addColumn('phone', function ($model) { + ->addColumn('mobile', function ($model) { $phone = ''; if ($model->phone_number) { $phone = $model->ext.' '.$model->phone_number; @@ -167,7 +188,7 @@ class UserController extends Controller return $phone; }) /* column account status */ - ->addColumn('status', function ($model) { + ->addColumn('active', function ($model) { $status = $model->active; if ($status == 1) { $stat = ''; @@ -177,19 +198,8 @@ class UserController extends Controller return $stat; }) - /* column ban status */ - ->addColumn('ban', function ($model) { - $status = $model->ban; - if ($status == 1) { - $stat = ''; - } else { - $stat = ''; - } - - return $stat; - }) /* column last login date */ - ->addColumn('lastlogin', function ($model) { + ->addColumn('updated_at', function ($model) { $t = $model->updated_at; return TicketController::usertimezone($t); diff --git a/resources/lang/de/lang.php b/resources/lang/de/lang.php index 4a04a3b01..936663210 100644 --- a/resources/lang/de/lang.php +++ b/resources/lang/de/lang.php @@ -1148,5 +1148,12 @@ return [ //update 18-12-2016 'account-created-contact-admin-as-we-were-not-able-to-send-opt' => 'Your account has been created successfully. Please contact admin for account activation as we were not able to send you an OPT code.', + //update 19-12-2016 + 'only-agents' => 'Agent users', + 'only-users' => 'Clients users', + 'banned-users' => 'Banned users', + 'inactive-users' => 'Inactive users', + 'all-users' => 'All users', + 'search' => 'Search...', ]; diff --git a/resources/lang/en/lang.php b/resources/lang/en/lang.php index 0869be465..3582fa87c 100644 --- a/resources/lang/en/lang.php +++ b/resources/lang/en/lang.php @@ -1585,5 +1585,11 @@ return [ //update 18-12-2016 'account-created-contact-admin-as-we-were-not-able-to-send-opt' => 'Your account has been created successfully. Please contact admin for account activation as we were not able to send you an OPT code.', - + //update 19-12-2016 + 'only-agents' => 'Agent users', + 'only-users' => 'Clients users', + 'banned-users' => 'Banned users', + 'inactive-users' => 'Inactive users', + 'all-users' => 'All users', + 'search' => 'Search...', ]; diff --git a/resources/lang/fr/lang.php b/resources/lang/fr/lang.php index 66b28872c..9cc8f4f5a 100644 --- a/resources/lang/fr/lang.php +++ b/resources/lang/fr/lang.php @@ -1556,5 +1556,12 @@ return [ //update 18-12-2016 'account-created-contact-admin-as-we-were-not-able-to-send-opt' => 'Your account has been created successfully. Please contact admin for account activation as we were not able to send you an OPT code.', + //update 19-12-2016 + 'only-agents' => 'Agent users', + 'only-users' => 'Clients users', + 'banned-users' => 'Banned users', + 'inactive-users' => 'Inactive users', + 'all-users' => 'All users', + 'search' => 'Search...', ]; diff --git a/resources/lang/it/lang.php b/resources/lang/it/lang.php index c9cc32aa8..94275e16a 100644 --- a/resources/lang/it/lang.php +++ b/resources/lang/it/lang.php @@ -1108,4 +1108,11 @@ return [ //update 18-12-2016 'account-created-contact-admin-as-we-were-not-able-to-send-opt' => 'Your account has been created successfully. Please contact admin for account activation as we were not able to send you an OPT code.', + //update 19-12-2016 + 'only-agents' => 'Agent users', + 'only-users' => 'Clients users', + 'banned-users' => 'Banned users', + 'inactive-users' => 'Inactive users', + 'all-users' => 'All users', + 'search' => 'Search...', ]; diff --git a/resources/lang/nl/lang.php b/resources/lang/nl/lang.php index 95bdb72a5..0f8fda029 100644 --- a/resources/lang/nl/lang.php +++ b/resources/lang/nl/lang.php @@ -1602,4 +1602,11 @@ return [ //update 18-12-2016 'account-created-contact-admin-as-we-were-not-able-to-send-opt' => 'Your account has been created successfully. Please contact admin for account activation as we were not able to send you an OPT code.', + //update 19-12-2016 + 'only-agents' => 'Agent users', + 'only-users' => 'Clients users', + 'banned-users' => 'Banned users', + 'inactive-users' => 'Inactive users', + 'all-users' => 'All users', + 'search' => 'Search...', ]; diff --git a/resources/lang/pt/lang.php b/resources/lang/pt/lang.php index 4db1a1d87..0121dd46a 100644 --- a/resources/lang/pt/lang.php +++ b/resources/lang/pt/lang.php @@ -1547,4 +1547,12 @@ return [ //update 18-12-2016 'account-created-contact-admin-as-we-were-not-able-to-send-opt' => 'Your account has been created successfully. Please contact admin for account activation as we were not able to send you an OPT code.', + //update 19-12-2016 + 'only-agents' => 'Agent users', + 'only-users' => 'Clients users', + 'banned-users' => 'Banned users', + 'inactive-users' => 'Inactive users', + 'all-users' => 'All users', + 'search' => 'Search...', + ]; diff --git a/resources/lang/ru/lang.php b/resources/lang/ru/lang.php index 5f06a8d0d..206d4a3b8 100644 --- a/resources/lang/ru/lang.php +++ b/resources/lang/ru/lang.php @@ -1055,4 +1055,12 @@ return [ //update 18-12-2016 'account-created-contact-admin-as-we-were-not-able-to-send-opt' => 'Your account has been created successfully. Please contact admin for account activation as we were not able to send you an OPT code.', + + //update 19-12-2016 + 'only-agents' => 'Agent users', + 'only-users' => 'Clients users', + 'banned-users' => 'Banned users', + 'inactive-users' => 'Inactive users', + 'all-users' => 'All users', + 'search' => 'Search...', ]; diff --git a/resources/views/themes/default1/agent/helpdesk/user/index.blade.php b/resources/views/themes/default1/agent/helpdesk/user/index.blade.php index 706d04845..e3d8edce5 100644 --- a/resources/views/themes/default1/agent/helpdesk/user/index.blade.php +++ b/resources/views/themes/default1/agent/helpdesk/user/index.blade.php @@ -34,20 +34,32 @@ class="active"
+

{{Lang::get('lang.user')}}

-
+
+
+
+ + +
+
-
+
Export diff --git a/resources/views/vendor/Chumper/user-javascript.blade.php b/resources/views/vendor/Chumper/user-javascript.blade.php index fd79a2be8..53bfe4e41 100644 --- a/resources/views/vendor/Chumper/user-javascript.blade.php +++ b/resources/views/vendor/Chumper/user-javascript.blade.php @@ -7,8 +7,9 @@ foreach($segments as $seg){ ?> \ No newline at end of file