Merge remote-tracking branch 'refs/remotes/origin/release-v1.9.2'

# Conflicts:
#	app/Console/Kernel.php
#	app/FaveoStorage/Controllers/SettingsController.php
#	app/Http/Controllers/Admin/helpdesk/TemplateController.php
This commit is contained in:
Manish Verma
2017-01-05 19:09:35 +05:30
59 changed files with 3240 additions and 1546 deletions

View File

@@ -85,7 +85,7 @@ class HelptopicController extends Controller
$departments = $department->get();
$topics = $topic->get();
$forms = $form->get();
$agents = $agent->where('role', '=', 'agent')->get();
$agents = $agent->where('role', '!=', 'user')->where('active', '=', 1)->orderBy('first_name')->get();
$slas = $sla->get();
$priority = Ticket_Priority::where('status', '=', 1)->get();
@@ -143,7 +143,7 @@ class HelptopicController extends Controller
public function edit($id, Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, Sla_plan $sla)
{
try {
$agents = User::where('role', '=', 'agent')->get();
$agents = User::where('role', '!=', 'user')->where('active', '=', 1)->orderBy('first_name')->get();
$departments = $department->get();
$topics = $topic->whereId($id)->first();
$forms = $form->get();

View File

@@ -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();
}
}
@@ -205,7 +210,8 @@ class LanguageController extends Controller
*/
public function download()
{
$file_path = base_path('public/downloads/en.zip');
$path = 'downloads'.DIRECTORY_SEPARATOR.'en.zip';
$file_path = public_path($path);
return response()->download($file_path);
}

View File

@@ -68,7 +68,7 @@ class TeamController extends Controller
public function create(User $user)
{
try {
$user = $user->where('role', '<>', 'user')->where('active', '=', 1)->get();
$user = $user->where('role', '<>', 'user')->where('active', '=', 1)->orderBy('first_name')->get();
return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user'));
} catch (Exception $e) {
@@ -86,15 +86,23 @@ class TeamController extends Controller
*/
public function store(Teams $team, TeamRequest $request)
{
if ($request->team_lead) {
$team_lead = $request->team_lead;
} else {
$team_lead = null;
}
$team->team_lead = $team_lead;
try {
/* Check whether function success or not */
$team->fill($request->except('team_lead'))->save();
$team_update = Teams::find($team->id);
if ($request->team_lead) {
$team_lead = $request->team_lead;
$team_update->update([
'team_lead' => $team_lead,
]);
Assign_team_agent::create([
'team_id' => $team_update->id,
'agent_id' => $team_lead,
]);
} else {
$team_lead = null;
}
/* redirect to Index page with Success Message */
return redirect('teams')->with('success', Lang::get('lang.teams_created_successfully'));
} catch (Exception $e) {
@@ -202,11 +210,16 @@ $users = DB::table('team_assign_agent')->select('team_assign_agent.id', 'team_as
public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team)
{
try {
$user = $user->where('role', '<>', 'user')->where('active', '=', 1)->get();
$a_id = [];
$teams = $team->whereId($id)->first();
$agent_team = $assign_team_agent->where('team_id', $id)->get();
$agent_id = $agent_team->lists('agent_id', 'agent_id');
foreach ($agent_id as $value) {
array_push($a_id, $value);
}
// dd($a_id);
$user = $user->whereIn('id', $a_id)->where('active', '=', 1)->orderBy('first_name')->get();
// dd($user);
return view('themes.default1.admin.helpdesk.agent.teams.edit', compact('agent_id', 'user', 'teams', 'allagents'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());

View File

@@ -132,7 +132,7 @@ class FilterController extends Controller
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('tickets.status', '=', 1)
// ->where('tickets.isanswered', '=', 0)
->where('tickets.isanswered', '=', 0)
->whereNotNull('tickets.duedate')
->where('tickets.duedate', '!=', '00-00-00 00:00:00')
@@ -196,6 +196,7 @@ class FilterController extends Controller
->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status');
})
->where('isanswered', '=', 0)
->where('tickets.status', '=', 1);
case '/duetoday':
if (Auth::user()->role == 'agent') {
@@ -238,7 +239,7 @@ class FilterController extends Controller
->whereNotNull('title')
->where('ticket_thread.is_internal', '<>', 1);
})
->leftJoin('ticket_thread as ticket_thread2', 'ticket_thread2.ticket_id', '=', 'tickets.id')
->Join('ticket_source', 'ticket_source.id', '=', 'tickets.source')
->leftJoin('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->leftJoin('users as u', 'u.id', '=', 'tickets.user_id')
@@ -255,17 +256,17 @@ class FilterController extends Controller
'u1.user_name as assign_user_name',
\DB::raw('max(ticket_thread.updated_at) as updated_at'),
\DB::raw('min(ticket_thread.updated_at) as created_at'),
'tickets.priority_id', 'tickets.assigned_to',
DB::raw('COUNT(ticket_thread.updated_at) as countthread'),
'ticket_priority.priority_color',
'u.first_name as first_name',
'u.last_name as last_name',
'u1.first_name as assign_first_name',
'u1.last_name as assign_last_name',
'tickets.status',
'tickets.user_id',
'ticket_priority.priority_color',
DB::raw('COUNT(DISTINCT ticket_thread2.id) as countthread'),
DB::raw('COUNT(ticket_attachment.thread_id) as countattachment'),
DB::raw('COUNT(ticket_collaborator.ticket_id) as countcollaborator'),
'tickets.status',
'tickets.user_id',
'tickets.priority_id', 'tickets.assigned_to',
'ticket_status.name as tickets_status',
'ticket_source.css_class as css',
DB::raw('substring_index(group_concat(ticket_thread.poster order by ticket_thread.id desc) , ",", 1) as last_replier'),

View File

@@ -2218,6 +2218,9 @@ class TicketController extends Controller
if ($count === 1) {
$user_id = $user->id;
$ticket = Tickets::where('id', '=', $id)->first();
if ($user_id === (int) $ticket->user_id) {
return 400;
}
$ticket_number = $ticket->ticket_number;
$ticket->user_id = $user_id;
$ticket->save();
@@ -2422,6 +2425,7 @@ class TicketController extends Controller
$success = 0;
}
}
$this->sendMergeNotification($p_id, $t_id);
return $success;
}
@@ -2896,4 +2900,32 @@ class TicketController extends Controller
return $base64;
}
/**
*@category function to send notification of ticket merging to the owners
*
*@param srting array $t_id, $p_id
*
*@return null
*/
public function sendMergeNotification($p_id, $t_id)
{
try {
$ticket_details = Tickets::select('ticket_number', 'user_id', 'dept_id')->where('id', '=', $p_id)->first();
$user_detail = User::where('id', '=', $ticket_details->user_id)->first();
if ($user_detail->count() > 0) {
if ($user_detail->email !== null || $user_detail->email !== '') {
$meged_ticket_details = Tickets::select('ticket_number')->whereIn('id', $t_id)->get();
$child_ticket_numbers = [];
foreach ($meged_ticket_details as $value) {
array_push($child_ticket_numbers, $value->ticket_number);
}
// dd(implode(", ",$child_ticket_numbers), $ticket_details->ticket_number);
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticket_details->dept_id), $to = ['user' => $user_detail->full_name, 'email' => $user_detail->email], $message = ['subject' => '', 'body' => '', 'scenario' => 'merge-ticket-notification'], $template_variables = ['user' => $user_detail->full_name, 'ticket_number' => $ticket_details->ticket_number, 'ticket_link' => route('ticket.thread', $p_id), 'merged_ticket_numbers' => implode(', ', $child_ticket_numbers)]);
}
}
} catch (\Exception $e) {
//catch the exception
}
}
}

View File

@@ -32,6 +32,7 @@ use App\Model\helpdesk\Utility\Otp;
use App\User;
// classes
use Auth;
use Datatables;
use DateTime;
use DB;
use Exception;
@@ -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') {
$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 = '<button class="btn btn-success btn-xs">Active</button>';
@@ -177,19 +198,8 @@ class UserController extends Controller
return $stat;
})
/* column ban status */
->addColumn('ban', function ($model) {
$status = $model->ban;
if ($status == 1) {
$stat = '<button class="btn btn-danger btn-xs">Banned</button>';
} else {
$stat = '<button class="btn btn-success btn-xs">Not Banned</button>';
}
return $stat;
})
/* column last login date */
->addColumn('lastlogin', function ($model) {
->addColumn('updated_at', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
@@ -1064,7 +1074,7 @@ class UserController extends Controller
public function getAgentDetails()
{
$users = User::where('role', '<>', 'user')->where('active', '=', 1)->get();
$users = User::where('role', '<>', 'user')->where('active', '=', 1)->orderBy('first_name')->get();
foreach ($users as $user) {
echo "<option value='user_$user->id'>".$user->name().'</option>';
}

View File

@@ -183,9 +183,11 @@ class AuthController extends Controller
$message12 = '';
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$sms = Plugin::select('status')->where('name', '=', 'SMS')->first();
// Event for login
\Event::fire(new \App\Events\LoginEvent($request));
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/'.$code)]);
// Event for login
\Event::fire(new \App\Events\LoginEvent($request));
if ($request->input('email') !== '') {
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/'.$code)]);
}
if ($settings->status == 1 || $settings->status == '1') {
if (count($sms) > 0) {
if ($sms->status == 1 || $sms->status == '1') {
@@ -194,7 +196,11 @@ class AuthController extends Controller
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_sms_plugin_inactive_or_not_setup');
}
} else {
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
if ($request->input('email') !== '') {
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
} else {
$message12 = Lang::get('lang.account-created-contact-admin-as-we-were-not-able-to-send-opt');
}
}
} else {
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');

View File

@@ -178,10 +178,13 @@ class FormController extends Controller
$sla = $ticket_settings->first()->sla;
// $priority = $ticket_settings->first()->priority;
$default_priority = Ticket_Priority::where('is_default', '=', 1)->first();
$default_priority = Ticket_Priority::where('is_default', '=', 1)->first();
$user_priority = CommonSettings::where('option_name', '=', 'user_priority')->first();
if (!($request->input('priority'))) {
$priority = $default_priority->priority_id;
if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
$priority = $helpTopicObj->value('priority');
}
} else {
$priority = $request->input('priority');
}
@@ -189,6 +192,9 @@ class FormController extends Controller
$attachments = $request->file('attachment');
$collaborator = null;
$assignto = null;
if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
$assignto = $helpTopicObj->value('auto_assign');
}
$auto_response = 0;
$team_assign = null;
if ($phone != null || $mobile_number != null) {

View File

@@ -164,7 +164,7 @@ class NotificationController extends Controller
}, 'notification.model' => function ($query) {
$query->select('id', 'ticket_number');
},
]);
])->where('user_id', '=', \Auth::user()->id);
return $notifications;
}

View File

@@ -115,7 +115,7 @@ class PhpMailController extends Controller
$department_sign = $this->checkElement('department_sign', $template_variables);
$password_reset_link = $this->checkElement('password_reset_link', $template_variables);
$user_password = $this->checkElement('user_password', $template_variables);
$merged_ticket_numbers = $this->checkElement('merged_ticket_numbers', $template_variables);
$email_address = $this->checkElement('email_address', $template_variables);
$user = $this->checkElement('user', $template_variables);
@@ -145,9 +145,9 @@ class PhpMailController extends Controller
$subject = null;
}
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}', '{!!$ticket_link!!}'];
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}', '{!!$ticket_link!!}', '{!!$merged_ticket_numbers!!}'];
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link, $ticket_link];
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link, $ticket_link, $merged_ticket_numbers];
foreach ($variables as $key => $variable) {
$messagebody = str_replace($variables[$key], $data[$key], $contents);