Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
be5df5334f
commit
d637c2b23f
File diff suppressed because it is too large
Load Diff
@@ -5,52 +5,42 @@ namespace App\Http\Controllers\Api\v1;
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\helpdesk\InstallerRequest;
|
||||
// models
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Form\Form_details;
|
||||
// models
|
||||
use App\Model\helpdesk\Utility\Date_time_format;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
// classes
|
||||
use App;
|
||||
use App\User;
|
||||
use Artisan;
|
||||
// classes
|
||||
use Config;
|
||||
use File;
|
||||
use Hash;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use View;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* |=======================================================================
|
||||
* |Class: InstallController
|
||||
* |=======================================================================
|
||||
* |=======================================================================.
|
||||
*
|
||||
* Class to perform the first install operation without this the database
|
||||
* settings could not be started
|
||||
*
|
||||
* @package Faveo HELPDESK
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*
|
||||
*/
|
||||
class InstallerApiController extends Controller {
|
||||
|
||||
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) {
|
||||
public function config_database(Request $request)
|
||||
{
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
|
||||
// Check for pre install
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
|
||||
$default = $request->database;
|
||||
$host = $request->host;
|
||||
$database = $request->databasename;
|
||||
@@ -74,7 +64,7 @@ class InstallerApiController extends Controller {
|
||||
}
|
||||
|
||||
// Write environment file
|
||||
$fp = fopen(base_path() . "/.env", 'w');
|
||||
$fp = fopen(base_path().'/.env', 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
|
||||
@@ -90,9 +80,11 @@ 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_system(Request $request) {
|
||||
public function config_system(Request $request)
|
||||
{
|
||||
// Check for pre install
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
$firstname = $request->firstname;
|
||||
@@ -104,8 +96,8 @@ class InstallerApiController extends Controller {
|
||||
$datetime = $request->datetime;
|
||||
|
||||
// Migrate database
|
||||
Artisan::call('migrate', array('--force' => true));
|
||||
Artisan::call('db:seed', array('--force' => true));
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
Artisan::call('db:seed', ['--force' => true]);
|
||||
|
||||
// checking requested timezone for the admin and system
|
||||
$timezones = Timezones::where('name', '=', $timezone)->first();
|
||||
@@ -118,7 +110,7 @@ class InstallerApiController extends Controller {
|
||||
return ['response' => 'fail', 'reason' => 'invalid date-time format', 'status' => '0'];
|
||||
}
|
||||
// Creating minum settings for system
|
||||
$system = new System;
|
||||
$system = new System();
|
||||
$system->status = 1;
|
||||
$system->department = 1;
|
||||
$system->date_time_format = $date_time_format->id;
|
||||
@@ -126,17 +118,17 @@ class InstallerApiController extends Controller {
|
||||
$system->save();
|
||||
|
||||
// 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',
|
||||
$user = User::create([
|
||||
'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,
|
||||
));
|
||||
'primary_dpt' => 1,
|
||||
]);
|
||||
|
||||
// Setting database installed status
|
||||
$value = '1';
|
||||
@@ -165,5 +157,4 @@ class InstallerApiController extends Controller {
|
||||
return ['response' => 'fail', 'reason' => 'this system is already installed', 'status' => '0'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,26 +2,26 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Exception;
|
||||
|
||||
class TestController extends Controller {
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
public $server;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$server = new Request();
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
$server = parse_url($url);
|
||||
$server["path"] = dirname($server["path"]);
|
||||
$server = parse_url($server["path"]);
|
||||
$server["path"] = dirname($server["path"]);
|
||||
$this->server = "http://" . $_SERVER['HTTP_HOST'] . $server['path'] . "/";
|
||||
$server['path'] = dirname($server['path']);
|
||||
$server = parse_url($server['path']);
|
||||
$server['path'] = dirname($server['path']);
|
||||
$this->server = 'http://'.$_SERVER['HTTP_HOST'].$server['path'].'/';
|
||||
}
|
||||
|
||||
static function callGetApi($url) {
|
||||
public static function callGetApi($url)
|
||||
{
|
||||
//dd($url);
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
@@ -31,14 +31,15 @@ class TestController extends Controller {
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if (curl_errno($curl)) {
|
||||
echo 'error:' . curl_error($curl);
|
||||
echo 'error:'.curl_error($curl);
|
||||
}
|
||||
|
||||
return $response;
|
||||
curl_close($curl);
|
||||
}
|
||||
|
||||
static function callPostApi($url, $data) {
|
||||
public static function callPostApi($url, $data)
|
||||
{
|
||||
//dd($url);
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
@@ -49,22 +50,23 @@ class TestController extends Controller {
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if (curl_errno($curl)) {
|
||||
echo 'error:' . curl_error($curl);
|
||||
echo 'error:'.curl_error($curl);
|
||||
}
|
||||
|
||||
return $response;
|
||||
curl_close($curl);
|
||||
}
|
||||
|
||||
public function ticketReply() {
|
||||
public function ticketReply()
|
||||
{
|
||||
|
||||
//$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
|
||||
|
||||
$data = [
|
||||
|
||||
'ticket_ID' => '1',
|
||||
'ticket_ID' => '1',
|
||||
'reply_content' => 'reply for the ticket id',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
// 'attachments' => [
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
@@ -82,28 +84,30 @@ class TestController extends Controller {
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
|
||||
$url = $this->server . "helpdesk/reply?token=" . \Config::get('app.token');
|
||||
$url = $this->server.'helpdesk/reply?token='.\Config::get('app.token');
|
||||
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function createTicket() {
|
||||
public function createTicket()
|
||||
{
|
||||
|
||||
//$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
|
||||
|
||||
$data = [
|
||||
'user_id' => 1,
|
||||
'subject' => 'Api create via faveo api',
|
||||
'body' => 'Test me when call api',
|
||||
'user_id' => 1,
|
||||
'subject' => 'Api create via faveo api',
|
||||
'body' => 'Test me when call api',
|
||||
'helptopic' => '1',
|
||||
'sla' => '1',
|
||||
'priority' => '1',
|
||||
'headers' => [0 => 'vijaycodename47@gmail.com'],
|
||||
'dept' => '1',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
/** if attachment */
|
||||
'sla' => '1',
|
||||
'priority' => '1',
|
||||
'headers' => [0 => 'vijaycodename47@gmail.com'],
|
||||
'dept' => '1',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
/* if attachment */
|
||||
// 'attachments' => [
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
@@ -121,280 +125,331 @@ class TestController extends Controller {
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
|
||||
$url = $this->server . "helpdesk/create?token=" . \Config::get('app.token');
|
||||
$url = $this->server.'helpdesk/create?token='.\Config::get('app.token');
|
||||
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function generateToken() {
|
||||
public function generateToken()
|
||||
{
|
||||
$data = [
|
||||
//'email'=>'vijaycodename47@gmail.com',
|
||||
'username' => 'vijay',
|
||||
'password' => 'manjapra',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
|
||||
$url = $this->server . "authenticate";
|
||||
$url = $this->server.'authenticate';
|
||||
//dd($url);
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function createUser() {
|
||||
public function createUser()
|
||||
{
|
||||
$data = [
|
||||
'email' => 'vijaycodename@gmail.com',
|
||||
'email' => 'vijaycodename@gmail.com',
|
||||
'password' => 'manjapra',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server . "register";
|
||||
$url = $this->server.'register';
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getAuthUser() {
|
||||
|
||||
$url = $this->server . "authenticate/user?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function getAuthUser()
|
||||
{
|
||||
$url = $this->server.'authenticate/user?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function editTicket() {
|
||||
public function editTicket()
|
||||
{
|
||||
$data = [
|
||||
'ticket_id' => '13',
|
||||
'subject' => 'Api editing ticket via faveo api',
|
||||
'sla_plan' => '2',
|
||||
'help_topic' => '2',
|
||||
'ticket_source' => '2',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
'ticket_id' => '13',
|
||||
'subject' => 'Api editing ticket via faveo api',
|
||||
'sla_plan' => '2',
|
||||
'help_topic' => '2',
|
||||
'ticket_source' => '2',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
'ticket_priority' => '2',
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server . "helpdesk/edit?token=" . \Config::get('app.token');
|
||||
$url = $this->server.'helpdesk/edit?token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function deleteTicket() {
|
||||
public function deleteTicket()
|
||||
{
|
||||
$data = [
|
||||
'ticket_id' => [11],
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server . "helpdesk/delete?token=" . \Config::get('app.token');
|
||||
$url = $this->server.'helpdesk/delete?token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function openedTickets() {
|
||||
$url = $this->server . "helpdesk/open?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function openedTickets()
|
||||
{
|
||||
$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() {
|
||||
public function unassignedTickets()
|
||||
{
|
||||
//dd('dsdf');
|
||||
$url = $this->server . "helpdesk/unassigned?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&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);
|
||||
//dd($respose);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function closeTickets() {
|
||||
$url = $this->server . "helpdesk/closed?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function closeTickets()
|
||||
{
|
||||
$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?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function getAgents()
|
||||
{
|
||||
$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?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function getTeams()
|
||||
{
|
||||
$url = $this->server.'helpdesk/teams?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function assignTicket() {
|
||||
public function assignTicket()
|
||||
{
|
||||
$data = [
|
||||
'ticket_id' => 1,
|
||||
'user' => 'vijay.sebastian@ladybirdweb.com',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'user' => 'vijay.sebastian@ladybirdweb.com',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server . "helpdesk/assign?token=" . \Config::get('app.token');
|
||||
$url = $this->server.'helpdesk/assign?token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getCustomers() {
|
||||
public function getCustomers()
|
||||
{
|
||||
$search = [
|
||||
'search' => 'vij',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'search' => 'vij',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/customers?token=" . \Config::get('app.token');
|
||||
$url = $url . '&' . $data;
|
||||
$url = $this->server.'helpdesk/customers?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getCustomer() {
|
||||
public function getCustomer()
|
||||
{
|
||||
$search = [
|
||||
'user_id' => '1',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/customer?token=" . \Config::get('app.token');
|
||||
$url = $url . '&' . $data;
|
||||
$url = $this->server.'helpdesk/customer?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getSearch() {
|
||||
public function getSearch()
|
||||
{
|
||||
$search = [
|
||||
'search' => 'api',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'search' => 'api',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/ticket-search?token=" . \Config::get('app.token');
|
||||
$url = $url . '&' . $data;
|
||||
$url = $this->server.'helpdesk/ticket-search?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function ticketThreads() {
|
||||
public function ticketThreads()
|
||||
{
|
||||
$search = [
|
||||
'id' => '1',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'id' => '1',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/ticket-thread?token=" . \Config::get('app.token');
|
||||
$url = $url . '&' . $data;
|
||||
$url = $this->server.'helpdesk/ticket-thread?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function url() {
|
||||
public function url()
|
||||
{
|
||||
$search = [
|
||||
'url' => 'http://localhost/faveo-helpdesk-github/public/',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'url' => 'http://localhost/faveo-helpdesk-github/public/',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server . "helpdesk/url?token=" . \Config::get('app.token');
|
||||
$url = $url . '&' . $data;
|
||||
$url = $this->server.'helpdesk/url?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function generateApiKey() {
|
||||
$url = $this->server . "helpdesk/api_key?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function generateApiKey()
|
||||
{
|
||||
$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=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function getHelpTopic()
|
||||
{
|
||||
$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=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function getSlaPlan()
|
||||
{
|
||||
$url = $this->server.'helpdesk/sla-plan?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getPriority() {
|
||||
$url = $this->server . "helpdesk/priority?api_key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token=" . \Config::get('app.token');
|
||||
public function getPriority()
|
||||
{
|
||||
$url = $this->server.'helpdesk/priority?api_key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getDepartment() {
|
||||
$url = $this->server . "helpdesk/department?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function getDepartment()
|
||||
{
|
||||
$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=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function getTickets()
|
||||
{
|
||||
$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=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
public function inbox()
|
||||
{
|
||||
$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() {
|
||||
public function internalNote()
|
||||
{
|
||||
$data = [
|
||||
'ticketid' => '1',
|
||||
'userid' => 1,
|
||||
'body' => 'Testing the api internal note',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN'
|
||||
'userid' => 1,
|
||||
'body' => 'Testing the api internal note',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server . "helpdesk/internal-note?token=" . \Config::get('app.token');
|
||||
$url = $this->server.'helpdesk/internal-note?token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function trash() {
|
||||
$url = $this->server . "helpdesk/trash?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
|
||||
public function trash()
|
||||
{
|
||||
$url = $this->server.'helpdesk/trash?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function myTickets(){
|
||||
try{
|
||||
$url = $this->server . "helpdesk/my-tickets?user_id=1&api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token=" . \Config::get('app.token');
|
||||
|
||||
public function myTickets()
|
||||
{
|
||||
try {
|
||||
$url = $this->server.'helpdesk/my-tickets?user_id=1&api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,70 +2,72 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use Auth;
|
||||
use Mail;
|
||||
use Input;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Settings\Alert;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Hash;
|
||||
use Input;
|
||||
use Mail;
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
* Ticket Controller
|
||||
* -----------------------------------------------------------------------------
|
||||
* -----------------------------------------------------------------------------.
|
||||
*
|
||||
*
|
||||
* @author Vijay Sebastian <vijay.sebastian@ladybirdweb.com>
|
||||
* @copyright (c) 2016, Ladybird Web Solution
|
||||
* @name Faveo HELPDESK
|
||||
*
|
||||
* @version v1
|
||||
*
|
||||
*
|
||||
*/
|
||||
class TicketController extends Controller {
|
||||
|
||||
class TicketController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function __construct() {
|
||||
$PhpMailController = new PhpMailController();
|
||||
public function __construct()
|
||||
{
|
||||
$PhpMailController = new PhpMailController();
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Ticket
|
||||
* Create Ticket.
|
||||
*
|
||||
* @param type $user_id
|
||||
* @param type $subject
|
||||
* @param type $body
|
||||
* @param type $helptopic
|
||||
* @param type $sla
|
||||
* @param type $priority
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function createTicket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach = '') {
|
||||
public function createTicket($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";
|
||||
$ticket_number = 'AAAA-9999-9999999';
|
||||
} else {
|
||||
foreach ($max_number as $number) {
|
||||
$ticket_number = $max_number->ticket_number;
|
||||
}
|
||||
}
|
||||
$ticket = new Tickets;
|
||||
$ticket = new Tickets();
|
||||
$ticket->ticket_number = $this->ticketNumber($ticket_number);
|
||||
//dd($this->ticketNumber($ticket_number));
|
||||
$ticket->user_id = $user_id;
|
||||
@@ -86,7 +88,7 @@ class TicketController extends Controller {
|
||||
foreach ($form_data as $key => $form_details) {
|
||||
foreach ($forms as $from) {
|
||||
if ($from->name == $key) {
|
||||
$form_value = new Ticket_Form_Data;
|
||||
$form_value = new Ticket_Form_Data();
|
||||
$form_value->ticket_id = $id;
|
||||
$form_value->title = $from->label;
|
||||
$form_value->content = $form_details;
|
||||
@@ -96,27 +98,30 @@ class TicketController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->storeCollaborators($headers, $id);
|
||||
|
||||
$thread = $this->ticketThread($subject, $body, $id, $user_id);
|
||||
if (!empty($attach)) {
|
||||
$this->attach($thread, $attach);
|
||||
}
|
||||
|
||||
return $thread;
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* store_collaborators
|
||||
* @param type $headers
|
||||
* store_collaborators.
|
||||
*
|
||||
* @param type $headers
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function storeCollaborators($headers, $id) {
|
||||
public function storeCollaborators($headers, $id)
|
||||
{
|
||||
try {
|
||||
$company = $this->company();
|
||||
if (isset($headers)) {
|
||||
@@ -124,11 +129,11 @@ class TicketController extends Controller {
|
||||
$name = $name;
|
||||
$email = $email;
|
||||
if ($this->checkEmail($email) == false) {
|
||||
$create_user = new User;
|
||||
$create_user = new User();
|
||||
$create_user->user_name = $name;
|
||||
$create_user->email = $email;
|
||||
$create_user->active = 1;
|
||||
$create_user->role = "user";
|
||||
$create_user->role = 'user';
|
||||
$password = $this->generateRandomString();
|
||||
$create_user->password = Hash::make($password);
|
||||
$create_user->save();
|
||||
@@ -138,19 +143,19 @@ class TicketController extends Controller {
|
||||
// });
|
||||
|
||||
$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]);
|
||||
|
||||
} else {
|
||||
$user = $this->checkEmail($email);
|
||||
$user_id = $user->id;
|
||||
}
|
||||
$collaborator_store = new Ticket_Collaborator;
|
||||
$collaborator_store = new Ticket_Collaborator();
|
||||
$collaborator_store->isactive = 1;
|
||||
$collaborator_store->ticket_id = $id;
|
||||
$collaborator_store->user_id = $user_id;
|
||||
$collaborator_store->role = "ccc";
|
||||
$collaborator_store->role = 'ccc';
|
||||
$collaborator_store->save();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
@@ -158,22 +163,26 @@ class TicketController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Ticket Thread
|
||||
* Generate Ticket Thread.
|
||||
*
|
||||
* @param type $subject
|
||||
* @param type $body
|
||||
* @param type $id
|
||||
* @param type $user_id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function ticketThread($subject, $body, $id, $user_id) {
|
||||
public function ticketThread($subject, $body, $id, $user_id)
|
||||
{
|
||||
try {
|
||||
$thread = new Ticket_Thread;
|
||||
$thread = new Ticket_Thread();
|
||||
$thread->user_id = $user_id;
|
||||
$thread->ticket_id = $id;
|
||||
$thread->poster = 'client';
|
||||
$thread->title = $subject;
|
||||
$thread->body = $body;
|
||||
$thread->save();
|
||||
|
||||
return $thread->id;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
@@ -181,11 +190,14 @@ class TicketController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates Ticket Number
|
||||
* Generates Ticket Number.
|
||||
*
|
||||
* @param type $ticket_number
|
||||
*
|
||||
* @return type integer
|
||||
*/
|
||||
public function ticketNumber($ticket_number) {
|
||||
public function ticketNumber($ticket_number)
|
||||
{
|
||||
try {
|
||||
//dd($ticket_number);
|
||||
$number = $ticket_number;
|
||||
@@ -207,21 +219,26 @@ class TicketController extends Controller {
|
||||
$number3++;
|
||||
$number2 = sprintf('%04s', $number2);
|
||||
$number3 = sprintf('%07s', $number3);
|
||||
$array = array($number1, $number2, $number3);
|
||||
$array = [$number1, $number2, $number3];
|
||||
$number = implode('-', $array);
|
||||
|
||||
return $number;
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random string for password
|
||||
* Generate a random string for password.
|
||||
*
|
||||
* @param type $length
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function generateRandomString($length = 10) {
|
||||
public function generateRandomString($length = 10)
|
||||
{
|
||||
try {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
@@ -229,6 +246,7 @@ class TicketController extends Controller {
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
|
||||
return $randomString;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
@@ -236,14 +254,16 @@ class TicketController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Replying a ticket
|
||||
* Replying a ticket.
|
||||
*
|
||||
* @param type Ticket_Thread $thread
|
||||
* @param type TicketRequest $request
|
||||
*
|
||||
* @return type bool
|
||||
*/
|
||||
public function reply($thread, $request, $ta, $attach = '') {
|
||||
public function reply($thread, $request, $ta, $attach = '')
|
||||
{
|
||||
try {
|
||||
|
||||
$check_attachment = null;
|
||||
$eventthread = $thread->where('ticket_id', $request->input('ticket_ID'))->first();
|
||||
$eventuserid = $eventthread->user_id;
|
||||
@@ -266,11 +286,11 @@ class TicketController extends Controller {
|
||||
if ($tickets->assigned_to == 0) {
|
||||
$tickets->assigned_to = Auth::user()->id;
|
||||
$tickets->save();
|
||||
$thread2 = New Ticket_Thread;
|
||||
$thread2 = new Ticket_Thread();
|
||||
$thread2->ticket_id = $thread->ticket_id;
|
||||
$thread2->user_id = Auth::user()->id;
|
||||
$thread2->is_internal = 1;
|
||||
$thread2->body = "This Ticket have been assigned to " . Auth::user()->first_name . " " . Auth::user()->last_name;
|
||||
$thread2->body = 'This Ticket have been assigned to '.Auth::user()->first_name.' '.Auth::user()->last_name;
|
||||
$thread2->save();
|
||||
}
|
||||
if ($tickets->status > 1) {
|
||||
@@ -280,7 +300,6 @@ class TicketController extends Controller {
|
||||
}
|
||||
$thread->save();
|
||||
|
||||
|
||||
if (!empty($attach)) {
|
||||
$check_attachment = $this->attach($thread->id, $attach);
|
||||
}
|
||||
@@ -313,22 +332,20 @@ class TicketController extends Controller {
|
||||
// }, true);
|
||||
|
||||
try {
|
||||
$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, 'ticket_number' => $ticket_number2]);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
$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, 'ticket_number' => $ticket_number2]);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
|
||||
$collaborators = Ticket_Collaborator::where('ticket_id', '=', $ticket_id)->get();
|
||||
foreach ($collaborators as $collaborator) {
|
||||
//mail to collaborators
|
||||
$collab_user_id = $collaborator->user_id;
|
||||
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
|
||||
$collab_email = $user_id_collab->email;
|
||||
if ($user_id_collab->role == "user") {
|
||||
if ($user_id_collab->role == 'user') {
|
||||
$collab_user_name = $user_id_collab->user_name;
|
||||
} else {
|
||||
$collab_user_name = $user_id_collab->first_name . " " . $user_id_collab->last_name;
|
||||
$collab_user_name = $user_id_collab->first_name.' '.$user_id_collab->last_name;
|
||||
}
|
||||
// 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 . ']');
|
||||
@@ -341,13 +358,11 @@ try {
|
||||
// }, true);
|
||||
|
||||
try {
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $admin_user, 'email' => $admin_email], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $admin_user, 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $admin_user, 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $admin_user, 'email' => $admin_email], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $admin_user, 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $admin_user, 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
return $thread;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
@@ -355,17 +370,20 @@ try {
|
||||
}
|
||||
|
||||
/**
|
||||
* company
|
||||
* company.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function company() {
|
||||
public function company()
|
||||
{
|
||||
try {
|
||||
$company = Company::Where('id', '=', '1')->first();
|
||||
if ($company->company_name == null) {
|
||||
$company = "Support Center";
|
||||
$company = 'Support Center';
|
||||
} else {
|
||||
$company = $company->company_name;
|
||||
}
|
||||
|
||||
return $company;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
@@ -373,25 +391,28 @@ try {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticket edit and save ticket data
|
||||
* @param type $ticket_id
|
||||
* Ticket edit and save ticket data.
|
||||
*
|
||||
* @param type $ticket_id
|
||||
* @param type Ticket_Thread $thread
|
||||
*
|
||||
* @return type bool
|
||||
*/
|
||||
public function ticketEditPost($ticket_id, $thread, $ticket) {
|
||||
public function ticketEditPost($ticket_id, $thread, $ticket)
|
||||
{
|
||||
try {
|
||||
|
||||
$ticket = $ticket->where('id', '=', $ticket_id)->first();
|
||||
|
||||
$ticket->sla = Input::get("sla_plan");
|
||||
$ticket->help_topic_id = Input::get("help_topic");
|
||||
$ticket->source = Input::get("ticket_source");
|
||||
$ticket->priority_id = Input::get("ticket_priority");
|
||||
$ticket->sla = Input::get('sla_plan');
|
||||
$ticket->help_topic_id = Input::get('help_topic');
|
||||
$ticket->source = Input::get('ticket_source');
|
||||
$ticket->priority_id = Input::get('ticket_priority');
|
||||
$ticket->save();
|
||||
|
||||
$threads = $thread->where('ticket_id', '=', $ticket_id)->first();
|
||||
$threads->title = Input::get("subject");
|
||||
$threads->title = Input::get('subject');
|
||||
$threads->save();
|
||||
|
||||
return $threads;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
@@ -399,11 +420,14 @@ try {
|
||||
}
|
||||
|
||||
/**
|
||||
* function to assign ticket
|
||||
* function to assign ticket.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type bool
|
||||
*/
|
||||
public function assign($id) {
|
||||
public function assign($id)
|
||||
{
|
||||
try {
|
||||
$UserEmail = Input::get('user');
|
||||
//dd($UserEmail);
|
||||
@@ -425,11 +449,11 @@ try {
|
||||
return ['error' => 'No thread not found'];
|
||||
}
|
||||
$ticket_subject = $ticket_thread->title;
|
||||
$thread = New Ticket_Thread;
|
||||
$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 assigned to " . $user->first_name . " " . $user->last_name;
|
||||
$thread->body = 'This Ticket has been assigned to '.$user->first_name.' '.$user->last_name;
|
||||
$thread->save();
|
||||
|
||||
$company = $this->company();
|
||||
@@ -438,7 +462,7 @@ try {
|
||||
$agent = $user->first_name;
|
||||
$agent_email = $user->email;
|
||||
|
||||
$master = Auth::user()->first_name . " " . Auth::user()->last_name;
|
||||
$master = Auth::user()->first_name.' '.Auth::user()->last_name;
|
||||
if (Alert::first()->internal_status == 1 || Alert::first()->internal_assigned_agent == 1) {
|
||||
// // ticket assigned send mail
|
||||
// Mail::send('emails.Ticket_assign', ['agent' => $agent, 'ticket_number' => $ticket_number, 'from' => $company, 'master' => $master, 'system' => $system], function ($message) use ($agent_email, $agent, $ticket_number, $ticket_subject) {
|
||||
@@ -446,13 +470,10 @@ try {
|
||||
// });
|
||||
|
||||
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]);
|
||||
$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]);
|
||||
} catch (\Exception $e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -462,13 +483,15 @@ try {
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to delete ticket
|
||||
* @param type $id
|
||||
* Function to delete ticket.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Tickets $ticket
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function delete($ids, $ticket) {
|
||||
|
||||
public function delete($ids, $ticket)
|
||||
{
|
||||
try {
|
||||
foreach ($ids as $id) {
|
||||
$ticket_delete = $ticket->where('id', '=', $id)->first();
|
||||
@@ -496,29 +519,33 @@ try {
|
||||
$ticket_delete->status = 5;
|
||||
$ticket_delete->save();
|
||||
$ticket_status_message = Ticket_Status::where('id', '=', $ticket_delete->status)->first();
|
||||
$thread = New Ticket_Thread;
|
||||
$thread = new Ticket_Thread();
|
||||
$thread->ticket_id = $ticket_delete->id;
|
||||
$thread->user_id = Auth::user()->id;
|
||||
$thread->is_internal = 1;
|
||||
$thread->body = $ticket_status_message->message . " " . Auth::user()->first_name . " " . Auth::user()->last_name;
|
||||
$thread->body = $ticket_status_message->message.' '.Auth::user()->first_name.' '.Auth::user()->last_name;
|
||||
$thread->save();
|
||||
}
|
||||
} else {
|
||||
return "ticket not found";
|
||||
return 'ticket not found';
|
||||
}
|
||||
}
|
||||
return "your tickets has been deleted";
|
||||
|
||||
return 'your tickets has been deleted';
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check email for dublicate entry
|
||||
* check email for dublicate entry.
|
||||
*
|
||||
* @param type $email
|
||||
*
|
||||
* @return type bool
|
||||
*/
|
||||
public function checkEmail($email) {
|
||||
public function checkEmail($email)
|
||||
{
|
||||
try {
|
||||
$check = User::where('email', '=', $email)->first();
|
||||
if ($check == true) {
|
||||
@@ -532,17 +559,20 @@ try {
|
||||
}
|
||||
|
||||
/**
|
||||
* system
|
||||
* system.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function system() {
|
||||
public function system()
|
||||
{
|
||||
try {
|
||||
$system = System::Where('id', '=', '1')->first();
|
||||
if ($system->name == null) {
|
||||
$system = "Support Center";
|
||||
$system = 'Support Center';
|
||||
} else {
|
||||
$system = $system->name;
|
||||
}
|
||||
|
||||
return $system;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
@@ -550,22 +580,25 @@ try {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Attachment
|
||||
* Create Attachment.
|
||||
*
|
||||
* @param type $thread
|
||||
* @param type $attach
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function attach($thread, $attach) {
|
||||
public function attach($thread, $attach)
|
||||
{
|
||||
try {
|
||||
$ta = new Ticket_attachments();
|
||||
foreach ($attach as $file) {
|
||||
$ta->create(['thread_id' => $thread, 'name' => $file['name'], 'size' => $file['size'], 'type' => $file['type'], 'file' => $file['file'], 'poster' => 'ATTACHMENT']);
|
||||
}
|
||||
$ta->create(['thread_id' => $thread, 'name' => $name, 'size' => $size, 'type' => $type, 'file' => $file, 'poster' => 'ATTACHMENT']);
|
||||
|
||||
return 1;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,39 +3,40 @@
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use JWTAuth;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
use App\Http\Requests;
|
||||
use Illuminate\Http\Request;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
* Token authenticate Controller
|
||||
* -----------------------------------------------------------------------------
|
||||
* -----------------------------------------------------------------------------.
|
||||
*
|
||||
*
|
||||
* @author Vijay Sebastian <vijay.sebastian@ladybirdweb.com>
|
||||
* @copyright (c) 2016, Ladybird Web Solution
|
||||
* @name Faveo HELPDESK
|
||||
*
|
||||
* @version v1
|
||||
*
|
||||
*
|
||||
*/
|
||||
class TokenAuthController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
class TokenAuthController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('api');
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticating user with username and password and retuen token
|
||||
* Authenticating user with username and password and retuen token.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function authenticate(Request $request) {
|
||||
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
$usernameinput = $request->input('username');
|
||||
$password = $request->input('password');
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
@@ -50,6 +51,7 @@ class TokenAuthController extends Controller {
|
||||
return response()->json(['error' => 'could_not_create_token', 500]);
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
|
||||
@@ -58,27 +60,26 @@ class TokenAuthController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user details from token
|
||||
* Get the user details from token.
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function getAuthenticatedUser() {
|
||||
public function getAuthenticatedUser()
|
||||
{
|
||||
//dd(JWTAuth::parseToken()->authenticate());
|
||||
try {
|
||||
|
||||
if (!$user = JWTAuth::parseToken()->authenticate()) {
|
||||
return response()->json(['user_not_found', 404]);
|
||||
}
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
|
||||
|
||||
return response()->json(['token_expired', $e->getStatusCode()]);
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenInvalidException $e) {
|
||||
|
||||
return response()->json(['token_invalid', $e->getStatusCode()]);
|
||||
} catch (\Tymon\JWTAuth\Exceptions\JWTException $e) {
|
||||
|
||||
return response()->json(['token_absent', $e->getStatusCode()]);
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
//dd($user);
|
||||
@@ -86,18 +87,22 @@ class TokenAuthController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a user with username and password
|
||||
* Register a user with username and password.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function register(Request $request) {
|
||||
public function register(Request $request)
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make($request->all(), [
|
||||
'email' => 'required|email|unique:users',
|
||||
'email' => 'required|email|unique:users',
|
||||
'password' => 'required',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
$error = $v->errors();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$newuser = $request->all();
|
||||
@@ -108,30 +113,34 @@ class TokenAuthController extends Controller {
|
||||
return User::create($newuser);
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verify the url is existing or not
|
||||
* verify the url is existing or not.
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function checkUrl() {
|
||||
public function checkUrl()
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make($request->all(), [
|
||||
'url' => 'required|url'
|
||||
'url' => 'required|url',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
$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