From c547b2e4384ea0b6cc44f613eca1bec6e720c58d Mon Sep 17 00:00:00 2001 From: Manish Verma Date: Mon, 6 Aug 2018 05:18:13 +0000 Subject: [PATCH] Apply fixes from StyleCI --- .../Controllers/StorageController.php | 115 +++++++++++------- app/Helper/Finder.php | 114 ++++++++--------- .../Admin/helpdesk/AgentController.php | 2 + .../Admin/helpdesk/EmailsController.php | 1 + .../Admin/helpdesk/FormController.php | 6 + .../Admin/helpdesk/PriorityController.php | 4 +- .../Admin/helpdesk/SettingsController2.php | 26 ++-- .../SocialMedia/SocialMediaController.php | 1 + .../Admin/helpdesk/TeamController.php | 10 +- .../Admin/helpdesk/TemplateController.php | 10 +- .../Admin/helpdesk/UrlSettingController.php | 2 +- .../Admin/helpdesk/WorkflowController.php | 1 + .../helpdesk/Filter/FilterController.php | 2 +- .../Agent/helpdesk/TicketController.php | 41 ++++--- .../Agent/helpdesk/UserController.php | 70 ++++++----- .../Controllers/Agent/kb/PageController.php | 3 + app/Http/Controllers/Api/v1/ApiController.php | 4 +- .../Controllers/Api/v1/TicketController.php | 25 ++-- .../Api/v1/TokenAuthController.php | 6 +- .../Controllers/Auth/PasswordController.php | 6 +- .../helpdesk/ClientTicketController.php | 2 +- .../Client/helpdesk/FormController.php | 1 + .../Client/helpdesk/GuestController.php | 11 +- .../Client/helpdesk/UnAuthController.php | 58 ++++----- app/Http/Controllers/Common/ApiSettings.php | 3 + .../Controllers/Common/PhpMailController.php | 6 +- .../Controllers/Common/SettingsController.php | 6 + .../Installer/helpdesk/InstallController.php | 3 +- app/Http/Controllers/Job/MailController.php | 1 + app/Http/Middleware/CheckUpdate.php | 4 +- app/Http/Middleware/VerifyCsrfToken.php | 8 +- app/Http/Requests/helpdesk/TicketRequest.php | 1 + app/Http/routes.php | 48 ++++---- .../helpdesk/Notification/Notification.php | 2 +- .../helpdesk/Ticket/Ticket_attachments.php | 2 +- app/User.php | 7 +- ...4_18_115852_create_workflow_name_table.php | 18 +-- ...4_18_115900_create_workflow_rule_table.php | 24 ++-- ...18_115908_create_workflow_action_table.php | 24 ++-- ..._102604_create_bar_notifications_table.php | 2 +- .../samples/old/assets/posteddata.php | 1 - 41 files changed, 373 insertions(+), 308 deletions(-) diff --git a/app/FaveoStorage/Controllers/StorageController.php b/app/FaveoStorage/Controllers/StorageController.php index 7cd9d064e..428381f0f 100644 --- a/app/FaveoStorage/Controllers/StorageController.php +++ b/app/FaveoStorage/Controllers/StorageController.php @@ -9,8 +9,8 @@ use App\Model\helpdesk\Ticket\Ticket_Thread; use Config; use Storage; -class StorageController extends Controller { - +class StorageController extends Controller +{ protected $default; protected $driver; protected $root; @@ -25,7 +25,8 @@ class StorageController extends Controller { protected $rackspace_endpoint; protected $rackspace_url_type; - public function __construct() { + public function __construct() + { $this->default = $this->defaults(); $this->driver = $this->driver(); $this->root = $this->root(); @@ -40,7 +41,8 @@ class StorageController extends Controller { $this->rackspace_username = $this->rackspaceUsername(); } - protected function settings($option) { + protected function settings($option) + { $settings = new CommonSettings(); $setting = $settings->getOptionValue('storage', $option); $value = ''; @@ -51,7 +53,8 @@ class StorageController extends Controller { return $value; } - public function defaults() { + public function defaults() + { $default = 'local'; if ($this->settings('default')) { $default = $this->settings('default'); @@ -60,11 +63,13 @@ class StorageController extends Controller { return $default; } - public function driver() { + public function driver() + { return $this->settings('default'); } - public function root() { + public function root() + { $root = storage_path('app'); if ($this->settings('root')) { $root = $this->settings('root'); @@ -73,47 +78,58 @@ class StorageController extends Controller { return $root; } - public function s3Key() { + public function s3Key() + { return $this->settings('s3_key'); } - public function s3Region() { + public function s3Region() + { return $this->settings('s3_region'); } - public function s3Secret() { + public function s3Secret() + { return $this->settings('s3_secret'); } - public function s3Bucket() { + public function s3Bucket() + { return $this->settings('s3_bucket'); } - public function rackspaceKey() { + public function rackspaceKey() + { return $this->settings('root'); } - public function rackspaceRegion() { + public function rackspaceRegion() + { return $this->settings('rackspace_region'); } - public function rackspaceUsername() { + public function rackspaceUsername() + { return $this->settings('rackspace_username'); } - public function rackspaceContainer() { + public function rackspaceContainer() + { return $this->settings('rackspace_container'); } - public function rackspaceEndpoint() { + public function rackspaceEndpoint() + { return $this->settings('rackspace_endpoint'); } - public function rackspaceUrlType() { + public function rackspaceUrlType() + { return $this->settings('rackspace_url_type'); } - protected function setFileSystem() { + protected function setFileSystem() + { $config = $this->config(); //dd($config); foreach ($config as $key => $con) { @@ -128,40 +144,43 @@ class StorageController extends Controller { return Config::get('filesystem'); } - protected function config() { + protected function config() + { return [ 'default' => $this->default, - 'cloud' => 's3', - 'disks' => $this->disks(), + 'cloud' => 's3', + 'disks' => $this->disks(), ]; } - protected function disks() { + protected function disks() + { return [ 'local' => [ 'driver' => 'local', - 'root' => $this->root . '/attachments', + 'root' => $this->root.'/attachments', ], 's3' => [ 'driver' => 's3', - 'key' => $this->s3_key, + 'key' => $this->s3_key, 'secret' => $this->s3_secret, 'region' => $this->s3_region, 'bucket' => $this->s3_bucket, ], 'rackspace' => [ - 'driver' => 'rackspace', - 'username' => $this->rackspace_username, - 'key' => $this->rackspace_key, + 'driver' => 'rackspace', + 'username' => $this->rackspace_username, + 'key' => $this->rackspace_key, 'container' => $this->rackspace_container, - 'endpoint' => $this->rackspace_endpoint, - 'region' => $this->rackspace_region, - 'url_type' => $this->rackspace_url_type, + 'endpoint' => $this->rackspace_endpoint, + 'region' => $this->rackspace_region, + 'url_type' => $this->rackspace_url_type, ], ]; } - public function upload($data, $filename, $type, $size, $disposition, $thread_id) { + public function upload($data, $filename, $type, $size, $disposition, $thread_id) + { $upload = new Ticket_attachments(); $upload->thread_id = $thread_id; $upload->name = $filename; @@ -169,11 +188,11 @@ class StorageController extends Controller { $upload->size = $size; $upload->poster = $disposition; $upload->driver = $this->default; - $upload->path = $this->root. DIRECTORY_SEPARATOR.'attachments'; + $upload->path = $this->root.DIRECTORY_SEPARATOR.'attachments'; if ($this->default !== 'database') { $this->setFileSystem(); Storage::disk($this->default)->put($filename, $data); - $storagePath = Storage::disk($this->default)->getDriver()->getAdapter()->getPathPrefix() . $filename; + $storagePath = Storage::disk($this->default)->getDriver()->getAdapter()->getPathPrefix().$filename; if (mime(\File::mimeType($storagePath)) != 'image' || mime(\File::extension($storagePath)) != 'image') { chmod($storagePath, 1204); } @@ -185,23 +204,23 @@ class StorageController extends Controller { } } - public function saveAttachments($thread_id, $attachments = []) { + public function saveAttachments($thread_id, $attachments = []) + { $disposition = 'ATTACHMENT'; $thread = ''; foreach ($attachments as $attachment) { if (is_object($attachment)) { if (method_exists($attachment, 'getStructure')) { - $structure = $attachment->getStructure(); if (isset($structure->disposition)) { $disposition = $structure->disposition; } - $filename = rand(1111, 9999) . "_" . $attachment->getFileName(); + $filename = rand(1111, 9999).'_'.$attachment->getFileName(); $type = $attachment->getMimeType(); $size = $attachment->getSize(); $data = $attachment->getData(); } else { - $filename = rand(1111, 9999) . "_" . $attachment->getClientOriginalName(); + $filename = rand(1111, 9999).'_'.$attachment->getClientOriginalName(); $type = $attachment->getMimeType(); $size = $attachment->getSize(); $data = file_get_contents($attachment->getRealPath()); @@ -210,10 +229,12 @@ class StorageController extends Controller { $thread = $this->updateBody($attachment, $thread_id, $filename); } } + return $thread; } - public function updateBody($attachment, $thread_id, $filename) { + public function updateBody($attachment, $thread_id, $filename) + { $threads = new Ticket_Thread(); $thread = $threads->find($thread_id); $disposition = 'ATTACHMENT'; @@ -225,27 +246,29 @@ class StorageController extends Controller { } } } - + if ($disposition == 'INLINE' || $disposition == 'inline') { $id = str_replace('>', '', str_replace('<', '', $structure->id)); $body = $thread->body; - // dd($id,$filename,$body); - $body = str_replace('cid:' . $id, $filename, $body); - // dd($body); + // dd($id,$filename,$body); + $body = str_replace('cid:'.$id, $filename, $body); + // dd($body); $thread->body = $body; $thread->save(); } + return $thread; } - public function getFile($drive, $name, $root) { - if ($drive != "database") { - $root = $root . DIRECTORY_SEPARATOR . $name; + public function getFile($drive, $name, $root) + { + if ($drive != 'database') { + $root = $root.DIRECTORY_SEPARATOR.$name; if (\File::exists($root)) { chmod($root, 0755); + return \File::get($root); } } } - } diff --git a/app/Helper/Finder.php b/app/Helper/Finder.php index 1895f451d..8f0bb2d30 100644 --- a/app/Helper/Finder.php +++ b/app/Helper/Finder.php @@ -58,26 +58,26 @@ class Finder return $group->first()->name; } - /** - * STATUS TYPE - * This function is used for returning status type name with respect to id. - * - * @param $id type int - * @param $custom type array/null - * - * @return type string - */ - public static function statusType($id, $custom = null) - { - if ($custom == null) { - $status_type = TicketStatusType::whereId($id)->select(['name']); - } elseif (isset($custom)) { - $status_type = TicketStatusType::whereId($id)->select($custom); - } - - return $status_type->first()->name; + /** + * STATUS TYPE + * This function is used for returning status type name with respect to id. + * + * @param $id type int + * @param $custom type array/null + * + * @return type string + */ + public static function statusType($id, $custom = null) + { + if ($custom == null) { + $status_type = TicketStatusType::whereId($id)->select(['name']); + } elseif (isset($custom)) { + $status_type = TicketStatusType::whereId($id)->select($custom); } + return $status_type->first()->name; + } + /** * STATUS * This function is used for returning status name with respect to id. @@ -137,48 +137,48 @@ class Finder } } - /** - * ANY TYPE STATUS - * This function is used to return the set of status which are of any type passed in the param. - * - * @param type $id - * - * @return type array - */ - public static function anyTypeStatus($id) - { - $status_group = Ticket_Status::where('purpose_of_status', '=', $id)->select(['id'])->get(); - foreach ($status_group as $status) { - $status_group2[] = $status->id; - } - - return $status_group2; + /** + * ANY TYPE STATUS + * This function is used to return the set of status which are of any type passed in the param. + * + * @param type $id + * + * @return type array + */ + public static function anyTypeStatus($id) + { + $status_group = Ticket_Status::where('purpose_of_status', '=', $id)->select(['id'])->get(); + foreach ($status_group as $status) { + $status_group2[] = $status->id; } - /** - * RETURNS ALL STATUS - * This function is used to return all the status given in the system. - * - * @return type array - */ - public static function getAllStatus() - { - $status = Ticket_Status::where('purpose_of_status', '!=', 3)->orwhere('purpose_of_status', '!=', 4)->get(); + return $status_group2; + } - return $status; + /** + * RETURNS ALL STATUS + * This function is used to return all the status given in the system. + * + * @return type array + */ + public static function getAllStatus() + { + $status = Ticket_Status::where('purpose_of_status', '!=', 3)->orwhere('purpose_of_status', '!=', 4)->get(); + + return $status; + } + + /** + * VARIABLE REPLACEMENT + * This function is used to replace the replaceable variables form a given content for templates. + */ + public static function replaceTemplateVariables($variables, $data, $contents) + { + foreach ($variables as $key => $variable) { + $messagebody = str_replace($variables[$key], $data[$key], $contents); + $contents = $messagebody; } - /** - * VARIABLE REPLACEMENT - * This function is used to replace the replaceable variables form a given content for templates. - */ - public static function replaceTemplateVariables($variables, $data, $contents) - { - foreach ($variables as $key => $variable) { - $messagebody = str_replace($variables[$key], $data[$key], $contents); - $contents = $messagebody; - } - - return $contents; - } + return $contents; + } } diff --git a/app/Http/Controllers/Admin/helpdesk/AgentController.php b/app/Http/Controllers/Admin/helpdesk/AgentController.php index 9b94793bd..7fd17f8f9 100644 --- a/app/Http/Controllers/Admin/helpdesk/AgentController.php +++ b/app/Http/Controllers/Admin/helpdesk/AgentController.php @@ -271,10 +271,12 @@ class AgentController extends Controller $team_assign_agent = $team_assign_agent->where('agent_id', $id); $team_assign_agent->delete(); $user = $user->whereId($id)->first(); + try { $error = Lang::get('lang.this_staff_is_related_to_some_tickets'); $user->id; $user->delete(); + throw new \Exception($error); return redirect('agents')->with('success', Lang::get('lang.agent_deleted_sucessfully')); } catch (\Exception $e) { diff --git a/app/Http/Controllers/Admin/helpdesk/EmailsController.php b/app/Http/Controllers/Admin/helpdesk/EmailsController.php index 8c15c251e..7b9be5355 100644 --- a/app/Http/Controllers/Admin/helpdesk/EmailsController.php +++ b/app/Http/Controllers/Admin/helpdesk/EmailsController.php @@ -428,6 +428,7 @@ class EmailsController extends Controller return redirect('emails')->with('fails', Lang::get('lang.you_cannot_delete_system_default_email')); } } + try { // fetching the database instance of the current email $emails = $email->whereId($id)->first(); diff --git a/app/Http/Controllers/Admin/helpdesk/FormController.php b/app/Http/Controllers/Admin/helpdesk/FormController.php index 5a7d90d9b..c5005cc39 100644 --- a/app/Http/Controllers/Admin/helpdesk/FormController.php +++ b/app/Http/Controllers/Admin/helpdesk/FormController.php @@ -106,6 +106,7 @@ class FormController extends Controller return view('themes.default1.admin.helpdesk.manage.form.preview', compact('form', 'fields')); } + throw new Exception("Sorry we can't find your request"); } catch (Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); @@ -125,6 +126,7 @@ class FormController extends Controller 'name.*' => 'required', 'type.*' => 'required', ]); + try { $forms = new Forms(); $require = Input::get('required'); @@ -195,6 +197,7 @@ class FormController extends Controller //dd($fields); return view('themes.default1.admin.helpdesk.manage.form.edit', compact('form', 'fields', 'select_forms')); } + throw new Exception("Sorry we can't find your request"); } catch (Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); @@ -213,6 +216,7 @@ class FormController extends Controller //dd($fields); return view('themes.default1.admin.helpdesk.manage.form.add-child', compact('form', 'fields', 'select_forms')); } + throw new Exception("Sorry we can't find your request"); } catch (Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); @@ -227,6 +231,7 @@ class FormController extends Controller 'name.*' => 'required', 'type.*' => 'required', ]); + try { if (!$request->input('formname')) { throw new Exception(Lang::get('lang.please_fill_form_name')); @@ -391,6 +396,7 @@ class FormController extends Controller public function addChild($fieldid, Request $request) { $ids = $request->except('_token'); + try { foreach ($ids as $valueid => $formid) { $field_value = new \App\Model\helpdesk\Form\FieldValue(); diff --git a/app/Http/Controllers/Admin/helpdesk/PriorityController.php b/app/Http/Controllers/Admin/helpdesk/PriorityController.php index 2b999d298..7e0b39289 100644 --- a/app/Http/Controllers/Admin/helpdesk/PriorityController.php +++ b/app/Http/Controllers/Admin/helpdesk/PriorityController.php @@ -46,7 +46,7 @@ class PriorityController extends Controller $user_status = CommonSettings::where('option_name', '=', 'user_priority')->first(); // dd( $user_status); - return view('themes.default1.admin.helpdesk.manage.ticket_priority.index', compact('user_status')); + return view('themes.default1.admin.helpdesk.manage.ticket_priority.index', compact('user_status')); } /** @@ -172,7 +172,7 @@ class PriorityController extends Controller public function destroy($priority_id) { $default_priority = Ticket_Priority::where('is_default', '>', '0')->first(); -// dd($default_priority->is_default); + // dd($default_priority->is_default); $topic = DB::table('help_topic')->where('priority', '=', $priority_id)->update(['priority' => $default_priority->is_default]); // if ($topic > 0) { // if ($topic > 1) { diff --git a/app/Http/Controllers/Admin/helpdesk/SettingsController2.php b/app/Http/Controllers/Admin/helpdesk/SettingsController2.php index 9682941f2..0a18728a1 100644 --- a/app/Http/Controllers/Admin/helpdesk/SettingsController2.php +++ b/app/Http/Controllers/Admin/helpdesk/SettingsController2.php @@ -150,8 +150,8 @@ class SettingsController2 extends Controller public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss) { // try { - /* fetch the values of company from company table */ - $statuss->name = Input::get('name'); + /* 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'); @@ -164,7 +164,7 @@ class SettingsController2 extends Controller $statuss->sort = Input::get('sort'); $statuss->save(); /* Direct to Company Settings Page */ - return redirect()->back()->with('success', 'Status has been created!'); + return redirect()->back()->with('success', 'Status has been created!'); // } catch (Exception $ex) { // return redirect()->back()->with('fails', $ex->errorInfo[2]); // } @@ -175,9 +175,9 @@ class SettingsController2 extends Controller 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'); + \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'); } @@ -446,12 +446,12 @@ class SettingsController2 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 { @@ -503,7 +503,7 @@ class SettingsController2 extends Controller // try { // /* fetch the values of access from access table */ // $accesses = $access->whereId('1')->first(); -// // Direct to Access Settings Page + // // Direct to Access Settings Page // return view('themes.default1.admin.helpdesk.settings.access', compact('accesses')); // } catch (Exception $e) { // return view('404'); diff --git a/app/Http/Controllers/Admin/helpdesk/SocialMedia/SocialMediaController.php b/app/Http/Controllers/Admin/helpdesk/SocialMedia/SocialMediaController.php index 0c8abfc65..64fa87207 100644 --- a/app/Http/Controllers/Admin/helpdesk/SocialMedia/SocialMediaController.php +++ b/app/Http/Controllers/Admin/helpdesk/SocialMedia/SocialMediaController.php @@ -32,6 +32,7 @@ class SocialMediaController extends Controller 'client_secret' => 'required', 'redirect' => 'required|url', ]); + try { $requests = $request->except('_token'); $this->insertProvider($provider, $requests); diff --git a/app/Http/Controllers/Admin/helpdesk/TeamController.php b/app/Http/Controllers/Admin/helpdesk/TeamController.php index d662875c1..b643bc915 100644 --- a/app/Http/Controllers/Admin/helpdesk/TeamController.php +++ b/app/Http/Controllers/Admin/helpdesk/TeamController.php @@ -143,16 +143,16 @@ class TeamController extends Controller { // dd($request); -// $id = $request->input('show_id'); + // $id = $request->input('show_id'); -// dd($id); + // dd($id); -$users = DB::table('team_assign_agent')->select('team_assign_agent.id', 'team_assign_agent.team_id', 'users.user_name', 'users.first_name', 'users.last_name', 'users.active', 'users.assign_group', 'users.primary_dpt', 'users.role') + $users = DB::table('team_assign_agent')->select('team_assign_agent.id', 'team_assign_agent.team_id', 'users.user_name', 'users.first_name', 'users.last_name', 'users.active', 'users.assign_group', 'users.primary_dpt', 'users.role') ->join('users', 'users.id', '=', 'team_assign_agent.agent_id') ->where('team_assign_agent.team_id', '=', $id); // ->get(); -// dd($users); - return \Datatable::query($users) + // dd($users); + return \Datatable::query($users) ->showColumns('user_name') ->addColumn('first_name', function ($model) { diff --git a/app/Http/Controllers/Admin/helpdesk/TemplateController.php b/app/Http/Controllers/Admin/helpdesk/TemplateController.php index 6158ac4ed..7103f7407 100644 --- a/app/Http/Controllers/Admin/helpdesk/TemplateController.php +++ b/app/Http/Controllers/Admin/helpdesk/TemplateController.php @@ -157,11 +157,11 @@ class TemplateController extends Controller $fname = Input::get('folder_name'); $filename = $directory.$fname; -// images folder creation using php -// $mydir = dirname( __FILE__ )."/html/images"; -// if(!is_dir($mydir)){ -// mkdir("html/images"); -// } + // images folder creation using php + // $mydir = dirname( __FILE__ )."/html/images"; + // if(!is_dir($mydir)){ + // mkdir("html/images"); + // } // Move all images files if (!file_exists($filename)) { diff --git a/app/Http/Controllers/Admin/helpdesk/UrlSettingController.php b/app/Http/Controllers/Admin/helpdesk/UrlSettingController.php index fd8d966b5..6e526bdae 100644 --- a/app/Http/Controllers/Admin/helpdesk/UrlSettingController.php +++ b/app/Http/Controllers/Admin/helpdesk/UrlSettingController.php @@ -91,7 +91,7 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"; public function changeHttp() { //$string = "RewriteCond %{HTTPS} off -//RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"; + //RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"; $string = ''; return $string; diff --git a/app/Http/Controllers/Admin/helpdesk/WorkflowController.php b/app/Http/Controllers/Admin/helpdesk/WorkflowController.php index f0756bf77..809a276f8 100644 --- a/app/Http/Controllers/Admin/helpdesk/WorkflowController.php +++ b/app/Http/Controllers/Admin/helpdesk/WorkflowController.php @@ -149,6 +149,7 @@ class WorkflowController extends Controller $email_data["E-$key"] = $email; } $emails = $email_data; + try { return view('themes.default1.admin.helpdesk.manage.workflow.create', compact('emails')); } catch (Exception $e) { diff --git a/app/Http/Controllers/Agent/helpdesk/Filter/FilterController.php b/app/Http/Controllers/Agent/helpdesk/Filter/FilterController.php index 927787da4..2c065b1f7 100644 --- a/app/Http/Controllers/Agent/helpdesk/Filter/FilterController.php +++ b/app/Http/Controllers/Agent/helpdesk/Filter/FilterController.php @@ -232,7 +232,7 @@ class FilterController extends Controller public function table() { // if (Auth::user()->role == 'admin') { - $ticket = new Tickets(); + $ticket = new Tickets(); $tickets = $ticket ->leftJoin('ticket_thread', function ($join) { $join->on('tickets.id', '=', 'ticket_thread.ticket_id') diff --git a/app/Http/Controllers/Agent/helpdesk/TicketController.php b/app/Http/Controllers/Agent/helpdesk/TicketController.php index 752f63a1c..586357fd7 100644 --- a/app/Http/Controllers/Agent/helpdesk/TicketController.php +++ b/app/Http/Controllers/Agent/helpdesk/TicketController.php @@ -37,10 +37,11 @@ use App\Model\helpdesk\Utility\Date_time_format; use App\Model\helpdesk\Utility\Timezones; use App\User; use Auth; +use Crypt; use DB; use Exception; -use GeoIP; // classes +use GeoIP; use Hash; use Illuminate\Http\Request; use Illuminate\support\Collection; @@ -49,7 +50,6 @@ use Lang; use Mail; use PDF; use UTC; -use Crypt; /** * TicketController. @@ -398,6 +398,7 @@ class TicketController extends Controller public function reply(Ticket_Thread $thread, Request $request, Ticket_attachments $ta, $mail = true, $system_reply = true, $user_id = '') { \Event::fire('reply.request', [$request]); + try { if (is_array($request->file('attachment'))) { } else { @@ -541,9 +542,9 @@ class TicketController extends Controller ], $template_variables = [ 'ticket_number' => $ticket_number, - 'user' => $username, - 'agent_sign' => $agentsign, - 'system_link'=>$link + 'user' => $username, + 'agent_sign' => $agentsign, + 'system_link' => $link, ] ); } @@ -810,6 +811,7 @@ class TicketController extends Controller } // Event fire \Event::fire(new \App\Events\ReadMailEvent($user_id, $password)); + try { if ($auto_response == 0) { $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user->first_name, 'email' => $emailadd], $message = ['subject' => null, 'scenario' => 'registration-notification'], $template_variables = ['user' => $user->first_name, 'email_address' => $emailadd, 'user_password' => $password]); @@ -850,11 +852,11 @@ class TicketController extends Controller if ($auto_response == 0) { $encoded_ticketid = Crypt::encrypt($ticketdata->id); $link = url('check_ticket/'.$encoded_ticketid); - $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket-by-agent', 'body' => $body], + $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket-by-agent', 'body' => $body], $template_variables = [ - 'agent_sign' => Auth::user()->agent_sign, + 'agent_sign' => Auth::user()->agent_sign, 'ticket_number' => $ticket_number2, - 'system_link'=>$link, + 'system_link' => $link, ]); } } catch (\Exception $e) { @@ -862,13 +864,14 @@ class TicketController extends Controller } } else { $body2 = null; + try { if ($auto_response == 0) { - $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket'], - $template_variables = ['user' => $username, - 'ticket_number' => $ticket_number2, - 'department_sign' => '', - 'system_link'=>$link, + $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket'], + $template_variables = ['user' => $username, + 'ticket_number' => $ticket_number2, + 'department_sign' => '', + 'system_link' => $link, ]); } } catch (\Exception $e) { @@ -1229,10 +1232,10 @@ class TicketController extends Controller } else { $ticket_status = $ticket->where('id', '=', $id)->first(); } - // checking for unautherised access attempt on other than owner ticket id - if ($ticket_status == null) { - return redirect()->route('unauth'); - } + // checking for unautherised access attempt on other than owner ticket id + if ($ticket_status == null) { + return redirect()->route('unauth'); + } $ticket_status->status = 3; $ticket_status->closed = 1; $ticket_status->closed_at = date('Y-m-d H:i:s'); @@ -1260,6 +1263,7 @@ class TicketController extends Controller } else { $from_email = $sending_emails->id; } + try { $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticket_status->dept_id), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'scenario' => 'close-ticket'], $template_variables = ['ticket_number' => $ticket_number]); } catch (\Exception $e) { @@ -1496,6 +1500,7 @@ class TicketController extends Controller $agent_email = $user_detail->email; $ticket_link = route('ticket.thread', $id); $master = Auth::user()->first_name.' '.Auth::user()->last_name; + try { $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticket->dept_id), $to = ['name' => $agent, 'email' => $agent_email], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'scenario' => 'assign-ticket'], $template_variables = ['ticket_agent_name' => $agent, 'ticket_number' => $ticket_number, 'ticket_assigner' => $master, 'ticket_link' => $ticket_link]); } catch (\Exception $e) { @@ -1629,6 +1634,7 @@ class TicketController extends Controller $create_user->password = Hash::make($password); $create_user->save(); $user_id = $create_user->id; + try { $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) { @@ -2316,6 +2322,7 @@ class TicketController extends Controller $user->role = 'user'; if ($user->save()) { $user_id = $user->id; + try { $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) { diff --git a/app/Http/Controllers/Agent/helpdesk/UserController.php b/app/Http/Controllers/Agent/helpdesk/UserController.php index b6fb024c6..a8fe00292 100644 --- a/app/Http/Controllers/Agent/helpdesk/UserController.php +++ b/app/Http/Controllers/Agent/helpdesk/UserController.php @@ -149,7 +149,7 @@ class UserController extends Controller } // displaying list of users with chumper datatables // return \Datatable::collection(User::where('role', "!=", "admin")->get()) - return \Datatables::of($users) + return \Datatables::of($users) /* column username */ ->removeColumn('id', 'last_name', 'country_code', 'phone_number') ->addColumn('user_name', function ($model) { @@ -218,14 +218,14 @@ class UserController extends Controller if (Auth::user()->role == 'admin') { // @if(Auth::user()->role == 'admin') - return ''.\Lang::get('lang.view').''; + return ''.\Lang::get('lang.view').''; } if (Auth::user()->role == 'agent') { // @if(Auth::user()->role == 'admin') - if ($model->role == 'user') { - return ''.\Lang::get('lang.view').''; - } + if ($model->role == 'user') { + return ''.\Lang::get('lang.view').''; + } } } }) @@ -235,7 +235,7 @@ class UserController extends Controller public function restoreUser($id) { // dd($id); - // $delete_all = Input::get('delete_all'); + // $delete_all = Input::get('delete_all'); $users = User::where('id', '=', $id)->first(); $users->is_delete = 0; $users->active = 1; @@ -298,6 +298,7 @@ class UserController extends Controller $password = $this->generateRandomString(); $user->password = Hash::make($password); $user->role = 'user'; + try { if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) { return redirect()->back()->with(['fails' => Lang::get('lang.country-code-required-error'), 'country_code_error' => 1])->withInput(); @@ -514,19 +515,19 @@ class UserController extends Controller // $ticket_logic4 = User_org::where('user_id', '=', $id)->update(['user_id' => $assign_to[1]]); // } - // $thread2 = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first(); - // $thread2->body = 'This Ticket have been Reassigned to' .' '. $assignee; - // $thread2->save(); - // UserNotification::where('notification_id', '=', $ticket->id)->delete(); - // $users = User::where('id', '=', $id)->get(); - // $organization = User_org::where('user_id', '=', $id)->delete(); - // Assign_team_agent::where('agent_id', '=', $id)->update(['agent_id' => $assign_to[1]]); - $tickets = Tickets::where('assigned_to', '=', $id)->get(); + // $thread2 = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first(); + // $thread2->body = 'This Ticket have been Reassigned to' .' '. $assignee; + // $thread2->save(); + // UserNotification::where('notification_id', '=', $ticket->id)->delete(); + // $users = User::where('id', '=', $id)->get(); + // $organization = User_org::where('user_id', '=', $id)->delete(); + // 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... - $ticket->assigned_to = $assign_to[1]; + $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; @@ -561,20 +562,20 @@ class UserController extends Controller } elseif ($delete_all == 1) { 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(); + $tickets = Tickets::where('assigned_to', '=', $id)->get(); + // dd($tickets); + 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; @@ -708,6 +709,7 @@ class UserController extends Controller public function getProfile() { $user = Auth::user(); + try { return view('themes.default1.agent.helpdesk.user.profile', compact('user')); } catch (Exception $e) { @@ -727,6 +729,7 @@ class UserController extends Controller $phonecode = $code->where('iso', '=', $location->iso_code)->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $status = $settings->status; + try { return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user')) ->with(['phonecode' => $phonecode->phonecode, @@ -766,13 +769,13 @@ class UserController extends Controller $name = Input::file('profile_pic')->getClientOriginalName(); // dd($name); // dd(str_replace(" ", "_", $name)); - // fetching upload destination path + // fetching upload destination path $destinationPath = 'uploads/profilepic'; - // adding a random value to profile picture filename - $fileName = rand(0000, 9999).'.'.str_replace(" ", "_", $name); - // moving the picture to a destination folder + // adding a random value to profile picture filename + $fileName = rand(0000, 9999).'.'.str_replace(' ', '_', $name); + // moving the picture to a destination folder Input::file('profile_pic')->move($destinationPath, $fileName); - // saving filename to database + // saving filename to database $user->profile_pic = $fileName; } if ($request->get('mobile')) { @@ -805,6 +808,7 @@ class UserController extends Controller // checking if the old password matches the new password if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { $user->password = Hash::make($request->input('new_password')); + try { $user->save(); diff --git a/app/Http/Controllers/Agent/kb/PageController.php b/app/Http/Controllers/Agent/kb/PageController.php index 92a74e1c3..104290086 100644 --- a/app/Http/Controllers/Agent/kb/PageController.php +++ b/app/Http/Controllers/Agent/kb/PageController.php @@ -51,6 +51,7 @@ class PageController extends Controller { $pages = $this->page->paginate(3); $pages->setPath('page'); + try { return view('themes.default1.agent.kb.pages.index', compact('pages')); } catch (Exception $e) { @@ -128,6 +129,7 @@ class PageController extends Controller $sl = $request->input('name'); $slug = str_slug($sl, '-'); $this->page->slug = $slug; + try { $this->page->fill($request->input())->save(); @@ -169,6 +171,7 @@ class PageController extends Controller $pages = $this->page->where('slug', $slug)->first(); $sl = $request->input('name'); $slug = str_slug($sl, '-'); + try { $pages->fill($request->all())->save(); $pages->slug = $slug; diff --git a/app/Http/Controllers/Api/v1/ApiController.php b/app/Http/Controllers/Api/v1/ApiController.php index 6878c510c..350453985 100644 --- a/app/Http/Controllers/Api/v1/ApiController.php +++ b/app/Http/Controllers/Api/v1/ApiController.php @@ -61,6 +61,7 @@ class ApiController extends Controller $this->middleware('jwt.auth'); $this->middleware('api', ['except' => 'GenerateApiKey']); + try { $user = \JWTAuth::parseToken()->authenticate(); $this->user = $user; @@ -1092,7 +1093,7 @@ class ApiController extends Controller $result = $this->user->join('tickets', function ($join) use ($id) { $join->on('users.id', '=', 'tickets.assigned_to') ->where('status', '=', 1); - //->where('user_id', '=', $id); + //->where('user_id', '=', $id); }) ->join('department', 'department.id', '=', 'tickets.dept_id') ->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') @@ -1288,6 +1289,7 @@ class ApiController extends Controller public function collaboratorSearch() { $this->validate($this->request, ['term' => 'required']); + try { $emails = $this->ticket->autosearch(); //return $emails; diff --git a/app/Http/Controllers/Api/v1/TicketController.php b/app/Http/Controllers/Api/v1/TicketController.php index b9e3bfc30..9e5f70bd8 100644 --- a/app/Http/Controllers/Api/v1/TicketController.php +++ b/app/Http/Controllers/Api/v1/TicketController.php @@ -329,12 +329,12 @@ class TicketController extends Controller // Mail::send(array('html' => 'emails.ticket_re-reply'), ['content' => $reply_content, 'ticket_number' => $ticket_number, 'From' => $company, 'name' => $username, 'Agent_Signature' => $agentsign], function ($message) use ($email, $user_name, $ticket_number, $ticket_subject, $check_attachment) { // $message->to($email, $user_name)->subject($ticket_subject . '[#' . $ticket_number . ']'); // // if(isset($attachments)){ -// // if ($check_attachment == 1) { -// // $size = count($attach); -// // for ($i = 0; $i < $size; $i++) { -// // $message->attach($attachments[$i]->getRealPath(), ['as' => $attachments[$i]->getClientOriginalName(), 'mime' => $attachments[$i]->getClientOriginalExtension()]); -// // } -// // } + // // if ($check_attachment == 1) { + // // $size = count($attach); + // // for ($i = 0; $i < $size; $i++) { + // // $message->attach($attachments[$i]->getRealPath(), ['as' => $attachments[$i]->getClientOriginalName(), 'mime' => $attachments[$i]->getClientOriginalExtension()]); + // // } + // // } // }, true); //dd('reply'); /* @@ -361,12 +361,12 @@ class TicketController extends Controller } // Mail::send('emails.ticket_re-reply', ['content' => $reply_content, 'ticket_number' => $ticket_number, 'From' => $company, 'name' => $collab_user_name, 'Agent_Signature' => $agentsign], function ($message) use ($collab_email, $collab_user_name, $ticket_number, $ticket_subject, $check_attachment) { // $message->to($collab_email, $collab_user_name)->subject($ticket_subject . '[#' . $ticket_number . ']'); -// // if ($check_attachment == 1) { -// // $size = sizeOf($attachments); -// // for ($i = 0; $i < $size; $i++) { -// // $message->attach($attachments[$i]->getRealPath(), ['as' => $attachments[$i]->getClientOriginalName(), 'mime' => $attachments[$i]->getClientOriginalExtension()]); -// // } -// // } + // // if ($check_attachment == 1) { + // // $size = sizeOf($attachments); + // // for ($i = 0; $i < $size; $i++) { + // // $message->attach($attachments[$i]->getRealPath(), ['as' => $attachments[$i]->getClientOriginalName(), 'mime' => $attachments[$i]->getClientOriginalExtension()]); + // // } + // // } // }, true); try { @@ -713,6 +713,7 @@ class TicketController extends Controller return $collab; } catch (\Exception $ex) { return $ex->getMessage(); + throw new \Exception('get collaborator for ticket fails'); } } diff --git a/app/Http/Controllers/Api/v1/TokenAuthController.php b/app/Http/Controllers/Api/v1/TokenAuthController.php index f08d0346d..f6f989bb6 100644 --- a/app/Http/Controllers/Api/v1/TokenAuthController.php +++ b/app/Http/Controllers/Api/v1/TokenAuthController.php @@ -47,7 +47,7 @@ class TokenAuthController extends Controller $password = $request->input('password'); $field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name'; -//$credentials = $request->only('email', 'password'); + //$credentials = $request->only('email', 'password'); try { if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password, 'active'=>1])) { @@ -62,7 +62,7 @@ class TokenAuthController extends Controller } $user_id = \Auth::user()->id; -// if no errors are encountered we can return a JWT + // if no errors are encountered we can return a JWT return response()->json(compact('token', 'user_id')); } @@ -89,7 +89,7 @@ class TokenAuthController extends Controller return response()->json(compact('error')); } -//dd($user); + //dd($user); return response()->json(compact('user')); } diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php index 978a41401..02a211bf7 100644 --- a/app/Http/Controllers/Auth/PasswordController.php +++ b/app/Http/Controllers/Auth/PasswordController.php @@ -57,8 +57,8 @@ class PasswordController extends Controller $user = User::where('email', '=', $request->only('email'))->orWhere('mobile', '=', $request->only('email'))->first(); if (isset($user)) { $user1 = $user->email; - //gen new code and pass - $code = str_random(60); + //gen new code and pass + $code = str_random(60); $password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->first(); if (isset($password_reset_table)) { $password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->update(['token' => $code, 'created_at' => $date]); @@ -107,7 +107,7 @@ class PasswordController extends Controller $this->getResetValidationCustomAttributes() ); $credentials = $this->getResetCredentials($request); - // dd($credentials); + // dd($credentials); $email = $credentials['email']; $password = $credentials['password']; $token = $credentials['token']; diff --git a/app/Http/Controllers/Client/helpdesk/ClientTicketController.php b/app/Http/Controllers/Client/helpdesk/ClientTicketController.php index 05a262173..d39ee57e9 100644 --- a/app/Http/Controllers/Client/helpdesk/ClientTicketController.php +++ b/app/Http/Controllers/Client/helpdesk/ClientTicketController.php @@ -32,7 +32,7 @@ class ClientTicketController extends Controller $this->TicketWorkflowController = $TicketWorkflowController; // $this->middleware('auth'); // $this->middleware('role.user'); - $this->middleware('board'); + $this->middleware('board'); } /** diff --git a/app/Http/Controllers/Client/helpdesk/FormController.php b/app/Http/Controllers/Client/helpdesk/FormController.php index 15afebc94..fa15bf34e 100644 --- a/app/Http/Controllers/Client/helpdesk/FormController.php +++ b/app/Http/Controllers/Client/helpdesk/FormController.php @@ -249,6 +249,7 @@ class FormController extends Controller } } catch (\Exception $ex) { dd($ex); + return redirect()->back()->with('fails', $ex->getMessage()); } // dd($result); diff --git a/app/Http/Controllers/Client/helpdesk/GuestController.php b/app/Http/Controllers/Client/helpdesk/GuestController.php index d1a0afd74..cdd03f0e6 100644 --- a/app/Http/Controllers/Client/helpdesk/GuestController.php +++ b/app/Http/Controllers/Client/helpdesk/GuestController.php @@ -98,13 +98,13 @@ class GuestController extends Controller if (Input::file('profile_pic')) { // fetching picture name $name = Input::file('profile_pic')->getClientOriginalName(); - // fetching upload destination path + // fetching upload destination path $destinationPath = 'uploads/profilepic'; - // adding a random value to profile picture filename - $fileName = rand(0000, 9999).'.'.str_replace(" ", "_", $name); - // moving the picture to a destination folder + // adding a random value to profile picture filename + $fileName = rand(0000, 9999).'.'.str_replace(' ', '_', $name); + // moving the picture to a destination folder Input::file('profile_pic')->move($destinationPath, $fileName); - // saving filename to database + // saving filename to database $user->profile_pic = $fileName; } if ($request->get('mobile')) { @@ -237,6 +237,7 @@ class GuestController extends Controller //echo $user->password; if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { $user->password = Hash::make($request->input('new_password')); + try { $user->save(); diff --git a/app/Http/Controllers/Client/helpdesk/UnAuthController.php b/app/Http/Controllers/Client/helpdesk/UnAuthController.php index 9af08b639..b90dded4e 100644 --- a/app/Http/Controllers/Client/helpdesk/UnAuthController.php +++ b/app/Http/Controllers/Client/helpdesk/UnAuthController.php @@ -94,6 +94,7 @@ class UnAuthController extends Controller $ticket_token->token = $hashed_token; $ticket_token->save(); } + try { $this->PhpMailController->sendmail( $from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $user_details->email], $message = ['subject' => 'Ticket link Request ['.$ticket_number.']', 'scenario' => 'check-ticket'], $template_variables = ['user' => $username, 'ticket_link_with_number' => url('show-ticket/'.$ticket->id.'/'.$token)] @@ -270,6 +271,7 @@ class UnAuthController extends Controller } else { $from_email = $sending_emails->id; } + try { $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $tickets->dept_id), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'scenario' => 'close-ticket'], $template_variables = ['ticket_number' => $ticket_number]); } catch (\Exception $e) { @@ -337,7 +339,7 @@ class UnAuthController extends Controller // app()->setLocale($lang); \Cache::forever('language', $lang); - // dd(Cache::get('language')); + // dd(Cache::get('language')); // dd() } else { return false; @@ -347,11 +349,11 @@ class UnAuthController extends Controller } // Follow up tickets - public function followup() - { - $followup = Followup::whereId('1')->first(); - $condition = $followup->condition; - // dd($condition); + public function followup() + { + $followup = Followup::whereId('1')->first(); + $condition = $followup->condition; + // dd($condition); switch ($condition) { case 'everyMinute': @@ -383,34 +385,34 @@ class UnAuthController extends Controller break; } - if ($followup->status = 1) { - $tickets = Tickets::where('id', '>=', 1)->where('status', '!=', 5)->get(); - // dd( $tickets); - // $tickets=Tickets::where('id', '>=', 1)->where('status', '!=', 5)->pluck('id'); - // dd( $tickets); - // $id=1; - foreach ($tickets as $ticket) { + if ($followup->status = 1) { + $tickets = Tickets::where('id', '>=', 1)->where('status', '!=', 5)->get(); + // dd( $tickets); + // $tickets=Tickets::where('id', '>=', 1)->where('status', '!=', 5)->pluck('id'); + // dd( $tickets); // $id=1; - // $id++; - // $ticket=Tickets::where('status', '!=', 5)->get(); + foreach ($tickets as $ticket) { + // $id=1; + // $id++; + // $ticket=Tickets::where('status', '!=', 5)->get(); - // dd($ticket); - // if($ticket != null){ + // dd($ticket); + // if($ticket != null){ // dd('here'); - $ck = date('Y-m-d H:i:s', strtotime($ticket->updated_at.$followup_set)); - // dd($ck); - $current_time = date('Y-m-d H:i:s'); - if ($current_time > $ck) { - $ticket->follow_up = 1; - $ticket->save(); - // Tickets::where('id', '=',$id) + $ck = date('Y-m-d H:i:s', strtotime($ticket->updated_at.$followup_set)); + // dd($ck); + $current_time = date('Y-m-d H:i:s'); + if ($current_time > $ck) { + $ticket->follow_up = 1; + $ticket->save(); + // Tickets::where('id', '=',$id) // ->update(['follow_up' => 1]); // } - } - // if($id=2) + } + // if($id=2) // {dd($ticket);} + } } - } - } + } } diff --git a/app/Http/Controllers/Common/ApiSettings.php b/app/Http/Controllers/Common/ApiSettings.php index ddc844401..2276963b7 100644 --- a/app/Http/Controllers/Common/ApiSettings.php +++ b/app/Http/Controllers/Common/ApiSettings.php @@ -51,6 +51,7 @@ class ApiSettings extends Controller $this->validate($request, [ 'ticket_detail' => 'url', ]); + try { // dd($request->input()); DB::table('settings_system') @@ -91,6 +92,7 @@ class ApiSettings extends Controller $this->postHook($data); } catch (Exception $ex) { dd($ex); + throw new Exception($ex->getMessage()); } } @@ -106,6 +108,7 @@ class ApiSettings extends Controller } } catch (Exception $ex) { dd($ex); + throw new Exception($ex->getMessage()); } } diff --git a/app/Http/Controllers/Common/PhpMailController.php b/app/Http/Controllers/Common/PhpMailController.php index 3432c50f5..b90c22138 100644 --- a/app/Http/Controllers/Common/PhpMailController.php +++ b/app/Http/Controllers/Common/PhpMailController.php @@ -234,15 +234,15 @@ class PhpMailController extends Controller if ($cc != null) { foreach ($cc as $collaborator) { //mail to collaborators - $collab_user_id = $collaborator->user_id; + $collab_user_id = $collaborator->user_id; $user_id_collab = User::where('id', '=', $collab_user_id)->first(); $collab_email = $user_id_collab->email; $m->cc($collab_email); } } - // $mail->addBCC($bc); - $size = count($attach); + // $mail->addBCC($bc); + $size = count($attach); if ($size > 0) { for ($i = 0; $i < $size; $i++) { if (is_array($attach) && array_key_exists($i, $attach)) { diff --git a/app/Http/Controllers/Common/SettingsController.php b/app/Http/Controllers/Common/SettingsController.php index ea9f5e7e5..800b94577 100644 --- a/app/Http/Controllers/Common/SettingsController.php +++ b/app/Http/Controllers/Common/SettingsController.php @@ -120,6 +120,7 @@ class SettingsController extends Controller $widget = $widgets->where('id', '=', $id)->first(); $widget->title = $request->title; $widget->value = $request->content; + try { $widget->save(); @@ -198,6 +199,7 @@ class SettingsController extends Controller $widget = $widgets->where('id', '=', $id)->first(); $widget->title = $request->title; $widget->value = $request->content; + try { $widget->save(); @@ -234,6 +236,7 @@ class SettingsController extends Controller $data->name = $request->input('name'); $data->email = $request->input('email'); $data->password = Crypt::encrypt($request->input('password')); + try { $data->save(); @@ -257,6 +260,7 @@ class SettingsController extends Controller $pass = $request->input('password'); $password = Crypt::encrypt($pass); $settings->password = $password; + try { $settings->save(); } catch (Exception $e) { @@ -270,6 +274,7 @@ class SettingsController extends Controller $settings->logo = $fileName; $settings->save(); } + try { $settings->fill($request->except('logo', 'password'))->save(); @@ -364,6 +369,7 @@ class SettingsController extends Controller public function PostPlugins(Request $request) { $this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']); + try { if (!extension_loaded('zip')) { throw new Exception('Please enable zip extension in your php'); diff --git a/app/Http/Controllers/Installer/helpdesk/InstallController.php b/app/Http/Controllers/Installer/helpdesk/InstallController.php index b77173fbf..c1fe9ed05 100644 --- a/app/Http/Controllers/Installer/helpdesk/InstallController.php +++ b/app/Http/Controllers/Installer/helpdesk/InstallController.php @@ -364,7 +364,7 @@ class InstallController extends Controller $datacontent = File::get($install); $datacontent = str_replace('%0%', $value, $datacontent); File::put($install, $datacontent); -// setting email settings in route + // setting email settings in route $smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()"; $link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; @@ -375,6 +375,7 @@ class InstallController extends Controller $datacontent2 = str_replace('http://localhost', $link, $datacontent2); File::put($app_url, $datacontent2); $language = Cache::get('language'); + try { Cache::flush(); diff --git a/app/Http/Controllers/Job/MailController.php b/app/Http/Controllers/Job/MailController.php index 0801c26ac..bab160754 100644 --- a/app/Http/Controllers/Job/MailController.php +++ b/app/Http/Controllers/Job/MailController.php @@ -43,6 +43,7 @@ class MailController extends Controller public function getServiceForm($short_name) { $form = ''; + try { switch ($short_name) { case 'smtp': diff --git a/app/Http/Middleware/CheckUpdate.php b/app/Http/Middleware/CheckUpdate.php index a37e617e0..59fdfc97f 100644 --- a/app/Http/Middleware/CheckUpdate.php +++ b/app/Http/Middleware/CheckUpdate.php @@ -49,8 +49,8 @@ class CheckUpdate $notify = new BarNotification(); if (!\Schema::hasTable('bar_notifications')) { $url = url('database-upgrade'); - //$string = "Your Database is outdated please upgrade Now !"; - echo view('themes.default1.update.database', compact('url')); + //$string = "Your Database is outdated please upgrade Now !"; + echo view('themes.default1.update.database', compact('url')); exit; } $not = $notify->get(); diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index e4bcc1e65..a67e252cf 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -4,21 +4,19 @@ namespace App\Http\Middleware; use Closure; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; -use Lang; class VerifyCsrfToken extends BaseVerifier { - - /** + /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ 'CheckSerial', - 'api/v1/*' + 'api/v1/*', ]; - + /** * Handle an incoming request. * diff --git a/app/Http/Requests/helpdesk/TicketRequest.php b/app/Http/Requests/helpdesk/TicketRequest.php index 3dd05d61e..de5d0e79c 100644 --- a/app/Http/Requests/helpdesk/TicketRequest.php +++ b/app/Http/Requests/helpdesk/TicketRequest.php @@ -29,6 +29,7 @@ class TicketRequest extends Request public function rules() { $error = ''; + try { $size = $this->size(); if ($size > 800 || $size == 0) { diff --git a/app/Http/routes.php b/app/Http/routes.php index 131494175..a5d92c950 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -28,7 +28,7 @@ Route::group(['middleware' => ['web']], function () { | Here is defining entire routes for the Admin Panel | */ - Route::get('password/email/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'password.email', 'uses' => 'Auth\PasswordController@getEmail']); + Route::get('password/email/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'password.email', 'uses' => 'Auth\PasswordController@getEmail']); Breadcrumbs::register('password.email', function ($breadcrumbs) { $breadcrumbs->parent('/'); $breadcrumbs->push('Login', url('auth/login')); @@ -36,15 +36,15 @@ Route::group(['middleware' => ['web']], function () { }); // register page - Route::get('auth/register/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@getRegister']); + Route::get('auth/register/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@getRegister']); Breadcrumbs::register('auth.register', function ($breadcrumbs) { $breadcrumbs->parent('/'); $breadcrumbs->push('Login', url('auth/login')); $breadcrumbs->push('Create Account', url('auth/register')); }); - // Auth login - Route::get('auth/login/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@getLogin']); + // Auth login + Route::get('auth/login/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@getLogin']); Breadcrumbs::register('auth.login', function ($breadcrumbs) { $breadcrumbs->parent('/'); $breadcrumbs->push('Create Account', url('auth/register')); @@ -83,10 +83,10 @@ Route::group(['middleware' => ['web']], function () { Route::resource('teams', 'Admin\helpdesk\TeamController'); // in teams module, for CRUD Route::get('/teams/show/{id}', ['as' => 'teams.show', 'uses' => 'Admin\helpdesk\TeamController@show']); /* Get Team View */ - Breadcrumbs::register('teams.show', function ($breadcrumbs) { - $breadcrumbs->parent('teams.index'); - $breadcrumbs->push(Lang::get('lang.show'), url('teams/{teams}/show')); - }); + Breadcrumbs::register('teams.show', function ($breadcrumbs) { + $breadcrumbs->parent('teams.index'); + $breadcrumbs->push(Lang::get('lang.show'), url('teams/{teams}/show')); + }); Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpdesk\TeamController@getshow']); Route::resource('agents', 'Admin\helpdesk\AgentController'); // in agents module, for CRUD @@ -428,7 +428,7 @@ Route::group(['middleware' => ['web']], function () { // route to get the data on change Route::post('help-topic-report/{date1}/{date2}/{id}', ['as' => 'report.helptopic', 'uses' => 'Agent\helpdesk\ReportController@chartdataHelptopic']); /* To show dashboard pages */ Route::post('help-topic-pdf', ['as' => 'help.topic.pdf', 'uses' => 'Agent\helpdesk\ReportController@helptopicPdf']); - // Route to get details of agents + // Route to get details of agents Route::post('get-agents', ['as' => 'get-agents', 'uses' => 'Agent\helpdesk\UserController@getAgentDetails']); /* @@ -446,12 +446,12 @@ Route::group(['middleware' => ['web']], function () { Route::get('get-tag', ['as'=>'tag.get', 'uses'=>'Agent\helpdesk\Filter\TagController@getTag']); }); - /* - * Followup tickets - */ - Route::get('/ticket/followup', ['as' => 'followup.ticket', 'uses' => 'Agent\helpdesk\TicketController@followupTicketList']); // Get Closed Ticket / + /* + * Followup tickets + */ + Route::get('/ticket/followup', ['as' => 'followup.ticket', 'uses' => 'Agent\helpdesk\TicketController@followupTicketList']); // Get Closed Ticket / - Route::get('/ticket/get-followup', ['as' => 'get.followup.ticket', 'uses' => 'Agent\helpdesk\TicketController@getFollowup']); // Get tickets in datatable / + Route::get('/ticket/get-followup', ['as' => 'get.followup.ticket', 'uses' => 'Agent\helpdesk\TicketController@getFollowup']); // Get tickets in datatable / Route::get('/ticket/close/get-approval/{id}', ['as' => 'get.close.approval.ticket', 'uses' => 'Agent\helpdesk\TicketController@getCloseapproval']); // Get tickets in datatable / /* |------------------------------------------------------------------ @@ -494,11 +494,11 @@ Route::group(['middleware' => ['web']], function () { Route::get('check_ticket/{id}', ['as' => 'check_ticket', 'uses' => 'Client\helpdesk\GuestController@get_ticket_email']); //detail ticket information -// show ticket via have a ticket + // show ticket via have a ticket Route::get('show-ticket/{id}/{code}', ['as' => 'show.ticket', 'uses' => 'Client\helpdesk\UnAuthController@showTicketCode']); //detail ticket information //testing ckeditor -//=================================================================================== + //=================================================================================== Route::group(['middleware' => 'role.user', 'middleware' => 'auth'], function () { Route::get('client-profile', ['as' => 'client.profile', 'uses' => 'Client\helpdesk\GuestController@getProfile']); /* User profile get */ @@ -511,7 +511,7 @@ Route::group(['middleware' => ['web']], function () { Route::post('verify-client-number2', ['as' => 'post-client-verify-number', 'uses' => 'Client\helpdesk\GuestController@verifyOTP']); }); -//==================================================================================== + //==================================================================================== Route::get('checkticket', 'Client\helpdesk\ClientTicketController@getCheckTicket'); /* Check your Ticket */ Route::get('myticket', ['as' => 'ticket', 'uses' => 'Client\helpdesk\GuestController@getMyticket']); /* Get my tickets */ Route::get('myticket/{id}', ['as' => 'ticket', 'uses' => 'Client\helpdesk\GuestController@thread']); /* Get my tickets */ @@ -816,8 +816,8 @@ Route::group(['middleware' => ['web']], function () { Route::post('ticket/priority/edit1', ['as' => 'priority.edit1', 'uses' => 'Admin\helpdesk\PriorityController@priorityEdit1']); Route::get('ticket/priority/{ticket_priority}/edit', ['as' => 'priority.edit', 'uses' => 'Admin\helpdesk\PriorityController@priorityEdit']); Route::get('ticket/priority/{ticket_priority}/destroy', ['as' => 'priority.destroy', 'uses' => 'Admin\helpdesk\PriorityController@destroy']); - // user---arindam - Route::post('rolechangeadmin/{id}', ['as' => 'user.post.rolechangeadmin', 'uses' =>'Agent\helpdesk\UserController@changeRoleAdmin']); + // user---arindam + Route::post('rolechangeadmin/{id}', ['as' => 'user.post.rolechangeadmin', 'uses' =>'Agent\helpdesk\UserController@changeRoleAdmin']); Route::post('rolechangeagent/{id}', ['as' => 'user.post.rolechangeagent', 'uses' =>'Agent\helpdesk\UserController@changeRoleAgent']); Route::post('rolechangeuser/{id}', ['as' => 'user.post.rolechangeuser', 'uses' =>'Agent\helpdesk\UserController@changeRoleUser']); Route::get('password', ['as' => 'user.changepassword', 'uses' =>'Agent\helpdesk\UserController@randomPassword']); @@ -825,15 +825,15 @@ Route::group(['middleware' => ['web']], function () { Route::post('delete/{id}', ['as' => 'user.post.delete', 'uses' =>'Agent\helpdesk\UserController@deleteAgent']); // deleted user list - Route::get('deleted/user', ['as' => 'user.deleted', 'uses' => 'Agent\helpdesk\UserController@deletedUser']); + Route::get('deleted/user', ['as' => 'user.deleted', 'uses' => 'Agent\helpdesk\UserController@deletedUser']); Route::post('restore/{id}', ['as' => 'user.restore', 'uses' => 'Agent\helpdesk\UserController@restoreUser']); - //due today ticket - Route::get('duetoday', ['as' => 'ticket.duetoday', 'uses' =>'Agent\helpdesk\TicketController@dueTodayTicketlist']); + //due today ticket + Route::get('duetoday', ['as' => 'ticket.duetoday', 'uses' =>'Agent\helpdesk\TicketController@dueTodayTicketlist']); - // Route::post('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']); - Route::get('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']); /* Get Open Ticket */ + // Route::post('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']); + Route::get('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']); /* Get Open Ticket */ // Breadcrumbs::register('open.ticket', function ($breadcrumbs) { // $breadcrumbs->parent('dashboard'); // $breadcrumbs->push(Lang::get('lang.tickets') . '  >  ' . Lang::get('lang.open'), route('open.ticket')); diff --git a/app/Model/helpdesk/Notification/Notification.php b/app/Model/helpdesk/Notification/Notification.php index 0dd581268..3345ef092 100644 --- a/app/Model/helpdesk/Notification/Notification.php +++ b/app/Model/helpdesk/Notification/Notification.php @@ -59,7 +59,7 @@ class Notification extends BaseModel public function delete() { $this->deleteUserNotification(); - // $this->dummyDelete(); + // $this->dummyDelete(); parent::delete(); } } diff --git a/app/Model/helpdesk/Ticket/Ticket_attachments.php b/app/Model/helpdesk/Ticket/Ticket_attachments.php index 163e864c7..0f6146270 100644 --- a/app/Model/helpdesk/Ticket/Ticket_attachments.php +++ b/app/Model/helpdesk/Ticket/Ticket_attachments.php @@ -35,7 +35,7 @@ class Ticket_attachments extends Model if ($content) { $value = base64_encode($content); if (mime($this->type) != 'image') { - $root = $root . "/" . $name; + $root = $root.'/'.$name; chmod($root, 1204); } } diff --git a/app/User.php b/app/User.php index 1ce1abfa8..afcecb28b 100644 --- a/app/User.php +++ b/app/User.php @@ -45,17 +45,18 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon $pic = $this->checkArray('avatar', $info); } if (!$pic && $value) { - $pic = ""; - $file = asset('uploads/profilepic/' . $value); + $pic = ''; + $file = asset('uploads/profilepic/'.$value); if ($file) { $type = pathinfo($file, PATHINFO_EXTENSION); $data = file_get_contents($file); - $pic = 'data:image/' . $type . ';base64,' . base64_encode($data); + $pic = 'data:image/'.$type.';base64,'.base64_encode($data); } } if (!$value) { $pic = \Gravatar::src($this->attributes['email']); } + return $pic; } diff --git a/database/migrations/2016_04_18_115852_create_workflow_name_table.php b/database/migrations/2016_04_18_115852_create_workflow_name_table.php index 06db5cd4a..8b8db67cf 100644 --- a/database/migrations/2016_04_18_115852_create_workflow_name_table.php +++ b/database/migrations/2016_04_18_115852_create_workflow_name_table.php @@ -23,13 +23,13 @@ class CreateWorkflowNameTable extends Migration }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('workflow_name'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('workflow_name'); + } } diff --git a/database/migrations/2016_04_18_115900_create_workflow_rule_table.php b/database/migrations/2016_04_18_115900_create_workflow_rule_table.php index 008d897bd..61c21b7e0 100644 --- a/database/migrations/2016_04_18_115900_create_workflow_rule_table.php +++ b/database/migrations/2016_04_18_115900_create_workflow_rule_table.php @@ -27,16 +27,16 @@ class CreateWorkflowRuleTable extends Migration }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('workflow_rules', function (Blueprint $table) { - $table->dropForeign('workflow_rules_1'); - }); - Schema::drop('workflow_rules'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('workflow_rules', function (Blueprint $table) { + $table->dropForeign('workflow_rules_1'); + }); + Schema::drop('workflow_rules'); + } } diff --git a/database/migrations/2016_04_18_115908_create_workflow_action_table.php b/database/migrations/2016_04_18_115908_create_workflow_action_table.php index 24b8471aa..5fc03fb97 100644 --- a/database/migrations/2016_04_18_115908_create_workflow_action_table.php +++ b/database/migrations/2016_04_18_115908_create_workflow_action_table.php @@ -24,16 +24,16 @@ class CreateWorkflowActionTable extends Migration }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('workflow_action'); - Schema::table('workflow_action', function (Blueprint $table) { - $table->dropForeign('workflow_action_idfk_1'); - }); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('workflow_action'); + Schema::table('workflow_action', function (Blueprint $table) { + $table->dropForeign('workflow_action_idfk_1'); + }); + } } diff --git a/database/migrations/2016_05_10_102604_create_bar_notifications_table.php b/database/migrations/2016_05_10_102604_create_bar_notifications_table.php index c11bffd1a..7885818ee 100644 --- a/database/migrations/2016_05_10_102604_create_bar_notifications_table.php +++ b/database/migrations/2016_05_10_102604_create_bar_notifications_table.php @@ -20,7 +20,7 @@ class CreateBarNotificationsTable extends Migration }); $version = \Config::get('app.version'); $date = date('Y-m-d H:i:s'); - //\DB::table('bar_notifications')->insert(['key'=>'new-install','value'=>"Congrates ! You have installed $version",'created_at'=>$date]); + //\DB::table('bar_notifications')->insert(['key'=>'new-install','value'=>"Congrates ! You have installed $version",'created_at'=>$date]); } /** diff --git a/public/ckeditor/samples/old/assets/posteddata.php b/public/ckeditor/samples/old/assets/posteddata.php index 2baa84ed6..70b4952f2 100644 --- a/public/ckeditor/samples/old/assets/posteddata.php +++ b/public/ckeditor/samples/old/assets/posteddata.php @@ -41,7 +41,6 @@ if (!empty($_POST)) {