update 1.0.7
This commit is contained in:
@@ -107,7 +107,8 @@ class AgentController extends Controller
|
||||
// fixing the user role to agent
|
||||
$user->fill($request->input())->save();
|
||||
// generate password and has immediately to store
|
||||
$user->password = Hash::make($this->generateRandomString());
|
||||
$password = $this->generateRandomString();
|
||||
$user->password = Hash::make($password);
|
||||
// fetching all the team details checked for this user
|
||||
$requests = $request->input('team_id');
|
||||
// get user id of the inserted user detail
|
||||
@@ -127,7 +128,7 @@ class AgentController 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]);
|
||||
} catch (Exception $e) {
|
||||
// returns if try fails
|
||||
return redirect('agents')->with('fails', 'Some error occured while sending mail to the agent. Please check email settings and try again');
|
||||
return redirect('agents')->with('fails', 'Some error occurred while sending mail to the agent. Please check email settings and try again');
|
||||
}
|
||||
// returns for the success case
|
||||
return redirect('agents')->with('success', 'Agent Created sucessfully');
|
||||
|
@@ -19,8 +19,6 @@ use Crypt;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
//use PhpImap\Mailbox as ImapMailbox;
|
||||
|
||||
/**
|
||||
* ======================================
|
||||
* EmailsController.
|
||||
@@ -120,9 +118,14 @@ class EmailsController extends Controller
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
if ($request->validate == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} else {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->fetching_status == 'on') {
|
||||
$imap_check = $this->getImapStream($request);
|
||||
if ($imap_check == 0) {
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
if ($imap_check[0] == 0) {
|
||||
return 'Incoming email connection failed';
|
||||
}
|
||||
$need_to_check_imap = 1;
|
||||
@@ -143,17 +146,17 @@ class EmailsController extends Controller
|
||||
|
||||
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check != 0 && $smtp_check != 0) {
|
||||
$this->store($request);
|
||||
$this->store($request, $imap_check[1]);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 1 && $need_to_check_smtp == 0) {
|
||||
if ($imap_check != 0 && $smtp_check == 0) {
|
||||
$this->store($request);
|
||||
$this->store($request, $imap_check[1]);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check == 0 && $smtp_check != 0) {
|
||||
$this->store($request);
|
||||
$this->store($request, null);
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ($need_to_check_imap == 0 && $need_to_check_smtp == 0) {
|
||||
@@ -174,14 +177,14 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store($request)
|
||||
public function store($request, $imap_check)
|
||||
{
|
||||
// dd($request);
|
||||
$email = new Emails();
|
||||
try {
|
||||
// getConnection($request->input('email_name'), $request->input('email_address'), $request->input('email_address'))
|
||||
// saving all the fields to the database
|
||||
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'sending_status', 'auto_response'))->save() == true) {
|
||||
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save() == true) {
|
||||
if ($request->fetching_status == 'on') {
|
||||
$email->fetching_status = 1;
|
||||
} else {
|
||||
@@ -197,7 +200,12 @@ class EmailsController extends Controller
|
||||
} else {
|
||||
$email->auto_response = 0;
|
||||
}
|
||||
// fetching department value
|
||||
if ($imap_check !== null) {
|
||||
$email->fetching_encryption = $imap_check;
|
||||
} else {
|
||||
$email->fetching_encryption = $request->fetching_encryption;
|
||||
}
|
||||
// fetching department value
|
||||
$email->department = $this->departmentValue($request->input('department'));
|
||||
// fetching priority value
|
||||
$email->priority = $this->priorityValue($request->input('priority'));
|
||||
@@ -289,8 +297,13 @@ class EmailsController extends Controller
|
||||
return $return_data;
|
||||
}
|
||||
// return $request;
|
||||
if ($request->validate == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} else {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->fetching_status == 'on') {
|
||||
$imap_check = $this->getImapStream($request);
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
if ($imap_check == 0) {
|
||||
return 'Incoming email connection failed';
|
||||
}
|
||||
@@ -425,7 +438,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function getImapStream($request)
|
||||
public function getImapStream($request, $validate)
|
||||
{
|
||||
$fetching_status = $request->input('fetching_status');
|
||||
$username = $request->input('email_address');
|
||||
@@ -433,13 +446,20 @@ class EmailsController extends Controller
|
||||
$protocol_id = $request->input('mailbox_protocol');
|
||||
$fetching_protocol = '/'.$request->input('fetching_protocol');
|
||||
$fetching_encryption = '/'.$request->input('fetching_encryption');
|
||||
if ($fetching_encryption == 'none') {
|
||||
$fetching_encryption = 'novalidate-cert';
|
||||
if ($fetching_encryption == '/none') {
|
||||
$fetching_encryption2 = '/novalidate-cert';
|
||||
$mailbox_protocol = $fetching_encryption2;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.'}INBOX';
|
||||
} else {
|
||||
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.$validate.'}INBOX';
|
||||
$mailbox_protocol = $fetching_encryption.$validate;
|
||||
}
|
||||
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.'}INBOX';
|
||||
|
||||
try {
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
} catch (\Exception $ex) {
|
||||
@@ -447,9 +467,9 @@ class EmailsController extends Controller
|
||||
}
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
if ($imap_stream) {
|
||||
$return = 1;
|
||||
$return = [0 => 1, 1 => $mailbox_protocol];
|
||||
} else {
|
||||
$return = 0;
|
||||
$return = [0 => 0];
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@@ -139,9 +139,6 @@ class GroupController extends Controller
|
||||
//Updating can_assign_ticket field
|
||||
$assignTicket = $request->Input('can_assign_ticket');
|
||||
$var->can_assign_ticket = $assignTicket;
|
||||
//Updating can_trasfer_ticket field
|
||||
$trasferTicket = $request->Input('can_trasfer_ticket');
|
||||
$var->can_trasfer_ticket = $trasferTicket;
|
||||
//Updating can_delete_ticket field
|
||||
$deleteTicket = $request->Input('can_delete_ticket');
|
||||
$var->can_delete_ticket = $deleteTicket;
|
||||
|
@@ -27,9 +27,11 @@ use App\Model\helpdesk\Utility\Date_time_format;
|
||||
use App\Model\helpdesk\Utility\Time_format;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* SettingsController.
|
||||
@@ -76,7 +78,7 @@ class SettingsController extends Controller
|
||||
/* Direct to Company Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.company', compact('companys'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,10 +112,31 @@ class SettingsController extends Controller
|
||||
return redirect('getcompany')->with('success', 'Company Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getcompany')->with('fails', 'Company can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('getcompany')->with('fails', 'Company can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to delete system logo.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function deleteLogo()
|
||||
{
|
||||
$path = $_GET['data1']; //get file path of logo image
|
||||
if (!unlink($path)) {
|
||||
return 'false';
|
||||
} else {
|
||||
$companys = Company::where('id', '=', 1)->first();
|
||||
$companys->logo = null;
|
||||
$companys->use_logo = '0';
|
||||
$companys->save();
|
||||
|
||||
return 'true';
|
||||
}
|
||||
// return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for System setting page.
|
||||
*
|
||||
@@ -138,7 +161,7 @@ class SettingsController extends Controller
|
||||
/* Direct to System Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +187,7 @@ class SettingsController extends Controller
|
||||
return redirect('getsystem')->with('success', 'System Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getsystem')->with('fails', 'System can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('getsystem')->with('fails', 'System can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +213,7 @@ class SettingsController extends Controller
|
||||
/* Direct to Ticket Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +248,7 @@ class SettingsController extends Controller
|
||||
return redirect('getticket')->with('success', 'Ticket Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getticket')->with('fails', 'Ticket can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('getticket')->with('fails', 'Ticket can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +273,7 @@ class SettingsController extends Controller
|
||||
/* Direct to Email Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.email', compact('emails', 'templates', 'emails1'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,8 +294,8 @@ class SettingsController extends Controller
|
||||
/* fill the values to email table */
|
||||
$emails->fill($request->except('email_fetching', 'all_emails', 'email_collaborator', 'strip', 'attachment'))->save();
|
||||
/* insert checkboxes to database */
|
||||
$emails->email_fetching = $request->input('email_fetching');
|
||||
$emails->notification_cron = $request->input('notification_cron');
|
||||
// $emails->email_fetching = $request->input('email_fetching');
|
||||
// $emails->notification_cron = $request->input('notification_cron');
|
||||
$emails->all_emails = $request->input('all_emails');
|
||||
$emails->email_collaborator = $request->input('email_collaborator');
|
||||
$emails->strip = $request->input('strip');
|
||||
@@ -283,7 +306,65 @@ class SettingsController extends Controller
|
||||
return redirect('getemail')->with('success', 'Email Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getemail')->with('fails', 'Email can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('getemail')->with('fails', 'Email can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for cron job setting page.
|
||||
*
|
||||
* @param type Email $email
|
||||
* @param type Template $template
|
||||
* @param type Emails $email1
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getSchedular(Email $email, Template $template, Emails $email1)
|
||||
{
|
||||
// try {
|
||||
/* fetch the values of email from Email table */
|
||||
$emails = $email->whereId('1')->first();
|
||||
/* Fetch the values from Template table */
|
||||
$templates = $template->get();
|
||||
/* Fetch the values from Emails table */
|
||||
$emails1 = $email1->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.crone', compact('emails', 'templates', 'emails1'));
|
||||
// } catch {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage for cron job.
|
||||
*
|
||||
* @param type Email $email
|
||||
* @param type EmailRequest $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postSchedular(Email $email, Template $template, Emails $email1, Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
try {
|
||||
/* fetch the values of email request */
|
||||
$emails = $email->whereId('1')->first();
|
||||
if ($request->email_fetching) {
|
||||
$emails->email_fetching = $request->email_fetching;
|
||||
} else {
|
||||
$emails->email_fetching = 0;
|
||||
}
|
||||
if ($request->notification_cron) {
|
||||
$emails->notification_cron = $request->notification_cron;
|
||||
} else {
|
||||
$emails->notification_cron = 0;
|
||||
}
|
||||
$emails->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +434,7 @@ class SettingsController extends Controller
|
||||
/* Direct to Responder Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.responder', compact('responders'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +464,7 @@ class SettingsController extends Controller
|
||||
return redirect('getresponder')->with('success', 'Responder Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getresponder')->with('fails', 'Responder can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('getresponder')->with('fails', 'Responder can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +483,7 @@ class SettingsController extends Controller
|
||||
/* Direct to Alert Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.alert', compact('alerts'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,7 +552,7 @@ class SettingsController extends Controller
|
||||
return redirect('getalert')->with('success', 'Alert Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getalert')->with('fails', 'Alert can not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('getalert')->with('fails', 'Alert can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -324,7 +324,7 @@ class TemplateController extends Controller
|
||||
return redirect('getdiagno')->with('fails', 'Please provide E-mail address !');
|
||||
}
|
||||
// sending mail via php mailer
|
||||
$mail = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['email' => $email], $message = ['subject' => 'Checking the connection', 'scenario' => 'error-report', 'content' => 'Email Received Successfully'], $template_variables = ['system_error' => 'hello']);
|
||||
$mail = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['email' => $email], $message = ['subject' => 'Checking the connection', 'scenario' => 'error-report', 'content' => 'Email Received Successfully'], $template_variables = ['system_error' => 'Email Received Successfully']);
|
||||
|
||||
if ($mail == null) {
|
||||
return redirect('getdiagno')->with('fails', 'Please check your E-mail settings. Unable to send mails');
|
||||
|
456
app/Http/Controllers/Admin/helpdesk/WorkflowController.php
Normal file
456
app/Http/Controllers/Admin/helpdesk/WorkflowController.php
Normal file
@@ -0,0 +1,456 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controller
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// request
|
||||
use App\Http\Requests\helpdesk\WorkflowCreateRequest;
|
||||
use App\Http\Requests\helpdesk\WorkflowUpdateRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
// model
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Manage\Sla_plan;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Workflow\WorkflowAction;
|
||||
use App\Model\helpdesk\Workflow\WorkflowName;
|
||||
use App\Model\helpdesk\Workflow\WorkflowRules;
|
||||
use App\User;
|
||||
use Datatable;
|
||||
//classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* WorkflowController
|
||||
* In this controller in the CRUD function for all the workflow applied in faveo.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class WorkflowController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking admin roles
|
||||
$this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of all the workflow.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.workflow.index');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List of all the workflow in the system.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function workFlowList()
|
||||
{
|
||||
// returns chumper datatable
|
||||
return Datatable::collection(WorkflowName::All())
|
||||
/* searcable column name */
|
||||
->searchColumns('name')
|
||||
/* order column name and description */
|
||||
->orderColumns('name')
|
||||
/* add column name */
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
/* add column status */
|
||||
->addColumn('status', function ($model) {
|
||||
if ($model->status == 1) {
|
||||
return 'Active';
|
||||
} elseif ($model->status == 0) {
|
||||
return 'Disabled';
|
||||
}
|
||||
})
|
||||
/* add column order */
|
||||
->addColumn('order', function ($model) {
|
||||
return $model->order;
|
||||
})
|
||||
/* add column rules */
|
||||
->addColumn('rules', function ($model) {
|
||||
$rules = WorkflowRules::where('workflow_id', '=', $model->id)->count();
|
||||
|
||||
return $rules;
|
||||
})
|
||||
/* add column target */
|
||||
->addColumn('target', function ($model) {
|
||||
$target = $model->target;
|
||||
$target1 = explode('-', $target);
|
||||
if ($target1[0] == 'A') {
|
||||
if ($target1[1] == 0) {
|
||||
return 'Any';
|
||||
} elseif ($target1[1] == 1) {
|
||||
return 'Web Forms';
|
||||
} elseif ($target1[1] == 2) {
|
||||
return 'Email';
|
||||
} elseif ($target1[1] == 4) {
|
||||
return 'API';
|
||||
}
|
||||
} elseif ($target1[0] == 'E') {
|
||||
$emails = Emails::where('id', '=', $target1[1])->first();
|
||||
|
||||
return $emails->email_address;
|
||||
}
|
||||
})
|
||||
/* add column created */
|
||||
->addColumn('Created', function ($model) {
|
||||
return TicketController::usertimezone($model->created_at);
|
||||
})
|
||||
/* add column updated */
|
||||
->addColumn('Updated', function ($model) {
|
||||
return TicketController::usertimezone($model->updated_at);
|
||||
})
|
||||
/* add column action */
|
||||
->addColumn('Actions', function ($model) {
|
||||
$confirmation = 'Are you sure?';
|
||||
|
||||
return "<a class='btn btn-info btn-xs btn-flat' href='".route('workflow.edit', $model->id)."'><i class='fa fa-edit text-black'></i> Edit</a> <a class='btn btn-danger btn-xs btn-flat' href='".route('workflow.delete', $model->id)."'><i class='fa fa-trash text-black'></i> Delete</a>";
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new workflow.
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(Emails $emails)
|
||||
{
|
||||
// dd($emails);
|
||||
foreach ($emails->lists('email_address', 'id') as $key => $email) {
|
||||
$email_data["E-$key"] = $email;
|
||||
}
|
||||
// dd($email_data);
|
||||
// dd($emails->lists('email_address' , 'id'));
|
||||
$emails = $email_data;
|
||||
try {
|
||||
// $emails = $emails->get();
|
||||
return view('themes.default1.admin.helpdesk.manage.workflow.create', compact('emails'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new workflow in to the system.
|
||||
*
|
||||
* @param \App\Http\Requests\helpdesk\WorkflowCreateRequest $request
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function store(WorkflowCreateRequest $request)
|
||||
{
|
||||
//dd($request);
|
||||
try {
|
||||
// store a new workflow credentials in to the system
|
||||
$workflow_name = new WorkflowName();
|
||||
$workflow_name->name = $request->name;
|
||||
$workflow_name->status = $request->status;
|
||||
$workflow_name->order = $request->execution_order;
|
||||
$workflow_name->target = $request->target_channel;
|
||||
$workflow_name->internal_note = $request->internal_note;
|
||||
$workflow_name->save();
|
||||
|
||||
$rules = $request->rule;
|
||||
$actions = $request->action;
|
||||
// store workflow rules into the system
|
||||
foreach ($rules as $rule) {
|
||||
$workflow_rule = new WorkflowRules();
|
||||
$workflow_rule->workflow_id = $workflow_name->id;
|
||||
$workflow_rule->matching_scenario = $rule['a'];
|
||||
$workflow_rule->matching_relation = $rule['b'];
|
||||
$workflow_rule->matching_value = $rule['c'];
|
||||
$workflow_rule->save();
|
||||
}
|
||||
// store a new workflow action into the system
|
||||
foreach ($actions as $action) {
|
||||
$workflow_action = new WorkflowAction();
|
||||
$workflow_action->workflow_id = $workflow_name->id;
|
||||
$workflow_action->condition = $action['a'];
|
||||
$workflow_action->action = $action['b'];
|
||||
$workflow_action->save();
|
||||
}
|
||||
|
||||
return redirect('workflow')->with('success', 'Workflow Created Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Editing the details of the banned users.
|
||||
*
|
||||
* @param type $id
|
||||
* @param User $ban
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, WorkflowName $work_flow_name, Emails $emails, WorkflowRules $workflow_rule, WorkflowAction $workflow_action)
|
||||
{
|
||||
try {
|
||||
$emails = $emails->get();
|
||||
$workflow = $work_flow_name->whereId($id)->first();
|
||||
$workflow_rules = $workflow_rule->whereWorkflow_id($id)->get();
|
||||
$workflow_actions = $workflow_action->whereWorkflow_id($id)->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.workflow.edit', compact('id', 'workflow', 'emails', 'workflow_rules', 'workflow_actions'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update ticket workflow.
|
||||
*
|
||||
* @param type $id
|
||||
* @param \App\Http\Requests\helpdesk\WorkflowUpdateRequest $request
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function update($id, WorkflowUpdateRequest $request)
|
||||
{
|
||||
try {
|
||||
// store a new workflow credentials in to the system
|
||||
$workflow_name = WorkflowName::whereId($id)->first();
|
||||
$workflow_name->name = $request->name;
|
||||
$workflow_name->status = $request->status;
|
||||
$workflow_name->order = $request->execution_order;
|
||||
$workflow_name->target = $request->target_channel;
|
||||
$workflow_name->internal_note = $request->internal_note;
|
||||
$workflow_name->save();
|
||||
|
||||
$rules = $request->rule;
|
||||
$actions = $request->action;
|
||||
// removing old foreign values to insert an updated one
|
||||
WorkflowAction::where('workflow_id', '=', $id)->delete();
|
||||
WorkflowRules::where('workflow_id', '=', $id)->delete();
|
||||
// update workflow rules into the system
|
||||
foreach ($rules as $rule) {
|
||||
$workflow_rule = new WorkflowRules();
|
||||
$workflow_rule->workflow_id = $workflow_name->id;
|
||||
$workflow_rule->matching_scenario = $rule['a'];
|
||||
$workflow_rule->matching_relation = $rule['b'];
|
||||
$workflow_rule->matching_value = $rule['c'];
|
||||
$workflow_rule->save();
|
||||
}
|
||||
// update workflow action into the system
|
||||
foreach ($actions as $action) {
|
||||
$workflow_action = new WorkflowAction();
|
||||
$workflow_action->workflow_id = $workflow_name->id;
|
||||
$workflow_action->condition = $action['a'];
|
||||
$workflow_action->action = $action['b'];
|
||||
$workflow_action->save();
|
||||
}
|
||||
|
||||
return redirect('workflow')->with('success', 'Workflow Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to delete workflow.
|
||||
*
|
||||
* @param type $id
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// remove all the contents of workflow
|
||||
$workflow_action = WorkflowAction::where('workflow_id', '=', $id)->delete();
|
||||
$workflow_rules = WorkflowRules::where('workflow_id', '=', $id)->delete();
|
||||
$workflow = WorkflowName::whereId($id)->delete();
|
||||
|
||||
return redirect('workflow')->with('success', 'Workflow Deleted Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to select action.
|
||||
*
|
||||
* @param type $id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public function selectAction($id, Request $request)
|
||||
{
|
||||
if ($request->option == 'reject') {
|
||||
return $this->rejectTicket($id);
|
||||
} elseif ($request->option == 'department') {
|
||||
return $this->department($id);
|
||||
} elseif ($request->option == 'priority') {
|
||||
return $this->priority($id);
|
||||
} elseif ($request->option == 'sla') {
|
||||
return $this->slaPlan($id);
|
||||
} elseif ($request->option == 'team') {
|
||||
return $this->assignTeam($id);
|
||||
} elseif ($request->option == 'agent') {
|
||||
return $this->assignAgent($id);
|
||||
} elseif ($request->option == 'helptopic') {
|
||||
return $this->helptopic($id);
|
||||
} elseif ($request->option == 'status') {
|
||||
return $this->ticketStatus($id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to reject ticket.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function rejectTicket($id)
|
||||
{
|
||||
$var = '<input type="hidden" name="action['.$id.'][b]" class="form-control" value="reject"><span text-red>Reject</span> ';
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to return deprtment select option.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function department($id)
|
||||
{
|
||||
$departments = Department::all();
|
||||
$var = "<select name='action[".$id."][b]' class='form-control' required>";
|
||||
foreach ($departments as $department) {
|
||||
$var .= "<option value='".$department->id."'>".$department->name.'</option>';
|
||||
}
|
||||
$var .= '</select>';
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to return the priority select option.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function priority($id)
|
||||
{
|
||||
$priorities = Ticket_Priority::all();
|
||||
$var = "<select name='action[".$id."][b]' class='form-control' required>";
|
||||
foreach ($priorities as $priority) {
|
||||
$var .= "<option value='".$priority->priority_id."'>".$priority->priority_desc.'</option>';
|
||||
}
|
||||
$var .= '</select>';
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to return the slaplan select option.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function slaPlan($id)
|
||||
{
|
||||
$sla_plans = Sla_plan::where('status', '=', 1)->get();
|
||||
$var = "<select name='action[".$id."][b]' class='form-control' required>";
|
||||
foreach ($sla_plans as $sla_plan) {
|
||||
$var .= "<option value='".$sla_plan->id."'>".$sla_plan->grace_period.'</option>';
|
||||
}
|
||||
$var .= '</select>';
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get system team select option.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function assignTeam($id)
|
||||
{
|
||||
$teams = Teams::where('status', '=', 1)->get();
|
||||
$var = "<select name='action[".$id."][b]' class='form-control' required>";
|
||||
foreach ($teams as $team) {
|
||||
$var .= "<option value='".$team->id."'>".$team->name.'</option>';
|
||||
}
|
||||
$var .= '</select>';
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get system agents select option.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function assignAgent($id)
|
||||
{
|
||||
$users = User::where('role', '!=', 'user')->where('active', '=', 1)->get();
|
||||
$var = "<select name='action[".$id."][b]' class='form-control' required>";
|
||||
foreach ($users as $user) {
|
||||
$var .= "<option value='".$user->id."'>".$user->first_name.' '.$user->last_name.'</option>';
|
||||
}
|
||||
$var .= '</select>';
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get the helptopic select option.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function helptopic($id)
|
||||
{
|
||||
$help_topics = Help_topic::where('status', '=', 1)->get();
|
||||
$var = "<select name='action[".$id."][b]' class='form-control' required>";
|
||||
foreach ($help_topics as $help_topic) {
|
||||
$var .= "<option value='".$help_topic->id."'>".$help_topic->topic.'</option>';
|
||||
}
|
||||
$var .= '</select>';
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get the select option to choose the ticket status.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function ticketStatus($id)
|
||||
{
|
||||
$ticket_status = Ticket_Status::all();
|
||||
$var = "<select name='action[".$id."][b]' class='form-control' required>";
|
||||
foreach ($ticket_status as $status) {
|
||||
$var .= "<option value='".$status->id."'>".$status->name.'</option>';
|
||||
}
|
||||
$var .= '</select>';
|
||||
|
||||
return $var;
|
||||
}
|
||||
}
|
@@ -35,9 +35,9 @@ class MailController extends Controller
|
||||
*
|
||||
* @param type TicketController $TicketController
|
||||
*/
|
||||
public function __construct(TicketController $TicketController)
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController)
|
||||
{
|
||||
$this->TicketController = $TicketController;
|
||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,6 +76,9 @@ class MailController extends Controller
|
||||
$protocol_value = $e_mail->mailbox_protocol;
|
||||
$get_mailboxprotocol = MailboxProtocol::where('id', '=', $protocol_value)->first();
|
||||
$protocol = $get_mailboxprotocol->value;
|
||||
} elseif ($e_mail->fetching_encryption == '/none') {
|
||||
$fetching_encryption2 = '/novalidate-cert';
|
||||
$protocol = $fetching_encryption2;
|
||||
} else {
|
||||
if ($e_mail->fetching_protocol) {
|
||||
$fetching_protocol = '/'.$e_mail->fetching_protocol;
|
||||
@@ -83,7 +86,7 @@ class MailController extends Controller
|
||||
$fetching_protocol = '';
|
||||
}
|
||||
if ($e_mail->fetching_encryption) {
|
||||
$fetching_encryption = '/'.$e_mail->fetching_encryption;
|
||||
$fetching_encryption = $e_mail->fetching_encryption;
|
||||
} else {
|
||||
$fetching_encryption = '';
|
||||
}
|
||||
@@ -130,7 +133,9 @@ class MailController extends Controller
|
||||
|
||||
$assign = $get_helptopic->auto_assign;
|
||||
$form_data = null;
|
||||
$result = $this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data, $auto_response);
|
||||
$team_assign = null;
|
||||
$ticket_status = null;
|
||||
$result = $this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
|
||||
// dd($result);
|
||||
if ($result[1] == true) {
|
||||
$ticket_table = Tickets::where('ticket_number', '=', $result[0])->first();
|
||||
|
@@ -76,6 +76,10 @@ class NotificationController extends Controller
|
||||
$view = View::make('emails.notifications.admin', ['company' => $company, 'name' => $user_name]);
|
||||
$contents = $view->render();
|
||||
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
|
||||
// \Mail::send('emails.notifications.admin', ['company' => $company, 'name' => $user_name], function ($message) use ($email, $user_name, $company) {
|
||||
// $message->to($email, $user_name)->subject($company.' Daily Report ');
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +103,10 @@ class NotificationController extends Controller
|
||||
$view = View::make('emails.notifications.manager', ['company' => $company, 'name' => $user_name]);
|
||||
$contents = $view->render();
|
||||
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
|
||||
// \Mail::send('emails.notifications.manager', ['company' => $company, 'name' => $user_name, 'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message) use ($email, $user_name, $company, $dept_name) {
|
||||
// $message->to($email, $user_name)->subject($company.' Daily Report for department manager of '.$dept_name.' department.');
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,6 +132,10 @@ class NotificationController extends Controller
|
||||
$view = View::make('emails.notifications.lead', ['company' => $company, 'name' => $user_name]);
|
||||
$contents = $view->render();
|
||||
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
|
||||
// \Mail::send('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id], function ($message) use ($email, $user_name, $company, $team_name) {
|
||||
// $message->to($email, $user_name)->subject($company.' Daily Report for Team Lead of team '.$team_name);
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,6 +157,10 @@ class NotificationController extends Controller
|
||||
$view = View::make('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => $user->id]);
|
||||
$contents = $view->render();
|
||||
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
|
||||
// \Mail::send('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => 1], function ($message) use ($email, $user_name, $company) {
|
||||
// $message->to($email, $user_name)->subject($company.' Daily Report for Agents');
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,4 +182,13 @@ class NotificationController extends Controller
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
// // testing
|
||||
// public function test(){
|
||||
// $email = "sujit.prasad@ladybirdweb.com";
|
||||
// $user_name = "sujit prasad";
|
||||
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
|
||||
// $message->to($email, $user_name)->subject('testing reporting');
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
@@ -8,18 +8,11 @@ use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use DB;
|
||||
// classes
|
||||
use Illuminate\support\Collection;
|
||||
use Input;
|
||||
use UTC;
|
||||
use Ttable;
|
||||
|
||||
/**
|
||||
* TicketController2.
|
||||
@@ -67,89 +60,7 @@ class Ticket2Controller extends Controller
|
||||
$tickets = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $dept->id)->get();
|
||||
}
|
||||
|
||||
return \Datatable::collection(new Collection($tickets))
|
||||
->addColumn('id', function ($ticket) {
|
||||
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();
|
||||
if (isset($subject->title)) {
|
||||
$string = $subject->title;
|
||||
if (strlen($string) > 20) {
|
||||
$stringCut = substr($string, 0, 30);
|
||||
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).' ...';
|
||||
}
|
||||
} else {
|
||||
$string = '(no subject)';
|
||||
}
|
||||
//collabrations
|
||||
$collaborators = DB::table('ticket_collaborator')->where('ticket_id', '=', $ticket->id)->get();
|
||||
$collab = count($collaborators);
|
||||
if ($collab > 0) {
|
||||
$collabString = ' <i class="fa fa-users"></i>';
|
||||
} else {
|
||||
$collabString = null;
|
||||
}
|
||||
$threads = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first(); //
|
||||
$count = Ticket_Thread::where('ticket_id', '=', $ticket->id)->count(); //
|
||||
$attachment = Ticket_attachments::where('thread_id', '=', $threads->id)->get();
|
||||
$attachCount = count($attachment);
|
||||
if ($attachCount > 0) {
|
||||
$attachString = ' <i class="fa fa-paperclip"></i>';
|
||||
} else {
|
||||
$attachString = '';
|
||||
}
|
||||
|
||||
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$subject->title."'>".$string." <span style='color:green'>(".$count.")<i class='fa fa-comment'></i></span></a>".$collabString.$attachString;
|
||||
})
|
||||
->addColumn('ticket_number', function ($ticket) {
|
||||
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$ticket->ticket_number."'>#".$ticket->ticket_number.'</a>';
|
||||
})
|
||||
->addColumn('priority', function ($ticket) {
|
||||
$priority = DB::table('ticket_priority')->select('priority_desc', 'priority_color')->where('priority_id', '=', $ticket->priority_id)->first();
|
||||
|
||||
return '<span class="btn btn-'.$priority->priority_color.' btn-xs">'.$priority->priority_desc.'</span>';
|
||||
})
|
||||
->addColumn('from', function ($ticket) {
|
||||
$from = DB::table('users')->select('user_name')->where('id', '=', $ticket->user_id)->first();
|
||||
|
||||
return "<span style='color:#508983'>".$from->user_name.'</span>';
|
||||
})
|
||||
->addColumn('Last Replier', function ($ticket) {
|
||||
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->where('is_internal', '=', 0)->max('id');
|
||||
$TicketDatarow = Ticket_Thread::where('id', '=', $TicketData)->first();
|
||||
$LastResponse = User::where('id', '=', $TicketDatarow->user_id)->first();
|
||||
if ($LastResponse->role == 'user') {
|
||||
$rep = '#F39C12';
|
||||
$username = $LastResponse->user_name;
|
||||
} else {
|
||||
$rep = '#000';
|
||||
$username = $LastResponse->first_name.' '.$LastResponse->last_name;
|
||||
if ($LastResponse->first_name == null || $LastResponse->last_name == null) {
|
||||
$username = $LastResponse->user_name;
|
||||
}
|
||||
}
|
||||
|
||||
return "<span style='color:".$rep."'>".$username.'</span>';
|
||||
})
|
||||
->addColumn('assigned_to', function ($ticket) {
|
||||
if ($ticket->assigned_to == null) {
|
||||
return "<span style='color:red'>Unassigned</span>";
|
||||
} else {
|
||||
$assign = DB::table('users')->where('id', '=', $ticket->assigned_to)->first();
|
||||
|
||||
return "<span style='color:green'>".$assign->first_name.' '.$assign->last_name.'</span>';
|
||||
}
|
||||
})
|
||||
->addColumn('Last', function ($ticket) {
|
||||
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->max('id');
|
||||
$TicketDatarow = Ticket_Thread::select('updated_at')->where('id', '=', $TicketData)->first();
|
||||
|
||||
return UTC::usertimezone($TicketDatarow->updated_at);
|
||||
})
|
||||
->searchColumns('subject', 'from', 'assigned_to', 'ticket_number', 'priority')
|
||||
->orderColumns('subject', 'from', 'assigned_to', 'Last Replier', 'ticket_number', 'priority', 'Last')
|
||||
->make();
|
||||
return Ttable::getTable($tickets);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,89 +91,7 @@ class Ticket2Controller extends Controller
|
||||
$tickets = Tickets::where('status', '=', '2')->where('dept_id', '=', $dept->id)->get();
|
||||
}
|
||||
|
||||
return \Datatable::collection(new Collection($tickets))
|
||||
->addColumn('id', function ($ticket) {
|
||||
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();
|
||||
if (isset($subject->title)) {
|
||||
$string = $subject->title;
|
||||
if (strlen($string) > 20) {
|
||||
$stringCut = substr($string, 0, 30);
|
||||
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).' ...';
|
||||
}
|
||||
} else {
|
||||
$string = '(no subject)';
|
||||
}
|
||||
//collabrations
|
||||
$collaborators = DB::table('ticket_collaborator')->where('ticket_id', '=', $ticket->id)->get();
|
||||
$collab = count($collaborators);
|
||||
if ($collab > 0) {
|
||||
$collabString = ' <i class="fa fa-users"></i>';
|
||||
} else {
|
||||
$collabString = null;
|
||||
}
|
||||
$threads = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first();
|
||||
$count = Ticket_Thread::where('ticket_id', '=', $ticket->id)->count();
|
||||
$attachment = Ticket_attachments::where('thread_id', '=', $threads->id)->get();
|
||||
$attachCount = count($attachment);
|
||||
if ($attachCount > 0) {
|
||||
$attachString = ' <i class="fa fa-paperclip"></i>';
|
||||
} else {
|
||||
$attachString = '';
|
||||
}
|
||||
|
||||
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$subject->title."'>".$string." <span style='color:green'>(".$count.")<i class='fa fa-comment'></i></span></a>".$collabString.$attachString;
|
||||
})
|
||||
->addColumn('ticket_number', function ($ticket) {
|
||||
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$ticket->ticket_number."'>#".$ticket->ticket_number.'</a>';
|
||||
})
|
||||
->addColumn('priority', function ($ticket) {
|
||||
$priority = DB::table('ticket_priority')->select('priority_desc', 'priority_color')->where('priority_id', '=', $ticket->priority_id)->first();
|
||||
|
||||
return '<span class="btn btn-'.$priority->priority_color.' btn-xs">'.$priority->priority_desc.'</span>';
|
||||
})
|
||||
->addColumn('from', function ($ticket) {
|
||||
$from = DB::table('users')->select('user_name')->where('id', '=', $ticket->user_id)->first();
|
||||
|
||||
return "<span style='color:#508983'>".$from->user_name.'</span>';
|
||||
})
|
||||
->addColumn('Last Replier', function ($ticket) {
|
||||
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->where('is_internal', '!=', 1)->max('id');
|
||||
$TicketDatarow = Ticket_Thread::where('id', '=', $TicketData)->first();
|
||||
$LastResponse = User::where('id', '=', $TicketDatarow->user_id)->first();
|
||||
if ($LastResponse->role == 'user') {
|
||||
$rep = '#F39C12';
|
||||
$username = $LastResponse->user_name;
|
||||
} else {
|
||||
$rep = '#000';
|
||||
$username = $LastResponse->first_name.' '.$LastResponse->last_name;
|
||||
if ($LastResponse->first_name == null || $LastResponse->last_name == null) {
|
||||
$username = $LastResponse->user_name;
|
||||
}
|
||||
}
|
||||
|
||||
return "<span style='color:".$rep."'>".$username.'</span>';
|
||||
})
|
||||
->addColumn('assigned_to', function ($ticket) {
|
||||
if ($ticket->assigned_to == null) {
|
||||
return "<span style='color:red'>Usernassigned</span>";
|
||||
} else {
|
||||
$assign = DB::table('users')->where('id', '=', $ticket->assigned_to)->first();
|
||||
|
||||
return "<span style='color:green'>".$assign->first_name.' '.$assign->last_name.'</span>';
|
||||
}
|
||||
})
|
||||
->addColumn('Last', function ($ticket) {
|
||||
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->max('id');
|
||||
$TicketDatarow = Ticket_Thread::select('updated_at')->where('id', '=', $TicketData)->first();
|
||||
|
||||
return UTC::usertimezone($TicketDatarow->updated_at);
|
||||
})
|
||||
->searchColumns('subject', 'from', 'assigned_to', 'ticket_number', 'priority')
|
||||
->orderColumns('subject', 'from', 'assigned_to', 'Last Replier', 'ticket_number', 'priority', 'Last')
|
||||
->make();
|
||||
return Ttable::getTable($tickets);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,88 +127,6 @@ class Ticket2Controller extends Controller
|
||||
$tickets = Tickets::where('status', '=', '1')->where('assigned_to', '>', 0)->where('dept_id', '=', $dept->id)->get();
|
||||
}
|
||||
|
||||
return \Datatable::collection(new Collection($tickets))
|
||||
->addColumn('id', function ($ticket) {
|
||||
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();
|
||||
if (isset($subject->title)) {
|
||||
$string = $subject->title;
|
||||
if (strlen($string) > 20) {
|
||||
$stringCut = substr($string, 0, 30);
|
||||
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).' ...';
|
||||
}
|
||||
} else {
|
||||
$string = '(no subject)';
|
||||
}
|
||||
//collabrations
|
||||
$collaborators = DB::table('ticket_collaborator')->where('ticket_id', '=', $ticket->id)->get();
|
||||
$collab = count($collaborators);
|
||||
if ($collab > 0) {
|
||||
$collabString = ' <i class="fa fa-users"></i>';
|
||||
} else {
|
||||
$collabString = null;
|
||||
}
|
||||
$threads = Ticket_Thread::where('ticket_id', '=', $ticket->id)->first();
|
||||
$count = Ticket_Thread::where('ticket_id', '=', $ticket->id)->count();
|
||||
$attachment = Ticket_attachments::where('thread_id', '=', $threads->id)->get();
|
||||
$attachCount = count($attachment);
|
||||
if ($attachCount > 0) {
|
||||
$attachString = ' <i class="fa fa-paperclip"></i>';
|
||||
} else {
|
||||
$attachString = '';
|
||||
}
|
||||
|
||||
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$subject->title."'>".$string." <span style='color:green'>(".$count.")<i class='fa fa-comment'></i></span></a>".$collabString.$attachString;
|
||||
})
|
||||
->addColumn('ticket_number', function ($ticket) {
|
||||
return "<a href='".route('ticket.thread', [$ticket->id])."' title='".$ticket->ticket_number."'>#".$ticket->ticket_number.'</a>';
|
||||
})
|
||||
->addColumn('priority', function ($ticket) {
|
||||
$priority = DB::table('ticket_priority')->select('priority_desc', 'priority_color')->where('priority_id', '=', $ticket->priority_id)->first();
|
||||
|
||||
return '<span class="btn btn-'.$priority->priority_color.' btn-xs">'.$priority->priority_desc.'</span>';
|
||||
})
|
||||
->addColumn('from', function ($ticket) {
|
||||
$from = DB::table('users')->select('user_name')->where('id', '=', $ticket->user_id)->first();
|
||||
|
||||
return "<span style='color:#508983'>".$from->user_name.'</span>';
|
||||
})
|
||||
->addColumn('Last Replier', function ($ticket) {
|
||||
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->where('is_internal', '!=', 1)->max('id');
|
||||
$TicketDatarow = Ticket_Thread::where('id', '=', $TicketData)->first();
|
||||
$LastResponse = User::where('id', '=', $TicketDatarow->user_id)->first();
|
||||
if ($LastResponse->role == 'user') {
|
||||
$rep = '#F39C12';
|
||||
$username = $LastResponse->user_name;
|
||||
} else {
|
||||
$rep = '#000';
|
||||
$username = $LastResponse->first_name.' '.$LastResponse->last_name;
|
||||
if ($LastResponse->first_name == null || $LastResponse->last_name == null) {
|
||||
$username = $LastResponse->user_name;
|
||||
}
|
||||
}
|
||||
|
||||
return "<span style='color:".$rep."'>".$username.'</span>';
|
||||
})
|
||||
->addColumn('assigned_to', function ($ticket) {
|
||||
if ($ticket->assigned_to == null) {
|
||||
return "<span style='color:red'>Usernassigned</span>";
|
||||
} else {
|
||||
$assign = DB::table('users')->where('id', '=', $ticket->assigned_to)->first();
|
||||
|
||||
return "<span style='color:green'>".$assign->first_name.' '.$assign->last_name.'</span>';
|
||||
}
|
||||
})
|
||||
->addColumn('Last', function ($ticket) {
|
||||
$TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->max('id');
|
||||
$TicketDatarow = Ticket_Thread::select('updated_at')->where('id', '=', $TicketData)->first();
|
||||
|
||||
return UTC::usertimezone($TicketDatarow->updated_at);
|
||||
})
|
||||
->searchColumns('subject', 'from', 'assigned_to', 'ticket_number', 'priority')
|
||||
->orderColumns('subject', 'from', 'assigned_to', 'Last Replier', 'ticket_number', 'priority', 'Last')
|
||||
->make();
|
||||
return Ttable::getTable($tickets);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
510
app/Http/Controllers/Agent/helpdesk/TicketWorkflowController.php
Normal file
510
app/Http/Controllers/Agent/helpdesk/TicketWorkflowController.php
Normal file
@@ -0,0 +1,510 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Manage\Sla_plan;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Workflow\WorkflowAction;
|
||||
use App\Model\helpdesk\Workflow\WorkflowName;
|
||||
use App\Model\helpdesk\Workflow\WorkflowRules;
|
||||
use App\User;
|
||||
|
||||
/**
|
||||
* TicketWorkflowController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class TicketWorkflowController extends Controller
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param type TicketController $TicketController
|
||||
*/
|
||||
public function __construct(TicketController $TicketController)
|
||||
{
|
||||
$this->TicketController = $TicketController;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the core function from where the workflow is applied.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function workflow($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response)
|
||||
{
|
||||
$contact_details = ['email' => $fromaddress, 'email_name' => $fromname, 'subject' => $subject, 'message' => $body];
|
||||
$ticket_settings_details = ['help_topic' => $helptopic, 'sla' => $sla, 'priority' => $priority, 'source' => $source, 'dept' => $dept, 'assign' => $assign, 'team' => $team_assign, 'status' => $ticket_status, 'reject' => false];
|
||||
// get all the workflow common to the entire system which includes any type of ticket creation where the execution order of the workflow should be starting with ascending order
|
||||
$workflows = WorkflowName::where('target', '=', 'A-0')->where('status', '=', '1')->orderBy('order', 'asc')->get();
|
||||
foreach ($workflows as $workflow) {
|
||||
// checking if any workflow defined in the system
|
||||
if ($workflow) {
|
||||
// get all the rules of workflow which has a foreign key of those workflow which are applied to creating any ticket from any source
|
||||
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflow->id)->get();
|
||||
foreach ($worklfow_rules as $worklfow_rule) {
|
||||
// checking for the workflow rules to which workflow rule type it is
|
||||
if ($worklfow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'subject') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflow->id, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($source == 1) {
|
||||
// get all the workflow which are applied to ticket generated via webforms and in ascending order
|
||||
$workflows_webs = WorkflowName::where('target', '=', 'A-1')->where('status', '=', '1')->orderBy('order', 'asc')->get();
|
||||
foreach ($workflows_webs as $workflows_web) {
|
||||
if ($workflows_web) {
|
||||
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_web->id)->get();
|
||||
foreach ($worklfow_rules as $worklfow_rule) {
|
||||
if ($worklfow_rule) {
|
||||
// checking for the workflow rules to which workflow rule type it is
|
||||
if ($worklfow_rule->matching_scenario == 'email') {
|
||||
if ($this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
|
||||
if ($this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'subject') {
|
||||
if ($this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'message') {
|
||||
if ($this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_web->id, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($source == 2) {
|
||||
// get all the workflow which are applied to ticket generated via emails and in ascending order
|
||||
$workflows_emails = WorkflowName::where('target', '=', 'A-2')->where('status', '=', '1')->orderBy('order', 'asc')->get();
|
||||
foreach ($workflows_emails as $workflows_email) {
|
||||
if ($workflows_email) {
|
||||
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_email->id)->get();
|
||||
foreach ($worklfow_rules as $worklfow_rule) {
|
||||
if ($worklfow_rule) {
|
||||
// checking for the workflow rules to which workflow rule type it is
|
||||
if ($worklfow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'subject') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_email->id, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($source == 4) {
|
||||
// get all the workflow which are applied to ticket generated via API and in ascending order
|
||||
$workflows_apis = WorkflowName::where('target', '=', 'A-4')->where('status', '=', '1')->orderBy('order', 'asc')->get();
|
||||
foreach ($workflows_apis as $workflows_api) {
|
||||
if ($workflows_api) {
|
||||
$worklfow_rules = WorkflowRules::where('workflow_id', '=', $workflows_api->id)->get();
|
||||
foreach ($worklfow_rules as $worklfow_rule) {
|
||||
if ($worklfow_rule) {
|
||||
// checking for the workflow rules to which workflow rule type it is
|
||||
if ($worklfow_rule->matching_scenario == 'email') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'email_name') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['email_name'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'subject') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['subject'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
} elseif ($worklfow_rule->matching_scenario == 'message') {
|
||||
if ($rule_condition = $this->checkRuleCondition($contact_details['message'], $worklfow_rule->matching_relation, $worklfow_rule->matching_value) == true) {
|
||||
$ticket_settings_details = $this->applyActionCondition($workflows_api->id, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($ticket_settings_details['reject'] == true) {
|
||||
return ['0' => false, '1' => false];
|
||||
} else {
|
||||
$create_ticket = $this->TicketController->create_user($contact_details['email'], $contact_details['email_name'], $contact_details['subject'], $contact_details['message'], $phone, $ticket_settings_details['help_topic'], $ticket_settings_details['sla'], $ticket_settings_details['priority'], $source, $collaborator, $ticket_settings_details['dept'], $ticket_settings_details['assign'], $form_data, $auto_response, $ticket_settings_details['status']);
|
||||
|
||||
return $create_ticket;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check the rules applied to the ticket workflow.
|
||||
*
|
||||
* @param type $to_check
|
||||
* @param type $condition
|
||||
* @param type $statement
|
||||
*
|
||||
* @return type boolean
|
||||
*/
|
||||
public function checkRuleCondition($to_check, $condition, $statement)
|
||||
{
|
||||
if ($condition == 'equal') {
|
||||
$return = $this->checkEqual($statement, $to_check);
|
||||
} elseif ($condition == 'not_equal') {
|
||||
$return = $this->checkNotEqual($statement, $to_check);
|
||||
} elseif ($condition == 'contains') {
|
||||
$return = $this->checkContains($statement, $to_check);
|
||||
} elseif ($condition == 'dn_contain') {
|
||||
$return = $this->checkDoNotContain($statement, $to_check);
|
||||
} elseif ($condition == 'starts') {
|
||||
$return = $this->checkStarts($statement, $to_check);
|
||||
} elseif ($condition == 'ends') {
|
||||
$return = $this->checkEnds($statement, $to_check);
|
||||
}
|
||||
// elseif($condition == 'match') {
|
||||
//
|
||||
// } elseif($condition == 'not_match') {
|
||||
//
|
||||
// }
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check if the equal functions are applied.
|
||||
*
|
||||
* @param type $statement
|
||||
* @param type $to_check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkEqual($statement, $to_check)
|
||||
{
|
||||
if ($statement == $to_check) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check if the not-equal functions are applied.
|
||||
*
|
||||
* @param type $statement
|
||||
* @param type $to_check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkNotEqual($statement, $to_check)
|
||||
{
|
||||
if ($statement != $to_check) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check if the contains functions are applied.
|
||||
*
|
||||
* @param type $statement
|
||||
* @param type $to_check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkContains($statement, $to_check)
|
||||
{
|
||||
if (strpos($to_check, $statement) !== false) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check if the do not contain functions are applied.
|
||||
*
|
||||
* @param type $statement
|
||||
* @param type $to_check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkDoNotContain($statement, $to_check)
|
||||
{
|
||||
if (strpos($to_check, $statement) == false) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check if the start functions are applied.
|
||||
*
|
||||
* @param type $statement
|
||||
* @param type $to_check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkStarts($statement, $to_check)
|
||||
{
|
||||
if (substr($to_check, 0, strlen($statement)) == $statement) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check if the ends functions are applied.
|
||||
*
|
||||
* @param type $statement
|
||||
* @param type $to_check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkEnds($statement, $to_check)
|
||||
{
|
||||
$to_check = strip_tags($to_check);
|
||||
if (substr($to_check, -strlen($statement)) == $statement) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// function startsWith($to_check, $statement) {
|
||||
// // search backwards starting from haystack length characters from the end
|
||||
// return $statement === "" || strrpos($to_check, $statement, -strlen($to_check)) !== false;
|
||||
// }
|
||||
|
||||
// function endsWith($to_check, $statement) {
|
||||
// // search forward starting from end minus needle length characters
|
||||
// return $statement === "" || (($temp = strlen($to_check) - strlen($statement)) >= 0 && strpos($to_check, $statement, $temp) !== false);
|
||||
// }
|
||||
|
||||
/**
|
||||
* function to apply the action to a ticket.
|
||||
*
|
||||
* @param type $workflow_id
|
||||
* @param type $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function applyActionCondition($workflow_id, $ticket_settings_details)
|
||||
{
|
||||
$workflow_actions = WorkflowAction::where('workflow_id', '=', $workflow_id)->get();
|
||||
foreach ($workflow_actions as $workflow_action) {
|
||||
if ($workflow_action->condition == 'reject') {
|
||||
$ticket_settings_details = $this->rejectTicket($ticket_settings_details);
|
||||
} elseif ($workflow_action->condition == 'department') {
|
||||
$ticket_settings_details = $this->changeDepartment($workflow_action, $ticket_settings_details);
|
||||
} elseif ($workflow_action->condition == 'priority') {
|
||||
$ticket_settings_details = $this->changePriority($workflow_action, $ticket_settings_details);
|
||||
} elseif ($workflow_action->condition == 'sla') {
|
||||
$ticket_settings_details = $this->changeSla($workflow_action, $ticket_settings_details);
|
||||
} elseif ($workflow_action->condition == 'team') {
|
||||
$ticket_settings_details = $this->changeTeam($workflow_action, $ticket_settings_details);
|
||||
} elseif ($workflow_action->condition == 'agent') {
|
||||
$ticket_settings_details = $this->changeAgent($workflow_action, $ticket_settings_details);
|
||||
} elseif ($workflow_action->condition == 'helptopic') {
|
||||
$ticket_settings_details = $this->changeHelptopic($workflow_action, $ticket_settings_details);
|
||||
} elseif ($workflow_action->condition == 'status') {
|
||||
$ticket_settings_details = $this->changeStatus($workflow_action, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to reject ticket.
|
||||
*
|
||||
* @param array $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function rejectTicket($ticket_settings_details)
|
||||
{
|
||||
$ticket_settings_details['reject'] = true;
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to change the department of a ticket.
|
||||
*
|
||||
* @param type $workflow_action
|
||||
* @param type $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function changeDepartment($workflow_action, $ticket_settings_details)
|
||||
{
|
||||
$dept = Department::where('id', '=', $workflow_action->action)->first();
|
||||
if ($dept == null) {
|
||||
return $ticket_settings_details;
|
||||
} else {
|
||||
$ticket_settings_details['dept'] = $dept->id;
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to change the priority of a ticket.
|
||||
*
|
||||
* @param type $workflow_action
|
||||
* @param type $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function changePriority($workflow_action, $ticket_settings_details)
|
||||
{
|
||||
$priority = Ticket_Priority::where('priority_id', '=', $workflow_action->action)->first();
|
||||
if ($priority == null) {
|
||||
return $ticket_settings_details;
|
||||
} else {
|
||||
$ticket_settings_details['priority'] = $priority->priority_id;
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to change the SLA of a ticket.
|
||||
*
|
||||
* @param type $workflow_action
|
||||
* @param type $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function changeSla($workflow_action, $ticket_settings_details)
|
||||
{
|
||||
$sla_plan = Sla_plan::where('id', '=', $workflow_action->action)->first();
|
||||
if ($sla_plan == null) {
|
||||
return $ticket_settings_details;
|
||||
} else {
|
||||
$ticket_settings_details['sla'] = $sla_plan->id;
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to assign tean to a ticket.
|
||||
*
|
||||
* @param type $workflow_action
|
||||
* @param type $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function changeTeam($workflow_action, $ticket_settings_details)
|
||||
{
|
||||
$team = Teams::where('id', '=', $workflow_action->action)->first();
|
||||
if ($team == null) {
|
||||
return $ticket_settings_details;
|
||||
} else {
|
||||
$ticket_settings_details['team'] = $team->id;
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to assing a ticket to an agent.
|
||||
*
|
||||
* @param type $workflow_action
|
||||
* @param type $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function changeAgent($workflow_action, $ticket_settings_details)
|
||||
{
|
||||
$agent = User::where('id', '=', $workflow_action->action)->where('role', '!=', 'user')->first();
|
||||
if ($agent == null) {
|
||||
return $ticket_settings_details;
|
||||
} else {
|
||||
$ticket_settings_details['assign'] = $agent->id;
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to change the helptopic of a ticket.
|
||||
*
|
||||
* @param type $workflow_action
|
||||
* @param type $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function changeHelptopic($workflow_action, $ticket_settings_details)
|
||||
{
|
||||
$help_topic = Help_topic::where('id', '=', $workflow_action->action)->first();
|
||||
if ($help_topic == null) {
|
||||
return $ticket_settings_details;
|
||||
} else {
|
||||
$ticket_settings_details['help_topic'] = $help_topic->id;
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to change the status of a ticket.
|
||||
*
|
||||
* @param type $workflow_action
|
||||
* @param type $ticket_settings_details
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function changeStatus($workflow_action, $ticket_settings_details)
|
||||
{
|
||||
$status = Ticket_Status::where('id', '=', $workflow_action->action)->first();
|
||||
if ($status == null) {
|
||||
return $ticket_settings_details;
|
||||
} else {
|
||||
$ticket_settings_details['status'] = $status->id;
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// Controllersuse App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
// Controllers
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// Request
|
||||
use App\Http\Requests\kb\ProfilePassword;
|
||||
|
@@ -60,9 +60,12 @@ class ApiController extends Controller
|
||||
|
||||
$this->middleware('jwt.auth');
|
||||
$this->middleware('api', ['except' => 'GenerateApiKey']);
|
||||
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$this->user = $user;
|
||||
try {
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$this->user = $user;
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
|
||||
} catch (\Tymon\JWTAuth\Exceptions\JWTException $e) {
|
||||
}
|
||||
|
||||
$ticket = new TicketController();
|
||||
$this->ticket = $ticket;
|
||||
@@ -82,6 +85,9 @@ class ApiController extends Controller
|
||||
$faveoUser = new User();
|
||||
$this->faveoUser = $faveoUser;
|
||||
|
||||
$faveoUser = new User();
|
||||
$this->user = $faveoUser;
|
||||
|
||||
$team = new Teams();
|
||||
$this->team = $team;
|
||||
|
||||
@@ -138,18 +144,23 @@ class ApiController extends Controller
|
||||
$helptopic = $this->request->input('helptopic');
|
||||
$sla = $this->request->input('sla');
|
||||
$priority = $this->request->input('priority');
|
||||
$headers = $this->request->input('headers');
|
||||
$header = $this->request->input('cc');
|
||||
$dept = $this->request->input('dept');
|
||||
|
||||
$assignto = $this->request->input('assignto');
|
||||
$form_data = $this->request->input('form_data');
|
||||
$source = $this->request->input('source');
|
||||
$attach = $this->request->input('attachments');
|
||||
$headers = [];
|
||||
if ($header) {
|
||||
$headers = explode(',', $header);
|
||||
}
|
||||
//return $headers;
|
||||
/*
|
||||
* return s ticket number
|
||||
*/
|
||||
$response = $this->ticket->createTicket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach);
|
||||
|
||||
//return $response;
|
||||
/*
|
||||
* return ticket details
|
||||
*/
|
||||
@@ -166,7 +177,8 @@ class ApiController extends Controller
|
||||
} catch (\TokenExpiredException $e) {
|
||||
$error = $e->getMessage();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
return response()->json(compact('error'))
|
||||
->header('Authenticate: xBasic realm', 'fake');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,6 +315,7 @@ class ApiController extends Controller
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select('first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->orderBy('ticket_thread.updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
->paginate(10)
|
||||
@@ -346,7 +359,8 @@ class ApiController extends Controller
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select('first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->select('user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->orderBy('ticket_thread.updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
->paginate(10)
|
||||
@@ -390,7 +404,8 @@ class ApiController extends Controller
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select('first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->select('user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->orderBy('ticket_thread.updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
->paginate(10)
|
||||
@@ -516,7 +531,8 @@ class ApiController extends Controller
|
||||
$search = $this->request->input('search');
|
||||
$result = $this->faveoUser->where('first_name', 'like', '%'.$search.'%')->orWhere('last_name', 'like', '%'.$search.'%')->orWhere('user_name', 'like', '%'.$search.'%')->orWhere('email', 'like', '%'.$search.'%')->get();
|
||||
|
||||
return response()->json(compact('result'));
|
||||
return response()->json(compact('result'))
|
||||
->header('X-Header-One', 'Header Value');
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
@@ -526,7 +542,9 @@ class ApiController extends Controller
|
||||
} catch (\TokenExpiredException $e) {
|
||||
$error = $e->getMessage();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
return response()->json(compact('error'))
|
||||
|
||||
->header('X-Header-One', 'Header Value');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,26 +556,16 @@ class ApiController extends Controller
|
||||
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);
|
||||
//dd($result);
|
||||
//$result->toJson();
|
||||
return $result->toJson();
|
||||
$users = $this->user
|
||||
->leftJoin('user_assign_organization', 'user_assign_organization.user_id', '=', 'users.id')
|
||||
->leftJoin('organization', 'organization.id', '=', 'user_assign_organization.org_id')
|
||||
->where('role', 'user')
|
||||
->select('users.id', 'user_name', 'first_name', 'last_name', 'email', 'phone_number', 'users.profile_pic', 'organization.name AS company', 'users.active')
|
||||
->paginate(10)
|
||||
->toJson();
|
||||
|
||||
//dd($users);
|
||||
return $users;
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
@@ -567,7 +575,8 @@ class ApiController extends Controller
|
||||
} catch (\TokenExpiredException $e) {
|
||||
$error = $e->getMessage();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
return response()->json(compact('error'))
|
||||
->header('Authenticate: xBasic realm', 'fake');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,9 +663,14 @@ class ApiController extends Controller
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$id = $this->request->input('id');
|
||||
$result = $this->thread->where('ticket_id', $id)->get();
|
||||
$result = $this->user
|
||||
->leftjoin('ticket_thread', 'ticket_thread.user_id', '=', 'users.id')
|
||||
->select('ticket_thread.id', 'ticket_id', 'user_id', 'poster', 'source', 'title', 'body', 'is_internal', 'format', 'ip_address', 'ticket_thread.created_at', 'ticket_thread.updated_at', 'users.first_name', 'users.last_name', 'users.user_name', 'users.email', 'users.profile_pic')
|
||||
->where('ticket_id', $id)
|
||||
->get()
|
||||
->toJson();
|
||||
|
||||
return response()->json(compact('result'));
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
@@ -689,6 +703,10 @@ class ApiController extends Controller
|
||||
}
|
||||
|
||||
$url = $this->request->input('url');
|
||||
if (!str_is('*/', $url)) {
|
||||
$url = str_finish($url, '/');
|
||||
}
|
||||
|
||||
$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);
|
||||
@@ -903,7 +921,7 @@ class ApiController extends Controller
|
||||
public function getTickets()
|
||||
{
|
||||
try {
|
||||
$tickets = $this->model->paginate(10);
|
||||
$tickets = $this->model->orderBy('created_at', 'desc')->paginate(10);
|
||||
$tickets->toJson();
|
||||
|
||||
return $tickets;
|
||||
@@ -938,7 +956,8 @@ class ApiController extends Controller
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select('first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->select('user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->orderBy('ticket_thread.updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
->paginate(10)
|
||||
@@ -946,9 +965,9 @@ class ApiController extends Controller
|
||||
|
||||
return $inbox;
|
||||
} catch (\Exception $ex) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
$error = $ex->getMessage();
|
||||
$line = $ex->getLine();
|
||||
$file = $ex->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
} catch (\TokenExpiredException $e) {
|
||||
@@ -1012,7 +1031,8 @@ class ApiController extends Controller
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select('first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->select('user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->orderBy('ticket_thread.updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
->paginate(10)
|
||||
@@ -1032,7 +1052,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getMyTickets()
|
||||
public function getMyTicketsAgent()
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
@@ -1045,7 +1065,58 @@ class ApiController extends Controller
|
||||
}
|
||||
$id = $this->request->input('user_id');
|
||||
if ($this->user->where('id', $id)->first()->role == 'user') {
|
||||
$error = 'This user is not an Aget or Admin';
|
||||
$error = 'This user is not an Agent or Admin';
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$result = $this->user->join('tickets', function ($join) use ($id) {
|
||||
$join->on('users.id', '=', 'tickets.assigned_to')
|
||||
->where('user_id', '=', $id);
|
||||
})
|
||||
->join('department', 'department.id', '=', 'tickets.dept_id')
|
||||
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
|
||||
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
|
||||
->join('help_topic', 'help_topic.id', '=', 'tickets.help_topic_id')
|
||||
->join('ticket_status', 'ticket_status.id', '=', 'tickets.status')
|
||||
->join('ticket_thread', function ($join) {
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select('user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->orderBy('ticket_thread.updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
->paginate(10)
|
||||
->toJson();
|
||||
|
||||
return $result;
|
||||
} 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'));
|
||||
}
|
||||
}
|
||||
|
||||
public function getMyTicketsUser()
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
$error = $v->errors();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$id = $this->request->input('user_id');
|
||||
if ($this->user->where('id', $id)->first()->role == 'admin' || $this->user->where('id', $id)->first()->role == 'agent') {
|
||||
$error = 'This is not a client';
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
@@ -1062,10 +1133,12 @@ class ApiController extends Controller
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select('first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
|
||||
->select('ticket_number', 'tickets.id', 'title', 'ticket_status.name as ticket_status_name')
|
||||
->orderBy('ticket_thread.updated_at', 'desc')
|
||||
->groupby('tickets.id')
|
||||
->distinct()
|
||||
->paginate(10)
|
||||
->get()
|
||||
// ->paginate(10)
|
||||
->toJson();
|
||||
|
||||
return $result;
|
||||
@@ -1143,4 +1216,160 @@ class ApiController extends Controller
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
}
|
||||
|
||||
public function collaboratorSearch()
|
||||
{
|
||||
$this->validate($this->request, ['term' => 'required']);
|
||||
try {
|
||||
$emails = $this->ticket->autosearch();
|
||||
//return $emails;
|
||||
$user = new User();
|
||||
if (count($emails) > 0) {
|
||||
foreach ($emails as $key => $email) {
|
||||
$user_model = $user->where('email', $email)->first();
|
||||
//return $user_model;
|
||||
$users[$key]['name'] = $user_model->first_name.' '.$user_model->last_name;
|
||||
$users[$key]['email'] = $email;
|
||||
$users[$key]['avatar'] = $this->avatarUrl($email);
|
||||
}
|
||||
}
|
||||
//return $users;
|
||||
|
||||
return response()->json(compact('users'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
public function avatarUrl($email)
|
||||
{
|
||||
try {
|
||||
$user = new User();
|
||||
$user = $user->where('email', $email)->first();
|
||||
if ($user->profile_pic) {
|
||||
$url = url('lb-faveo/media/profilepic/'.$user->profile_pic);
|
||||
} else {
|
||||
$url = \Gravatar::src($email);
|
||||
}
|
||||
|
||||
return $url;
|
||||
} catch (\Exception $ex) {
|
||||
//return $ex->getMessage();
|
||||
throw new \Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function addCollaboratorForTicket()
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make(\Input::get(), [
|
||||
'email' => 'required|email|unique:users',
|
||||
'ticket_id' => 'required',
|
||||
]
|
||||
);
|
||||
if ($v->fails()) {
|
||||
$error = $v->messages();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$collaborator = $this->ticket->useradd();
|
||||
|
||||
return response()->json(compact('collaborator'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
} catch (Tymon\JWTAuth\Exceptions\TokenExpiredException $ex) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
public function getCollaboratorForTicket()
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make(\Input::get(), [
|
||||
'ticket_id' => 'required',
|
||||
]
|
||||
);
|
||||
if ($v->fails()) {
|
||||
$error = $v->messages();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$collaborator = $this->ticket->getCollaboratorForTicket();
|
||||
|
||||
return response()->json(compact('collaborator'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
} catch (Tymon\JWTAuth\Exceptions\TokenExpiredException $ex) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCollaborator()
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make(\Input::get(), [
|
||||
'ticketid' => 'required',
|
||||
'email' => 'required',
|
||||
]
|
||||
);
|
||||
if ($v->fails()) {
|
||||
$result = $v->messages();
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
$collaborator = $this->ticket->userremove();
|
||||
|
||||
return response()->json(compact('collaborator'));
|
||||
} catch (\Exception $ex) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
public function dependency()
|
||||
{
|
||||
try {
|
||||
$department = $this->department->select('name', 'id')->get()->toArray();
|
||||
$sla = $this->slaPlan->select('name', 'id')->get()->toArray();
|
||||
$staff = $this->user->where('role', 'agent')->select('email', 'id')->get()->toArray();
|
||||
$team = $this->team->select('name', 'id')->get()->toArray();
|
||||
$priority = \DB::table('ticket_priority')->select('priority', 'priority_id')->get();
|
||||
$helptopic = $this->helptopic->select('topic', 'id')->get()->toArray();
|
||||
$status = \DB::table('ticket_status')->select('name', 'id')->get();
|
||||
$source = \DB::table('ticket_source')->select('name', 'id')->get();
|
||||
$result = ['departments' => $department, 'sla' => $sla, 'staffs' => $staff, 'teams' => $team,
|
||||
'priorities' => $priority, 'helptopics' => $helptopic, 'status' => $status, 'sources' => $source, ];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ class ApiExceptAuthController extends Controller
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->middleware('api');
|
||||
//$this->middleware('api');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,12 @@ class ApiExceptAuthController extends Controller
|
||||
}
|
||||
|
||||
$url = $this->request->input('url');
|
||||
$url = $url.'/api/v1/helpdesk/check-url';
|
||||
if (!str_is('*/', $url)) {
|
||||
$url = str_finish($url, '/');
|
||||
}
|
||||
|
||||
$url = $url.'api/v1/helpdesk/check-url';
|
||||
//return $url;
|
||||
$result = $this->CallGetApi($url);
|
||||
// dd($result);
|
||||
return response()->json(compact('result'));
|
||||
|
@@ -58,6 +58,7 @@ class TicketController extends Controller
|
||||
public function createTicket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach = '')
|
||||
{
|
||||
try {
|
||||
//return $headers;
|
||||
$max_number = Tickets::whereRaw('id = (select max(`id`) from tickets)')->first();
|
||||
//dd($max_number);
|
||||
if ($max_number == null) {
|
||||
@@ -97,7 +98,7 @@ class TicketController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//return $headers;
|
||||
$this->storeCollaborators($headers, $id);
|
||||
|
||||
$thread = $this->ticketThread($subject, $body, $id, $user_id);
|
||||
@@ -123,10 +124,11 @@ class TicketController extends Controller
|
||||
public function storeCollaborators($headers, $id)
|
||||
{
|
||||
try {
|
||||
//return $headers;
|
||||
$company = $this->company();
|
||||
if (isset($headers)) {
|
||||
foreach ($headers as $email => $name) {
|
||||
$name = $name;
|
||||
foreach ($headers as $email) {
|
||||
$name = $email;
|
||||
$email = $email;
|
||||
if ($this->checkEmail($email) == false) {
|
||||
$create_user = new User();
|
||||
@@ -147,6 +149,7 @@ class TicketController extends Controller
|
||||
$user = $this->checkEmail($email);
|
||||
$user_id = $user->id;
|
||||
}
|
||||
//return $user_id;
|
||||
$collaborator_store = new Ticket_Collaborator();
|
||||
$collaborator_store->isactive = 1;
|
||||
$collaborator_store->ticket_id = $id;
|
||||
@@ -331,10 +334,10 @@ 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) {
|
||||
}
|
||||
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) {
|
||||
}
|
||||
|
||||
$collaborators = Ticket_Collaborator::where('ticket_id', '=', $ticket_id)->get();
|
||||
foreach ($collaborators as $collaborator) {
|
||||
@@ -357,10 +360,10 @@ 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) {
|
||||
}
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
return $thread;
|
||||
@@ -548,7 +551,7 @@ try {
|
||||
{
|
||||
try {
|
||||
$check = User::where('email', '=', $email)->first();
|
||||
if ($check == true) {
|
||||
if ($check) {
|
||||
return $check;
|
||||
} else {
|
||||
return false;
|
||||
@@ -601,4 +604,123 @@ try {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* autosearch.
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function autosearch()
|
||||
{
|
||||
$term = \Input::get('term');
|
||||
$user = \App\User::where('email', 'LIKE', '%'.$term.'%')->orWhere('first_name', 'LIKE', '%'.$term.'%')->orWhere('last_name', 'LIKE', '%'.$term.'%')->orWhere('user_name', 'LIKE', '%'.$term.'%')->lists('email');
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* useradd.
|
||||
*
|
||||
* @param type Image $image
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function useradd()
|
||||
{
|
||||
$email = Input::get('email');
|
||||
$ticket_id = Input::get('ticket_id');
|
||||
$company = $this->company();
|
||||
$user = new User();
|
||||
$user->user_name = $email;
|
||||
$user->email = $email;
|
||||
$password = $this->generateRandomString();
|
||||
$user->password = \Hash::make($password);
|
||||
$user->role = 'user';
|
||||
$user->active = 1;
|
||||
if ($user->save()) {
|
||||
$user_id = $user->id;
|
||||
$php_mailer = new PhpMailController();
|
||||
$php_mailer->sendmail($from = $php_mailer->mailfrom('1', '0'), $to = ['name' => $email, 'email' => $email], $message = ['subject' => 'Password', 'scenario' => 'registration-notification'], $template_variables = ['user' => $email, 'email_address' => $email, 'user_password' => $password]);
|
||||
}
|
||||
$ticket_collaborator = new Ticket_Collaborator();
|
||||
$ticket_collaborator->isactive = 1;
|
||||
$ticket_collaborator->ticket_id = $ticket_id;
|
||||
$ticket_collaborator->user_id = $user->id;
|
||||
$ticket_collaborator->role = 'ccc';
|
||||
$ticket_collaborator->save();
|
||||
|
||||
$result = [$user->user_name => $user->email];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* user remove.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function userremove()
|
||||
{
|
||||
$email = Input::get('email');
|
||||
$ticketid = Input::get('ticketid');
|
||||
$user = new User();
|
||||
$user = $user->where('email', $email)->first();
|
||||
$ticket_collaborator = Ticket_Collaborator::where('ticket_id', '=', $ticketid)
|
||||
->where('user_id', $user->id)
|
||||
->first();
|
||||
if ($ticket_collaborator) {
|
||||
$ticket_collaborator->delete();
|
||||
|
||||
return 'deleted successfully';
|
||||
} else {
|
||||
return 'not found';
|
||||
}
|
||||
}
|
||||
|
||||
public function getCollaboratorForTicket()
|
||||
{
|
||||
try {
|
||||
$ticketid = Input::get('ticket_id');
|
||||
|
||||
$ticket_collaborator = \DB::table('users')
|
||||
->join('ticket_collaborator', function ($join) use ($ticketid) {
|
||||
$join->on('users.id', '=', 'ticket_collaborator.user_id')
|
||||
->where('ticket_collaborator.ticket_id', '=', $ticketid);
|
||||
})
|
||||
->select('users.email', 'users.user_name')
|
||||
->get();
|
||||
if (count($ticket_collaborator) > 0) {
|
||||
foreach ($ticket_collaborator as $key => $collaborator) {
|
||||
$collab[$key]['email'] = $collaborator->email;
|
||||
$collab[$key]['user_name'] = $collaborator->user_name;
|
||||
$collab[$key]['avatar'] = $this->avatarUrl($collaborator->email);
|
||||
}
|
||||
} else {
|
||||
$collab = $ticket_collaborator;
|
||||
}
|
||||
|
||||
return $collab;
|
||||
} catch (\Exception $ex) {
|
||||
return $ex->getMessage();
|
||||
throw new \Exception('get collaborator for ticket fails');
|
||||
}
|
||||
}
|
||||
|
||||
public function avatarUrl($email)
|
||||
{
|
||||
try {
|
||||
$user = new User();
|
||||
$user = $user->where('email', $email)->first();
|
||||
if ($user->profile_pic) {
|
||||
$url = url('lb-faveo/media/profilepic/'.$user->profile_pic);
|
||||
} else {
|
||||
$url = \Gravatar::src($email);
|
||||
}
|
||||
|
||||
return $url;
|
||||
} catch (\Exception $ex) {
|
||||
//return $ex->getMessage();
|
||||
throw new \Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -23,9 +24,14 @@ use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
*/
|
||||
class TokenAuthController extends Controller
|
||||
{
|
||||
public $PhpMailController;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('api');
|
||||
|
||||
$PhpMailController = new PhpMailController();
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +47,7 @@ class TokenAuthController extends Controller
|
||||
$password = $request->input('password');
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
|
||||
//$credentials = $request->only('email', 'password');
|
||||
//$credentials = $request->only('email', 'password');
|
||||
|
||||
try {
|
||||
if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password])) {
|
||||
@@ -56,7 +62,7 @@ class TokenAuthController extends Controller
|
||||
}
|
||||
|
||||
$user_id = \Auth::user()->id;
|
||||
// if no errors are encountered we can return a JWT
|
||||
// if no errors are encountered we can return a JWT
|
||||
return response()->json(compact('token', 'user_id'));
|
||||
}
|
||||
|
||||
@@ -72,18 +78,18 @@ class TokenAuthController extends Controller
|
||||
if (!$user = JWTAuth::parseToken()->authenticate()) {
|
||||
return response()->json(['user_not_found', 404]);
|
||||
}
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
|
||||
} catch (Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
|
||||
return response()->json(['token_expired', $e->getStatusCode()]);
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenInvalidException $e) {
|
||||
} catch (Tymon\JWTAuth\Exceptions\TokenInvalidException $e) {
|
||||
return response()->json(['token_invalid', $e->getStatusCode()]);
|
||||
} catch (\Tymon\JWTAuth\Exceptions\JWTException $e) {
|
||||
} 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);
|
||||
//dd($user);
|
||||
return response()->json(compact('user'));
|
||||
}
|
||||
|
||||
@@ -124,7 +130,7 @@ class TokenAuthController extends Controller
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function checkUrl()
|
||||
public function checkUrl(Request $request)
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make($request->all(), [
|
||||
@@ -144,4 +150,43 @@ class TokenAuthController extends Controller
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
}
|
||||
|
||||
public function forgotPassword(Request $request)
|
||||
{
|
||||
try {
|
||||
$v = \Validator::make($request->all(), [
|
||||
'email' => 'required|email|exists:users,email',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
$error = $v->errors();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$user = User::where('email', '=', $request->only('email'))->first();
|
||||
if (isset($user)) {
|
||||
$user1 = $user->email;
|
||||
//gen new code and pass
|
||||
$code = str_random(60);
|
||||
$password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->first();
|
||||
if (isset($password_reset_table)) {
|
||||
$password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->update(['token' => $code, 'created_at' => $date]);
|
||||
// $password_reset_table->token = $code;
|
||||
// $password_reset_table->update(['token' => $code]);
|
||||
} else {
|
||||
$create_password_reset = \DB::table('password_resets')->insert(['email' => $user->email, 'token' => $code, 'created_at' => $date]);
|
||||
}
|
||||
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user->user_name, 'email' => $user->email], $message = ['subject' => 'Your Password Reset Link', 'scenario' => 'reset-password'], $template_variables = ['user' => $user->user_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/'.$code)]);
|
||||
$result = 'We have e-mailed your password reset link!';
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$error = $e->getMessage();
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers\Client\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
@@ -14,6 +14,7 @@ use App\Model\helpdesk\Form\Fields;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Ticket;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
@@ -39,12 +40,12 @@ class FormController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TicketController $TicketController)
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController)
|
||||
{
|
||||
// mail smtp settings
|
||||
SettingsController::smtp();
|
||||
// SettingsController::smtp();
|
||||
// creating a TicketController instance
|
||||
$this->TicketController = $TicketController;
|
||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +130,7 @@ class FormController extends Controller
|
||||
* @param type Request $request
|
||||
* @param type User $user
|
||||
*/
|
||||
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source)
|
||||
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta)
|
||||
{
|
||||
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token');
|
||||
|
||||
@@ -147,13 +148,33 @@ class FormController extends Controller
|
||||
$helptopic = $ticket_settings->first()->help_topic;
|
||||
$sla = $ticket_settings->first()->sla;
|
||||
$priority = $ticket_settings->first()->priority;
|
||||
$source = $ticket_source->where('name', '=', 'web')->first();
|
||||
$source = $ticket_source->where('name', '=', 'web')->first()->id;
|
||||
$attachments = $request->file('attachment');
|
||||
|
||||
$collaborator = null;
|
||||
$assignto = null;
|
||||
$auto_response = 0;
|
||||
if ($this->TicketController->create_user($email, $name, $subject, $details, $phone, $helptopic, $sla, $priority, $source->id, $collaborator, $department, $assignto, $form_extras, $auto_response)) {
|
||||
return Redirect::route('guest.getform')->with('success', 'Ticket Created Successfully');
|
||||
$team_assign = null;
|
||||
|
||||
$result = $this->TicketWorkflowController->workflow($email, $name, $subject, $details, $phone, $helptopic, $sla, $priority, $source, $collaborator, $department, $assignto, $team_assign, $status, $form_extras, $auto_response);
|
||||
|
||||
if ($result[1] == 1) {
|
||||
$ticketId = Tickets::where('ticket_number', '=', $result[0])->first();
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $ticketId->id)->first();
|
||||
if ($attachments != null) {
|
||||
foreach ($attachments as $attachment) {
|
||||
if ($attachment != null) {
|
||||
$name = $attachment->getClientOriginalName();
|
||||
$type = $attachment->getClientOriginalExtension();
|
||||
$size = $attachment->getSize();
|
||||
$data = file_get_contents($attachment->getRealPath());
|
||||
$attachPath = $attachment->getRealPath();
|
||||
$ta->create(['thread_id' => $thread->id, 'name' => $name, 'size' => $size, 'type' => $type, 'file' => $data, 'poster' => 'ATTACHMENT']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect::route('guest.getform')->with('success', 'Ticket has been created successfully, your ticket number is <b>'.$result[0].'</b> Please save this for future reference.');
|
||||
}
|
||||
}
|
||||
|
||||
|
83
app/Http/Controllers/Common/NotificationController.php
Normal file
83
app/Http/Controllers/Common/NotificationController.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Notification\Notification;
|
||||
use App\Model\helpdesk\Notification\UserNotification;
|
||||
use App\User;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$user = new User();
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the page to list the notifications.
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public static function getNotifications()
|
||||
{
|
||||
$notifications = UserNotification::join('notifications', 'user_notification.notification_id', '=', 'notifications.id')
|
||||
->join('notification_types', 'notifications.type_id', '=', 'notification_types.id')
|
||||
->where('user_notification.is_read', '=', '0')
|
||||
->where('user_notification.user_id', '=', \Auth::user()->id)
|
||||
->get();
|
||||
|
||||
return $notifications;
|
||||
}
|
||||
|
||||
public function create($model_id, $userid_created, $type_id, $forwhome = [])
|
||||
{
|
||||
try {
|
||||
if (empty($forwhome)) {
|
||||
$forwhome = $this->user->where('role', '!=', 'user')->get()->toArray();
|
||||
}
|
||||
//dd($forwhome);
|
||||
//system notification
|
||||
$notification = new Notification();
|
||||
$UN = new UserNotification();
|
||||
|
||||
$notify = $notification->create(['model_id' => $model_id, 'userid_created' => $userid_created, 'type_id' => $type_id]);
|
||||
foreach ($forwhome as $agent) {
|
||||
$user_notify = $UN->create(['notification_id' => $notify->id, 'user_id' => $agent['id'], 'is_read' => 0]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function markRead($id)
|
||||
{
|
||||
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->is_read = '1';
|
||||
$mark->save();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
$notifications = $this->getNotifications();
|
||||
|
||||
return view('notifications-all', compact('notifications'));
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->delete();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
@@ -414,7 +414,7 @@ class SettingsController extends Controller
|
||||
public function version_check()
|
||||
{
|
||||
$response_url = \URL::route('post-version-check');
|
||||
echo "<form action='http://www.faveohelpdesk.com/bill/version' method='post' name='redirect'>";
|
||||
echo "<form action='http://www.faveohelpdesk.com/billing/version' method='post' name='redirect'>";
|
||||
echo "<input type='hidden' name='_token' value='csrf_token()'/>";
|
||||
echo "<input type='hidden' name='title' value='helpdeskcommunityedition'/>";
|
||||
echo "<input type='hidden' name='id' value='19'/>";
|
||||
|
@@ -298,7 +298,6 @@ class InstallController extends Controller
|
||||
// checking is the installation was done previously
|
||||
try {
|
||||
$check_for_pre_installation = System::all();
|
||||
dd($check_for_pre_installation);
|
||||
if ($check_for_pre_installation) {
|
||||
return redirect()->back()->with('fails', 'The data in database already exist. Please provide fresh database');
|
||||
}
|
||||
|
Reference in New Issue
Block a user