update v1.0.6
This commit is contained in:
@@ -13,7 +13,7 @@ use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\kb\Settings;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Manage\Sla_plan;
|
||||
use App\Model\helpdesk\Utility\Priority;
|
||||
@@ -86,7 +86,7 @@ class ApiController extends Controller {
|
||||
$team = new Teams();
|
||||
$this->team = $team;
|
||||
|
||||
$setting = new Settings();
|
||||
$setting = new System();
|
||||
$this->setting = $setting;
|
||||
|
||||
$helptopic = new Help_topic();
|
||||
@@ -150,6 +150,7 @@ class ApiController extends Controller {
|
||||
/**
|
||||
* return ticket details
|
||||
*/
|
||||
//dd($response);
|
||||
$result = $this->thread->where('id', $response)->first();
|
||||
//$result = $this->attach($result->id,$file);
|
||||
return response()->json(compact('result'));
|
||||
@@ -259,7 +260,7 @@ class ApiController extends Controller {
|
||||
*/
|
||||
public function OpenedTickets() {
|
||||
try {
|
||||
$result = $this->model->where('status', '=', 1)->where('isanswered', '=', 0)->where('assigned_to', '=', 0)->orderBy('id', 'DESC')->get();
|
||||
$result = $this->model->where('status', '=', 1)->where('isanswered', '=', 0)->where('assigned_to', '=', null)->orderBy('id', 'DESC')->get();
|
||||
return response()->json(compact('result'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
@@ -278,7 +279,7 @@ class ApiController extends Controller {
|
||||
*/
|
||||
public function UnassignedTickets() {
|
||||
try {
|
||||
$result = $this->model->where('assigned_to', '=', 0)->where('status', '1')->orderBy('id', 'DESC')->get();
|
||||
$result = $this->model->where('assigned_to', '=', null)->where('status', '1')->orderBy('id', 'DESC')->get();
|
||||
return response()->json(compact('result'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
@@ -316,7 +317,7 @@ class ApiController extends Controller {
|
||||
*/
|
||||
public function GetAgents() {
|
||||
try {
|
||||
$result = $this->faveoUser->where('role', 'agent')->where('active', 1)->get();
|
||||
$result = $this->faveoUser->where('role', 'agent')->orWhere('role', 'admin')->where('active', 1)->get();
|
||||
return response()->json(compact('result'));
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
@@ -505,8 +506,9 @@ class ApiController extends Controller {
|
||||
}
|
||||
|
||||
$url = $this->request->input('url');
|
||||
$url = $url . "/api/v1/helpdesk/check-url?token=" . \Config::get('app.token');
|
||||
$url = $url . "/api/v1/helpdesk/check-url?api-key=" . $this->request->input('api-key') . "&token=" . \Config::get('app.token');
|
||||
$result = $this->CallGetApi($url);
|
||||
//dd($result);
|
||||
return response()->json(compact('result'));
|
||||
} catch (Exception $ex) {
|
||||
$error = $e->getMessage();
|
||||
@@ -579,6 +581,7 @@ class ApiController extends Controller {
|
||||
public function GenerateApiKey() {
|
||||
try {
|
||||
$set = $this->setting->where('id', '1')->first();
|
||||
//dd($set);
|
||||
if ($set->api_enable == 1) {
|
||||
$key = str_random(32);
|
||||
$set->api_key = $key;
|
||||
@@ -675,6 +678,7 @@ class ApiController extends Controller {
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting the tickets
|
||||
* @return type json
|
||||
@@ -694,12 +698,11 @@ class ApiController extends Controller {
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetching the Inbox details
|
||||
* @return type json
|
||||
*/
|
||||
|
||||
public function Inbox() {
|
||||
try {
|
||||
$result = $this->user->join('tickets', 'users.id', '=', 'tickets.user_id')
|
||||
@@ -725,6 +728,7 @@ class ApiController extends Controller {
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create internal note
|
||||
* @return type json
|
||||
@@ -742,7 +746,7 @@ class ApiController extends Controller {
|
||||
}
|
||||
$userid = $this->request->input('userid');
|
||||
$ticketid = $this->request->input('ticketid');
|
||||
|
||||
|
||||
$body = $this->request->input('body');
|
||||
$thread = $this->thread->create(['ticket_id' => $ticketid, 'user_id' => $userid, 'is_internal' => 1, 'body' => $body]);
|
||||
return response()->json(compact('thread'));
|
||||
@@ -753,7 +757,5 @@ class ApiController extends Controller {
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,7 @@
|
||||
<?php namespace App\Http\Controllers\Api\v1;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
@@ -37,124 +40,130 @@ use Exception;
|
||||
*/
|
||||
class InstallerApiController extends Controller {
|
||||
|
||||
/**
|
||||
* config_database
|
||||
* This function is to configure the database and install the application via API call.
|
||||
* @return type Json
|
||||
*/
|
||||
public function config_database(Request $request) {
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
/**
|
||||
* config_database
|
||||
* This function is to configure the database and install the application via API call.
|
||||
* @return type Json
|
||||
*/
|
||||
public function config_database(Request $request) {
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
|
||||
// Check for pre install
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
// Check for pre install
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
|
||||
$default = $request->database;
|
||||
$host = $request->host;
|
||||
$database = $request->databasename;
|
||||
$dbusername = $request->dbusername;
|
||||
$dbpassword = $request->dbpassword;
|
||||
$port = $request->port;
|
||||
$default = $request->database;
|
||||
$host = $request->host;
|
||||
$database = $request->databasename;
|
||||
$dbusername = $request->dbusername;
|
||||
$dbpassword = $request->dbpassword;
|
||||
$port = $request->port;
|
||||
|
||||
if(isset($default) && isset($host) && isset($database) && isset($dbusername)){
|
||||
if (isset($default) && isset($host) && isset($database) && isset($dbusername)) {
|
||||
|
||||
// Setting environment values
|
||||
$_ENV['DB_TYPE'] = $default;
|
||||
$_ENV['DB_HOST'] = $host;
|
||||
$_ENV['DB_PORT'] = $port;
|
||||
$_ENV['DB_DATABASE'] = $database;
|
||||
$_ENV['DB_USERNAME'] = $dbusername;
|
||||
$_ENV['DB_PASSWORD'] = $dbpassword;
|
||||
// Setting environment values
|
||||
$_ENV['DB_TYPE'] = $default;
|
||||
$_ENV['DB_HOST'] = $host;
|
||||
$_ENV['DB_PORT'] = $port;
|
||||
$_ENV['DB_DATABASE'] = $database;
|
||||
$_ENV['DB_USERNAME'] = $dbusername;
|
||||
$_ENV['DB_PASSWORD'] = $dbpassword;
|
||||
|
||||
$config = '';
|
||||
foreach ($_ENV as $key => $val) {
|
||||
$config .= "{$key}={$val}\n";
|
||||
}
|
||||
$config = '';
|
||||
foreach ($_ENV as $key => $val) {
|
||||
$config .= "{$key}={$val}\n";
|
||||
}
|
||||
|
||||
// Write environment file
|
||||
$fp = fopen(base_path()."/.env", 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
|
||||
return ['response'=>'success','status'=>'1'];
|
||||
} else {
|
||||
return ['response'=>'fail','reason'=>'insufficient parameters','status'=>'0'];
|
||||
}
|
||||
} else {
|
||||
return ['response'=>'fail','reason'=>'this system is already installed','status'=>'0'];
|
||||
}
|
||||
}
|
||||
// Write environment file
|
||||
$fp = fopen(base_path() . "/.env", 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
|
||||
/**
|
||||
* config_database
|
||||
* This function is to configure the database and install the application via API call.
|
||||
* @return type Json
|
||||
*/
|
||||
public function config_system(Request $request) {
|
||||
// Check for pre install
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
$firstname = $request->firstname;
|
||||
$lastname = $request->lastname;
|
||||
$email = $request->email;
|
||||
$username = $request->username;
|
||||
$password = $request->password;
|
||||
$timezone = $request->timezone;
|
||||
$datetime = $request->datetime;
|
||||
return ['response' => 'success', 'status' => '1'];
|
||||
} else {
|
||||
return ['response' => 'fail', 'reason' => 'insufficient parameters', 'status' => '0'];
|
||||
}
|
||||
} else {
|
||||
return ['response' => 'fail', 'reason' => 'this system is already installed', 'status' => '0'];
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate database
|
||||
Artisan::call('migrate', array('--force' => true));
|
||||
Artisan::call('db:seed', array('--force' => true));
|
||||
/**
|
||||
* config_database
|
||||
* This function is to configure the database and install the application via API call.
|
||||
* @return type Json
|
||||
*/
|
||||
public function config_system(Request $request) {
|
||||
// Check for pre install
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
$firstname = $request->firstname;
|
||||
$lastname = $request->lastname;
|
||||
$email = $request->email;
|
||||
$username = $request->username;
|
||||
$password = $request->password;
|
||||
$timezone = $request->timezone;
|
||||
$datetime = $request->datetime;
|
||||
|
||||
// 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'];
|
||||
}
|
||||
// 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){
|
||||
return ['response'=>'fail','reason'=>'invalid date-time format','status'=>'0'];
|
||||
}
|
||||
// Creating minum settings for system
|
||||
$system = new System;
|
||||
$system->status = 1;
|
||||
$system->department = 1;
|
||||
$system->date_time_format = $date_time_format->id;
|
||||
$system->time_zone = $timezones->id;
|
||||
$system->save();
|
||||
// Migrate database
|
||||
Artisan::call('migrate', array('--force' => true));
|
||||
Artisan::call('db:seed', array('--force' => true));
|
||||
|
||||
// Creating user
|
||||
$user = User::create(array(
|
||||
'first_name' => $firstname,
|
||||
'last_name' => $lastname,
|
||||
'email' => $email,
|
||||
'user_name' => $username,
|
||||
'password' => Hash::make($password),
|
||||
'active' => 1,
|
||||
'role' => 'admin',
|
||||
'assign_group' => 1,
|
||||
'primary_dpt' => 1,
|
||||
));
|
||||
// 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'];
|
||||
}
|
||||
// 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) {
|
||||
return ['response' => 'fail', 'reason' => 'invalid date-time format', 'status' => '0'];
|
||||
}
|
||||
// Creating minum settings for system
|
||||
$system = new System;
|
||||
$system->status = 1;
|
||||
$system->department = 1;
|
||||
$system->date_time_format = $date_time_format->id;
|
||||
$system->time_zone = $timezones->id;
|
||||
$system->save();
|
||||
|
||||
// Setting database installed status
|
||||
$value = '1';
|
||||
$install = app_path('../config/database.php');
|
||||
$datacontent = File::get($install);
|
||||
$datacontent = str_replace('%0%', $value, $datacontent);
|
||||
File::put($install, $datacontent);
|
||||
// Creating user
|
||||
$user = User::create(array(
|
||||
'first_name' => $firstname,
|
||||
'last_name' => $lastname,
|
||||
'email' => $email,
|
||||
'user_name' => $username,
|
||||
'password' => Hash::make($password),
|
||||
'active' => 1,
|
||||
'role' => 'admin',
|
||||
'assign_group' => 1,
|
||||
'primary_dpt' => 1,
|
||||
));
|
||||
|
||||
// Applying email configuration on route
|
||||
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
|
||||
$path22 = app_path('Http/routes.php');
|
||||
$content23 = File::get($path22);
|
||||
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
|
||||
File::put($path22, $content23);
|
||||
// Setting database installed status
|
||||
$value = '1';
|
||||
$install = app_path('../config/database.php');
|
||||
$datacontent = File::get($install);
|
||||
$datacontent = str_replace('%0%', $value, $datacontent);
|
||||
File::put($install, $datacontent);
|
||||
|
||||
// If user created return success
|
||||
if($user){
|
||||
return ['response'=>'success','status'=>'1'];
|
||||
}
|
||||
} else {
|
||||
return ['response'=>'fail','reason'=>'this system is already installed','status'=>'0'];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Applying email configuration on route
|
||||
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
|
||||
$lfmpath = "url('photos').'/'";
|
||||
$path22 = app_path('Http/routes.php');
|
||||
$path23 = app_path('config/lfm.php');
|
||||
$content23 = File::get($path22);
|
||||
$content24 = File::get($path23);
|
||||
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
|
||||
$content24 = str_replace("'%url%'", $lfmpath, $content24);
|
||||
File::put($path22, $content23);
|
||||
File::put($path23, $content24);
|
||||
|
||||
// If user created return success
|
||||
if ($user) {
|
||||
return ['response' => 'success', 'status' => '1'];
|
||||
}
|
||||
} else {
|
||||
return ['response' => 'fail', 'reason' => 'this system is already installed', 'status' => '0'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -56,28 +56,28 @@ class TestController extends Controller {
|
||||
}
|
||||
|
||||
public function TicketReply() {
|
||||
|
||||
$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
|
||||
|
||||
|
||||
//$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
|
||||
|
||||
$data = [
|
||||
|
||||
'ticket_ID' => '81',
|
||||
'ticket_ID' => '13',
|
||||
'ReplyContent' => 'reply for the ticket id',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg',
|
||||
'attachments' => [
|
||||
[
|
||||
'name' => 'ladybird',
|
||||
'size' => '26398',
|
||||
'type' => 'png',
|
||||
'file' => $file,
|
||||
],
|
||||
[
|
||||
'name' => 'ladybird',
|
||||
'size' => '26398',
|
||||
'type' => 'png',
|
||||
'file' => $file,
|
||||
]
|
||||
],
|
||||
// 'attachments' => [
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
// 'size' => '26398',
|
||||
// 'type' => 'png',
|
||||
// 'file' => $file,
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
// 'size' => '26398',
|
||||
// 'type' => 'png',
|
||||
// 'file' => $file,
|
||||
// ]
|
||||
// ],
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
|
||||
@@ -90,10 +90,10 @@ class TestController extends Controller {
|
||||
|
||||
public function CreateTicket() {
|
||||
|
||||
$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
|
||||
//$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
|
||||
|
||||
$data = [
|
||||
'user_id' => '1',
|
||||
'user_id' => 1,
|
||||
'subject' => 'Api create via faveo api',
|
||||
'body' => 'Test me when call api',
|
||||
'helptopic' => '1',
|
||||
@@ -101,24 +101,22 @@ class TestController extends Controller {
|
||||
'priority' => '1',
|
||||
'headers' => [0 => 'vijaycodename47@gmail.com'],
|
||||
'dept' => '1',
|
||||
'assignto' => '0',
|
||||
'source' => 'api',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg',
|
||||
/** if attachment */
|
||||
'attachments' => [
|
||||
[
|
||||
'name' => 'ladybird',
|
||||
'size' => '26398',
|
||||
'type' => 'png',
|
||||
'file' => $file,
|
||||
],
|
||||
[
|
||||
'name' => 'ladybird',
|
||||
'size' => '26398',
|
||||
'type' => 'png',
|
||||
'file' => $file,
|
||||
]
|
||||
],
|
||||
/** if attachment */
|
||||
// 'attachments' => [
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
// 'size' => '26398',
|
||||
// 'type' => 'png',
|
||||
// 'file' => $file,
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
// 'size' => '26398',
|
||||
// 'type' => 'png',
|
||||
// 'file' => $file,
|
||||
// ]
|
||||
// ],
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
|
||||
@@ -162,7 +160,7 @@ class TestController extends Controller {
|
||||
|
||||
public function GetAuthUser() {
|
||||
|
||||
$url = $this->server . "authenticate/user?token=" . \Config::get('app.token');
|
||||
$url = $this->server . "authenticate/user?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
@@ -170,12 +168,12 @@ class TestController extends Controller {
|
||||
|
||||
public function EditTicket() {
|
||||
$data = [
|
||||
'ticket_id' => '81',
|
||||
'ticket_id' => '13',
|
||||
'subject' => 'Api editing ticket via faveo api',
|
||||
'sla_plan' => '2',
|
||||
'help_topic' => '2',
|
||||
'ticket_source' => '2',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg',
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
'ticket_priority' => '2',
|
||||
];
|
||||
|
||||
@@ -188,8 +186,8 @@ class TestController extends Controller {
|
||||
|
||||
public function DeleteTicket() {
|
||||
$data = [
|
||||
'ticket_id' => [],
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
|
||||
'ticket_id' => [11],
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
@@ -200,35 +198,35 @@ class TestController extends Controller {
|
||||
}
|
||||
|
||||
public function OpenedTickets() {
|
||||
$url = $this->server . "helpdesk/open?token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/open?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function UnassignedTickets() {
|
||||
$url = $this->server . "helpdesk/unassigned?token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/unassigned?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function CloseTickets() {
|
||||
$url = $this->server . "helpdesk/closed?token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/closed?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function GetAgents() {
|
||||
$url = $this->server . "helpdesk/agents?token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/agents?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function GetTeams() {
|
||||
$url = $this->server . "helpdesk/teams?token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/teams?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
@@ -236,9 +234,9 @@ class TestController extends Controller {
|
||||
|
||||
public function AssignTicket() {
|
||||
$data = [
|
||||
'ticket_id' => '8',
|
||||
'user' => 'vijay.sebastian@ladybird.com',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
|
||||
'ticket_id' => 1,
|
||||
'user' => 'vijay.sebastian@ladybirdweb.com',
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server . "helpdesk/assign?token=" . \Config::get('app.token');
|
||||
@@ -250,7 +248,7 @@ class TestController extends Controller {
|
||||
public function GetCustomers() {
|
||||
$search = [
|
||||
'search' => 'vij',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/customers?token=" . \Config::get('app.token');
|
||||
@@ -263,7 +261,7 @@ class TestController extends Controller {
|
||||
public function GetCustomer() {
|
||||
$search = [
|
||||
'user_id' => '1',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/customer?token=" . \Config::get('app.token');
|
||||
@@ -276,7 +274,7 @@ class TestController extends Controller {
|
||||
public function GetSearch() {
|
||||
$search = [
|
||||
'search' => 'api',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/ticket-search?token=" . \Config::get('app.token');
|
||||
@@ -288,8 +286,8 @@ class TestController extends Controller {
|
||||
|
||||
public function TicketThreads() {
|
||||
$search = [
|
||||
'id' => '8',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
|
||||
'id' => '1',
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/ticket-thread?token=" . \Config::get('app.token');
|
||||
@@ -301,8 +299,8 @@ class TestController extends Controller {
|
||||
|
||||
public function Url() {
|
||||
$search = [
|
||||
'url' => 'http://localhost/FaveoHELPDESK+KBLatests',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
|
||||
'url' => 'http://localhost/Faveo-HelpDesk-My-Branch/public/',
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/url?token=" . \Config::get('app.token');
|
||||
@@ -313,21 +311,21 @@ class TestController extends Controller {
|
||||
}
|
||||
|
||||
public function GenerateApiKey() {
|
||||
$url = $this->server . "helpdesk/api-key?token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/api-key?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function GetHelpTopic() {
|
||||
$url = $this->server . "helpdesk/help-topic?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/help-topic?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function GetSlaPlan() {
|
||||
$url = $this->server . "helpdesk/sla-plan?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/sla-plan?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
@@ -341,32 +339,32 @@ class TestController extends Controller {
|
||||
}
|
||||
|
||||
public function GetDepartment() {
|
||||
$url = $this->server . "helpdesk/department?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/department?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function GetTickets() {
|
||||
$url = $this->server . "helpdesk/tickets?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/tickets?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function Inbox() {
|
||||
$url = $this->server . "helpdesk/inbox?api-key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token');
|
||||
$url = $this->server . "helpdesk/inbox?api-key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->CallGetApi($url);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
|
||||
public function InternalNote() {
|
||||
$data = [
|
||||
'ticketid' => '23',
|
||||
'userid' => 1,
|
||||
'body' => 'Testing the api internal note',
|
||||
'api-key' => 'clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg'
|
||||
'api-key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server . "helpdesk/internal-note?token=" . \Config::get('app.token');
|
||||
|
@@ -17,6 +17,7 @@ use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Alert;
|
||||
use Hash;
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
@@ -31,7 +32,6 @@ use App\Model\helpdesk\Settings\Alert;
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class TicketController extends Controller {
|
||||
|
||||
/**
|
||||
@@ -47,6 +47,7 @@ class TicketController extends Controller {
|
||||
public function create_ticket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach = '') {
|
||||
try {
|
||||
$max_number = Tickets::whereRaw('id = (select max(`id`) from tickets)')->first();
|
||||
//dd($max_number);
|
||||
if ($max_number == null) {
|
||||
$ticket_number = "AAAA-9999-9999999";
|
||||
} else {
|
||||
@@ -56,6 +57,7 @@ class TicketController extends Controller {
|
||||
}
|
||||
$ticket = new Tickets;
|
||||
$ticket->ticket_number = $this->ticket_number($ticket_number);
|
||||
//dd($this->ticket_number($ticket_number));
|
||||
$ticket->user_id = $user_id;
|
||||
$ticket->dept_id = $dept;
|
||||
$ticket->help_topic_id = $helptopic;
|
||||
@@ -65,6 +67,7 @@ class TicketController extends Controller {
|
||||
$ticket->priority_id = $priority;
|
||||
$ticket->source = $source;
|
||||
$ticket->save();
|
||||
//dd($ticket);
|
||||
$ticket_number = $ticket->ticket_number;
|
||||
$id = $ticket->id;
|
||||
if ($form_data != null) {
|
||||
@@ -93,6 +96,7 @@ class TicketController extends Controller {
|
||||
}
|
||||
return $thread;
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
@@ -170,6 +174,7 @@ class TicketController extends Controller {
|
||||
*/
|
||||
public function ticket_number($ticket_number) {
|
||||
try {
|
||||
//dd($ticket_number);
|
||||
$number = $ticket_number;
|
||||
$number = explode('-', $number);
|
||||
$number1 = $number[0];
|
||||
@@ -193,6 +198,7 @@ class TicketController extends Controller {
|
||||
$number = implode('-', $array);
|
||||
return $number;
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
@@ -373,15 +379,24 @@ class TicketController extends Controller {
|
||||
public function assign($id) {
|
||||
try {
|
||||
$UserEmail = Input::get('user');
|
||||
//dd($id);
|
||||
//dd($UserEmail);
|
||||
// $UserEmail = 'sujitprasad12@yahoo.in';
|
||||
$user = User::where('email', '=', $UserEmail)->first();
|
||||
if (!$user) {
|
||||
return ['error' => 'No agent not found'];
|
||||
}
|
||||
$user_id = $user->id;
|
||||
$ticket = Tickets::where('id', '=', $id)->first();
|
||||
if (!$ticket) {
|
||||
return ['error' => 'No ticket not found'];
|
||||
}
|
||||
$ticket_number = $ticket->ticket_number;
|
||||
$ticket->assigned_to = $user_id;
|
||||
$ticket->save();
|
||||
$ticket_thread = Ticket_Thread::where('ticket_id', '=', $id)->first();
|
||||
if (!$ticket_thread) {
|
||||
return ['error' => 'No thread not found'];
|
||||
}
|
||||
$ticket_subject = $ticket_thread->title;
|
||||
$thread = New Ticket_Thread;
|
||||
$thread->ticket_id = $ticket->id;
|
||||
@@ -497,6 +512,7 @@ class TicketController extends Controller {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Attachment
|
||||
* @param type $thread
|
||||
|
@@ -23,31 +23,32 @@ use Illuminate\Support\Facades\Hash;
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class TokenAuthController extends Controller {
|
||||
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('api');
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticating user with username and password and retuen token
|
||||
* @param Request $request
|
||||
* @return type json
|
||||
*/
|
||||
public function authenticate(Request $request) {
|
||||
$usernameinput = $request->input('username');
|
||||
$password = $request->input('password');
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
|
||||
|
||||
$usernameinput = $request->input('username');
|
||||
$password = $request->input('password');
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
|
||||
//$credentials = $request->only('email', 'password');
|
||||
|
||||
try {
|
||||
if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password])) {
|
||||
return response()->json(['error' => 'invalid_credentials', 'status_code'=>401]);
|
||||
return response()->json(['error' => 'invalid_credentials', 'status_code' => 401]);
|
||||
}
|
||||
} catch (JWTException $e) {
|
||||
return response()->json(['error' => 'could_not_create_token', 500]);
|
||||
} catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
@@ -55,6 +56,7 @@ class TokenAuthController extends Controller {
|
||||
// if no errors are encountered we can return a JWT
|
||||
return response()->json(compact('token'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user details from token
|
||||
* @return type json
|
||||
@@ -75,15 +77,14 @@ class TokenAuthController extends Controller {
|
||||
} catch (\Tymon\JWTAuth\Exceptions\JWTException $e) {
|
||||
|
||||
return response()->json(['token_absent', $e->getStatusCode()]);
|
||||
}
|
||||
catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
//dd($user);
|
||||
return response()->json(compact('user'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a user with username and password
|
||||
* @param Request $request
|
||||
@@ -110,6 +111,7 @@ class TokenAuthController extends Controller {
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verify the url is existing or not
|
||||
* @return type json
|
||||
@@ -123,10 +125,9 @@ class TokenAuthController extends Controller {
|
||||
$error = $v->errors();
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
|
||||
|
||||
$url = $this->request->input('url');
|
||||
$url = $url.'/api/v1/helpdesk/check-url';
|
||||
|
||||
$url = $url . '/api/v1/helpdesk/check-url';
|
||||
} catch (Exception $ex) {
|
||||
$error = $e->getMessage();
|
||||
return response()->json(compact('error'));
|
||||
|
Reference in New Issue
Block a user