Update v1.0.6.5

This commit is contained in:
sujitprasad
2016-03-02 12:25:21 +05:30
parent 7011553462
commit c56ff86194
218 changed files with 17161 additions and 2358 deletions

View File

@@ -25,10 +25,10 @@ class Handler extends ExceptionHandler
*
* @return void
*/
public function __construct(PhpMailController $PhpMailController)
{
$this->PhpMailController = $PhpMailController;
}
// public function __construct(PhpMailController $PhpMailController)
// {
// $this->PhpMailController = $PhpMailController;
// }
/**
* Report or log an exception.

View File

@@ -37,6 +37,7 @@ use Exception;
use Hash;
use Illuminate\support\Collection;
use Input;
use Lang;
use Mail;
use PDF;
use UTC;
@@ -80,7 +81,7 @@ class TicketController extends Controller
return \Datatable::collection(new Collection($tickets))
->addColumn('id', function ($ticket) {
return "<input type='checkbox' name='select_all[]' class='icheckbox_flat-blue' value='".$ticket->id."'></input>";
return "<input type='checkbox' name='select_all[]' id='".$ticket->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$ticket->id."'></input>";
})
->addColumn('subject', function ($ticket) {
$subject = DB::table('ticket_thread')->select('title')->where('ticket_id', '=', $ticket->id)->first();
@@ -801,8 +802,13 @@ class TicketController extends Controller
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('id', '=', $id)->where('dept_id', '=', $dept->id)->first();
} else {
} elseif (Auth::user()->role == 'admin') {
$tickets = Tickets::where('id', '=', $id)->first();
} elseif (Auth::user()->role == 'user') {
$thread = Ticket_Thread::where('ticket_id', '=', $id)->first();
$ticket_id = \Crypt::encrypt($id);
// dd($ticket_id);
return redirect()->route('check_ticket', compact('ticket_id'));
}
$thread = Ticket_Thread::where('ticket_id', '=', $id)->first();
//$tickets = Tickets::where('id', '=', $id)->first();
@@ -2577,4 +2583,151 @@ class TicketController extends Controller
}
// return '<div id="alert11" class="alert alert-dismissable" ><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-user"></i>'.$data->user_name.'</h4><div id="message-success1">'.$data->email.'</div></div>';
}
public function getMergeTickets($id)
{
if ($id == 0) {
$t_id = Input::get('data1');
foreach ($t_id as $value) {
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $value)->first();
echo "<option value='$value'>".$title->title.'</option>';
}
} else {
$ticket = Tickets::select('user_id')->where('id', '=', $id)->first();
$ticket_data = Tickets::select('ticket_number', 'id')
->where('user_id', '=', $ticket->user_id)->where('id', '!=', $id)->where('status', '=', 1)->get();
foreach ($ticket_data as $value) {
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $value->id)->first();
echo "<option value='$value->id'>".$title->title.'</option>';
}
}
}
public function checkMergeTickets($id)
{
if ($id == 0) {
if (Input::get('data1') == null || count(Input::get('data1')) == 1) {
return 0;
} else {
$t_id = Input::get('data1');
$previousValue = null;
$match = 1;
foreach ($t_id as $value) {
$ticket = Tickets::select('user_id')->where('id', '=', $value)->first();
if ($previousValue == null || $previousValue == $ticket->user_id) {
$previousValue = $ticket->user_id;
$match = 1;
} else {
$match = 2;
break;
}
}
return $match;
}
} else {
$ticket = Tickets::select('user_id')->where('id', '=', $id)->first();
$ticket_data = Tickets::select('ticket_number', 'id')
->where('user_id', '=', $ticket->user_id)
->where('id', '!=', $id)
->where('status', '=', 1)->get();
if (isset($ticket_data) && count($ticket_data) >= 1) {
return 1;
} else {
return 0;
}
}
}
public function mergeTickets($id)
{
// split the phrase by any number of commas or space characters,
// which include " ", \r, \t, \n and \f
$t_id = preg_split("/[\s,]+/", $id);
if (count($t_id) > 1) {
$p_id = Input::get('p_id');
$t_id = array_diff($t_id, [$p_id]);
} else {
$t_id = Input::get('t_id'); //getting array of tickets to merge
if ($t_id == null) {
return 2;
} else {
$temp_id = Input::get('p_id'); //getting parent ticket
if ($id == $temp_id) {
$p_id = $id;
} else {
$p_id = $temp_id;
array_push($t_id, $id);
$t_id = array_diff($t_id, [$temp_id]);
}
}
}
$parent_ticket = Tickets::select('ticket_number')->where('id', '=', $p_id)->first();
$parent_thread = Ticket_thread::where('ticket_id', '=', $p_id)->first();
foreach ($t_id as $value) {//to create new thread of the tickets to be merged with parent
$thread = Ticket_thread::where('ticket_id', '=', $value)->first();
$ticket = Tickets::select('ticket_number')->where('id', '=', $value)->first();
Ticket_thread::where('ticket_id', '=', $value)
->update(['ticket_id' => $p_id]);
Ticket_Form_Data::where('ticket_id', '=', $value)
->update(['ticket_id' => $p_id]);
Ticket_Collaborator::where('ticket_id', '=', $value)
->update(['ticket_id' => $p_id]);
Tickets::where('id', '=', $value)
->update(['status' => 3]);
if (!empty(Input::get('reason'))) {
$reason = Input::get('reason');
} else {
$reason = '';
}
if (!empty(Input::get('title'))) {
Ticket_thread::where('ticket_id', '=', $p_id)->first()
->update(['title' => Input::get('title')]);
}
$new_thread = new Ticket_thread();
$new_thread->ticket_id = $thread->ticket_id;
$new_thread->user_id = Auth::user()->id;
$new_thread->poster = $thread->poster;
$new_thread->source = $thread->source;
$new_thread->is_internal = 0;
$new_thread->title = $thread->title;
$new_thread->body = Lang::get('lang.get_merge_message').
"&nbsp;&nbsp;<a href='".route('ticket.thread', [$p_id]).
"'>#".$parent_ticket->ticket_number.'</a><br>'.$reason;
$new_thread->format = $thread->format;
$new_thread->ip_address = $thread->ip_address;
//$new_thread->save();
$new_parent_thread = new Ticket_thread();
$new_parent_thread->ticket_id = $p_id;
$new_parent_thread->user_id = Auth::user()->id;
$new_parent_thread->poster = $parent_thread->poster;
$new_parent_thread->source = $parent_thread->source;
$new_parent_thread->is_internal = 1;
$new_parent_thread->title = $thread->title;
$new_parent_thread->body = Lang::get('lang.ticket')."&nbsp;<a href='".route('ticket.thread', [$value])."'>#".$ticket->ticket_number.'</a>&nbsp'.Lang::get('lang.ticket_merged').'<br>'.$reason;
$new_parent_thread->format = $parent_thread->format;
$new_parent_thread->ip_address = $parent_thread->ip_address;
//$new_parent_thread->save();
if ($new_thread->save() && $new_parent_thread->save()) {
$success = 1;
} else {
$success = 0;
}
}
return $success;
}
public function getParentTickets($id)
{
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $id)->first();
echo "<option value='$id'>".$title->title.'</option>';
$tickets = Input::get('data1');
foreach ($tickets as $value) {
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $value)->first();
echo "<option value='$value'>".$title->title.'</option>';
}
}
}

View File

@@ -18,6 +18,8 @@ use App\Model\helpdesk\Utility\Priority;
use App\User;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
/**
* -----------------------------------------------------------------------------
@@ -528,6 +530,46 @@ class ApiController extends Controller
}
}
/**
* Get all customers having client_id, client_picture, client_name, client_email, client_phone.
*
* @return json
*/
public function getCustomersWith()
{
try {
$users = $this->faveoUser->select('id', 'user_name', 'first_name', 'last_name', 'email', 'phone_number', 'profile_pic')->where('role', 'user')->get();
$result = [];
foreach ($users as $key => $user) {
$result[$key]['id'] = $user->id;
$result[$key]['user_name'] = $user->user_name;
$result[$key]['first_name'] = $user->first_name;
$result[$key]['last_name'] = $user->last_name;
$result[$key]['email'] = $user->email;
$result[$key]['phone_number'] = $user->phone_number;
if ($user->profile_pic) {
$path = 'lb-faveo/media/profilepic/'.$user->profile_pic;
} else {
$path = \Gravatar::src($user->email);
}
$result[$key]['picture'] = $path;
}
$result = $this->createPagination($result, 10);
//$result->toJson();
return $result->toJson();
} catch (Exception $e) {
$error = $e->getMessage();
$line = $e->getLine();
$file = $e->getFile();
return response()->json(compact('error', 'file', 'line'));
} catch (\TokenExpiredException $e) {
$error = $e->getMessage();
return response()->json(compact('error'));
}
}
/**
* Get a customer by id.
*
@@ -545,7 +587,7 @@ class ApiController extends Controller
return response()->json(compact('error'));
}
$id = $this->request->input('user_id');
$result = $this->faveoUser->where('id', $id)->first();
$result = $this->faveoUser->where('id', $id)->where('role', 'user')->first();
return response()->json(compact('result'));
} catch (Exception $e) {
@@ -1071,4 +1113,33 @@ class ApiController extends Controller
return response()->json(compact('error'));
}
}
public function createPagination($array, $perPage)
{
try {
//Get current page form url e.g. &page=6
$currentPage = LengthAwarePaginator::resolveCurrentPage();
//Create a new Laravel collection from the array data
$collection = new Collection($array);
//Slice the collection to get the items to display in current page
$currentPageSearchResults = $collection->slice($currentPage * $perPage, $perPage)->all();
//Create our paginator and pass it to the view
$paginatedResults = new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage);
return $paginatedResults;
} catch (\Exception $e) {
$error = $e->getMessage();
$line = $e->getLine();
$file = $e->getFile();
return response()->json(compact('error', 'file', 'line'));
} catch (\TokenExpiredException $e) {
$error = $e->getMessage();
return response()->json(compact('error'));
}
}
}

View File

@@ -37,8 +37,34 @@ class InstallerApiController extends Controller
*/
public function config_database(Request $request)
{
error_reporting(E_ALL & ~E_NOTICE);
$validator = \Validator::make(
[
'database' => $request->database,
'host' => $request->host,
'databasename' => $request->databasename,
'dbusername' => $request->dbusername,
'port' => $request->port,
],
[
'database' => 'required|min:1',
'host' => 'required',
'databasename' => 'required|min:1',
'dbusername' => 'required|min:1',
'port' => 'integer|min:0',
]
);
if ($validator->fails()) {
$jsons = $validator->messages();
$val = '';
foreach ($jsons->all() as $key => $value) {
$val .= $value;
}
$return_data = rtrim(str_replace('.', ',', $val), ',');
return ['response' => 'fail', 'reason' => $return_data, 'status' => '0'];
}
// dd($validator->messages());
// error_reporting(E_ALL & ~E_NOTICE);
// Check for pre install
if (\Config::get('database.install') == '%0%') {
$default = $request->database;
@@ -47,9 +73,7 @@ class InstallerApiController extends Controller
$dbusername = $request->dbusername;
$dbpassword = $request->dbpassword;
$port = $request->port;
if (isset($default) && isset($host) && isset($database) && isset($dbusername)) {
// Setting environment values
$_ENV['DB_TYPE'] = $default;
$_ENV['DB_HOST'] = $host;
@@ -57,12 +81,10 @@ class InstallerApiController extends Controller
$_ENV['DB_DATABASE'] = $database;
$_ENV['DB_USERNAME'] = $dbusername;
$_ENV['DB_PASSWORD'] = $dbpassword;
$config = '';
foreach ($_ENV as $key => $val) {
$config .= "{$key}={$val}\n";
}
// Write environment file
$fp = fopen(base_path().'/.env', 'w');
fwrite($fp, $config);
@@ -85,6 +107,36 @@ class InstallerApiController extends Controller
*/
public function config_system(Request $request)
{
$validator = \Validator::make(
[
'firstname' => $request->firstname,
'lastname' => $request->lastname,
'email' => $request->email,
'username' => $request->username,
'password' => $request->password,
'timezone' => $request->timezone,
'datetime' => $request->datetime,
],
[
'firstname' => 'required|alpha|min:1',
'lastname' => 'required|alpha|min:1',
'email' => 'required|email|min:1',
'username' => 'required|min:4',
'password' => 'required|min:6',
'timezone' => 'required|min:1',
'datetime' => 'required|min:1',
]
);
if ($validator->fails()) {
$jsons = $validator->messages();
$val = '';
foreach ($jsons->all() as $key => $value) {
$val .= $value;
}
$return_data = rtrim(str_replace('.', ',', $val), ',');
return ['response' => 'fail', 'reason' => $return_data, 'status' => '0'];
}
// Check for pre install
if (\Config::get('database.install') == '%0%') {
$firstname = $request->firstname;
@@ -101,12 +153,16 @@ class InstallerApiController extends Controller
// checking requested timezone for the admin and system
$timezones = Timezones::where('name', '=', $timezone)->first();
if ($timezones->id == null) {
if ($timezones == null) {
Artisan::call('migrate:reset', ['--force' => true]);
return ['response' => 'fail', 'reason' => 'Invalid time-zone', 'status' => '0'];
}
// checking requested date time format for the admin and system
$date_time_format = Date_time_format::where('format', '=', $datetime)->first();
if ($date_time_format->id == null) {
if ($date_time_format == null) {
Artisan::call('migrate:reset', ['--force' => true]);
return ['response' => 'fail', 'reason' => 'invalid date-time format', 'status' => '0'];
}
// Creating minum settings for system

View File

@@ -469,4 +469,16 @@ class TestController extends Controller
return response()->json(compact('error', 'file', 'line'));
}
}
public function getCustomersWith()
{
try {
} catch (\Exception $e) {
$error = $e->getMessage();
$line = $e->getLine();
$file = $e->getFile();
return response()->json(compact('error', 'file', 'line'));
}
}
}

View File

@@ -55,8 +55,9 @@ class TokenAuthController extends Controller
return response()->json(compact('error'));
}
$user_id = \Auth::user()->id;
// if no errors are encountered we can return a JWT
return response()->json(compact('token'));
return response()->json(compact('token', 'user_id'));
}
/**

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Installer\helpdesk;
// controllers
use App\Http\Controllers\Controller;
// requests
use App\Http\Requests\helpdesk\DatabaseRequest;
use App\Http\Requests\helpdesk\InstallerRequest;
// models
use App\Model\helpdesk\Settings\System;
@@ -133,7 +134,6 @@ class InstallController extends Controller
public function localizationcheck()
{
Session::put('step3', 'step3');
Session::put('language', Input::get('language'));
Session::put('timezone', Input::get('timezone'));
Session::put('date', Input::get('date'));
@@ -168,22 +168,21 @@ class InstallController extends Controller
*
* @return type view
*/
public function configurationcheck()
public function configurationcheck(DatabaseRequest $request)
{
Session::put('step4', 'step4');
// dd(Input::get('default'));
// dd(Input::get('host'));
// dd(Input::get('databasename'));
// dd(Input::get('username'));
// dd(Input::get('password'));
// dd(Input::get('port'));
Session::put('default', Input::get('default'));
Session::put('host', Input::get('host'));
Session::put('databasename', Input::get('databasename'));
Session::put('username', Input::get('username'));
Session::put('password', Input::get('password'));
Session::put('port', Input::get('port'));
// dd($request->input('default'));
// dd($request->input('host'));
// dd($request->input('databasename'));
// dd($request->input('username'));
// dd($request->input('password'));
// dd($request->input('port'));
Session::put('default', $request->input('default'));
Session::put('host', $request->input('host'));
Session::put('databasename', $request->input('databasename'));
Session::put('username', $request->input('username'));
Session::put('password', $request->input('password'));
Session::put('port', $request->input('port'));
return Redirect::route('database');
}
@@ -311,15 +310,15 @@ class InstallController extends Controller
// $system->save();
// checking requested timezone for the admin and system
$timezones = Timezones::where('name', '=', $timezone)->first();
if ($timezones->id == null) {
return ['response' => 'fail', 'reason' => 'Invalid time-zone', 'status' => '0'];
if ($timezones == null) {
return redirect()->back()->with('fails', 'Invalid time-zone');
// return ['response' => 'fail', 'reason' => 'Invalid time-zone', 'status' => '0'];
}
// var_dump($datetime);
// checking requested date time format for the admin and system
$date_time_format = Date_time_format::where('format', '=', $datetime)->first();
// dd($date_time_format);
if ($date_time_format->id == null) {
return ['response' => 'fail', 'reason' => 'invalid date-time format', 'status' => '0'];
if ($date_time_format == null) {
return redirect()->back()->with('fails', 'invalid date-time format');
// return ['response' => 'fail', 'reason' => 'invalid date-time format', 'status' => '0'];
}
// Creating minum settings for system

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request;
/**
* InstallerRequest.
*
* @author Ladybird <info@ladybirdweb.com>
*/
class DatabaseRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'default' => 'required',
'host' => 'required',
'databasename' => 'required',
'username' => 'required',
// 'password' => '',
'port' => 'integer|min:0',
];
}
}

View File

@@ -346,6 +346,16 @@ Route::group(['middleware' => 'role.agent', 'middleware' => 'auth'], function ()
Route::patch('/change-owner/{id}', ['as' => 'change.owner.ticket', 'uses' => 'Agent\helpdesk\TicketController@changeOwner']); /* change owner */
//To merge tickets
Route::get('/get-merge-tickets/{id}', ['as' => 'get.merge.tickets', 'uses' => 'Agent\helpdesk\TicketController@getMergeTickets']);
Route::get('/check-merge-ticket/{id}', ['as' => 'check.merge.tickets', 'uses' => 'Agent\helpdesk\TicketController@checkMergeTickets']);
Route::get('/get-parent-tickets/{id}', ['as' => 'get.parent.ticket', 'uses' => 'Agent\helpdesk\TicketController@getParentTickets']);
Route::patch('/merge-tickets/{id}', 'Agent\helpdesk\TicketController@mergeTickets');
});
/*
@@ -636,6 +646,12 @@ Route::group(['prefix' => 'api/v1'], function () {
Route::get('trash', 'Api\v1\ApiController@getTrash');
Route::get('my-tickets', 'Api\v1\ApiController@getMyTickets');
Route::post('internal-note', 'Api\v1\ApiController@internalNote');
/*
* Newly added
*/
Route::get('customers-custom', 'Api\v1\ApiController@getCustomersWith');
});
/*
@@ -668,7 +684,11 @@ Route::group(['prefix' => 'api/v1'], function () {
Route::get('ticket/internal', 'Api\v1\TestController@internalNote');
Route::get('ticket/trash', 'Api\v1\TestController@trash');
Route::get('ticket/my', 'Api\v1\TestController@myTickets');
Route::get('ticket', 'Api\v1\TestController@getTicketById');
Route::get('ticket', 'Api\v1\TestController@getTicketById');
/*
* Newly added
*/
Route::get('customers-custom', 'Api\v1\TestController@getCustomersWith');
Route::get('generate/token', 'Api\v1\TestController@generateToken');
Route::get('get/user', 'Api\v1\TestController@getAuthUser');