From 6d60b564ad3dcb4a943a1dc2db659cb47753a180 Mon Sep 17 00:00:00 2001 From: Manish Verma Date: Thu, 16 Aug 2018 10:50:08 +0530 Subject: [PATCH] Plugin updates Fixed plugin installation updates Updates language updates --- .../Admin/helpdesk/SettingsController.php | 75 +++++++++++++ .../Controllers/Common/SettingsController.php | 2 +- config/app.php | 3 +- resources/lang/en/lang.php | 63 +++++++---- .../helpdesk/settings/cleandata.blade.php | 106 ++++++++++++++++++ routes/web.php | 3 + 6 files changed, 227 insertions(+), 25 deletions(-) create mode 100644 resources/views/themes/default1/admin/helpdesk/settings/cleandata.blade.php diff --git a/app/Http/Controllers/Admin/helpdesk/SettingsController.php b/app/Http/Controllers/Admin/helpdesk/SettingsController.php index 3560dd273..ee1790a3c 100644 --- a/app/Http/Controllers/Admin/helpdesk/SettingsController.php +++ b/app/Http/Controllers/Admin/helpdesk/SettingsController.php @@ -1049,4 +1049,79 @@ class SettingsController extends Controller return $char; } + + /** + * @category function to return clean data view + * @param null + * @return respone/view + */ + public function getCleanUpView() { + $system_check = CommonSettings::select('status')->where('option_name', '=', 'dummy_data_installation')->first(); + if ($system_check) { + if ($system_check->status == 1 || $system_check->status == '1') { + return View('themes.default1.admin.helpdesk.settings.cleandata'); + } + } + return redirect()->route('error404')->with('fails', Lang::get('lang.no-dummy-data')); + } + + /** + * @category function to clean dummy database and reseed tables with default options + * @param null + * @return + * Very dangerous function should be call by admin only + */ + private function cleanDatabase() { + try { + $user = \App\User::select( + 'user_name', 'first_name', 'last_name', 'email', 'password', 'agent_tzone' + )->where('id', '=', 1)->first(); + $system = System::where('id', '=', 1)->first(); + $tableNames = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames(); + foreach ($tableNames as $name) { + //if you don't want to truncate migrations + if ($name == 'migrations' || + $name == 'sd_attachment_types' || + $name == 'sd_change_priorities' || + $name == 'sd_change_status' || + $name == 'sd_change_types' || + $name == 'sd_release_priorities' || + $name == 'sd_release_status' || + $name == 'sd_release_types' || + $name == 'pro_serial_key') { + continue; + } + DB::table($name)->truncate(); + } + DB::commit(); + \Artisan::call('db:seed', ['--force' => true]); + $user2 = \App\User::updateOrCreate(['id' => 1], [ + 'first_name' => $user->first_name, + 'last_name' => $user->last_name, + 'email' => $user->email, + 'user_name' => $user->user_name, + 'password' => $user->password, + 'assign_group' => 1, + 'primary_dpt' => 1, + 'active' => 1, + 'agent_tzone' => $user->agent_tzone, + 'role' => 'admin', + ]); + $system2 = System::find(1); + $system2->time_zone = $system->time_zone; + $system2->date_time_format = $system->date_time_format; + $system2->save(); + + // updating business hours + $bhours = BusinessHours::where('id', '=', 1)->first(); + $bhours->timezone = $system2->time_zone; + $bhours->save(); + + $response = 'success'; + return $response; + } catch (\Exception $e) { + $error = $e->getMessage(); + return $error; + } + } } diff --git a/app/Http/Controllers/Common/SettingsController.php b/app/Http/Controllers/Common/SettingsController.php index 4771d2e39..e2b863062 100644 --- a/app/Http/Controllers/Common/SettingsController.php +++ b/app/Http/Controllers/Common/SettingsController.php @@ -599,7 +599,7 @@ class SettingsController extends Controller $plug->status = 1; $app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php'; - $str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',"; + $str = "\n 'App\\Plugins\\$slug"."\\ServiceProvider',"; $line_i_am_looking_for = 190; $lines = file($app, FILE_IGNORE_NEW_LINES); $lines[$line_i_am_looking_for] = $str; diff --git a/config/app.php b/config/app.php index abf117bdc..f42a13854 100644 --- a/config/app.php +++ b/config/app.php @@ -188,6 +188,7 @@ return [ App\FaveoStorage\StorageServiceProvider::class, Yajra\Datatables\DatatablesServiceProvider::class, \App\Api\ApiServiceProvider::class, + ], /* |-------------------------------------------------------------------------- @@ -257,4 +258,4 @@ return [ 'Datatables' => Yajra\Datatables\Facades\Datatables::class, 'Notification' => Illuminate\Support\Facades\Notification::class, ], -]; +]; \ No newline at end of file diff --git a/resources/lang/en/lang.php b/resources/lang/en/lang.php index 5403ae5ec..5c842d760 100644 --- a/resources/lang/en/lang.php +++ b/resources/lang/en/lang.php @@ -1594,27 +1594,44 @@ return [ 'session-expired' => 'Session expired or invalid, please try again.', //update since v1.10 - 'your_helpdesk_is_ready' => 'Your Helpdesk is Ready!', - 'all_right_sparky_you_have_made_it' => 'All right, sparky! You’ve made it through the installation.', - 'next_step' => 'Next Step', - 'login_to_faveo' => 'Login to Faveo', - 'learn_more' => 'Learn More', - 'video_walk_through' => 'Video walk through', - 'email_support' => 'Email Support', - 'not-answered' => 'Not answered', - 'default-fallback' => 'Fallback language', - 'system-language' => 'System\'s default language', - 'set_as_sys_lang' => 'Make default', - 'filtered-results' => 'Filtered results', - 'methon_not_allowed' => 'Method not allowed', - 'confirm-to-proceed' => 'Are you sure?', - 'change-ticket-status-to' => 'Change status of tickets to ', - 'your-ticket-status-changed' => 'Your ticket\'s status has been changed.', - 'reload-be-patient-message' => 'Please be patient we are reloading the page.', - 'status-changed-successfully' => 'Status changed successfully.', - 'system-outgoing-incoming-mail-not-configured' => 'You have not configured system mail. Faveo can\'t fetch tickets from mail or send mail to users without it.', - 'confihure-the-mail-now' => 'Click here to configure the mail.', - 'system-mail-not-configured-agent-message' => 'System incoming and outgoing email settings are not configured. Please contct your system\'s admin and report the problem.', - 'ticket-assigned-successfully' => 'Selected tickets have been assigned sucessfully.', - 'canned_response_deleted' => 'Canned response deleted successfully', + 'your_helpdesk_is_ready' => 'Your Helpdesk is Ready!', + 'all_right_sparky_you_have_made_it' => 'All right, sparky! You’ve made it through the installation.', + 'next_step' => 'Next Step', + 'login_to_faveo' => 'Login to Faveo', + 'learn_more' => 'Learn More', + 'video_walk_through' => 'Video walk through', + 'email_support' => 'Email Support', + 'not-answered' => 'Not answered', + 'default-fallback' => 'Fallback language', + 'system-language' => 'System\'s default language', + 'set_as_sys_lang' => 'Make default', + 'filtered-results' => 'Filtered results', + 'methon_not_allowed' => 'Method not allowed', + 'confirm-to-proceed' => 'Are you sure?', + 'change-ticket-status-to' => 'Change status of tickets to ', + 'your-ticket-status-changed' => 'Your ticket\'s status has been changed.', + 'reload-be-patient-message' => 'Please be patient we are reloading the page.', + 'status-changed-successfully' => 'Status changed successfully.', + 'system-outgoing-incoming-mail-not-configured' => 'You have not configured system mail. Faveo can\'t fetch tickets from mail or send mail to users without it.', + 'confihure-the-mail-now' => 'Click here to configure the mail.', + 'system-mail-not-configured-agent-message' => 'System incoming and outgoing email settings are not configured. Please contct your system\'s admin and report the problem.', + 'ticket-assigned-successfully' => 'Selected tickets have been assigned sucessfully.', + 'canned_response_deleted' => 'Canned response deleted successfully', + 'no-dummy-data' => 'Your system is in production, we could not find dummy data installed in your system.', + 'dummy_data_installation_message' => 'You are using Faveo with dummy data, which should be used only for testing purpose. Your system will not fetch or send any mail as dummy data has minimal configuration settings. We recommend not to feed any live data in the system till you are testing the system. Once you are done with testing clear all dummy data and configure system settings to get started with the system.', + 'clear-dummy-data-agent-message' => 'Your Faveo system has been installed with dummy data which should be used only for testing purpose. Your system will not fetch or send any mail as dummy data has minimal configuration settings. We recommend not to feed any live data in the system till you are testing the system. Once you are done with testing contact your system admin to clean dummy data and configure system settings.', + 'clear-dummy-data' => 'to clear dummy data.', + 'delete_dummy_data' => 'Clean dummy data', + 'plugin-with-dummy-data-error-message' => 'You\'ve installed Faveo with dummy data for testing. Plugins can only be used in live/production mode. If you are done with testing clear dummy data and start using Faveo in live/production mode.', + 'clean-data-box-title' => 'Cleaning Dummy data will perform following actions', + 'clean-dummy-ticket-conversation' => 'Clean all dummy tickets and their conversations.', + 'clean-dummy-notification' => 'Clean all dummy notifications.', + 'clean-dummy-users' => 'Clean all dummy users and their data.', + 'clean-other-data' => 'Clean dummy departments, teams, labels, tags etc.', + 'clean-user-created-data' => 'Clean all data created during testing with dummy data.', + 'clean-data-btn' => 'Clear data', + 'clean-confirm' => 'Yes I want to clean dummy data', + 'do-not-refresh' => '(Please do not use "Refresh" or "Back" button)', + 'cleaning-in-progress' => 'Cleaning in progress, please wait while we are cleaning your database', + 'cleaning-database' => 'Cleaning dummy data from database.', ]; diff --git a/resources/views/themes/default1/admin/helpdesk/settings/cleandata.blade.php b/resources/views/themes/default1/admin/helpdesk/settings/cleandata.blade.php new file mode 100644 index 000000000..0b89e6620 --- /dev/null +++ b/resources/views/themes/default1/admin/helpdesk/settings/cleandata.blade.php @@ -0,0 +1,106 @@ +@extends('themes.default1.admin.layout.admin') + +@section('Settings') +active +@stop + +@section('settings-bar') +active +@stop + +@section('clean') +class="active" +@stop + +@section('HeadInclude') +@stop + +@section('PageHeader') +

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

+@stop + + +@section('breadcrumbs') + +@stop + + +@section('content') +
+
+

{!! Lang::get('lang.clean-data-box-title')!!}

+
+
+
    +
  • {!! Lang::get('lang.clean-dummy-ticket-conversation') !!}
  • +
  • {!! Lang::get('lang.clean-dummy-notification') !!}
  • +
  • {!! Lang::get('lang.clean-dummy-users') !!}
  • +
  • {!! Lang::get('lang.clean-other-data') !!}
  • +
  • {!! Lang::get('lang.clean-user-created-data') !!}
  • +
+
+ + +
+ +@stop +@section('FooterInclude') + +@stop \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 69c2b9b95..4a406677f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -278,6 +278,9 @@ Route::group(['middleware' => ['web']], function () { Route::resource('labels', 'Admin\helpdesk\Label\LabelController'); Route::get('labels-ajax', ['as'=>'labels.ajax', 'uses'=>'Admin\helpdesk\Label\LabelController@ajaxTable']); Route::get('labels/delete/{id}', ['as' => 'labels.destroy', 'uses' => 'Admin\helpdesk\Label\LabelController@destroy']); + + Route::get('clean-dummy-data', ['as' => 'clean-database', 'uses' => 'Admin\helpdesk\SettingsController@getCleanUpView']); + Route::post('post-clean-dummy-data', ['as' => 'post-clean-database', 'uses' => 'Admin\helpdesk\SettingsController@postCleanDummyData']); }); /* |------------------------------------------------------------------