Updates
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Fetch\Server as Server;
|
||||
|
||||
class MailFetch extends Server
|
||||
{
|
||||
public function __construct($serverPath, $port = 143, $service = 'imap')
|
||||
{
|
||||
class MailFetch extends Server{
|
||||
|
||||
public function __construct($serverPath, $port = 143, $service = 'imap') {
|
||||
$this->serverPath = $serverPath;
|
||||
|
||||
$this->port = $port;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controller
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
// request
|
||||
use App\Http\Requests\helpdesk\AgentRequest;
|
||||
use App\Http\Requests\helpdesk\AgentUpdate;
|
||||
@@ -79,11 +79,11 @@ class AgentController extends Controller
|
||||
{
|
||||
try {
|
||||
// gte all the teams
|
||||
$team = $team_all->get();
|
||||
$team = $team_all->where('status', '=', 1)->get();
|
||||
// get all the timezones
|
||||
$timezones = $timezone->get();
|
||||
// get all the groups
|
||||
$groups = $group->get();
|
||||
$groups = $group->where('group_status', '=', 1)->get();
|
||||
// get all department
|
||||
$departments = $department->get();
|
||||
// list all the teams in a single variable
|
||||
@@ -92,7 +92,6 @@ class AgentController extends Controller
|
||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
// returns to the page with all the variables and their datas
|
||||
$send_otp = DB::table('common_settings')->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team', 'send_otp'))->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
// returns if try fails with exception meaagse
|
||||
@@ -121,9 +120,10 @@ class AgentController extends Controller
|
||||
}
|
||||
// fixing the user role to agent
|
||||
$user->fill($request->except(['group', 'primary_department', 'agent_time_zone', 'mobile']))->save();
|
||||
if ($request->get('mobile')) {
|
||||
if ($request->get('mobile'))
|
||||
{
|
||||
$user->mobile = $request->get('mobile');
|
||||
} else {
|
||||
} else{
|
||||
$user->mobile = null;
|
||||
}
|
||||
$user->assign_group = $request->group;
|
||||
@@ -146,7 +146,7 @@ class AgentController extends Controller
|
||||
// fetch user credentails to send mail
|
||||
$name = $user->first_name;
|
||||
$email = $user->email;
|
||||
if ($request->input('send_email')) {
|
||||
if($request->input('send_email')) {
|
||||
try {
|
||||
// send mail on registration
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $email], $message = ['subject' => null, 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $email, 'user_password' => $password]);
|
||||
@@ -159,7 +159,6 @@ class AgentController extends Controller
|
||||
if ($request->input('active') == '0' || $request->input('active') == 0) {
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
}
|
||||
|
||||
return redirect('agents')->with('success', Lang::get('lang.agent_creation_success'));
|
||||
} else {
|
||||
// returns if fails
|
||||
@@ -186,10 +185,10 @@ class AgentController extends Controller
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
$user = $user->whereId($id)->first();
|
||||
$team = $team->get();
|
||||
$team = $team->where('status', '=', 1)->get();
|
||||
$teams1 = $team->lists('name', 'id');
|
||||
$timezones = $timezone->get();
|
||||
$groups = $group->get();
|
||||
$groups = $group->where('group_status', '=', 1)->get();
|
||||
$departments = $department->get();
|
||||
$table = $team_assign_agent->where('agent_id', $id)->first();
|
||||
$teams = $team->lists('id', 'name')->toArray();
|
||||
@@ -276,6 +275,7 @@ class AgentController extends Controller
|
||||
$user->id;
|
||||
$user->delete();
|
||||
throw new \Exception($error);
|
||||
|
||||
return redirect('agents')->with('success', Lang::get('lang.agent_deleted_sucessfully'));
|
||||
} catch (\Exception $e) {
|
||||
return redirect('agents')->with('fails', $error);
|
||||
|
||||
@@ -29,15 +29,14 @@ use Lang;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class DepartmentController extends Controller
|
||||
{
|
||||
class DepartmentController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
@@ -49,11 +48,9 @@ class DepartmentController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function index(Department $department)
|
||||
{
|
||||
public function index(Department $department) {
|
||||
try {
|
||||
$departments = $department->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
@@ -73,14 +70,14 @@ class DepartmentController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group)
|
||||
{
|
||||
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group) {
|
||||
try {
|
||||
$slas = $sla->get();
|
||||
$slas = $sla->where('status', '=', 1)
|
||||
->select('grace_period','id')->get();
|
||||
$user = $user->where('role', '<>', 'user')
|
||||
->where('active', '=', 1)
|
||||
->get();
|
||||
$emails = $email->get();
|
||||
$emails = $email->select('email_name','id')->get();
|
||||
$templates = $template->get();
|
||||
$department = $department->get();
|
||||
$groups = $group->lists('id', 'name');
|
||||
@@ -99,8 +96,7 @@ class DepartmentController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function store(Department $department, DepartmentRequest $request)
|
||||
{
|
||||
public function store(Department $department, DepartmentRequest $request) {
|
||||
try {
|
||||
$department->fill($request->except('group_id', 'manager', 'sla'))->save();
|
||||
if ($request->sla) {
|
||||
@@ -123,7 +119,6 @@ class DepartmentController extends Controller
|
||||
->where('id', 1)
|
||||
->update(['department' => $department->id]);
|
||||
}
|
||||
|
||||
return redirect('departments')->with('success', Lang::get('lang.department_created_sucessfully'));
|
||||
} else {
|
||||
return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department'));
|
||||
@@ -148,24 +143,24 @@ class DepartmentController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group)
|
||||
{
|
||||
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group) {
|
||||
try {
|
||||
$sys_department = \DB::table('settings_system')
|
||||
->select('department')
|
||||
->where('id', '=', 1)
|
||||
->first();
|
||||
$slas = $sla->get();
|
||||
$slas = $sla->where('status', '=', 1)
|
||||
->select('grace_period','id')->get();
|
||||
$user = $user->where('primary_dpt', $id)
|
||||
->where('active', '=', 1)
|
||||
->get();
|
||||
$emails = $email->get();
|
||||
->get();
|
||||
$emails = $email->select('email_name','id')->get();
|
||||
$templates = $template->get();
|
||||
$departments = $department->whereId($id)->first();
|
||||
$groups = $group->lists('id', 'name');
|
||||
//$groups = $group->lists('id', 'name');
|
||||
$assign = $group_assign_department->where('department_id', $id)->lists('group_id');
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'groups', 'sys_department'));
|
||||
return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'sys_department'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('departments')->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -181,8 +176,7 @@ class DepartmentController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request)
|
||||
{
|
||||
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) {
|
||||
// dd($id);
|
||||
try {
|
||||
$table = $group_assign_department->where('department_id', $id);
|
||||
@@ -230,10 +224,9 @@ class DepartmentController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets)
|
||||
{
|
||||
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets) {
|
||||
// try {
|
||||
|
||||
|
||||
$system = $system->where('id', '=', '1')->first();
|
||||
if ($system->department == $id) {
|
||||
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
|
||||
@@ -245,7 +238,7 @@ class DepartmentController extends Controller
|
||||
} else {
|
||||
$text_tickets = 'Ticket';
|
||||
}
|
||||
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_department').'</li>';
|
||||
$ticket = '<li>' . $tickets . ' ' . $text_tickets . Lang::get('lang.have_been_moved_to_default_department') . '</li>';
|
||||
} else {
|
||||
$ticket = '';
|
||||
}
|
||||
@@ -256,7 +249,7 @@ class DepartmentController extends Controller
|
||||
} else {
|
||||
$text_user = 'User';
|
||||
}
|
||||
$user = '<li>'.$users.' '.$text_user.Lang::get('lang.have_been_moved_to_default_department').'</li>';
|
||||
$user = '<li>' . $users . ' ' . $text_user . Lang::get('lang.have_been_moved_to_default_department') . '</li>';
|
||||
} else {
|
||||
$user = '';
|
||||
}
|
||||
@@ -267,27 +260,28 @@ class DepartmentController extends Controller
|
||||
} else {
|
||||
$text_emails = 'Email';
|
||||
}
|
||||
$email = '<li>'.$emails.' System '.$text_emails.Lang::get('lang.have_been_moved_to_default_department').' </li>';
|
||||
$email = '<li>' . $emails . ' System ' . $text_emails . Lang::get('lang.have_been_moved_to_default_department') . ' </li>';
|
||||
} else {
|
||||
$email = '';
|
||||
}
|
||||
$helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']);
|
||||
if ($helptopic > 0) {
|
||||
$helptopic = '<li>'.Lang::get('lang.the_associated_helptopic_has_been_deactivated').'</li>';
|
||||
$helptopic = '<li>' . Lang::get('lang.the_associated_helptopic_has_been_deactivated') . '</li>';
|
||||
} else {
|
||||
$helptopic = '';
|
||||
}
|
||||
$message = $ticket.$user.$email.$helptopic;
|
||||
$message = $ticket . $user . $email . $helptopic;
|
||||
/* Becouse of foreign key we delete group_assign_department first */
|
||||
$group_assign_department = $group_assign_department->where('department_id', $id);
|
||||
$group_assign_department->delete();
|
||||
$departments = $department->whereId($id)->first();
|
||||
/* Check the function is Success or Fail */
|
||||
if ($departments->delete() == true) {
|
||||
return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully').$message);
|
||||
return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully') . $message);
|
||||
} else {
|
||||
return redirect('departments')->with('fails', Lang::get('lang.department_can_not_delete'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,21 +3,21 @@
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\EmailsRequest;
|
||||
// model
|
||||
use App\Http\Requests\helpdesk\Mail\MailRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
// model
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
// classes
|
||||
use App\Model\helpdesk\Utility\MailboxProtocol;
|
||||
use Crypt;
|
||||
// classes
|
||||
use Exception;
|
||||
use Lang;
|
||||
use App\Http\Requests\helpdesk\Mail\MailRequest;
|
||||
use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
|
||||
/**
|
||||
* ======================================
|
||||
@@ -27,15 +27,14 @@ use Lang;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class EmailsController extends Controller
|
||||
{
|
||||
class EmailsController extends Controller {
|
||||
|
||||
/**
|
||||
* Defining constructor variables.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
@@ -47,8 +46,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index(Emails $email)
|
||||
{
|
||||
public function index(Emails $email) {
|
||||
try {
|
||||
// fetch all the emails from emails table
|
||||
$emails = $email->get();
|
||||
@@ -69,14 +67,13 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
|
||||
{
|
||||
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol) {
|
||||
try {
|
||||
// fetch all the departments from the department table
|
||||
$departments = $department->get();
|
||||
// fetch all the helptopics from the helptopic table
|
||||
$helps = $help->where('status', '=', 1)->get();
|
||||
// fetch all the types of active priority from the ticket_priority table
|
||||
// fetch all the types of priority from the ticket_priority table
|
||||
$priority = $ticket_priority->where('status', '=', 1)->get();
|
||||
// fetch all the types of mailbox protocols from the mailbox_protocols table
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
@@ -99,8 +96,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettings(MailRequest $request, $id = '')
|
||||
{
|
||||
public function validatingEmailSettings(MailRequest $request, $id = "") {
|
||||
//dd($request->all());
|
||||
try {
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code');
|
||||
@@ -118,10 +114,8 @@ class EmailsController extends Controller
|
||||
}
|
||||
if ($send == 1 && $fetch == 1) {
|
||||
$this->store($request, $service_request, $id);
|
||||
|
||||
return $this->jsonResponse('success', Lang::get('lang.success'));
|
||||
}
|
||||
|
||||
return $this->validateEmailError($send, $fetch);
|
||||
} catch (Exception $ex) {
|
||||
$message = $ex->getMessage();
|
||||
@@ -129,13 +123,11 @@ class EmailsController extends Controller
|
||||
$message = imap_last_error();
|
||||
}
|
||||
loging('mail-config', $message);
|
||||
|
||||
return $this->jsonResponse('fails', $message);
|
||||
}
|
||||
}
|
||||
|
||||
public function validateEmailError($out, $in)
|
||||
{
|
||||
public function validateEmailError($out, $in) {
|
||||
if ($out !== 1) {
|
||||
return $this->jsonResponse('fails', Lang::get('lang.outgoing_email_connection_failed'));
|
||||
}
|
||||
@@ -144,15 +136,13 @@ class EmailsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function jsonResponse($type, $message)
|
||||
{
|
||||
public function jsonResponse($type, $message) {
|
||||
if ($type == 'fails') {
|
||||
$result = ['fails' => $message];
|
||||
}
|
||||
if ($type == 'success') {
|
||||
$result = ['success' => $message];
|
||||
}
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
||||
@@ -164,10 +154,9 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store($request, $service_request = [], $id = '')
|
||||
{
|
||||
public function store($request, $service_request = [], $id = "") {
|
||||
$email = new Emails();
|
||||
if ($id !== '') {
|
||||
if ($id !== "") {
|
||||
$email = $email->find($id);
|
||||
}
|
||||
|
||||
@@ -219,7 +208,7 @@ class EmailsController extends Controller
|
||||
if ($request->input('fetching_status')) {
|
||||
$this->fetch($email);
|
||||
}
|
||||
if ($id === '') {
|
||||
if ($id === "") {
|
||||
// Creating a default system email as the first email is inserted to the system
|
||||
$email_settings = Email::where('id', '=', '1')->first();
|
||||
$email_settings->sys_email = $email->id;
|
||||
@@ -233,12 +222,31 @@ class EmailsController extends Controller
|
||||
if ($request->input('fetching_status')) {
|
||||
$this->fetch($email);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function sendDiagnoEmail($request)
|
||||
{
|
||||
public function checkMail($request) {
|
||||
$mailservice_id = $request->input('sending_protocol');
|
||||
$driver = $this->getDriver($mailservice_id);
|
||||
$username = $request->input('email_address');
|
||||
$password = $request->input('password');
|
||||
$name = $request->input('email_name');
|
||||
$host = $request->input('sending_host');
|
||||
$port = $request->input('sending_port');
|
||||
$enc = $request->input('sending_encryption');
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode');
|
||||
|
||||
$this->emailService($driver, $service_request);
|
||||
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
|
||||
$transport = \Swift_SmtpTransport::newInstance($host, $port, $enc);
|
||||
$transport->setUsername($username);
|
||||
$transport->setPassword($password);
|
||||
$mailer = \Swift_Mailer::newInstance($transport);
|
||||
$mailer->getTransport()->start();
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function sendDiagnoEmail($request) {
|
||||
$mailservice_id = $request->input('sending_protocol');
|
||||
$driver = $this->getDriver($mailservice_id);
|
||||
$username = $request->input('email_address');
|
||||
@@ -252,45 +260,41 @@ class EmailsController extends Controller
|
||||
$this->emailService($driver, $service_request);
|
||||
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
|
||||
$controller = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$subject = 'test';
|
||||
$data = 'test';
|
||||
$subject = "test";
|
||||
$data = "test";
|
||||
//dd(\Config::get('mail'),\Config::get('services'));
|
||||
$send = $controller->laravelMail($username, $name, $subject, $data, [], []);
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port)
|
||||
{
|
||||
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port) {
|
||||
$configs = [
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $name],
|
||||
'password' => $password,
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $name,],
|
||||
'password' => $password,
|
||||
'encryption' => $enc,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $driver,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $driver,
|
||||
];
|
||||
foreach ($configs as $key => $config) {
|
||||
if (is_array($config)) {
|
||||
foreach ($config as $from) {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
\Config::set('mail.' . $key, $config);
|
||||
}
|
||||
} else {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
\Config::set('mail.' . $key, $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDriver($driver_id)
|
||||
{
|
||||
$short = '';
|
||||
public function getDriver($driver_id) {
|
||||
$short = "";
|
||||
$email_drivers = new \App\Model\MailJob\MailService();
|
||||
$email_driver = $email_drivers->find($driver_id);
|
||||
if ($email_driver) {
|
||||
$short = $email_driver->short_name;
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
|
||||
@@ -306,8 +310,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
|
||||
{
|
||||
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol) {
|
||||
try {
|
||||
$sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first();
|
||||
// dd($sys_email);
|
||||
@@ -319,8 +322,8 @@ class EmailsController extends Controller
|
||||
$count = $email->count();
|
||||
// get all the helptopic
|
||||
$helps = $help->where('status', '=', 1)->get();
|
||||
// get all active the priority
|
||||
$priority = $ticket_priority->where('status', '=', 1)->get();
|
||||
// get all the priority
|
||||
$priority = $ticket_priority->where('status', '=', 1)->get();
|
||||
// get all the mailbox protocols
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
|
||||
@@ -342,8 +345,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettingsUpdate($id, MailRequest $request)
|
||||
{
|
||||
public function validatingEmailSettingsUpdate($id, MailRequest $request) {
|
||||
try {
|
||||
return $this->validatingEmailSettings($request, $id);
|
||||
} catch (Exception $ex) {
|
||||
@@ -367,9 +369,9 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, $request)
|
||||
{
|
||||
public function update($id, $request) {
|
||||
try {
|
||||
|
||||
if ($request->sys_email == 'on') {
|
||||
$system = \DB::table('settings_email')
|
||||
->where('id', '=', 1)
|
||||
@@ -395,8 +397,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Emails $email)
|
||||
{
|
||||
public function destroy($id, Emails $email) {
|
||||
// fetching the details on the basis of the $id passed to the function
|
||||
$default_system_email = Email::where('id', '=', '1')->first();
|
||||
if ($default_system_email->sys_email) {
|
||||
@@ -410,7 +411,6 @@ class EmailsController extends Controller
|
||||
$emails = $email->whereId($id)->first();
|
||||
// checking if deleting the email is success or if it's carrying any dependencies
|
||||
$emails->delete();
|
||||
|
||||
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
|
||||
} catch (Exception $e) {
|
||||
// returns if the try fails
|
||||
@@ -425,8 +425,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function getImapStream($request)
|
||||
{
|
||||
public function getImapStream($request) {
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$service = $request->input('fetching_protocol');
|
||||
@@ -436,7 +435,7 @@ class EmailsController extends Controller
|
||||
$password = $request->input('password');
|
||||
$server = new Fetch($host, $port, $service);
|
||||
//$server->setFlag('novalidate-cert');
|
||||
if ($encryption != '') {
|
||||
if ($encryption != "") {
|
||||
$server->setFlag($encryption);
|
||||
}
|
||||
if (!$validate) {
|
||||
@@ -447,7 +446,6 @@ class EmailsController extends Controller
|
||||
|
||||
$server->setAuthentication($username, $password);
|
||||
$server->getImapStream();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -458,8 +456,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function checkImapStream($imap_stream)
|
||||
{
|
||||
public function checkImapStream($imap_stream) {
|
||||
$check_imap_stream = imap_check($imap_stream);
|
||||
if ($check_imap_stream) {
|
||||
$imap_stream = 1;
|
||||
@@ -477,8 +474,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSmtp($request)
|
||||
{
|
||||
public function getSmtp($request) {
|
||||
$sending_status = $request->input('sending_status');
|
||||
// cheking for the sending protocol
|
||||
if ($request->input('sending_protocol') == 'smtp') {
|
||||
@@ -494,8 +490,8 @@ class EmailsController extends Controller
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->SMTPOptions = [
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true,
|
||||
],
|
||||
];
|
||||
@@ -527,8 +523,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function departmentValue($dept)
|
||||
{
|
||||
public function departmentValue($dept) {
|
||||
if ($dept) {
|
||||
$email_department = $dept;
|
||||
} else {
|
||||
@@ -545,8 +540,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function priorityValue($priority)
|
||||
{
|
||||
public function priorityValue($priority) {
|
||||
if ($priority) {
|
||||
$email_priority = $priority;
|
||||
} else {
|
||||
@@ -563,8 +557,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function helpTopicValue($help_topic)
|
||||
{
|
||||
public function helpTopicValue($help_topic) {
|
||||
if ($help_topic) {
|
||||
$email_help_topic = $help_topic;
|
||||
} else {
|
||||
@@ -574,20 +567,18 @@ class EmailsController extends Controller
|
||||
return $email_help_topic;
|
||||
}
|
||||
|
||||
public function emailService($service, $value = [])
|
||||
{
|
||||
public function emailService($service, $value = []) {
|
||||
switch ($service) {
|
||||
case 'mailgun':
|
||||
case "mailgun":
|
||||
$this->setServiceConfig($service, $value);
|
||||
case 'mandrill':
|
||||
case "mandrill":
|
||||
$this->setServiceConfig($service, $value);
|
||||
case 'ses':
|
||||
case "ses":
|
||||
$this->setServiceConfig($service, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setServiceConfig($service, $value)
|
||||
{
|
||||
public function setServiceConfig($service, $value) {
|
||||
//dd($service);
|
||||
if (count($value) > 0) {
|
||||
foreach ($value as $k => $v) {
|
||||
@@ -596,8 +587,7 @@ class EmailsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function saveMailService($emailid, $request, $driver)
|
||||
{
|
||||
public function saveMailService($emailid, $request, $driver) {
|
||||
$mail_service = new \App\Model\MailJob\FaveoMail();
|
||||
$mails = $mail_service->where('email_id', $emailid)->get();
|
||||
if (count($request) > 0) {
|
||||
@@ -606,17 +596,16 @@ class EmailsController extends Controller
|
||||
}
|
||||
foreach ($request as $key => $value) {
|
||||
$mail_service->create([
|
||||
'drive' => $driver,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'drive' => $driver,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'email_id' => $emailid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function readMails()
|
||||
{
|
||||
public function readMails() {
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
|
||||
@@ -629,8 +618,7 @@ class EmailsController extends Controller
|
||||
$controller->readmails($emails, $settings_email, $system, $ticket);
|
||||
}
|
||||
|
||||
public function fetch($email)
|
||||
{
|
||||
public function fetch($email) {
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
|
||||
@@ -639,26 +627,4 @@ class EmailsController extends Controller
|
||||
$controller->fetch($email);
|
||||
}
|
||||
|
||||
public function checkMail($request)
|
||||
{
|
||||
$mailservice_id = $request->input('sending_protocol');
|
||||
$driver = $this->getDriver($mailservice_id);
|
||||
$username = $request->input('email_address');
|
||||
$password = $request->input('password');
|
||||
$name = $request->input('email_name');
|
||||
$host = $request->input('sending_host');
|
||||
$port = $request->input('sending_port');
|
||||
$enc = $request->input('sending_encryption');
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode');
|
||||
|
||||
$this->emailService($driver, $service_request);
|
||||
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
|
||||
$transport = \Swift_SmtpTransport::newInstance($host, $port, $enc);
|
||||
$transport->setUsername($username);
|
||||
$transport->setPassword($password);
|
||||
$mailer = \Swift_Mailer::newInstance($transport);
|
||||
$mailer->getTransport()->start();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,637 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// request
|
||||
use App\Http\Requests\helpdesk\EmailsEditRequest;
|
||||
use App\Http\Requests\helpdesk\EmailsRequest;
|
||||
use App\Http\Requests\helpdesk\Mail\MailRequest;
|
||||
// model
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Utility\MailboxProtocol;
|
||||
// classes
|
||||
use Crypt;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* ======================================
|
||||
* EmailsController.
|
||||
* ======================================
|
||||
* This Controller is used to define below mentioned set of functions applied to the Emails in the system.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class EmailsControllerOld extends Controller
|
||||
{
|
||||
/**
|
||||
* Defining constructor variables.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the Emails.
|
||||
*
|
||||
* @param type Emails $emails
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index(Emails $email)
|
||||
{
|
||||
try {
|
||||
// fetch all the emails from emails table
|
||||
$emails = $email->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param type Department $department
|
||||
* @param type Help_topic $help
|
||||
* @param type Priority $priority
|
||||
* @param type MailboxProtocol $mailbox_protocol
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
|
||||
{
|
||||
try {
|
||||
// fetch all the departments from the department table
|
||||
$departments = $department->get();
|
||||
// fetch all the helptopics from the helptopic table
|
||||
$helps = $help->get();
|
||||
// fetch all the types of priority from the ticket_priority table
|
||||
$priority = $ticket_priority->get();
|
||||
// fetch all the types of mailbox protocols from the mailbox_protocols table
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
|
||||
$service = new \App\Model\MailJob\MailService();
|
||||
$services = $service->lists('name', 'id')->toArray();
|
||||
|
||||
// return with all the table data
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'services'));
|
||||
} catch (Exception $e) {
|
||||
// return error messages if any
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for email input validation.
|
||||
*
|
||||
* @param EmailsRequest $request
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettings(MailRequest $request, $id = '')
|
||||
{
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code');
|
||||
$service = $request->input('sending_protocol');
|
||||
$send = 0;
|
||||
$imap_check[0] = 0;
|
||||
if ($request->input('imap_validate') == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} elseif (!$request->input('imap_validate')) {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
try {
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
} catch (Exception $ex) {
|
||||
\Log::error($ex->getMessage());
|
||||
$result = ['fails' => $ex->getMessage()];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
if ($imap_check[0] == 0) {
|
||||
$response = Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
|
||||
}
|
||||
} else {
|
||||
$imap_check[0] = 1;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$this->emailService($service, $service_request);
|
||||
try {
|
||||
$send = $this->sendDiagnoEmail($request);
|
||||
} catch (Exception $ex) {
|
||||
\Log::error($ex->getMessage());
|
||||
$result = ['fails' => $ex->getMessage()];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
if ($send === 0) {
|
||||
$response = Lang::get('lang.outgoing_email_connection_failed');
|
||||
}
|
||||
} else {
|
||||
$send = 1;
|
||||
}
|
||||
if ($send === 1 && $imap_check[0] === 1) {
|
||||
$this->store($request, $imap_check, $service_request, $id);
|
||||
}
|
||||
|
||||
return $this->jsonResponse($send, $imap_check);
|
||||
}
|
||||
|
||||
public function sendDiagnoEmail($request)
|
||||
{
|
||||
try {
|
||||
$mailservice_id = $request->input('sending_protocol');
|
||||
$driver = $this->getDriver($mailservice_id);
|
||||
$username = $request->input('email_address');
|
||||
$password = $request->input('password');
|
||||
$name = $request->input('email_name');
|
||||
$host = $request->input('sending_host');
|
||||
$port = $request->input('sending_port');
|
||||
$enc = $request->input('sending_encryption');
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode');
|
||||
|
||||
$this->emailService($driver, $service_request);
|
||||
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
|
||||
$controller = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$to = 'example@ladybirdweb.com';
|
||||
$toname = 'test';
|
||||
$subject = 'test';
|
||||
$data = 'test';
|
||||
//dd(\Config::get('mail'),\Config::get('services'));
|
||||
$send = $controller->laravelMail($to, $toname, $subject, $data, [], []);
|
||||
} catch (Exception $e) {
|
||||
\Log::error($e->getMessage());
|
||||
//dd($e);
|
||||
}
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port)
|
||||
{
|
||||
$configs = [
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $name],
|
||||
'password' => $password,
|
||||
'encryption' => $enc,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $driver,
|
||||
];
|
||||
foreach ($configs as $key => $config) {
|
||||
if (is_array($config)) {
|
||||
foreach ($config as $from) {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
} else {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDriver($driver_id)
|
||||
{
|
||||
$short = '';
|
||||
$email_drivers = new \App\Model\MailJob\MailService();
|
||||
$email_driver = $email_drivers->find($driver_id);
|
||||
if ($email_driver) {
|
||||
$short = $email_driver->short_name;
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param type Emails $email
|
||||
* @param type EmailsRequest $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store($request, $imap_check, $service_request = [], $id = '')
|
||||
{
|
||||
$email = new Emails();
|
||||
if ($id !== '') {
|
||||
$email = $email->find($id);
|
||||
}
|
||||
try {
|
||||
$email->email_address = $request->email_address;
|
||||
|
||||
$email->email_name = $request->email_name;
|
||||
$email->fetching_host = $request->fetching_host;
|
||||
$email->fetching_port = $request->fetching_port;
|
||||
$email->fetching_protocol = $request->fetching_protocol;
|
||||
$email->sending_host = $request->sending_host;
|
||||
$email->sending_port = $request->sending_port;
|
||||
$email->sending_protocol = $this->getDriver($request->sending_protocol);
|
||||
$email->sending_encryption = $request->sending_encryption;
|
||||
|
||||
if ($request->smtp_validate == 'on') {
|
||||
$email->smtp_validate = $request->smtp_validate;
|
||||
}
|
||||
|
||||
if ($request->input('password')) {
|
||||
$email->password = Crypt::encrypt($request->input('password'));
|
||||
}
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$email->fetching_status = 1;
|
||||
} else {
|
||||
$email->fetching_status = 0;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$email->sending_status = 1;
|
||||
} else {
|
||||
$email->sending_status = 0;
|
||||
}
|
||||
if ($request->input('auto_response') == 'on') {
|
||||
$email->auto_response = 1;
|
||||
} else {
|
||||
$email->auto_response = 0;
|
||||
}
|
||||
//dd($email);
|
||||
if ($imap_check !== null) {
|
||||
$email->fetching_encryption = $imap_check[0];
|
||||
} else {
|
||||
$email->fetching_encryption = $request->input('fetching_encryption');
|
||||
}
|
||||
|
||||
// fetching department value
|
||||
$email->department = $this->departmentValue($request->input('department'));
|
||||
// fetching priority value
|
||||
$email->priority = $this->priorityValue($request->input('priority'));
|
||||
// fetching helptopic value
|
||||
$email->help_topic = $this->helpTopicValue($request->input('help_topic'));
|
||||
// inserting the encrypted value of password
|
||||
$email->password = Crypt::encrypt($request->input('password'));
|
||||
$email->save(); // run save
|
||||
if ($id === '') {
|
||||
// Creating a default system email as the first email is inserted to the system
|
||||
$email_settings = Email::where('id', '=', '1')->first();
|
||||
$email_settings->sys_email = $email->id;
|
||||
$email_settings->save();
|
||||
} else {
|
||||
$this->update($id, $request);
|
||||
}
|
||||
if (count($service_request) > 0) {
|
||||
$this->saveMailService($email->id, $service_request, $this->getDriver($request->sending_protocol));
|
||||
}
|
||||
|
||||
return 1;
|
||||
} catch (Exception $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Department $department
|
||||
* @param type Help_topic $help
|
||||
* @param type Emails $email
|
||||
* @param type Priority $priority
|
||||
* @param type MailboxProtocol $mailbox_protocol
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
|
||||
{
|
||||
try {
|
||||
$sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first();
|
||||
// dd($sys_email);
|
||||
// fetch the selected emails
|
||||
$emails = $email->whereId($id)->first();
|
||||
// get all the departments
|
||||
$departments = $department->get();
|
||||
//get count of emails
|
||||
$count = $email->count();
|
||||
// get all the helptopic
|
||||
$helps = $help->get();
|
||||
// get all the priority
|
||||
$priority = $ticket_priority->get();
|
||||
// get all the mailbox protocols
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
|
||||
$service = new \App\Model\MailJob\MailService();
|
||||
$services = $service->lists('name', 'id')->toArray();
|
||||
|
||||
// return if the execution is succeeded
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails', 'sys_email', 'services'))->with('count', $count);
|
||||
} catch (Exception $e) {
|
||||
// return if try fails
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for email input validation.
|
||||
*
|
||||
* @param EmailsRequest $request
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettingsUpdate($id, MailRequest $request)
|
||||
{
|
||||
return $this->validatingEmailSettings($request, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Emails $email
|
||||
* @param type EmailsEditRequest $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, $request)
|
||||
{
|
||||
try {
|
||||
if ($request->sys_email == 'on') {
|
||||
$system = \DB::table('settings_email')
|
||||
->where('id', '=', 1)
|
||||
->update(['sys_email' => $id]);
|
||||
} elseif ($request->input('count') <= 1 && $request->sys_email == null) {
|
||||
$system = \DB::table('settings_email')
|
||||
->where('id', '=', 1)
|
||||
->update(['sys_email' => null]);
|
||||
}
|
||||
$return = 1;
|
||||
} catch (Exception $e) {
|
||||
$return = $e->getMessage();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Emails $email
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Emails $email)
|
||||
{
|
||||
// fetching the details on the basis of the $id passed to the function
|
||||
$default_system_email = Email::where('id', '=', '1')->first();
|
||||
if ($default_system_email->sys_email) {
|
||||
// checking if the default system email is the passed email
|
||||
if ($id == $default_system_email->sys_email) {
|
||||
return redirect('emails')->with('fails', Lang::get('lang.you_cannot_delete_system_default_email'));
|
||||
}
|
||||
}
|
||||
try {
|
||||
// fetching the database instance of the current email
|
||||
$emails = $email->whereId($id)->first();
|
||||
// checking if deleting the email is success or if it's carrying any dependencies
|
||||
if ($emails->delete() == true) {
|
||||
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
|
||||
} else {
|
||||
return redirect('emails')->with('fails', Lang::get('lang.email_can_not_delete'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// returns if the try fails
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create imap connection.
|
||||
*
|
||||
* @param type $request
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function getImapStream($request, $validate)
|
||||
{
|
||||
$fetching_status = $request->input('fetching_status');
|
||||
$username = $request->input('email_address');
|
||||
$password = $request->input('password');
|
||||
$protocol_id = $request->input('mailbox_protocol');
|
||||
$fetching_protocol = '/'.$request->input('fetching_protocol');
|
||||
$fetching_encryption = '/'.$request->input('fetching_encryption');
|
||||
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.$fetching_protocol.$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;
|
||||
}
|
||||
try {
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
} catch (\Exception $ex) {
|
||||
\Log::error($ex->getMessage());
|
||||
|
||||
return $ex->getMessage();
|
||||
}
|
||||
//$imap_stream = imap_open($mailbox, $username, $password);
|
||||
if ($imap_stream) {
|
||||
$return = [0 => 1, 1 => $mailbox_protocol];
|
||||
} else {
|
||||
$return = [0 => 0];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check connection.
|
||||
*
|
||||
* @param type $imap_stream
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function checkImapStream($imap_stream)
|
||||
{
|
||||
$check_imap_stream = imap_check($imap_stream);
|
||||
if ($check_imap_stream) {
|
||||
$imap_stream = 1;
|
||||
} else {
|
||||
$imap_stream = 0;
|
||||
}
|
||||
|
||||
return $imap_stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get smtp connection.
|
||||
*
|
||||
* @param type $request
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSmtp($request)
|
||||
{
|
||||
$sending_status = $request->input('sending_status');
|
||||
// cheking for the sending protocol
|
||||
if ($request->input('sending_protocol') == 'smtp') {
|
||||
$mail = new \PHPMailer();
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $request->input('sending_host'); // Specify main and backup SMTP servers
|
||||
//$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $request->input('email_address'); // SMTP username
|
||||
$mail->Password = $request->input('password'); // SMTP password
|
||||
$mail->SMTPSecure = $request->input('sending_encryption'); // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $request->input('sending_port'); // TCP port to connect to
|
||||
if (!$request->input('smtp_validate')) {
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->SMTPOptions = [
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true,
|
||||
],
|
||||
];
|
||||
if ($mail->smtpConnect($mail->SMTPOptions) == true) {
|
||||
$mail->smtpClose();
|
||||
$return = 1;
|
||||
} else {
|
||||
$return = 0;
|
||||
}
|
||||
} else {
|
||||
if ($mail->smtpConnect()) {
|
||||
$mail->smtpClose();
|
||||
$return = 1;
|
||||
} else {
|
||||
$return = 0;
|
||||
}
|
||||
}
|
||||
} elseif ($request->input('sending_protocol') == 'mail') {
|
||||
$return = 1;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if department value is null.
|
||||
*
|
||||
* @param type $dept
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function departmentValue($dept)
|
||||
{
|
||||
if ($dept) {
|
||||
$email_department = $dept;
|
||||
} else {
|
||||
$email_department = null;
|
||||
}
|
||||
|
||||
return $email_department;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if priority value is null.
|
||||
*
|
||||
* @param type $priority
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function priorityValue($priority)
|
||||
{
|
||||
if ($priority) {
|
||||
$email_priority = $priority;
|
||||
} else {
|
||||
$email_priority = null;
|
||||
}
|
||||
|
||||
return $email_priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if helptopic value is null.
|
||||
*
|
||||
* @param type $help_topic
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function helpTopicValue($help_topic)
|
||||
{
|
||||
if ($help_topic) {
|
||||
$email_help_topic = $help_topic;
|
||||
} else {
|
||||
$email_help_topic = null;
|
||||
}
|
||||
|
||||
return $email_help_topic;
|
||||
}
|
||||
|
||||
public function emailService($service, $value = [])
|
||||
{
|
||||
switch ($service) {
|
||||
case 'mailgun':
|
||||
$this->setServiceConfig($service, $value);
|
||||
case 'mandrill':
|
||||
$this->setServiceConfig($service, $value);
|
||||
case 'ses':
|
||||
$this->setServiceConfig($service, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setServiceConfig($service, $value)
|
||||
{
|
||||
//dd($service);
|
||||
if (count($value) > 0) {
|
||||
foreach ($value as $k => $v) {
|
||||
\Config::set("services.$service.$k", $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function jsonResponse($out, $in)
|
||||
{
|
||||
if ($out !== 1) {
|
||||
$result = ['fails' => Lang::get('lang.outgoing_email_connection_failed')];
|
||||
}
|
||||
if ($in[0] !== 1) {
|
||||
$result = ['fails' => Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings')];
|
||||
}
|
||||
if ($out === 1 && $in[0] === 1) {
|
||||
$result = ['success' => Lang::get('lang.success')];
|
||||
}
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
||||
public function saveMailService($emailid, $request, $driver)
|
||||
{
|
||||
$mail_service = new \App\Model\MailJob\FaveoMail();
|
||||
$mails = $mail_service->where('email_id', $emailid)->get();
|
||||
if (count($request) > 0) {
|
||||
foreach ($mails as $mail) {
|
||||
$mail->delete();
|
||||
}
|
||||
foreach ($request as $key => $value) {
|
||||
$mail_service->create([
|
||||
'drive' => $driver,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'email_id' => $emailid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,13 @@ use App\Model\helpdesk\Form\Fields;
|
||||
use App\Model\helpdesk\Form\Forms;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
// Request
|
||||
use Exception;
|
||||
// Class
|
||||
use Form;
|
||||
use Illuminate\Http\Request;
|
||||
// Class
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
use Exception;
|
||||
use Form;
|
||||
|
||||
/**
|
||||
* FormController
|
||||
@@ -23,13 +23,12 @@ use Redirect;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class FormController extends Controller
|
||||
{
|
||||
class FormController extends Controller {
|
||||
|
||||
private $fields;
|
||||
private $forms;
|
||||
|
||||
public function __construct(Fields $fields, Forms $forms)
|
||||
{
|
||||
public function __construct(Fields $fields, Forms $forms) {
|
||||
$this->fields = $fields;
|
||||
$this->forms = $forms;
|
||||
$this->middleware('auth', [
|
||||
@@ -44,7 +43,7 @@ class FormController extends Controller
|
||||
'jqueryScript',
|
||||
'jqueryCheckboxScript',
|
||||
'jquerySelectScript',
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -53,8 +52,7 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function home()
|
||||
{
|
||||
public function home() {
|
||||
return view('forms.home');
|
||||
}
|
||||
|
||||
@@ -65,8 +63,7 @@ class FormController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index(Forms $forms)
|
||||
{
|
||||
public function index(Forms $forms) {
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms'));
|
||||
} catch (Exception $e) {
|
||||
@@ -79,8 +76,7 @@ class FormController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
public function create() {
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.form.form');
|
||||
} catch (Exception $e) {
|
||||
@@ -95,15 +91,13 @@ class FormController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
public function show($id) {
|
||||
try {
|
||||
$forms = new Forms();
|
||||
$form = $forms->find($id);
|
||||
//dd($form);
|
||||
if ($form) {
|
||||
$fields = $form->fields();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('form', 'fields'));
|
||||
}
|
||||
throw new Exception("Sorry we can't find your request");
|
||||
@@ -117,13 +111,12 @@ class FormController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
public function store(Request $request) {
|
||||
$this->validate($request, [
|
||||
'formname' => 'required|unique:custom_forms,formname',
|
||||
'label.*' => 'required',
|
||||
'name.*' => 'required',
|
||||
'type.*' => 'required',
|
||||
'label.*' => 'required',
|
||||
'name.*' => 'required',
|
||||
'type.*' => 'required',
|
||||
]);
|
||||
try {
|
||||
$forms = new Forms();
|
||||
@@ -138,18 +131,19 @@ class FormController extends Controller
|
||||
$name = str_slug(Input::get('name')[$i], '_');
|
||||
$field = Fields::create([
|
||||
'forms_id' => $forms->id,
|
||||
'label' => Input::get('label')[$i],
|
||||
'name' => $name,
|
||||
'type' => Input::get('type')[$i],
|
||||
'label' => Input::get('label')[$i],
|
||||
'name' => $name,
|
||||
'type' => Input::get('type')[$i],
|
||||
'required' => $require[$i],
|
||||
]);
|
||||
$field_id = $field->id;
|
||||
$this->createValues($field_id, Input::get('value')[$i]);
|
||||
$this->createValues($field_id, Input::get('value')[$i],null,$name);
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect::back()->with('success', Lang::get('lang.successfully_created_form'));
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -164,8 +158,7 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic)
|
||||
{
|
||||
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic) {
|
||||
$fields = $field->where('forms_id', $id)->get();
|
||||
$help_topics = $help_topic->where('custom_form', '=', $id)->get();
|
||||
foreach ($help_topics as $help_topic) {
|
||||
@@ -181,8 +174,7 @@ class FormController extends Controller
|
||||
return redirect()->back()->with('success', Lang::get('lang.form_deleted_successfully'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
public function edit($id) {
|
||||
try {
|
||||
$forms = new Forms();
|
||||
$form = $forms->find($id);
|
||||
@@ -195,12 +187,12 @@ class FormController extends Controller
|
||||
}
|
||||
throw new Exception("Sorry we can't find your request");
|
||||
} catch (Exception $ex) {
|
||||
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function addChildForm($id)
|
||||
{
|
||||
public function addChildForm($id) {
|
||||
try {
|
||||
$forms = new Forms();
|
||||
$form = $forms->find($id);
|
||||
@@ -213,17 +205,17 @@ class FormController extends Controller
|
||||
}
|
||||
throw new Exception("Sorry we can't find your request");
|
||||
} catch (Exception $ex) {
|
||||
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
public function update($id, Request $request) {
|
||||
$this->validate($request, [
|
||||
'formname' => 'required|unique:custom_forms,formname,'.$id,
|
||||
'label.*' => 'required',
|
||||
'name.*' => 'required',
|
||||
'type.*' => 'required',
|
||||
'formname' => 'required|unique:custom_forms,formname,' . $id,
|
||||
'label.*' => 'required',
|
||||
'name.*' => 'required',
|
||||
'type.*' => 'required',
|
||||
]);
|
||||
try {
|
||||
if (!$request->input('formname')) {
|
||||
@@ -232,7 +224,7 @@ class FormController extends Controller
|
||||
$form = new Forms();
|
||||
$forms = $form->find($id);
|
||||
if (!$forms) {
|
||||
throw new Exception('Sorry we can not find your request');
|
||||
throw new Exception("Sorry we can not find your request");
|
||||
}
|
||||
$forms->formname = Input::get('formname');
|
||||
$forms->save();
|
||||
@@ -249,24 +241,23 @@ class FormController extends Controller
|
||||
$name = str_slug(Input::get('name')[$i], '_');
|
||||
$field = $field->create([
|
||||
'forms_id' => $forms->id,
|
||||
'label' => Input::get('label')[$i],
|
||||
'name' => $name,
|
||||
'type' => Input::get('type')[$i],
|
||||
'label' => Input::get('label')[$i],
|
||||
'name' => $name,
|
||||
'type' => Input::get('type')[$i],
|
||||
'required' => Input::get('required')[$i],
|
||||
]);
|
||||
$field_id = $field->id;
|
||||
$this->createValues($field_id, Input::get('value')[$i]);
|
||||
$this->createValues($field_id, Input::get('value')[$i],null,$name);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'updated');
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function renderForm($formid)
|
||||
{
|
||||
$html = '';
|
||||
public function renderForm($formid) {
|
||||
$html = "";
|
||||
$forms = new Forms();
|
||||
$form = $forms->find($formid);
|
||||
if ($form) {
|
||||
@@ -275,58 +266,54 @@ class FormController extends Controller
|
||||
$html .= self::getForm($field);
|
||||
}
|
||||
}
|
||||
|
||||
return self::requiredStyle().$html;
|
||||
return self::requiredStyle() . $html;
|
||||
}
|
||||
|
||||
public static function getType($type)
|
||||
{
|
||||
public static function getType($type) {
|
||||
switch ($type) {
|
||||
case 'select':
|
||||
return 'select';
|
||||
case 'text':
|
||||
return 'text';
|
||||
case 'email':
|
||||
return 'email';
|
||||
case 'textarea':
|
||||
return 'textarea';
|
||||
case 'select':
|
||||
return 'select';
|
||||
case 'radio':
|
||||
return 'radio';
|
||||
case 'checkbox':
|
||||
return 'checkbox';
|
||||
case 'hidden':
|
||||
return 'hidden';
|
||||
case 'password':
|
||||
return 'password';
|
||||
case "select":
|
||||
return "select";
|
||||
case "text":
|
||||
return "text";
|
||||
case "email":
|
||||
return "email";
|
||||
case "textarea":
|
||||
return "textarea";
|
||||
case "select":
|
||||
return "select";
|
||||
case "radio":
|
||||
return "radio";
|
||||
case "checkbox":
|
||||
return "checkbox";
|
||||
case "hidden":
|
||||
return "hidden";
|
||||
case "password":
|
||||
return "password";
|
||||
}
|
||||
}
|
||||
|
||||
public static function getAttribute($type)
|
||||
{
|
||||
public static function getAttribute($type) {
|
||||
switch ($type) {
|
||||
case 'select':
|
||||
case "select":
|
||||
return "null,['class'=>'form-control']";
|
||||
case 'text':
|
||||
case "text":
|
||||
return "['class'=>'form-control']";
|
||||
case 'email':
|
||||
case "email":
|
||||
return "['class'=>'form-control']";
|
||||
case 'textarea':
|
||||
case "textarea":
|
||||
return "['class'=>'form-control']";
|
||||
case 'radio':
|
||||
return '';
|
||||
case 'checkbox':
|
||||
return '';
|
||||
case 'hidden':
|
||||
return '';
|
||||
case 'password':
|
||||
case "radio":
|
||||
return "";
|
||||
case "checkbox":
|
||||
return "";
|
||||
case "hidden":
|
||||
return "";
|
||||
case "password":
|
||||
return "['class'=>'form-control']";
|
||||
}
|
||||
}
|
||||
|
||||
public static function getForm($field)
|
||||
{
|
||||
public static function getForm($field) {
|
||||
$required = false;
|
||||
$required_class = self::requiredClass($field->required);
|
||||
if ($field->required === '1') {
|
||||
@@ -335,33 +322,32 @@ class FormController extends Controller
|
||||
$type = $field->type;
|
||||
$field_type = self::getType($type);
|
||||
switch ($field_type) {
|
||||
case 'select':
|
||||
case "select":
|
||||
return self::selectForm($field_type, $field, $required, $required_class);
|
||||
case 'text':
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]).
|
||||
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case 'email':
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]).
|
||||
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case 'password':
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]).
|
||||
case "text":
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]) .
|
||||
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case "email":
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]) .
|
||||
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case "password":
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]) .
|
||||
Form::$field_type($field->name, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
|
||||
case 'textarea':
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]).
|
||||
Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case 'radio':
|
||||
case "textarea":
|
||||
return Form::label($field->label, $field->label, ['class' => $required_class]) .
|
||||
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
|
||||
case "radio":
|
||||
return self::radioForm($field_type, $field, $required, $required_class);
|
||||
|
||||
case 'checkbox':
|
||||
case "checkbox":
|
||||
return self::checkboxForm($field_type, $field, $required, $required_class);
|
||||
case 'hidden':
|
||||
return Form::$field_type($field->name, null, ['id' => $field->id]);
|
||||
case "hidden":
|
||||
return Form::$field_type($field->name, NULL, ['id' => $field->id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function createValues($fieldid, $values, $childid = null, $key = '')
|
||||
{
|
||||
public function createValues($fieldid, $values, $childid = NULL, $key = "") {
|
||||
if ($values) {
|
||||
$values_array = explode(',', $values);
|
||||
$field_values = new \App\Model\helpdesk\Form\FieldValue();
|
||||
@@ -374,9 +360,9 @@ class FormController extends Controller
|
||||
if (count($values_array) > 0) {
|
||||
foreach ($values_array as $value) {
|
||||
$field_values->create([
|
||||
'field_id' => $fieldid,
|
||||
'child_id' => $childid,
|
||||
'field_key' => $key,
|
||||
'field_id' => $fieldid,
|
||||
'child_id' => $childid,
|
||||
'field_key' => $key,
|
||||
'field_value' => str_slug($value, '_'),
|
||||
]);
|
||||
}
|
||||
@@ -384,8 +370,7 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function addChild($fieldid, Request $request)
|
||||
{
|
||||
public function addChild($fieldid, Request $request) {
|
||||
$ids = $request->except('_token');
|
||||
try {
|
||||
foreach ($ids as $valueid => $formid) {
|
||||
@@ -399,91 +384,86 @@ class FormController extends Controller
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Updated');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function renderChild(Request $request)
|
||||
{
|
||||
public function renderChild(Request $request) {
|
||||
self::setSession();
|
||||
$render = '';
|
||||
$render = "";
|
||||
$value = $request->input('valueid');
|
||||
$fieldid = $request->input('fieldid');
|
||||
$field_values = new \App\Model\helpdesk\Form\FieldValue();
|
||||
$field_value = $field_values->where('field_id', $fieldid)->where('field_value', $value)->first();
|
||||
$child = '';
|
||||
$child = "";
|
||||
if ($field_value) {
|
||||
$child = $field_value->child_id;
|
||||
}
|
||||
if ($child !== '') {
|
||||
if ($child !== "") {
|
||||
$render = $this->renderForm($child);
|
||||
}
|
||||
|
||||
return $render;
|
||||
}
|
||||
|
||||
public static function jqueryScript($value, $fieldid, $fieldname, $type = '', $index = '')
|
||||
{
|
||||
if ($type == 'select') {
|
||||
public static function jqueryScript($value, $fieldid, $fieldname, $type = "", $index = "") {
|
||||
if ($type == "select") {
|
||||
return self::jquerySelectScript($fieldid);
|
||||
}
|
||||
if ($type == 'checkbox') {
|
||||
if ($type == "checkbox") {
|
||||
return self::jqueryCheckboxScript($fieldid, $index);
|
||||
}
|
||||
|
||||
return '<script>
|
||||
$("#'.str_slug($value).'").on("change", function () {
|
||||
var valueid = $("#'.str_slug($value).'").val();
|
||||
var fieldid = $("#'.$fieldid.str_slug($value).'").val();
|
||||
send'.$fieldid.str_slug($value).'(valueid,fieldid);
|
||||
$("#' . str_slug($value) . '").on("change", function () {
|
||||
var valueid = $("#' . str_slug($value) . '").val();
|
||||
var fieldid = $("#' . $fieldid . str_slug($value) . '").val();
|
||||
send' . $fieldid . str_slug($value) . '(valueid,fieldid);
|
||||
});
|
||||
function send'.$fieldid.str_slug($value).'(valueid,fieldid) {
|
||||
function send' . $fieldid . str_slug($value) . '(valueid,fieldid) {
|
||||
$.ajax({
|
||||
url: "'.url('forms/render/child/').'",
|
||||
url: "' . url('forms/render/child/') . '",
|
||||
dataType: "html",
|
||||
data: {"valueid": valueid,"fieldid": fieldid},
|
||||
success: function (response) {
|
||||
$("#'.$fieldname.'").html(response);
|
||||
$("#' . $fieldname . '").html(response);
|
||||
},
|
||||
error: function (response) {
|
||||
$("#'.$fieldname.'").html(response);
|
||||
$("#' . $fieldname . '").html(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>';
|
||||
}
|
||||
|
||||
public static function jqueryCheckboxScript($fieldid, $index)
|
||||
{
|
||||
public static function jqueryCheckboxScript($fieldid, $index) {
|
||||
$session = self::getSession();
|
||||
$fields = new Fields();
|
||||
$field = $fields->find($fieldid);
|
||||
if ($field) {
|
||||
return '<script>
|
||||
$("#'.$session.$index.'").on("change", function () {
|
||||
var valueid = $("#'.$session.$index.'").val();
|
||||
var fieldid = $("#f'.$session.$index.'").val();
|
||||
$("#' . $session . $index . '").on("change", function () {
|
||||
var valueid = $("#' . $session . $index . '").val();
|
||||
var fieldid = $("#f' . $session . $index . '").val();
|
||||
if($(this).is(":checked")) {
|
||||
send'.$session.$index.'(valueid,fieldid);
|
||||
send' . $session . $index . '(valueid,fieldid);
|
||||
}else{
|
||||
$("#div'.$session.'"+valueid).empty();
|
||||
$("#div' . $session . '"+valueid).empty();
|
||||
}
|
||||
});
|
||||
function send'.$session.$index.'(valueid,fieldid) {
|
||||
function send' . $session . $index . '(valueid,fieldid) {
|
||||
$.ajax({
|
||||
url: "'.url('forms/render/child/').'",
|
||||
url: "' . url('forms/render/child/') . '",
|
||||
dataType: "html",
|
||||
data: {"valueid": valueid,"fieldid": fieldid},
|
||||
success: function (response) {
|
||||
|
||||
$("#div'.$session.'"+valueid).html(response);
|
||||
$("#div' . $session . '"+valueid).html(response);
|
||||
|
||||
},
|
||||
error: function (response) {
|
||||
$("#div'.$session.'"+valueid).html(response);
|
||||
$("#div' . $session . '"+valueid).html(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -491,32 +471,31 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public static function jquerySelectScript($fieldid)
|
||||
{
|
||||
public static function jquerySelectScript($fieldid) {
|
||||
$fields = new Fields();
|
||||
$field = $fields->find($fieldid);
|
||||
$session = self::getSession();
|
||||
if ($field) {
|
||||
return '<script>
|
||||
$(document).ready(function () {
|
||||
var valueid = $(".'.$session.$fieldid.'").val();
|
||||
var fieldid = $("#hidden'.$session.$fieldid.'").val();
|
||||
send'.$session.$fieldid.'(valueid,fieldid);
|
||||
$(".'.$session.$fieldid.'").on("change", function () {
|
||||
valueid = $(".'.$session.$fieldid.'").val();
|
||||
var fieldid = $("#hidden'.$session.$fieldid.'").val();
|
||||
send'.$session.$fieldid.'(valueid,fieldid);
|
||||
var valueid = $(".' . $session . $fieldid . '").val();
|
||||
var fieldid = $("#hidden' . $session . $fieldid . '").val();
|
||||
send' . $session . $fieldid . '(valueid,fieldid);
|
||||
$(".' . $session . $fieldid . '").on("change", function () {
|
||||
valueid = $(".' . $session . $fieldid . '").val();
|
||||
var fieldid = $("#hidden' . $session . $fieldid . '").val();
|
||||
send' . $session . $fieldid . '(valueid,fieldid);
|
||||
});
|
||||
function send'.$session.$fieldid.'(valueid,fieldid) {
|
||||
function send' . $session . $fieldid . '(valueid,fieldid) {
|
||||
$.ajax({
|
||||
url: "'.url('forms/render/child/').'",
|
||||
url: "' . url('forms/render/child/') . '",
|
||||
dataType: "html",
|
||||
data: {"valueid": valueid,"fieldid": fieldid},
|
||||
success: function (response) {
|
||||
$("#'.$session.$field->name.'").html(response);
|
||||
$("#' . $session . $field->name . '").html(response);
|
||||
},
|
||||
error: function (response) {
|
||||
$("#'.$session.$field->name.'").html(response);
|
||||
$("#' . $session . $field->name . '").html(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -526,60 +505,55 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public static function selectForm($field_type, $field, $required, $required_class)
|
||||
{
|
||||
public static function selectForm($field_type, $field, $required, $required_class) {
|
||||
$session = self::getSession();
|
||||
$script = self::jqueryScript($field_value = '', $field->id, $field->name, $field_type);
|
||||
$form_hidden = Form::hidden('fieldid[]', $field->id, ['id' => 'hidden'.$session.$field->id]).Form::label($field->label, $field->label, ['class' => $required_class]);
|
||||
$select = Form::$field_type($field->name, ['' => 'Select', 'Selects' => $field->values()->lists('field_value', 'field_value')->toArray()], null, ['class' => "form-control $session$field->id", 'id' => $session.$field->id, 'required' => $required]).'</br>';
|
||||
$html = $script.$form_hidden.$select;
|
||||
$response_div = '<div id='.$session.$field->name.'></div>';
|
||||
|
||||
return $html.$response_div;
|
||||
$script = self::jqueryScript($field_value = "", $field->id, $field->name, $field_type);
|
||||
$form_hidden = Form::hidden('fieldid[]', $field->id, ['id' => "hidden" . $session . $field->id]) . Form::label($field->label, $field->label, ['class' => $required_class]);
|
||||
$select = Form::$field_type($field->name, ['' => 'Select', 'Selects' => self::removeUnderscoreFromDB($field->values()->lists('field_value', 'field_value')->toArray())], null, ['class' => "form-control $session$field->id", 'id' => $session . $field->id, 'required' => $required]) . "</br>";
|
||||
$html = $script . $form_hidden . $select;
|
||||
$response_div = "<div id=" . $session . $field->name . "></div>";
|
||||
return $html . $response_div;
|
||||
}
|
||||
|
||||
public static function radioForm($field_type, $field, $required, $required_class)
|
||||
{
|
||||
$radio = '';
|
||||
$html = '';
|
||||
public static function radioForm($field_type, $field, $required, $required_class) {
|
||||
$radio = "";
|
||||
$html = "";
|
||||
$values = $field->values()->lists('field_value')->toArray();
|
||||
if (count($values) > 0) {
|
||||
foreach ($values as $field_value) {
|
||||
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type);
|
||||
$radio .= '<div>'.Form::hidden('fieldid[]', $field->id, ['id' => $field->id.str_slug($field_value)]);
|
||||
$radio .= Form::$field_type($field->name, $field_value, null, ['class' => "$field->id", 'id' => str_slug($field_value), 'required' => $required]).$script.'<span> '.removeUnderscore($field_value).'</span></div>';
|
||||
}
|
||||
$html = Form::label($field->label, $field->label, ['class' => $required_class]).'</br>'.$radio.'<div id='.$field->name.'></br></div>';
|
||||
}
|
||||
|
||||
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type);
|
||||
$radio .= "<div>" . Form::hidden('fieldid[]', $field->id, ['id' => $field->id . str_slug($field_value)]);
|
||||
$radio .= Form::$field_type($field->name, $field_value, NULL, ['class' => "$field->id", 'id' => str_slug($field_value), 'required' => $required]) . $script . "<span> " . removeUnderscore($field_value) . "</span></div>";
|
||||
}
|
||||
$html = Form::label($field->label, $field->label, ['class' => $required_class]) . "</br>" . $radio . "<div id=" . $field->name . "></br></div>";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function checkboxForm($field_type, $field, $required, $required_class)
|
||||
{
|
||||
public static function checkboxForm($field_type, $field, $required, $required_class) {
|
||||
$session = self::getSession();
|
||||
$checkbox = '';
|
||||
$html = '';
|
||||
$checkbox = "";
|
||||
$html = "";
|
||||
$values = $field->values()->lists('field_value')->toArray();
|
||||
if (count($values) > 0) {
|
||||
$i = 1;
|
||||
foreach ($values as $field_value) {
|
||||
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type, $i);
|
||||
$checkbox .= Form::hidden('fieldid[]', $field->id, ['id' => 'f'.$session.$i]);
|
||||
$checkbox .= Form::$field_type($field->name, $field_value, null, ['class' => "$field->id", 'id' => $session.$i, 'required' => $required]);
|
||||
$checkbox .= '<span> '.removeUnderscore($field_value).'</span>';
|
||||
$checkbox .= Form::hidden('fieldid[]', $field->id, ['id' => 'f' . $session . $i]);
|
||||
$checkbox .= Form::$field_type($field->name, $field_value, NULL, ['class' => "$field->id", 'id' => $session . $i, 'required' => $required]);
|
||||
$checkbox .= "<span> " . removeUnderscore($field_value) . "</span>";
|
||||
//$checkbox .="</br>";
|
||||
$checkbox .= '<div>'.$script.'<div id=div'.$session.$field_value.'></div></div>';
|
||||
$checkbox .="<div>" . $script . "<div id=div" . $session . $field_value . "></div></div>";
|
||||
$i++;
|
||||
}
|
||||
$html = Form::label($field->label, $field->label, ['class' => $required_class]).'</br>'.$checkbox;
|
||||
$html = Form::label($field->label, $field->label, ['class' => $required_class]) . "</br>" . $checkbox;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function requiredStyle()
|
||||
{
|
||||
public static function requiredStyle() {
|
||||
|
||||
$style = "<style>
|
||||
.required:after {
|
||||
color: #e32 !important;
|
||||
@@ -587,34 +561,39 @@ class FormController extends Controller
|
||||
display:inline !important;
|
||||
}
|
||||
</style>";
|
||||
|
||||
return $style;
|
||||
}
|
||||
|
||||
public static function requiredClass($required)
|
||||
{
|
||||
$class = '';
|
||||
public static function requiredClass($required) {
|
||||
$class = "";
|
||||
if ($required === '1') {
|
||||
$class = 'required';
|
||||
$class = "required";
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function setSession()
|
||||
{
|
||||
public static function setSession() {
|
||||
$form = self::getSession();
|
||||
$form++;
|
||||
\Session::set('fromid', $form);
|
||||
}
|
||||
|
||||
public static function getSession()
|
||||
{
|
||||
public static function getSession() {
|
||||
$form = 0;
|
||||
if (\Session::has('fromid')) {
|
||||
$form = \Session::get('fromid');
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public static function removeUnderscoreFromDB($array) {
|
||||
$result = [];
|
||||
if (is_array($array) && count($array) > 0) {
|
||||
foreach ($array as $key => $value) {
|
||||
$result[$key] = removeUnderscore($value);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -124,6 +124,10 @@ class GroupController extends Controller
|
||||
{
|
||||
// Database instannce to the current id
|
||||
$var = $group->whereId($id)->first();
|
||||
$is_group_assigned = User::select('id')->where('assign_group', '=', $id)->count();
|
||||
if ($is_group_assigned >= 1 && $request->input('group_status') == '0') {
|
||||
return redirect('groups')->with('fails', Lang::get('lang.group_can_not_update').'<li>'.Lang::get('lang.can-not-inactive-group').'</li>');
|
||||
}
|
||||
// Updating Name
|
||||
$var->name = $request->input('name');
|
||||
//Updating Status
|
||||
|
||||
@@ -87,8 +87,7 @@ class HelptopicController extends Controller
|
||||
$forms = $form->get();
|
||||
$agents = $agent->where('role', '=', 'agent')->get();
|
||||
$slas = $sla->get();
|
||||
$priority = Ticket_Priority::where('status', '=', 1)->get();
|
||||
|
||||
$priority = Ticket_Priority::where('status','=',1)->get();
|
||||
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
@@ -148,7 +147,7 @@ class HelptopicController extends Controller
|
||||
$topics = $topic->whereId($id)->first();
|
||||
$forms = $form->get();
|
||||
$slas = $sla->get();
|
||||
$priority = Ticket_Priority::where('status', '=', 1)->get();
|
||||
$priority = Ticket_Priority::where('status','=',1)->get();
|
||||
$sys_help_topic = \DB::table('settings_ticket')
|
||||
->select('help_topic')
|
||||
->where('id', '=', 1)->first();
|
||||
|
||||
@@ -8,6 +8,7 @@ use App;
|
||||
use App\Http\Controllers\Controller;
|
||||
//supports
|
||||
use App\Http\Requests;
|
||||
use Cache;
|
||||
use Config;
|
||||
//classes
|
||||
use File;
|
||||
@@ -16,8 +17,8 @@ use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Input;
|
||||
use Lang;
|
||||
use UnAuth;
|
||||
use Validator;
|
||||
use UnAuth;
|
||||
|
||||
/**
|
||||
* SlaController.
|
||||
@@ -52,6 +53,7 @@ class LanguageController extends Controller
|
||||
} else {
|
||||
return \Redirect::back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,10 +89,11 @@ class LanguageController extends Controller
|
||||
return \Datatable::collection(new Collection($values))
|
||||
->addColumn('language', function ($model) {
|
||||
if ($model == Config::get('app.fallback_locale')) {
|
||||
return Config::get('languages.'.$model).' ('.Lang::get('lang.default').')';
|
||||
return Config::get('languages.'.$model).' ('.Lang::get('lang.default').')';
|
||||
} else {
|
||||
return Config::get('languages.'.$model);
|
||||
}
|
||||
|
||||
})
|
||||
->addColumn('id', function ($model) {
|
||||
return $model;
|
||||
@@ -226,17 +229,16 @@ class LanguageController extends Controller
|
||||
if ($success) {
|
||||
//sending back with success message
|
||||
Session::flash('success', Lang::get('lang.delete-success'));
|
||||
|
||||
|
||||
return Redirect::back();
|
||||
} else {
|
||||
//sending back with error message
|
||||
Session::flash('fails', Lang::get('lang.lang-doesnot-exist'));
|
||||
|
||||
|
||||
return Redirect::back();
|
||||
}
|
||||
} else {
|
||||
Session::flash('fails', Lang::get('lang.lang-fallback-lang'));
|
||||
|
||||
return redirect('languages');
|
||||
}
|
||||
} else {
|
||||
@@ -245,4 +247,5 @@ class LanguageController extends Controller
|
||||
return redirect('languages');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,33 +5,61 @@ namespace App\Http\Controllers\Admin\helpdesk;
|
||||
// controllers
|
||||
use App\Http\Controllers\Common\NotificationController;
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Common\FileuploadController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CreateTicketRequest;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
use App\Http\Requests\helpdesk\PriorityRequest;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Form\Fields;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Manage\Sla_plan;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Notification\Notification;
|
||||
use App\Model\helpdesk\Notification\UserNotification;
|
||||
use App\Model\helpdesk\Settings\Alert;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Form_Data;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\Model\helpdesk\Utility\Date_time_format;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Exception;
|
||||
use ForceUTF8\Encoding;
|
||||
use GeoIP;
|
||||
// classes
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\support\Collection;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Mail;
|
||||
use PDF;
|
||||
use UTC;
|
||||
|
||||
/**
|
||||
* TicketController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PriorityController extends Controller
|
||||
{
|
||||
public function __construct(PhpMailController $PhpMailController, NotificationController $NotificationController)
|
||||
{
|
||||
class PriorityController extends Controller {
|
||||
|
||||
public function __construct(PhpMailController $PhpMailController, NotificationController $NotificationController) {
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
$this->NotificationController = $NotificationController;
|
||||
$this->middleware('auth');
|
||||
@@ -42,61 +70,57 @@ class PriorityController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function priorityIndex()
|
||||
{
|
||||
$user_status = CommonSettings::where('id', '=', 6)->first();
|
||||
public function priorityIndex() {
|
||||
$user_status=CommonSettings::where('option_name','=', 'user_priority')->first();
|
||||
// dd( $user_status);
|
||||
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.ticket_priority.index', compact('user_status'));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Show the Inbox ticket list page.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function userPriorityIndex(Request $request)
|
||||
{
|
||||
try {
|
||||
$user_status = $request->user_settings_priority;
|
||||
public function userPriorityIndex(Request $request) {
|
||||
try {
|
||||
$user_status= $request->user_settings_priority;
|
||||
|
||||
CommonSettings::where('option_name','=', 'user_priority')->update(['status' => $user_status]);
|
||||
|
||||
CommonSettings::where('id', '=', 6)->update(['status' => $user_status]);
|
||||
|
||||
return 'Your Status Updated';
|
||||
} catch (Exception $e) {
|
||||
return 'Your Status Updated';
|
||||
} catch (Exception $e) {
|
||||
return Redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function priorityIndex1()
|
||||
{
|
||||
public function priorityIndex1() {
|
||||
try {
|
||||
$ticket = new Ticket_Priority();
|
||||
$tickets = $ticket->select('priority_id', 'priority', 'priority_desc', 'priority_color', 'status', 'is_default', 'ispublic')->get();
|
||||
|
||||
return \Datatable::Collection($tickets)
|
||||
->showColumns('priority', 'priority_desc')
|
||||
->addColumn('priority_color', function ($model) {
|
||||
->addColumn('priority_color', function($model) {
|
||||
return "<button class='btn' style = 'background-color:$model->priority_color'></button>";
|
||||
})
|
||||
->addColumn('status', function ($model) {
|
||||
->addColumn('status', function($model) {
|
||||
if ($model->status == 1) {
|
||||
return "<a style='color:green'>active</a>";
|
||||
} elseif ($model->status == 0) {
|
||||
Ticket_Priority::where('priority_id', '=', '$priority_id')
|
||||
->update(['priority_id' => '']);
|
||||
|
||||
return "<a style='color:red'>inactive</a>";
|
||||
}
|
||||
})
|
||||
->addColumn('action', function ($model) {
|
||||
->addColumn('action', function($model) {
|
||||
if ($model->is_default > 0) {
|
||||
return '<a href='.url('ticket/priority/'.$model->priority_id.'/edit')." class='btn btn-info btn-xs' disabled='disabled'>Edit</a> <a href=".url('ticket_priority/'.$model->priority_id.'/destroy')." class='btn btn-warning btn-info btn-xs' disabled='disabled' > delete </a>";
|
||||
return "<a href=" . url('ticket/priority/' . $model->priority_id . '/edit') . " class='btn btn-info btn-xs' disabled='disabled'>Edit</a> <a href=" . url('ticket/priority/' . $model->priority_id . '/destroy') . " class='btn btn-warning btn-info btn-xs' disabled='disabled' > delete </a>";
|
||||
} else {
|
||||
return '<a href='.url('ticket/priority/'.$model->priority_id.'/edit')." class='btn btn-info btn-xs'>Edit</a> <a class='btn btn-danger btn-xs' onclick='confirmDelete(".$model->priority_id.")'>Delete </a>";
|
||||
return "<a href=" . url('ticket/priority/' . $model->priority_id . '/edit') . " class='btn btn-info btn-xs'>Edit</a> <a class='btn btn-danger btn-xs' onclick='confirmDelete(" . $model->priority_id . ")'>Delete </a>";
|
||||
}
|
||||
})
|
||||
->searchColumns('priority')
|
||||
@@ -108,45 +132,42 @@ class PriorityController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function priorityCreate()
|
||||
{
|
||||
public function priorityCreate() {
|
||||
return view('themes.default1.admin.helpdesk.manage.ticket_priority.create');
|
||||
}
|
||||
|
||||
public function priorityCreate1(PriorityRequest $request)
|
||||
{
|
||||
$tk_priority = new Ticket_Priority();
|
||||
public function priorityCreate1(PriorityRequest $request) {
|
||||
$tk_priority = new Ticket_Priority;
|
||||
$tk_priority->priority = $request->priority;
|
||||
$tk_priority->status = $request->status;
|
||||
$tk_priority->priority_desc = $request->priority_desc;
|
||||
$tk_priority->priority_color = $request->priority_color;
|
||||
$tk_priority->ispublic = $request->ispublic;
|
||||
$tk_priority->save();
|
||||
|
||||
return \Redirect::route('priority.index')->with('success', Lang::get('lang.priority_successfully_created'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $priority_id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function priorityEdit($priority_id)
|
||||
{
|
||||
$tk_priority = Ticket_Priority::wherepriority_id($priority_id)->first();
|
||||
|
||||
public function priorityEdit($priority_id) {
|
||||
|
||||
$tk_priority = Ticket_Priority::wherepriority_id($priority_id)->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.ticket_priority.edit', compact('tk_priority'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param PriorityRequest $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function priorityEdit1(PriorityRequest $request)
|
||||
{
|
||||
public function priorityEdit1(PriorityRequest $request) {
|
||||
$priority_id = $request->priority_id;
|
||||
$tk_priority = Ticket_Priority::findOrFail($priority_id);
|
||||
$tk_priority->priority = $request->priority;
|
||||
@@ -156,22 +177,21 @@ class PriorityController extends Controller
|
||||
$tk_priority->ispublic = $request->ispublic;
|
||||
$tk_priority->save();
|
||||
if ($request->input('default_priority') == 'on') {
|
||||
Ticket_Priority::where('is_default', '=', 1)
|
||||
Ticket_Priority::where('is_default', '>', 0)
|
||||
->update(['is_default' => 0]);
|
||||
Ticket_Priority::where('priority_id', '=', $priority_id)
|
||||
->update(['is_default' => 1]);
|
||||
}
|
||||
|
||||
return \Redirect::route('priority.index')->with('success', (Lang::get('lang.priority_successfully_updated')));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $priority_id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function destroy($priority_id)
|
||||
{
|
||||
public function destroy($priority_id) {
|
||||
|
||||
$default_priority = Ticket_Priority::where('is_default', '>', '0')->first();
|
||||
// dd($default_priority->is_default);
|
||||
$topic = DB::table('help_topic')->where('priority', '=', $priority_id)->update(['priority' => $default_priority->is_default]);
|
||||
@@ -192,4 +212,5 @@ class PriorityController extends Controller
|
||||
|
||||
return \Redirect::route('priority.index')->with('success', (Lang::get('lang.delete_successfully')));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CompanyRequest;
|
||||
use App\Http\Requests\helpdesk\EmailRequest;
|
||||
use App\Http\Requests\helpdesk\Job\TaskRequest;
|
||||
use App\Http\Requests\helpdesk\RatingUpdateRequest;
|
||||
use App\Http\Requests\helpdesk\StatusRequest;
|
||||
// models
|
||||
use App\Http\Requests\helpdesk\SystemRequest;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Email\Template;
|
||||
@@ -20,10 +19,9 @@ use App\Model\helpdesk\Manage\Sla_plan;
|
||||
use App\Model\helpdesk\Notification\UserNotification;
|
||||
use App\Model\helpdesk\Ratings\Rating;
|
||||
use App\Model\helpdesk\Settings\Alert;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Settings\Followup;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Settings\Responder;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Ticket;
|
||||
@@ -33,29 +31,30 @@ use App\Model\helpdesk\Utility\Date_time_format;
|
||||
use App\Model\helpdesk\Utility\Time_format;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use App\Model\helpdesk\Workflow\WorkflowClose;
|
||||
// classes
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use DateTime;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use File;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Http\Requests\helpdesk\Job\TaskRequest;
|
||||
|
||||
/**
|
||||
* SettingsController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
class SettingsController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
// $this->smtp();
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
@@ -69,8 +68,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getcompany(Company $company)
|
||||
{
|
||||
public function getcompany(Company $company) {
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$companys = $company->whereId('1')->first();
|
||||
@@ -90,14 +88,13 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function postcompany($id, Company $company, CompanyRequest $request)
|
||||
{
|
||||
public function postcompany($id, Company $company, CompanyRequest $request) {
|
||||
/* fetch the values of company request */
|
||||
$companys = $company->whereId('1')->first();
|
||||
if (Input::file('logo')) {
|
||||
$name = Input::file('logo')->getClientOriginalName();
|
||||
$destinationPath = 'uploads/company/';
|
||||
$fileName = rand(0000, 9999).'.'.$name;
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
Input::file('logo')->move($destinationPath, $fileName);
|
||||
$companys->logo = $fileName;
|
||||
}
|
||||
@@ -111,7 +108,7 @@ class SettingsController extends Controller
|
||||
return redirect('getcompany')->with('success', Lang::get('lang.company_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,8 +117,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function deleteLogo()
|
||||
{
|
||||
public function deleteLogo() {
|
||||
$path = $_GET['data1']; //get file path of logo image
|
||||
if (!unlink($path)) {
|
||||
return 'false';
|
||||
@@ -148,8 +144,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time, CommonSettings $common_settings)
|
||||
{
|
||||
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time, CommonSettings $common_settings) {
|
||||
try {
|
||||
/* fetch the values of system from system table */
|
||||
$systems = $system->whereId('1')->first();
|
||||
@@ -183,8 +178,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postsystem($id, System $system, SystemRequest $request)
|
||||
{
|
||||
public function postsystem($id, System $system, SystemRequest $request) {
|
||||
try {
|
||||
/* fetch the values of system request */
|
||||
$systems = $system->whereId('1')->first();
|
||||
@@ -208,11 +202,18 @@ class SettingsController extends Controller
|
||||
->update(['status' => $request->send_otp]);
|
||||
$email_mandatory = CommonSettings::where('option_name', '=', 'email_mandatory')
|
||||
->update(['status' => $request->email_mandatory]);
|
||||
|
||||
if($request->has('itil')){
|
||||
$itil = $request->input('itil');
|
||||
$sett = CommonSettings::firstOrCreate(['option_name'=>'itil']);
|
||||
$sett->status = $itil;
|
||||
$sett->save();
|
||||
}
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated').'<br>'.$e->getMessage());
|
||||
return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated') . '<br>' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,8 +227,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority)
|
||||
{
|
||||
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) {
|
||||
try {
|
||||
/* fetch the values of ticket from ticket table */
|
||||
$tickets = $ticket->whereId('1')->first();
|
||||
@@ -251,8 +251,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postticket($id, Ticket $ticket, Request $request)
|
||||
{
|
||||
public function postticket($id, Ticket $ticket, Request $request) {
|
||||
try {
|
||||
/* fetch the values of ticket request */
|
||||
$tickets = $ticket->whereId('1')->first();
|
||||
@@ -273,7 +272,7 @@ class SettingsController extends Controller
|
||||
return redirect('getticket')->with('success', Lang::get('lang.ticket_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,8 +285,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getemail(Email $email, Template $template, Emails $email1)
|
||||
{
|
||||
public function getemail(Email $email, Template $template, Emails $email1) {
|
||||
try {
|
||||
/* fetch the values of email from Email table */
|
||||
$emails = $email->whereId('1')->first();
|
||||
@@ -311,8 +309,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postemail($id, Email $email, EmailRequest $request)
|
||||
{
|
||||
public function postemail($id, Email $email, EmailRequest $request) {
|
||||
try {
|
||||
/* fetch the values of email request */
|
||||
$emails = $email->whereId('1')->first();
|
||||
@@ -331,7 +328,7 @@ class SettingsController extends Controller
|
||||
return redirect('getemail')->with('success', Lang::get('lang.email_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,8 +341,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getSchedular(Email $email, Template $template, Emails $email1, WorkflowClose $workflow)
|
||||
{
|
||||
public function getSchedular(Email $email, Template $template, Emails $email1, WorkflowClose $workflow) {
|
||||
// try {
|
||||
/* fetch the values of email from Email table */
|
||||
$emails = $email->whereId('1')->first();
|
||||
@@ -356,45 +352,43 @@ class SettingsController extends Controller
|
||||
|
||||
$workflow = $workflow->whereId('1')->first();
|
||||
$cron_path = base_path('artisan');
|
||||
$command = ":- <pre>***** php $cron_path schedule:run > /dev/null 2>&1</pre>";
|
||||
$shared = ":- <pre>/usr/bin/php-cli -q $cron_path schedule:run > /dev/null 2>&1</pre>";
|
||||
$warn = '';
|
||||
$command = ":- <pre>***** php $cron_path schedule:run >> /dev/null 2>&1</pre>";
|
||||
$shared = ":- <pre>/usr/bin/php-cli -q $cron_path schedule:run >> /dev/null 2>&1</pre>";
|
||||
$warn = "";
|
||||
$condition = new \App\Model\MailJob\Condition();
|
||||
$job = $condition->checkActiveJob();
|
||||
$commands = [
|
||||
'' => 'Select',
|
||||
'everyMinute' => 'Every Minute',
|
||||
'everyFiveMinutes' => 'Every Five Minute',
|
||||
'everyTenMinutes' => 'Every Ten Minute',
|
||||
'' => 'Select',
|
||||
'everyMinute' => 'Every Minute',
|
||||
'everyFiveMinutes' => 'Every Five Minute',
|
||||
'everyTenMinutes' => 'Every Ten Minute',
|
||||
'everyThirtyMinutes' => 'Every Thirty Minute',
|
||||
'hourly' => 'Every Hour',
|
||||
'daily' => 'Every Day',
|
||||
'dailyAt' => 'Daily at',
|
||||
'weekly' => 'Every Week',
|
||||
'monthly' => 'Monthly',
|
||||
'yearly' => 'Yearly',
|
||||
'hourly' => 'Every Hour',
|
||||
'daily' => 'Every Day',
|
||||
'dailyAt' => 'Daily at',
|
||||
'weekly' => 'Every Week',
|
||||
'monthly' => 'Monthly',
|
||||
'yearly' => 'Yearly',
|
||||
];
|
||||
$followupcommands = [
|
||||
'' => 'Select',
|
||||
'everyMinute' => 'Every Minute',
|
||||
'everyFiveMinutes' => 'Every Five Minute',
|
||||
'everyTenMinutes' => 'Every Ten Minute',
|
||||
'' => 'Select',
|
||||
'everyMinute' => 'Every Minute',
|
||||
'everyFiveMinutes' => 'Every Five Minute',
|
||||
'everyTenMinutes' => 'Every Ten Minute',
|
||||
'everyThirtyMinutes' => 'Every Thirty Minute',
|
||||
'hourly' => 'Every Hour',
|
||||
'daily' => 'Every Day',
|
||||
'weekly' => 'Every Week',
|
||||
'monthly' => 'Monthly',
|
||||
'yearly' => 'Yearly',
|
||||
'hourly' => 'Every Hour',
|
||||
'daily' => 'Every Day',
|
||||
'weekly' => 'Every Week',
|
||||
'monthly' => 'Monthly',
|
||||
'yearly' => 'Yearly',
|
||||
];
|
||||
if (ini_get('register_argc_argv') == '') {
|
||||
if (ini_get('register_argc_argv') == "") {
|
||||
//$warn = "Please make 'register_argc_argv' flag as on. Or you can set all your job url in cron";
|
||||
}
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands', 'followupcommands', 'condition', 'shared'));
|
||||
return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands','followupcommands','condition','shared'));
|
||||
// } catch {
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified schedular in storage for cron job.
|
||||
*
|
||||
@@ -403,16 +397,18 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postSchedular(Email $email, Template $template, Followup $followup, Emails $email1, TaskRequest $request, WorkflowClose $workflow)
|
||||
{
|
||||
public function postSchedular(Email $email, Template $template, Followup $followup, Emails $email1, TaskRequest $request, WorkflowClose $workflow) {
|
||||
try {
|
||||
$followup = $followup->whereId('1')->first();
|
||||
$status = $request->followup_notification_cron;
|
||||
|
||||
if ($status = 'null') {
|
||||
$followup=$followup->whereId('1')->first();
|
||||
$status=$request->followup_notification_cron;
|
||||
|
||||
if ($status='null') {
|
||||
|
||||
$followup->status = $request->followup_notification_cron;
|
||||
|
||||
}
|
||||
if ($status = 1) {
|
||||
if($status= 1) {
|
||||
$followup->status = $request->followup_notification_cron;
|
||||
$followup->condition = $request->followup_notification_commands;
|
||||
$followup->save();
|
||||
@@ -448,7 +444,7 @@ class SettingsController extends Controller
|
||||
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>');
|
||||
return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,8 +455,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getresponder(Responder $responder)
|
||||
{
|
||||
public function getresponder(Responder $responder) {
|
||||
try {
|
||||
/* fetch the values of responder from responder table */
|
||||
$responders = $responder->whereId('1')->first();
|
||||
@@ -479,8 +474,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function postresponder(Responder $responder, Request $request)
|
||||
{
|
||||
public function postresponder(Responder $responder, Request $request) {
|
||||
try {
|
||||
/* fetch the values of responder request */
|
||||
$responders = $responder->whereId('1')->first();
|
||||
@@ -497,7 +491,7 @@ class SettingsController extends Controller
|
||||
return redirect('getresponder')->with('success', Lang::get('lang.auto_response_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,8 +502,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getalert(Alert $alert)
|
||||
{
|
||||
public function getalert(Alert $alert) {
|
||||
try {
|
||||
/* fetch the values of alert from alert table */
|
||||
$alerts = $alert->whereId('1')->first();
|
||||
@@ -529,8 +522,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postalert($id, Alert $alert, Request $request)
|
||||
{
|
||||
public function postalert($id, Alert $alert, Request $request) {
|
||||
try {
|
||||
/* fetch the values of alert request */
|
||||
$alerts = $alert->whereId('1')->first();
|
||||
@@ -585,7 +577,7 @@ class SettingsController extends Controller
|
||||
return redirect('getalert')->with('success', Lang::get('lang.alert_&_notices_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,8 +586,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function generateApiKey()
|
||||
{
|
||||
public function generateApiKey() {
|
||||
$key = str_random(32);
|
||||
|
||||
return $key;
|
||||
@@ -606,8 +597,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
public function settings() {
|
||||
return view('themes.default1.admin.helpdesk.setting');
|
||||
}
|
||||
|
||||
@@ -619,8 +609,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getStatuses()
|
||||
{
|
||||
public function getStatuses() {
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$statuss = \DB::table('ticket_status')->get();
|
||||
@@ -639,8 +628,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getEditStatuses($id)
|
||||
{
|
||||
public function getEditStatuses($id) {
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$status = \DB::table('ticket_status')->where('id', '=', $id)->first();
|
||||
@@ -659,8 +647,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function editStatuses($id, StatusRequest $request)
|
||||
{
|
||||
public function editStatuses($id, StatusRequest $request) {
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first();
|
||||
@@ -691,8 +678,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request)
|
||||
{
|
||||
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request) {
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$statuss->name = $request->input('name');
|
||||
@@ -721,8 +707,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function deleteStatuses($id)
|
||||
{
|
||||
public function deleteStatuses($id) {
|
||||
try {
|
||||
if ($id > 5) {
|
||||
/* fetch the values of company from company table */
|
||||
@@ -742,8 +727,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function notificationSettings()
|
||||
{
|
||||
public function notificationSettings() {
|
||||
return view('themes.default1.admin.helpdesk.settings.notification');
|
||||
}
|
||||
|
||||
@@ -752,8 +736,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function deleteReadNoti()
|
||||
{
|
||||
public function deleteReadNoti() {
|
||||
$markasread = UserNotification::where('is_read', '=', 1)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->delete();
|
||||
@@ -768,14 +751,13 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function deleteNotificationLog()
|
||||
{
|
||||
public function deleteNotificationLog() {
|
||||
$days = Input::get('no_of_days');
|
||||
if ($days == null) {
|
||||
return redirect()->back()->with('fails', 'Please enter valid no of days');
|
||||
}
|
||||
$date = new DateTime();
|
||||
$date->modify($days.' day');
|
||||
$date->modify($days . ' day');
|
||||
$formatted_date = $date->format('Y-m-d H:i:s');
|
||||
$markasread = UserNotification::where('created_at', '<=', $formatted_date)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
@@ -783,7 +765,7 @@ class SettingsController extends Controller
|
||||
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_notification_records_since').$days.' days.');
|
||||
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_notification_records_since') . $days . ' days.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -791,8 +773,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type View
|
||||
*/
|
||||
public function RatingSettings()
|
||||
{
|
||||
public function RatingSettings() {
|
||||
try {
|
||||
$ratings = Rating::orderBy('display_order', 'asc')->get();
|
||||
|
||||
@@ -809,8 +790,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function editRatingSettings($id)
|
||||
{
|
||||
public function editRatingSettings($id) {
|
||||
try {
|
||||
$rating = Rating::whereId($id)->first();
|
||||
|
||||
@@ -825,8 +805,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request)
|
||||
{
|
||||
public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request) {
|
||||
try {
|
||||
$rating = $ratings->whereId($id)->first();
|
||||
$rating->name = $request->input('name');
|
||||
@@ -848,12 +827,11 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function createRating()
|
||||
{
|
||||
public function createRating() {
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.settings.create-ratings');
|
||||
} catch (Exception $ex) {
|
||||
return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created').'<li>'.$ex->getMessage().'</li>');
|
||||
return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created') . '<li>' . $ex->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -866,8 +844,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request)
|
||||
{
|
||||
public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request) {
|
||||
$rating->name = $request->input('name');
|
||||
$rating->display_order = $request->input('display_order');
|
||||
$rating->allow_modification = $request->input('allow_modification');
|
||||
@@ -886,16 +863,13 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs)
|
||||
{
|
||||
public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs) {
|
||||
$ratingrefs->where('rating_id', '=', $slug)->delete();
|
||||
Rating::whereId($slug)->delete();
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.rating_deleted_successfully'));
|
||||
}
|
||||
|
||||
public function saveConditions()
|
||||
{
|
||||
public function saveConditions() {
|
||||
if (\Input::get('fetching-commands') && \Input::get('notification-commands')) {
|
||||
$fetching_commands = \Input::get('fetching-commands');
|
||||
$fetching_dailyAt = \Input::get('fetching-dailyAt');
|
||||
@@ -906,66 +880,62 @@ class SettingsController extends Controller
|
||||
$fetching_command = $this->getCommand($fetching_commands, $fetching_dailyAt);
|
||||
$notification_command = $this->getCommand($notification_commands, $notification_dailyAt);
|
||||
$work_command = $this->getCommand($work_commands, $workflow_dailyAt);
|
||||
$jobs = ['fetching' => $fetching_command, 'notification' => $notification_command, 'work' => $work_command];
|
||||
$jobs = ['fetching'=>$fetching_command,'notification'=>$notification_command,'work'=>$work_command];
|
||||
$this->storeCommand($jobs);
|
||||
}
|
||||
}
|
||||
|
||||
public function getCommand($command, $daily_at)
|
||||
{
|
||||
public function getCommand($command, $daily_at) {
|
||||
|
||||
|
||||
if ($command == 'dailyAt') {
|
||||
$command = "dailyAt,$daily_at";
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
public function storeCommand($array = [])
|
||||
{
|
||||
|
||||
public function storeCommand($array=[]){
|
||||
$command = new \App\Model\MailJob\Condition();
|
||||
$commands = $command->get();
|
||||
if ($commands->count() > 0) {
|
||||
foreach ($commands as $condition) {
|
||||
if($commands->count()>0){
|
||||
foreach($commands as $condition){
|
||||
$condition->delete();
|
||||
}
|
||||
}
|
||||
if (count($array) > 0) {
|
||||
foreach ($array as $key => $save) {
|
||||
if(count($array)>0){
|
||||
foreach($array as $key=>$save){
|
||||
$command->create([
|
||||
'job' => $key,
|
||||
'value' => $save,
|
||||
'job'=>$key,
|
||||
'value'=>$save,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getTicketNumber(Request $request)
|
||||
{
|
||||
public function getTicketNumber(Request $request) {
|
||||
$this->validate($request, [
|
||||
'format' => ['required', 'regex:/^(?=.*[$|-|#]).+$/'],
|
||||
'type' => 'required',
|
||||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$format = $request->input('format');
|
||||
$type = $request->input('type');
|
||||
$number = $this->switchNumber($format, $type);
|
||||
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function switchNumber($format, $type)
|
||||
{
|
||||
public function switchNumber($format, $type) {
|
||||
switch ($type) {
|
||||
case 'random':
|
||||
case "random":
|
||||
return $this->createRandomNumber($format);
|
||||
case 'sequence':
|
||||
case "sequence":
|
||||
return $this->createSequencialNumber($format);
|
||||
}
|
||||
}
|
||||
|
||||
public function createRandomNumber($format)
|
||||
{
|
||||
$number = '';
|
||||
public function createRandomNumber($format) {
|
||||
$number = "";
|
||||
$array = str_split($format);
|
||||
for ($i = 0; $i < count($array); $i++) {
|
||||
if ($array[$i] === '$') {
|
||||
@@ -978,13 +948,11 @@ class SettingsController extends Controller
|
||||
$number .= $array[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function createSequencialNumber($format)
|
||||
{
|
||||
$number = '';
|
||||
public function createSequencialNumber($format) {
|
||||
$number = "";
|
||||
$array_format = str_split($format);
|
||||
$count = count($array_format);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
@@ -997,17 +965,16 @@ class SettingsController extends Controller
|
||||
$number .= '0';
|
||||
}
|
||||
|
||||
|
||||
if ($array_format[$i] !== '$' && $array_format[$i] !== '#') {
|
||||
$number .= $array_format[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $number;
|
||||
//return $this->nthTicketNumber($number);
|
||||
}
|
||||
|
||||
public function checkCurrentFormat($current, $format)
|
||||
{
|
||||
public function checkCurrentFormat($current, $format) {
|
||||
$check = true;
|
||||
$array_current = str_split($current);
|
||||
$array_format = str_split($format);
|
||||
@@ -1021,12 +988,11 @@ class SettingsController extends Controller
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function nthTicketNumber($current, $type, $format, $force = false)
|
||||
{
|
||||
public function nthTicketNumber($current, $type, $format, $force = false) {
|
||||
|
||||
$check = $this->checkCurrentFormat($current, $format);
|
||||
if ($check === false && $force === false) {
|
||||
$current = $this->createSequencialNumber($format);
|
||||
@@ -1046,17 +1012,16 @@ class SettingsController extends Controller
|
||||
if ($type === 'random') {
|
||||
$number = $this->createRandomNumber($format);
|
||||
}
|
||||
|
||||
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function getRandomAlphebet()
|
||||
{
|
||||
$alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
public function getRandomAlphebet() {
|
||||
$alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
$shuffled = str_shuffle($alpha);
|
||||
$shuffled_array = str_split($shuffled);
|
||||
$char = $shuffled_array[0];
|
||||
|
||||
return $char;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,87 +2,76 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk\SocialMedia;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Settings\SocialMedia;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use App\Model\helpdesk\Settings\SocialMedia;
|
||||
|
||||
class SocialMediaController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
class SocialMediaController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware(['auth', 'roles'], ['except' => ['configService']]);
|
||||
}
|
||||
|
||||
public function settings($provider)
|
||||
{
|
||||
public function settings($provider) {
|
||||
try {
|
||||
$social = new SocialMedia();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.social-media.settings', compact('social', 'provider'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postSettings($provider, Request $request)
|
||||
{
|
||||
public function postSettings($provider, Request $request) {
|
||||
$this->validate($request, [
|
||||
'client_id' => 'required',
|
||||
'client_id' => 'required',
|
||||
'client_secret' => 'required',
|
||||
'redirect' => 'required|url',
|
||||
'redirect' => 'required|url',
|
||||
]);
|
||||
try {
|
||||
$requests = $request->except('_token');
|
||||
$this->insertProvider($provider, $requests);
|
||||
|
||||
return redirect()->back()->with('success', 'Updated');
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProvider($provider, $requests)
|
||||
{
|
||||
public function deleteProvider($provider, $requests) {
|
||||
$social = new SocialMedia();
|
||||
$socials = $social->where('provider', $provider)->get();
|
||||
if ($socials->count() > 0) {
|
||||
foreach ($socials as $media) {
|
||||
if (array_key_exists($media->key, $requests)) {
|
||||
if (array_key_exists($media->key,$requests)) {
|
||||
$media->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function insertProvider($provider, $requests = [])
|
||||
{
|
||||
public function insertProvider($provider, $requests = []) {
|
||||
$this->deleteProvider($provider, $requests);
|
||||
$social = new SocialMedia();
|
||||
foreach ($requests as $key => $value) {
|
||||
$social->create([
|
||||
'provider' => $provider,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
try {
|
||||
$social = new SocialMedia();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.social-media.index', compact('social'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function configService()
|
||||
{
|
||||
public function configService() {
|
||||
$social = new SocialMedia();
|
||||
$services = $this->services();
|
||||
foreach ($services as $service) {
|
||||
@@ -93,8 +82,7 @@ class SocialMediaController extends Controller
|
||||
// dd(\Config::get('services'));
|
||||
}
|
||||
|
||||
public function services()
|
||||
{
|
||||
public function services() {
|
||||
return [
|
||||
'facebook',
|
||||
'google',
|
||||
@@ -104,4 +92,5 @@ class SocialMediaController extends Controller
|
||||
'bitbucket',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ use App\Http\Requests\helpdesk\TeamRequest;
|
||||
use App\Http\Requests\helpdesk\TeamUpdate;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Assign_team_agent;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Agent\Groups;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\User;
|
||||
// classes
|
||||
use DB;
|
||||
@@ -102,8 +102,7 @@ class TeamController extends Controller
|
||||
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_create').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param type $id
|
||||
@@ -118,76 +117,79 @@ class TeamController extends Controller
|
||||
try {
|
||||
$user = $user->whereId($id)->first();
|
||||
$teams = $team->whereId($id)->first();
|
||||
|
||||
|
||||
// $team_lead_name=User::whereId($teams->team_lead)->first();
|
||||
|
||||
|
||||
// $team_lead = $team_lead_name->first_name . " " . $team_lead_name->last_name;
|
||||
|
||||
|
||||
// $total_members = $assign_team_agent->where('team_id',$id)->count();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.teams.show', compact('user', 'teams', 'id'));
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.teams.show', compact('user', 'teams','id'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getshow($id)
|
||||
{
|
||||
// dd($request);
|
||||
|
||||
public function getshow($id) {
|
||||
// dd($request);
|
||||
|
||||
// $id = $request->input('show_id');
|
||||
|
||||
// dd($id);
|
||||
|
||||
$users = DB::table('team_assign_agent')->select('team_assign_agent.id', 'team_assign_agent.team_id', 'users.user_name', 'users.first_name', 'users.last_name', 'users.active', 'users.assign_group', 'users.primary_dpt', 'users.role')
|
||||
->join('users', 'users.id', '=', 'team_assign_agent.agent_id')
|
||||
->where('team_assign_agent.team_id', '=', $id);
|
||||
|
||||
$users = DB::table('team_assign_agent')->select('team_assign_agent.id','team_assign_agent.team_id','users.user_name','users.first_name' ,'users.last_name','users.active','users.assign_group','users.primary_dpt','users.role')
|
||||
->join('users','users.id','=','team_assign_agent.agent_id')
|
||||
->where('team_assign_agent.team_id', '=',$id);
|
||||
// ->get();
|
||||
// dd($users);
|
||||
return \Datatable::query($users)
|
||||
->showColumns('user_name')
|
||||
|
||||
->addColumn('first_name', function ($model) {
|
||||
->addColumn('first_name', function($model) {
|
||||
|
||||
$full_name = ucfirst($model->first_name).' '.ucfirst($model->last_name);
|
||||
return $full_name;
|
||||
})
|
||||
|
||||
return $full_name;
|
||||
})
|
||||
|
||||
->addColumn('active', function ($model) {
|
||||
->addColumn('active', function($model) {
|
||||
if ($model->active == '1') {
|
||||
$role = "<a class='btn btn-success btn-xs'>".'Active'.'</a>';
|
||||
$role = "<a class='btn btn-success btn-xs'>".'Active'."</a>";
|
||||
} elseif ($model->active == 'agent') {
|
||||
$role = "<a class='btn btn-primary btn-xs'>".'Inactive'.'</a>';
|
||||
$role = "<a class='btn btn-primary btn-xs'>".'Inactive'."</a>";
|
||||
}
|
||||
return $role;
|
||||
})
|
||||
|
||||
return $role;
|
||||
})
|
||||
|
||||
->addColumn('assign_group', function ($model) {
|
||||
$group = Groups::whereId($model->assign_group)->first();
|
||||
|
||||
return $group->name;
|
||||
})
|
||||
->addColumn('primary_dpt', function ($model) {
|
||||
$dept = Department::whereId($model->primary_dpt)->first();
|
||||
|
||||
return $dept->name;
|
||||
})
|
||||
->addColumn('role', function ($model) {
|
||||
->addColumn('assign_group', function($model) {
|
||||
$group=Groups::whereId($model->assign_group)->first();
|
||||
return ($group->name);
|
||||
})
|
||||
->addColumn('primary_dpt', function($model) {
|
||||
$dept=Department::whereId($model->primary_dpt)->first();
|
||||
return $dept->name;
|
||||
})
|
||||
->addColumn('role', function($model) {
|
||||
if ($model->role == 'admin') {
|
||||
$role = "<a class='btn btn-success btn-xs'>".$model->role.'</a>';
|
||||
$role = "<a class='btn btn-success btn-xs'>".$model->role."</a>";
|
||||
} elseif ($model->role == 'agent') {
|
||||
$role = "<a class='btn btn-primary btn-xs'>".$model->role.'</a>';
|
||||
$role = "<a class='btn btn-primary btn-xs'>".$model->role."</a>";
|
||||
}
|
||||
|
||||
return $role;
|
||||
})
|
||||
return $role;
|
||||
})
|
||||
|
||||
// ->showColumns('role')
|
||||
->searchColumns('first_name', 'last_name')
|
||||
->orderColumns('first_name', 'last_name')
|
||||
->searchColumns('first_name','last_name')
|
||||
->orderColumns('first_name','last_name')
|
||||
->make();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
|
||||
@@ -13,25 +13,26 @@ use App\Http\Requests\helpdesk\TemplateUdate;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Email\Template;
|
||||
use App\Model\helpdesk\Utility\Languages;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* TemplateController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class TemplateController extends Controller
|
||||
{
|
||||
class TemplateController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public function __construct(PhpMailController $PhpMailController)
|
||||
{
|
||||
public function __construct(PhpMailController $PhpMailController) {
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
@@ -44,8 +45,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function index(Template $template)
|
||||
{
|
||||
public function index(Template $template) {
|
||||
try {
|
||||
$templates = $template->get();
|
||||
|
||||
@@ -63,8 +63,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(Languages $language, Template $template)
|
||||
{
|
||||
public function create(Languages $language, Template $template) {
|
||||
try {
|
||||
$templates = $template->get();
|
||||
$languages = $language->get();
|
||||
@@ -83,8 +82,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function store(Template $template, TemplateRequest $request)
|
||||
{
|
||||
public function store(Template $template, TemplateRequest $request) {
|
||||
try {
|
||||
/* Check whether function success or not */
|
||||
if ($template->fill($request->input())->save() == true) {
|
||||
@@ -107,8 +105,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
public function show($id) {
|
||||
//
|
||||
}
|
||||
|
||||
@@ -121,41 +118,37 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function listdirectories()
|
||||
{
|
||||
$path = \Config::get('view.paths')[0].'/emails/';
|
||||
public function listdirectories() {
|
||||
$path = \Config::get('view.paths')[0] . '/emails/';
|
||||
$directories = scandir($path);
|
||||
$directory = str_replace('/', '-', $path);
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.template.listdirectories', compact('directories', 'directory'));
|
||||
}
|
||||
|
||||
public function listtemplates($template, $path)
|
||||
{
|
||||
public function listtemplates($template, $path) {
|
||||
$paths = str_replace('-', '/', $path);
|
||||
$directory2 = $paths.$template;
|
||||
$directory2 = $paths . $template;
|
||||
|
||||
$templates = scandir($directory2);
|
||||
$directory = str_replace('/', '-', $directory2.'/');
|
||||
$directory = str_replace('/', '-', $directory2 . '/');
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates', 'directory'));
|
||||
}
|
||||
|
||||
public function readtemplate($template, $path)
|
||||
{
|
||||
public function readtemplate($template, $path) {
|
||||
$directory = str_replace('-', '/', $path);
|
||||
$handle = fopen($directory.$template, 'r');
|
||||
$contents = fread($handle, filesize($directory.$template));
|
||||
$handle = fopen($directory . $template, 'r');
|
||||
$contents = fread($handle, filesize($directory . $template));
|
||||
fclose($handle);
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.template.readtemplates', compact('contents', 'template', 'path'));
|
||||
}
|
||||
|
||||
public function createtemplate()
|
||||
{
|
||||
public function createtemplate() {
|
||||
$directory = '../resources/views/emails/';
|
||||
$fname = Input::get('folder_name');
|
||||
$filename = $directory.$fname;
|
||||
$filename = $directory . $fname;
|
||||
|
||||
// images folder creation using php
|
||||
// $mydir = dirname( __FILE__ )."/html/images";
|
||||
@@ -167,7 +160,7 @@ class TemplateController extends Controller
|
||||
if (!file_exists($filename)) {
|
||||
mkdir($filename, 0777);
|
||||
}
|
||||
$files = array_filter(scandir($directory.'default'));
|
||||
$files = array_filter(scandir($directory . 'default'));
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($file === '.' or $file === '..') {
|
||||
@@ -175,29 +168,27 @@ class TemplateController extends Controller
|
||||
}
|
||||
if (!is_dir($file)) {
|
||||
// $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file);
|
||||
$destination = $directory.$fname.'/';
|
||||
$destination = $directory . $fname . '/';
|
||||
|
||||
copy($directory.'default/'.$file, $destination.$file);
|
||||
copy($directory . 'default/' . $file, $destination . $file);
|
||||
}
|
||||
}
|
||||
|
||||
return \Redirect::back()->with('success', 'Successfully copied');
|
||||
}
|
||||
|
||||
public function writetemplate($template, $path)
|
||||
{
|
||||
public function writetemplate($template, $path) {
|
||||
$directory = str_replace('-', '/', $path);
|
||||
$b = Input::get('templatedata');
|
||||
|
||||
file_put_contents($directory.$template, print_r($b, true));
|
||||
file_put_contents($directory . $template, print_r($b, true));
|
||||
|
||||
return \Redirect::back()->with('success', 'Successfully updated');
|
||||
}
|
||||
|
||||
public function deletetemplate($template, $path)
|
||||
{
|
||||
public function deletetemplate($template, $path) {
|
||||
$directory = str_replace('-', '/', $path);
|
||||
$dir = $directory.$template;
|
||||
$dir = $directory . $template;
|
||||
$status = \DB::table('settings_email')->first();
|
||||
if ($template == 'default' or $template == $status->template) {
|
||||
return \Redirect::back()->with('fails', 'You cannot delete a default or active directory!');
|
||||
@@ -206,7 +197,7 @@ class TemplateController extends Controller
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != '.' && $object != '..') {
|
||||
unlink($dir.'/'.$object);
|
||||
unlink($dir . '/' . $object);
|
||||
}
|
||||
}
|
||||
rmdir($dir);
|
||||
@@ -217,15 +208,13 @@ class TemplateController extends Controller
|
||||
return \Redirect::back()->with('success', 'Successfully Deleted');
|
||||
}
|
||||
|
||||
public function activateset($setname)
|
||||
{
|
||||
public function activateset($setname) {
|
||||
\DB::table('settings_email')->update(['template' => $setname]);
|
||||
|
||||
return \Redirect::back()->with('success', 'You have Successfully Activated this Set');
|
||||
}
|
||||
|
||||
public function edit($id, Template $template, Languages $language)
|
||||
{
|
||||
public function edit($id, Template $template, Languages $language) {
|
||||
try {
|
||||
$templates = $template->whereId($id)->first();
|
||||
$languages = $language->get();
|
||||
@@ -245,8 +234,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, Template $template, TemplateUdate $request)
|
||||
{
|
||||
public function update($id, Template $template, TemplateUdate $request) {
|
||||
try {
|
||||
//TODO validation
|
||||
$templates = $template->whereId($id)->first();
|
||||
@@ -272,8 +260,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function destroy($id, Template $template)
|
||||
{
|
||||
public function destroy($id, Template $template) {
|
||||
try {
|
||||
$templates = $template->whereId($id)->first();
|
||||
/* Check whether function success or not */
|
||||
@@ -297,8 +284,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function formDiagno(Emails $email)
|
||||
{
|
||||
public function formDiagno(Emails $email) {
|
||||
try {
|
||||
$emails = $email->get();
|
||||
|
||||
@@ -315,8 +301,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function postDiagno(DiagnosRequest $request)
|
||||
{
|
||||
public function postDiagno(DiagnosRequest $request) {
|
||||
try {
|
||||
$to = $request->input('to');
|
||||
$subject = $request->input('subject');
|
||||
@@ -328,13 +313,12 @@ class TemplateController extends Controller
|
||||
}
|
||||
$controller = new PhpMailController();
|
||||
$controller->setMailConfig($from_address);
|
||||
$controller->laravelMail($to, '', $subject, $msg, [], null);
|
||||
|
||||
$controller->laravelMail($to, '', $subject, $msg,[],null);
|
||||
return redirect()->back()->with('success', 'Mail has send successfully');
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,116 +2,104 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UrlSettingController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
class UrlSettingController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function settings(Request $request)
|
||||
{
|
||||
public function settings(Request $request) {
|
||||
$url = $request->url();
|
||||
$www = $this->checkWWW($url);
|
||||
$https = $this->checkHTTP($url);
|
||||
//dd($www, $https);
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.settings.url.settings', compact('www', 'https'));
|
||||
return view('themes.default1.admin.helpdesk.settings.url.settings',compact('www','https'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postSettings(Request $request)
|
||||
{
|
||||
public function postSettings(Request $request) {
|
||||
try {
|
||||
$www = $request->input('www');
|
||||
$ssl = $request->input('ssl');
|
||||
$string_www = $this->www($www);
|
||||
$sting_ssl = $this->ssl($ssl);
|
||||
$string = $string_www.$sting_ssl;
|
||||
$string = $string_www . $sting_ssl;
|
||||
$this->writeHtaccess($string);
|
||||
|
||||
return redirect()->back()->with('success', 'updated');
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function www($www)
|
||||
{
|
||||
public function www($www) {
|
||||
switch ($www) {
|
||||
case 'yes':
|
||||
case "yes":
|
||||
return $this->changeWww();
|
||||
case 'no':
|
||||
case "no":
|
||||
return $this->changeNonwww();
|
||||
}
|
||||
}
|
||||
|
||||
public function changeWww()
|
||||
{
|
||||
public function changeWww() {
|
||||
$string = "RewriteCond %{HTTP_HOST} !^www\.
|
||||
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function changeNonwww()
|
||||
{
|
||||
// $string = "\nRewriteEngine On
|
||||
//RewriteBase /
|
||||
//RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
|
||||
//RewriteRule ^(.*)$ http://%1/$1 [R=301,L]\n";
|
||||
$string = '';
|
||||
|
||||
public function changeNonwww() {
|
||||
$string = "RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
|
||||
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]\n";
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function ssl($ssl)
|
||||
{
|
||||
public function ssl($ssl) {
|
||||
switch ($ssl) {
|
||||
case 'yes':
|
||||
case "yes":
|
||||
return $this->changeHttps();
|
||||
case 'no':
|
||||
case "no":
|
||||
return $this->changeHttp();
|
||||
}
|
||||
}
|
||||
|
||||
public function changeHttps()
|
||||
{
|
||||
public function changeHttps() {
|
||||
$string = "RewriteCond %{HTTPS} off
|
||||
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function changeHttp()
|
||||
{
|
||||
public function changeHttp() {
|
||||
//$string = "RewriteCond %{HTTPS} off
|
||||
//RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
$string = '';
|
||||
|
||||
$string = "";
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function writeHtaccess($string)
|
||||
{
|
||||
public function writeHtaccess($string) {
|
||||
//dd(public_path('.htaccess'),base_path('.htaccess'));
|
||||
$file = public_path('.htaccess');
|
||||
if(!\File::exists($file)){
|
||||
$file = base_path('/../.htaccess');
|
||||
}
|
||||
$this->deleteCustom();
|
||||
$content = file_get_contents($file);
|
||||
file_put_contents($file, $content."#custom\n".$string);
|
||||
file_put_contents($file, $content . "#custom\n" . $string);
|
||||
$new_content = file_get_contents($file);
|
||||
}
|
||||
|
||||
public function deleteCustom()
|
||||
{
|
||||
public function deleteCustom() {
|
||||
$file = public_path('.htaccess');
|
||||
if(!\File::exists($file)){
|
||||
$file = base_path('/../.htaccess');
|
||||
}
|
||||
$content = file_get_contents($file);
|
||||
$custom_pos = strpos($content, '#custom');
|
||||
if ($custom_pos) {
|
||||
@@ -120,28 +108,23 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
public function checkWwwInUrl($url)
|
||||
{
|
||||
public function checkWwwInUrl($url) {
|
||||
$check = false;
|
||||
if (strpos($url, 'www') !== false) {
|
||||
$check = true;
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function checkHttpsInUrl($url)
|
||||
{
|
||||
public function checkHttpsInUrl($url) {
|
||||
$check = false;
|
||||
if (strpos($url, 'https') !== false) {
|
||||
$check = true;
|
||||
}
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
public function checkWWW($url)
|
||||
{
|
||||
public function checkWWW($url) {
|
||||
$check = $this->checkWwwInUrl($url);
|
||||
$array['www'] = true;
|
||||
$array['nonwww'] = false;
|
||||
@@ -149,12 +132,9 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
$array['www'] = false;
|
||||
$array['nonwww'] = true;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function checkHTTP($url)
|
||||
{
|
||||
public function checkHTTP($url) {
|
||||
$check = $this->checkHttpsInUrl($url);
|
||||
$array['https'] = true;
|
||||
$array['http'] = false;
|
||||
@@ -162,7 +142,7 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
|
||||
$array['https'] = false;
|
||||
$array['http'] = true;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ class WorkflowController extends Controller
|
||||
*/
|
||||
public function priority($id)
|
||||
{
|
||||
$priorities = Ticket_Priority::all();
|
||||
$priorities = Ticket_Priority::where('status', '=', 1)->get();
|
||||
$var = "<select name='action[".$id."][b]' class='form-control' required>";
|
||||
foreach ($priorities as $priority) {
|
||||
$var .= "<option value='".$priority->priority_id."'>".$priority->priority_desc.'</option>';
|
||||
|
||||
325
app/Http/Controllers/Agent/helpdesk/Filter/FilterController.php
Normal file
325
app/Http/Controllers/Agent/helpdesk/Filter/FilterController.php
Normal file
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Agent\helpdesk\Filter;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Filters\Label;
|
||||
use App\Model\helpdesk\Filters\Filter;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use DB;
|
||||
use Auth;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use Datatables;
|
||||
|
||||
class FilterController extends Controller {
|
||||
|
||||
protected $request;
|
||||
|
||||
public function __construct(Request $req) {
|
||||
$this->middleware(['auth', 'role.agent']);
|
||||
$this->request = $req;
|
||||
}
|
||||
|
||||
public function getFilter(Request $request) {
|
||||
$labels = $this->request->input('labels');
|
||||
$tags = $this->request->input('tags');
|
||||
if($request->has('department')) {
|
||||
$table = $this->departmentTickets($request->input('department'), $request->input('status'));
|
||||
} else {
|
||||
$segment = $this->request->input('segment');
|
||||
$table = $this->segments($segment);
|
||||
}
|
||||
$tickets = [];
|
||||
$render = false;
|
||||
if (is_array($labels) && count($labels) > 0) {
|
||||
$table = $table
|
||||
->leftJoin('filters as label',function($join){
|
||||
$join->on('tickets.id', '=', 'label.ticket_id')
|
||||
->where('label.key','=','label');
|
||||
})
|
||||
->whereIn('label.value',$labels);
|
||||
}
|
||||
if (is_array($tags) && count($tags) > 0) {
|
||||
$table = $table
|
||||
->leftJoin('filters as tag',function($join){
|
||||
$join->on('tickets.id', '=', 'tag.ticket_id')
|
||||
->where('tag.key','=','tag');
|
||||
})
|
||||
->whereIn('tag.value',$tags);
|
||||
|
||||
}
|
||||
if((is_array($tags) && count($tags) > 0) || (is_array($labels) && count($labels) > 0)){
|
||||
$render = true;
|
||||
}
|
||||
// return \Datatables::of($table)->make();
|
||||
return \Ttable::getTable($table);
|
||||
}
|
||||
|
||||
public function filterByKey($key,$labels = []) {
|
||||
$filter = new Filter();
|
||||
$query = $filter->where('key', $key)
|
||||
->where(function($query) use($labels) {
|
||||
if (is_array($labels) && count($labels) > 0) {
|
||||
for ($i = 0; $i < count($labels); $i++) {
|
||||
$query->orWhere('value', 'LIKE', '%' . $labels[$i] . '%');
|
||||
}
|
||||
}
|
||||
})
|
||||
->lists('ticket_id')
|
||||
->toArray();
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function segments($segment){
|
||||
if (strpos($segment, "user") !== false) {
|
||||
return $this->formatUserTickets($segment);
|
||||
}
|
||||
$table = $this->table();
|
||||
switch($segment){
|
||||
case "/ticket/inbox":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id)->orWhere('assigned_to', '=', Auth::user()->id);
|
||||
}
|
||||
return $table
|
||||
->Join('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id', '=', 'tickets.status')
|
||||
->whereIn('ticket_status.id', [1, 7]);
|
||||
});
|
||||
case "/ticket/closed":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->Join('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status')
|
||||
->whereIn('ticket_status.state',['closed']);
|
||||
|
||||
});
|
||||
case "/ticket/myticket":
|
||||
return $table
|
||||
->leftJoin('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status');
|
||||
|
||||
})
|
||||
->orWhere('tickets.assigned_to', '=', Auth::user()->id)
|
||||
->where('tickets.status','=',1 );
|
||||
case "/unassigned":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->leftJoin('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status');
|
||||
|
||||
})
|
||||
->where('tickets.assigned_to', '=', null)
|
||||
->where('tickets.status','=',1 );
|
||||
case "/ticket/overdue":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->leftJoin('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status');
|
||||
|
||||
})
|
||||
->where('tickets.status', '=', 1)
|
||||
// ->where('tickets.isanswered', '=', 0)
|
||||
->whereNotNull('tickets.duedate')
|
||||
->where('tickets.duedate','!=', '00-00-00 00:00:00')
|
||||
|
||||
// ->where('duedate','>',\Carbon\Carbon::now());
|
||||
->where('tickets.duedate','<', \Carbon\Carbon::now());
|
||||
case "/ticket/approval/closed":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->Join('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status')
|
||||
->where('tickets.status','=',7 );
|
||||
|
||||
});
|
||||
|
||||
case "/trash":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->Join('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status')
|
||||
->where('tickets.status','=',5 );
|
||||
});
|
||||
|
||||
case "/ticket/answered":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->Join('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status')
|
||||
->where('tickets.status','=',1 )
|
||||
->where('tickets.isanswered', '=', 1);
|
||||
|
||||
});
|
||||
case "/ticket/assigned":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->leftJoin('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status');
|
||||
|
||||
})
|
||||
->where('tickets.assigned_to', '>', 0)
|
||||
->where('tickets.status','=',1 );
|
||||
case "/ticket/open":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->leftJoin('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status');
|
||||
|
||||
})
|
||||
->where('tickets.status','=',1 );
|
||||
case "/duetoday":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->leftJoin('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status');
|
||||
|
||||
})
|
||||
->where('tickets.status','=',1 )
|
||||
|
||||
->whereNotNull('tickets.duedate')
|
||||
->whereDate('tickets.duedate','=', \Carbon\Carbon::now()->format('Y-m-d'));
|
||||
|
||||
case "/ticket/followup":
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id=Auth::user()->primary_dpt;
|
||||
$table = $table->where('tickets.dept_id', '=', $id);
|
||||
}
|
||||
return $table
|
||||
->leftJoin('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id','=','tickets.status');
|
||||
|
||||
})
|
||||
->where('tickets.status', '=', 1)
|
||||
// ->where('tickets.isanswered', '=', 0)
|
||||
->where('tickets.follow_up', '=', 1);
|
||||
}
|
||||
}
|
||||
|
||||
public function table(){
|
||||
// if (Auth::user()->role == 'admin') {
|
||||
$ticket = new Tickets();
|
||||
$tickets = $ticket
|
||||
->leftJoin('ticket_thread', function ($join) {
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->whereNotNull('title')
|
||||
->where('ticket_thread.is_internal', '<>', 1);
|
||||
})
|
||||
|
||||
->Join('ticket_source', 'ticket_source.id', '=', 'tickets.source')
|
||||
->leftJoin('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
|
||||
->leftJoin('users as u', 'u.id', '=', 'tickets.user_id')
|
||||
->leftJoin('users as u1', 'u1.id', '=', 'tickets.assigned_to')
|
||||
->leftJoin('ticket_attachment', 'ticket_attachment.thread_id', '=', 'ticket_thread.id')
|
||||
|
||||
->leftJoin('ticket_collaborator', 'ticket_collaborator.ticket_id', '=', 'tickets.id')
|
||||
->select(
|
||||
'tickets.id',
|
||||
'ticket_thread.title',
|
||||
'tickets.ticket_number',
|
||||
'ticket_priority.priority',
|
||||
'u.user_name as user_name',
|
||||
'u1.user_name as assign_user_name',
|
||||
\DB::raw('max(ticket_thread.updated_at) as updated_at'),
|
||||
\DB::raw('min(ticket_thread.updated_at) as created_at'),
|
||||
'tickets.priority_id', 'tickets.assigned_to',
|
||||
DB::raw('COUNT(ticket_thread.updated_at) as countthread'),
|
||||
'ticket_priority.priority_color',
|
||||
'u.first_name as first_name',
|
||||
'u.last_name as last_name',
|
||||
'u1.first_name as assign_first_name',
|
||||
'u1.last_name as assign_last_name',
|
||||
'tickets.status',
|
||||
'tickets.user_id',
|
||||
DB::raw('COUNT(ticket_attachment.thread_id) as countattachment'),
|
||||
DB::raw('COUNT(ticket_collaborator.ticket_id) as countcollaborator'),
|
||||
'ticket_status.name as tickets_status',
|
||||
'ticket_source.css_class as css',
|
||||
DB::raw('substring_index(group_concat(ticket_thread.poster order by ticket_thread.id desc) , ",", 1) as last_replier'),
|
||||
DB::raw('substring_index(group_concat(ticket_thread.title order by ticket_thread.id asc) , ",", 1) as ticket_title'),
|
||||
'u.active as verified')
|
||||
->groupby('tickets.id');
|
||||
return $tickets;
|
||||
}
|
||||
|
||||
public function filter($render,$ticket_id=[]){
|
||||
if (Auth::user()->role == 'admin') {
|
||||
$tickets = Tickets::whereIn('status', array(1, 7));
|
||||
} else {
|
||||
$dept = DB::table('department')->where('id', '=', Auth::user()->primary_dpt)->first();
|
||||
$tickets = Tickets::whereIn('status', array(1, 7))->where('dept_id', '=', $dept->id);
|
||||
}
|
||||
if($render==true){
|
||||
$tickets = $tickets->whereIn('id',$ticket_id);
|
||||
}
|
||||
return $tickets;
|
||||
}
|
||||
|
||||
public function ticketController(){
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$ticket_controller = new TicketController($PhpMailController, $NotificationController);
|
||||
return $ticket_controller;
|
||||
}
|
||||
|
||||
public function departmentTickets($dept, $status)
|
||||
{
|
||||
$table = $this->table();
|
||||
return $table->leftJoin('department as dep', 'tickets.dept_id', '=', 'dep.id')
|
||||
->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
|
||||
->where('dep.name',$dept)
|
||||
->where('ticket_status.name',$status);
|
||||
}
|
||||
|
||||
/**
|
||||
*@category function to format and return user tickets
|
||||
*@param string $segment
|
||||
*@return builder
|
||||
*/
|
||||
public function formatUserTickets($segment)
|
||||
{
|
||||
$convert_to_array = explode("/",$segment);
|
||||
$user_id = $convert_to_array[2];
|
||||
$user = \DB::table('users')->select('role', 'id')->where('id', '=', $user_id)->first();
|
||||
$table = $this->table();
|
||||
if ($user->role == 'user') {
|
||||
$table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
|
||||
->where('tickets.user_id', '=', $user->id)
|
||||
->where('ticket_status.name',$convert_to_array[3]);
|
||||
} else {
|
||||
$table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
|
||||
->where('tickets.assigned_to', '=', $user->id)
|
||||
->where('ticket_status.name',$convert_to_array[3]);
|
||||
}
|
||||
return $table;
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,10 @@ namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
use PhpImap\Mailbox;
|
||||
|
||||
class ImapMail extends Mailbox
|
||||
{
|
||||
public function get_overview($mailId)
|
||||
{
|
||||
$overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID);
|
||||
class ImapMail extends Mailbox {
|
||||
|
||||
public function get_overview($mailId) {
|
||||
$overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID);
|
||||
return $overview;
|
||||
}
|
||||
|
||||
@@ -18,14 +16,13 @@ class ImapMail extends Mailbox
|
||||
* For example, to match all unanswered mails sent by Mom, you'd use: "UNANSWERED FROM mom".
|
||||
*
|
||||
* @param string $criteria See http://php.net/imap_search for a complete list of available criteria
|
||||
*
|
||||
* @return array mailsIds (or empty array)
|
||||
*/
|
||||
public function searchMailbox($criteria = 'ALL')
|
||||
{
|
||||
public function searchMailbox($criteria = 'ALL') {
|
||||
//dd($this->getImapStream());
|
||||
$mailsIds = imap_search($this->getImapStream(), $criteria, SE_UID);
|
||||
//dd($mailsIds);
|
||||
return $mailsIds ? $mailsIds : [];
|
||||
return $mailsIds ? $mailsIds : array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// models
|
||||
use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
@@ -13,24 +12,24 @@ 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;
|
||||
// classes
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
// classes
|
||||
use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
|
||||
/**
|
||||
* MailController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class MailController extends Controller
|
||||
{
|
||||
class MailController extends Controller {
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param type TicketController $TicketController
|
||||
*/
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController)
|
||||
{
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController) {
|
||||
$this->middleware('board');
|
||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||
}
|
||||
@@ -40,8 +39,7 @@ class MailController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket)
|
||||
{
|
||||
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) {
|
||||
//dd($emails);
|
||||
if ($settings_email->first()->email_fetching == 1) {
|
||||
if ($settings_email->first()->all_emails == 1) {
|
||||
@@ -62,8 +60,7 @@ class MailController extends Controller
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function separate_reply($body)
|
||||
{
|
||||
public function separate_reply($body) {
|
||||
$body2 = explode('---Reply above this line---', $body);
|
||||
$body3 = $body2[0];
|
||||
|
||||
@@ -71,64 +68,51 @@ class MailController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param object $email
|
||||
*
|
||||
* @return int
|
||||
* @return integer
|
||||
*/
|
||||
public function priority($email)
|
||||
{
|
||||
public function priority($email) {
|
||||
$priority = $email->priority;
|
||||
if (!$priority) {
|
||||
$priority = $this->ticketController()->getSystemDefaultPriority();
|
||||
}
|
||||
|
||||
return $priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* get department.
|
||||
*
|
||||
* get department
|
||||
* @param object $email
|
||||
*
|
||||
* @return int
|
||||
* @return integer
|
||||
*/
|
||||
public function department($email)
|
||||
{
|
||||
public function department($email) {
|
||||
$department = $email->department;
|
||||
if (!$department) {
|
||||
$department = $this->ticketController()->getSystemDefaultDepartment();
|
||||
}
|
||||
|
||||
return $department;
|
||||
}
|
||||
|
||||
/**
|
||||
* get help topic.
|
||||
*
|
||||
* get help topic
|
||||
* @param object $email
|
||||
*
|
||||
* @return int
|
||||
* @return integer
|
||||
*/
|
||||
public function helptopic($email)
|
||||
{
|
||||
public function helptopic($email) {
|
||||
//dd($email);
|
||||
$helptopic = $email->help_topic;
|
||||
if (!$helptopic) {
|
||||
$helptopic = $this->ticketController()->getSystemDefaultHelpTopic();
|
||||
}
|
||||
|
||||
return $helptopic;
|
||||
}
|
||||
|
||||
/**
|
||||
* get sla.
|
||||
*
|
||||
* get sla
|
||||
* @param object $email
|
||||
*
|
||||
* @return int
|
||||
* @return integer
|
||||
*/
|
||||
public function sla($email)
|
||||
{
|
||||
public function sla($email) {
|
||||
$helptopic = $this->helptopic($email);
|
||||
$help = Help_topic::where('id', '=', $helptopic)->first();
|
||||
if ($help) {
|
||||
@@ -137,26 +121,21 @@ class MailController extends Controller
|
||||
if (!$sla) {
|
||||
$sla = $this->ticketController()->getSystemDefaultSla();
|
||||
}
|
||||
|
||||
return $sla;
|
||||
}
|
||||
|
||||
/**
|
||||
* get ticket controller.
|
||||
*
|
||||
* get ticket controller
|
||||
* @return \App\Http\Controllers\Agent\helpdesk\TicketController
|
||||
*/
|
||||
public function ticketController()
|
||||
{
|
||||
public function ticketController() {
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$controller = new TicketController($PhpMailController, $NotificationController);
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
public function fetch($email)
|
||||
{
|
||||
public function fetch($email) {
|
||||
// dd($email);
|
||||
if ($email) {
|
||||
$username = $email->email_address;
|
||||
@@ -167,30 +146,31 @@ class MailController extends Controller
|
||||
$encryption = $email->fetching_encryption;
|
||||
$cert = $email->mailbox_protocol;
|
||||
$server = new Fetch($host, $port, $service);
|
||||
if ($encryption != null || $encryption != '') {
|
||||
if ($encryption != null || $encryption != "") {
|
||||
$server->setFlag($encryption);
|
||||
}
|
||||
$server->setFlag($cert);
|
||||
$server->setAuthentication($username, $password);
|
||||
$date = date('d M Y', strtotime('-1 days'));
|
||||
$date = date("d M Y", strToTime("-1 days"));
|
||||
$messages = $server->search("SINCE \"$date\" UNSEEN");
|
||||
$this->message($messages, $email);
|
||||
}
|
||||
}
|
||||
|
||||
public function message($messages, $email)
|
||||
{
|
||||
foreach ($messages as $message) {
|
||||
$this->getMessageContent($message, $email);
|
||||
public function message($messages, $email) {
|
||||
if (count($messages) > 0) {
|
||||
foreach ($messages as $message) {
|
||||
$this->getMessageContent($message, $email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getMessageContent($message, $email)
|
||||
{
|
||||
public function getMessageContent($message, $email) {
|
||||
$body = $message->getMessageBody(true);
|
||||
if (!$body) {
|
||||
$body = $message->getMessageBody();
|
||||
}
|
||||
$body = $this->separateReply($body);
|
||||
$subject = $message->getSubject();
|
||||
$address = $message->getAddresses('reply-to');
|
||||
if (!$address) {
|
||||
@@ -202,8 +182,7 @@ class MailController extends Controller
|
||||
$this->workflow($address, $subject, $body, $collaborators, $attachments, $email);
|
||||
}
|
||||
|
||||
public function workflow($address, $subject, $body, $collaborator, $attachments, $email)
|
||||
{
|
||||
public function workflow($address, $subject, $body, $collaborator, $attachments, $email) {
|
||||
$fromaddress = checkArray('address', $address[0]);
|
||||
$fromname = checkArray('name', $address[0]);
|
||||
$helptopic = $this->helptopic($email);
|
||||
@@ -224,39 +203,49 @@ class MailController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function updateThread($ticket_number, $body, $attachments)
|
||||
{
|
||||
public function updateThread($ticket_number, $body, $attachments) {
|
||||
$ticket_table = Tickets::where('ticket_number', '=', $ticket_number)->first();
|
||||
$thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
|
||||
$thread = Ticket_Thread::where('id', '=', $thread_id)->first();
|
||||
$thread->body = $this->separate_reply($body);
|
||||
$thread->save();
|
||||
$this->saveAttachments($thread->id, $attachments);
|
||||
\Log::info('Ticket has created : ', ['id' => $thread->ticket_id]);
|
||||
if (file_exists(app_path('/FaveoStorage/Controllers/StorageController.php'))) {
|
||||
try {
|
||||
$storage = new \App\FaveoStorage\Controllers\StorageController();
|
||||
$storage->saveAttachments($thread->id, $attachments);
|
||||
} catch (\Exception $ex) {
|
||||
loging('attachment', $ex->getMessage());
|
||||
}
|
||||
} else {
|
||||
loging('attachment', 'FaveoStorage not installed');
|
||||
}
|
||||
|
||||
\Log::info("Ticket has created : ", ['id' => $thread->ticket_id]);
|
||||
}
|
||||
|
||||
public function saveAttachments($thread_id, $attachments = [])
|
||||
{
|
||||
public function saveAttachments($thread_id, $attachments = []) {
|
||||
if (is_array($attachments) && count($attachments) > 0) {
|
||||
foreach ($attachments as $attachment) {
|
||||
|
||||
$structure = $attachment->getStructure();
|
||||
$disposition = 'ATTACHMENT';
|
||||
if (isset($structure->disposition)) {
|
||||
$disposition = $structure->disposition;
|
||||
}
|
||||
|
||||
$filename = str_random(16).'-'.$attachment->getFileName();
|
||||
$filename = str_random(16) . '-' . $attachment->getFileName();
|
||||
$type = $attachment->getMimeType();
|
||||
$size = $attachment->getSize();
|
||||
$data = $attachment->getData();
|
||||
//$path = storage_path('/');
|
||||
//$attachment->saveToDirectory($path);
|
||||
$this->manageAttachment($data, $filename, $type, $size, $disposition, $thread_id);
|
||||
$this->updateBody($attachment, $thread_id, $filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function manageAttachment($data, $filename, $type, $size, $disposition, $thread_id)
|
||||
{
|
||||
public function manageAttachment($data, $filename, $type, $size, $disposition, $thread_id) {
|
||||
$upload = new Ticket_attachments();
|
||||
$upload->file = $data;
|
||||
$upload->thread_id = $thread_id;
|
||||
@@ -269,30 +258,25 @@ class MailController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function updateBody($attachment, $thread_id, $filename)
|
||||
{
|
||||
public function updateBody($attachment, $thread_id, $filename) {
|
||||
$structure = $attachment->getStructure();
|
||||
$disposition = 'ATTACHMENT';
|
||||
if (isset($structure->disposition)) {
|
||||
$disposition = $structure->disposition;
|
||||
}
|
||||
if ($disposition == 'INLINE') {
|
||||
$id = str_replace('>', '', str_replace('<', '', $structure->id));
|
||||
if ($disposition == 'INLINE' || $disposition == 'inline') {
|
||||
$id = str_replace(">", "", str_replace("<", "", $structure->id));
|
||||
//$filename = $attachment->getFileName();
|
||||
$path = public_path('attachments');
|
||||
$filepath = asset('attachments/'.$filename);
|
||||
$threads = new Ticket_Thread();
|
||||
$thread = $threads->find($thread_id);
|
||||
$body = $thread->body;
|
||||
$body = str_replace('cid:'.$id, $filename, $body);
|
||||
$body = str_replace('cid:' . $id, $filename, $body);
|
||||
$thread->body = $body;
|
||||
$thread->save();
|
||||
$attachment->saveToDirectory($path);
|
||||
}
|
||||
}
|
||||
|
||||
public function collaburators($message, $email)
|
||||
{
|
||||
public function collaburators($message, $email) {
|
||||
$this_address = $email->email_address;
|
||||
$collaborator_cc = $message->getAddresses('cc');
|
||||
//dd($collaborator_cc);
|
||||
@@ -327,7 +311,6 @@ class MailController extends Controller
|
||||
if (array_key_exists($this_address, $array)) {
|
||||
unset($array[$this_address]);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -338,21 +321,35 @@ class MailController extends Controller
|
||||
*
|
||||
* @return type file
|
||||
*/
|
||||
public function get_data($id)
|
||||
{
|
||||
public function get_data($id) {
|
||||
$attachment = \App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->first();
|
||||
if (mime($attachment->type) == true) {
|
||||
echo "<img src=data:$attachment->type;base64,".$attachment->file.'>';
|
||||
echo "<img src=data:$attachment->type;base64," . $attachment->file . ">";
|
||||
} else {
|
||||
$file = base64_decode($attachment->file);
|
||||
|
||||
return response($file)
|
||||
->header('Cache-Control', 'no-cache private')
|
||||
->header('Content-Description', 'File Transfer')
|
||||
->header('Content-Type', $attachment->type)
|
||||
->header('Content-length', strlen($file))
|
||||
->header('Content-Disposition', 'attachment; filename='.$attachment->name)
|
||||
->header('Content-Disposition', 'attachment; filename=' . $attachment->name)
|
||||
->header('Content-Transfer-Encoding', 'binary');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* separate reply.
|
||||
*
|
||||
* @param type $body
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function separateReply($body) {
|
||||
$body2 = explode('---Reply above this line---', $body);
|
||||
if (is_array($body2) && array_key_exists(0, $body2)) {
|
||||
$body = $body2[0];
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,25 +22,23 @@ use View;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
public function __construct(PhpMailController $PhpMailController)
|
||||
{
|
||||
class NotificationController extends Controller {
|
||||
|
||||
public function __construct(PhpMailController $PhpMailController) {
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for sending daily report/notification about the system.
|
||||
* */
|
||||
public function send_notification()
|
||||
{
|
||||
// dd('sdckjdsc');
|
||||
public function send_notification() {
|
||||
// dd('sdckjdsc');
|
||||
//fetching email settings
|
||||
$email = Email::where('id', '=', '1')->first();
|
||||
//dd('yes');
|
||||
$send = 0;
|
||||
$date = [0];
|
||||
// dd($date);
|
||||
// dd($date);
|
||||
// checking if the daily notification is enabled or not
|
||||
if ($email->notification_cron == 1) {
|
||||
// checking if current date is equal to the last entered daily notification log
|
||||
@@ -48,22 +46,21 @@ class NotificationController extends Controller
|
||||
if ($notification) {
|
||||
$date = explode(' ', $notification->created_at);
|
||||
}
|
||||
// if (date('Y-m-d') !== $date[0]) {
|
||||
// creating a daily notification log
|
||||
// if (date('Y-m-d') !== $date[0]) {
|
||||
// creating a daily notification log
|
||||
|
||||
$company = $this->company();
|
||||
// Send notification details to admin
|
||||
$send += $this->send_notification_to_admin($company);
|
||||
// Send notification details to team lead
|
||||
$send += $this->send_notification_to_team_lead($company);
|
||||
// Send notification details to manager of a department
|
||||
$send += $this->send_notification_to_manager($company);
|
||||
// Send notification details to all the agents
|
||||
$send += $this->send_notification_to_agent($company);
|
||||
$company = $this->company();
|
||||
// Send notification details to admin
|
||||
$send += $this->send_notification_to_admin($company);
|
||||
// Send notification details to team lead
|
||||
$send += $this->send_notification_to_team_lead($company);
|
||||
// Send notification details to manager of a department
|
||||
$send += $this->send_notification_to_manager($company);
|
||||
// Send notification details to all the agents
|
||||
$send += $this->send_notification_to_agent($company);
|
||||
//}
|
||||
Log_notification::create(['log' => 'NOT-1']);
|
||||
Log_notification::create(['log' => 'NOT-1']);
|
||||
}
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
@@ -74,31 +71,27 @@ class NotificationController extends Controller
|
||||
*
|
||||
* @return mail
|
||||
* */
|
||||
public function send_notification_to_admin($company)
|
||||
{
|
||||
public function send_notification_to_admin($company) {
|
||||
// get all admin users
|
||||
$users = User::where('role', '=', 'admin')->get();
|
||||
foreach ($users as $user) {
|
||||
// Send notification details to admin
|
||||
$email = $user->email;
|
||||
$user_name = $user->first_name.' '.$user->last_name;
|
||||
$user_name = $user->first_name . ' ' . $user->last_name;
|
||||
$view = View::make('emails.notifications.admin', ['company' => $company, 'name' => $user_name]);
|
||||
$contents = $view->render();
|
||||
$from = $this->PhpMailController->mailfrom('1', '0');
|
||||
$to = [
|
||||
'name' => $user_name,
|
||||
'email' => $email,
|
||||
'name' => $user_name,
|
||||
'email' => $email
|
||||
];
|
||||
$message = [
|
||||
'subject' => 'Daily Report',
|
||||
'subject' => 'Daily Report',
|
||||
'scenario' => null,
|
||||
'body' => $contents,
|
||||
'body' => $contents
|
||||
];
|
||||
$job = new \App\Jobs\SendEmail($from, $to, $message);
|
||||
$dispatch = $this->dispatch($job);
|
||||
|
||||
return $dispatch;
|
||||
//return $this->PhpMailController->sendEmail($from,$to,$message);
|
||||
return $this->PhpMailController->sendEmail($from, $to, $message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +100,7 @@ class NotificationController extends Controller
|
||||
*
|
||||
* @return mail
|
||||
* */
|
||||
public function send_notification_to_manager($company)
|
||||
{
|
||||
public function send_notification_to_manager($company) {
|
||||
// get all department managers
|
||||
$depts = Department::all();
|
||||
foreach ($depts as $dept) {
|
||||
@@ -118,22 +110,20 @@ class NotificationController extends Controller
|
||||
foreach ($users as $user) {
|
||||
// Send notification details to manager of a department
|
||||
$email = $user->email;
|
||||
$user_name = $user->first_name.' '.$user->last_name;
|
||||
$user_name = $user->first_name . ' ' . $user->last_name;
|
||||
$view = View::make('emails.notifications.manager', ['company' => $company, 'name' => $user_name]);
|
||||
$contents = $view->render();
|
||||
$from = $this->PhpMailController->mailfrom('1', '0');
|
||||
$to = [
|
||||
'name' => $user_name,
|
||||
'email' => $email,
|
||||
'name' => $user_name,
|
||||
'email' => $email
|
||||
];
|
||||
$message = [
|
||||
'subject' => 'Daily Report',
|
||||
'subject' => 'Daily Report',
|
||||
'scenario' => null,
|
||||
'body' => $contents,
|
||||
'body' => $contents
|
||||
];
|
||||
|
||||
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
|
||||
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
return $this->PhpMailController->sendEmail($from, $to, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,8 +134,7 @@ class NotificationController extends Controller
|
||||
*
|
||||
* @return mail
|
||||
* */
|
||||
public function send_notification_to_team_lead($company)
|
||||
{
|
||||
public function send_notification_to_team_lead($company) {
|
||||
// get all Team leads
|
||||
$teams = Teams::all();
|
||||
foreach ($teams as $team) {
|
||||
@@ -155,22 +144,20 @@ class NotificationController extends Controller
|
||||
foreach ($users as $user) {
|
||||
// Send notification details to team lead
|
||||
$email = $user->email;
|
||||
$user_name = $user->first_name.' '.$user->last_name;
|
||||
$user_name = $user->first_name . ' ' . $user->last_name;
|
||||
$view = View::make('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id]);
|
||||
$contents = $view->render();
|
||||
$from = $this->PhpMailController->mailfrom('1', '0');
|
||||
$to = [
|
||||
'name' => $user_name,
|
||||
'email' => $email,
|
||||
'name' => $user_name,
|
||||
'email' => $email
|
||||
];
|
||||
$message = [
|
||||
'subject' => 'Daily Report',
|
||||
'subject' => 'Daily Report',
|
||||
'scenario' => null,
|
||||
'body' => $contents,
|
||||
'body' => $contents
|
||||
];
|
||||
|
||||
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
|
||||
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
return $this->PhpMailController->sendEmail($from, $to, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,29 +168,26 @@ class NotificationController extends Controller
|
||||
*
|
||||
* @return mail
|
||||
* */
|
||||
public function send_notification_to_agent($company)
|
||||
{
|
||||
public function send_notification_to_agent($company) {
|
||||
// get all agents users
|
||||
$users = User::where('role', '=', 'agent')->get();
|
||||
foreach ($users as $user) {
|
||||
// Send notification details to all the agents
|
||||
$email = $user->email;
|
||||
$user_name = $user->first_name.' '.$user->last_name;
|
||||
$user_name = $user->first_name . ' ' . $user->last_name;
|
||||
$view = View::make('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => $user->id]);
|
||||
$contents = $view->render();
|
||||
$from = $this->PhpMailController->mailfrom('1', '0');
|
||||
$to = [
|
||||
'name' => $user_name,
|
||||
'email' => $email,
|
||||
];
|
||||
'name' => $user_name,
|
||||
'email' => $email
|
||||
];
|
||||
$message = [
|
||||
'subject' => 'Daily Report',
|
||||
'subject' => 'Daily Report',
|
||||
'scenario' => null,
|
||||
'body' => $contents,
|
||||
];
|
||||
|
||||
return $this->dispatch((new \App\Jobs\SendEmail($from, $to, $message)));
|
||||
//$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
|
||||
'body' => $contents
|
||||
];
|
||||
return $this->PhpMailController->sendEmail($from,$to,$message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,8 +196,7 @@ class NotificationController extends Controller
|
||||
*
|
||||
* @return type variable
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
public function company() {
|
||||
// fetching comapny model
|
||||
$company = Company::Where('id', '=', '1')->first();
|
||||
// fetching company name
|
||||
@@ -225,4 +208,5 @@ class NotificationController extends Controller
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ use App\Model\helpdesk\Agent_panel\User_org;
|
||||
use App\User;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* OrganizationController
|
||||
@@ -61,16 +61,6 @@ class OrganizationController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used autofill organizations name .
|
||||
*
|
||||
* @return datatable
|
||||
*/
|
||||
public function organizationAutofill()
|
||||
{
|
||||
return view('themes.default1.agent.helpdesk.organization.getautocomplete');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to display the list of Organizations.
|
||||
*
|
||||
@@ -339,16 +329,24 @@ class OrganizationController extends Controller
|
||||
|
||||
return '['.$last.']';
|
||||
}
|
||||
|
||||
public function getOrgAjax(Request $request)
|
||||
{
|
||||
|
||||
public function getOrgAjax(Request $request){
|
||||
$org = new Organization();
|
||||
$q = $request->input('term');
|
||||
$orgs = $org->where('name', 'LIKE', '%'.$q.'%')
|
||||
->select('name as label', 'id as value')
|
||||
$orgs = $org->where('name','LIKE','%'.$q.'%')
|
||||
->select('name as label','id as value')
|
||||
->get()
|
||||
->toJson();
|
||||
|
||||
return $orgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used autofill organizations name .
|
||||
*
|
||||
* @return datatable
|
||||
*/
|
||||
public function organizationAutofill()
|
||||
{
|
||||
return view('themes.default1.agent.helpdesk.organization.getautocomplete');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace App\Http\Controllers\Agent\helpdesk;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
// request
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
// Model
|
||||
use Illuminate\Http\Request;
|
||||
// Model
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
// classes
|
||||
use PDF;
|
||||
|
||||
@@ -18,8 +18,8 @@ use PDF;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class ReportController extends Controller
|
||||
{
|
||||
class ReportController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
@@ -29,8 +29,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
// checking for authentication
|
||||
$this->middleware('auth');
|
||||
// checking if the role is agent
|
||||
@@ -39,26 +38,23 @@ class ReportController extends Controller
|
||||
|
||||
/**
|
||||
* Get the Report page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.report.index');
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get help_topic graph.
|
||||
*
|
||||
* function to get help_topic graph
|
||||
* @param type $date111
|
||||
* @param type $date122
|
||||
* @param type $helptopic
|
||||
*/
|
||||
public function chartdataHelptopic(Request $request, $date111 = '', $date122 = '', $helptopic = '')
|
||||
{
|
||||
public function chartdataHelptopic(Request $request, $date111 = '', $date122 = '', $helptopic = '') {
|
||||
$date11 = strtotime($date122);
|
||||
$date12 = strtotime($date111);
|
||||
$help_topic = $helptopic;
|
||||
@@ -77,24 +73,25 @@ class ReportController extends Controller
|
||||
$format = 'Y-m-d';
|
||||
// generating a date range of 1 month
|
||||
if ($request->input('duration') == 'day') {
|
||||
$date1 = strtotime(date($format, strtotime('-15 day'.$date3)));
|
||||
$date1 = strtotime(date($format, strtotime('-15 day' . $date3)));
|
||||
} elseif ($request->input('duration') == 'week') {
|
||||
$date1 = strtotime(date($format, strtotime('-69 days'.$date3)));
|
||||
$date1 = strtotime(date($format, strtotime('-69 days' . $date3)));
|
||||
} elseif ($request->input('duration') == 'month') {
|
||||
$date1 = strtotime(date($format, strtotime('-179 days'.$date3)));
|
||||
$date1 = strtotime(date($format, strtotime('-179 days' . $date3)));
|
||||
} else {
|
||||
$date1 = strtotime(date($format, strtotime('-30 days'.$date3)));
|
||||
$date1 = strtotime(date($format, strtotime('-30 days' . $date3)));
|
||||
}
|
||||
// $help_topic = Help_topic::where('status', '=', '1')->min('id');
|
||||
}
|
||||
|
||||
|
||||
$return = '';
|
||||
$last = '';
|
||||
$j = 0;
|
||||
$created1 = '';
|
||||
$closed1 = '';
|
||||
$reopened1 = '';
|
||||
$in_progress = \DB::table('tickets')->where('help_topic_id', '=', $help_topic)->where('status', '=', 1)->count();
|
||||
$in_progress = \DB::table('tickets')->where('help_topic_id', '=', $help_topic)->where('status','=',1)->count();
|
||||
|
||||
for ($i = $date1; $i <= $date2; $i = $i + 86400) {
|
||||
$j++;
|
||||
@@ -106,15 +103,15 @@ class ReportController extends Controller
|
||||
|
||||
if ($request->input('open') || $request->input('closed') || $request->input('reopened')) {
|
||||
if ($request->input('open') && $request->input('open') == 'on') {
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$open_array = ['open' => $created];
|
||||
}
|
||||
if ($request->input('closed') && $request->input('closed') == 'on') {
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$closed_array = ['closed' => $closed];
|
||||
}
|
||||
if ($request->input('reopened') && $request->input('reopened') == 'on') {
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$reopened_array = ['reopened' => $reopened];
|
||||
}
|
||||
// if ($request->input('overdue') && $request->input('overdue') == 'on') {
|
||||
@@ -134,14 +131,14 @@ class ReportController extends Controller
|
||||
// }
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
$return .= $json . ',';
|
||||
} else {
|
||||
if ($duration == 'week') {
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$created1 += $created;
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$closed1 += $closed;
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$reopened1 += $reopened;
|
||||
if ($j % 7 == 0) {
|
||||
$open_array = ['open' => $created1];
|
||||
@@ -161,14 +158,14 @@ class ReportController extends Controller
|
||||
// }
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
$return .= $json . ',';
|
||||
}
|
||||
} elseif ($duration == 'month') {
|
||||
$created_month = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$created_month = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$created1 += $created_month;
|
||||
$closed_month = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed_month = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$closed1 += $closed_month;
|
||||
$reopened_month = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened_month = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$reopened1 += $reopened_month;
|
||||
if ($j % 30 == 0) {
|
||||
$open_array = ['open' => $created1];
|
||||
@@ -186,17 +183,17 @@ class ReportController extends Controller
|
||||
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
$return .= $json . ',';
|
||||
}
|
||||
} else {
|
||||
if ($request->input('default') == null) {
|
||||
$help_topic = Help_topic::where('status', '=', '1')->min('id');
|
||||
}
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$open_array = ['open' => $created];
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$closed_array = ['closed' => $closed];
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count();
|
||||
$reopened_array = ['reopened' => $reopened];
|
||||
if ($j % 1 == 0) {
|
||||
$open_array = ['open' => $created];
|
||||
@@ -235,7 +232,7 @@ class ReportController extends Controller
|
||||
// }
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
$return .= $json . ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,19 +247,20 @@ class ReportController extends Controller
|
||||
// if($reopened_array) {
|
||||
// $value = array_merge($value,$reopened_array);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
$last = rtrim($return, ',');
|
||||
|
||||
return '['.$last.']';
|
||||
return '[' . $last . ']';
|
||||
}
|
||||
|
||||
public function helptopicPdf(Request $request)
|
||||
{
|
||||
public function helptopicPdf(Request $request){
|
||||
$table_datas = json_decode($request->input('pdf_form'));
|
||||
$table_help_topic = json_decode($request->input('pdf_form_help_topic'));
|
||||
$html = view('themes.default1.agent.helpdesk.report.pdf', compact('table_datas', 'table_help_topic'))->render();
|
||||
$html1 = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
return PDF::load($html1)->show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\User;
|
||||
use Auth;
|
||||
// classes
|
||||
use Ttable;
|
||||
|
||||
/**
|
||||
* TicketController2.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class Ticket2Controller extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Inbox ticket list page.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function deptopen($id)
|
||||
{
|
||||
$dept = Department::where('name', '=', $id)->first();
|
||||
if (Auth::user()->role == 'agent') {
|
||||
if (Auth::user()->dept_id == $dept->id) {
|
||||
return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', 'Unauthorised!');
|
||||
}
|
||||
} else {
|
||||
return view('themes.default1.agent.helpdesk.dept-ticket.open', compact('id'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this function returns the list of open tickets of a particular department.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getOpenTickets($id)
|
||||
{
|
||||
if (Auth::user()->role == 'admin') {
|
||||
$tickets = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $id)->get();
|
||||
} else {
|
||||
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
|
||||
$tickets = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $dept->id)->get();
|
||||
}
|
||||
|
||||
return Ttable::getTable($tickets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Inbox ticket list page.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function deptclose($id)
|
||||
{
|
||||
$dept = Department::where('name', '=', $id)->first();
|
||||
if (Auth::user()->role == 'agent') {
|
||||
if (Auth::user()->dept_id == $dept->id) {
|
||||
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', 'Unauthorised!');
|
||||
}
|
||||
} else {
|
||||
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this function returns the list of close tickets of a particular department.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getCloseTickets($id)
|
||||
{
|
||||
if (Auth::user()->role == 'admin') {
|
||||
$tickets = Tickets::where('status', '=', '2')->where('status', '=', '3')->where('dept_id', '=', $id)->get();
|
||||
} else {
|
||||
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
|
||||
$tickets = Tickets::where('status', '=', '2')->where('status', '=', '3')->where('dept_id', '=', $dept->id)->get();
|
||||
}
|
||||
|
||||
return Ttable::getTable($tickets);
|
||||
}
|
||||
|
||||
/**
|
||||
* this function returns the list of close tickets of a particular department.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function deptinprogress($id)
|
||||
{
|
||||
$dept = Department::where('name', '=', $id)->first();
|
||||
if (Auth::user()->role == 'agent') {
|
||||
if (Auth::user()->dept_id == $dept->id) {
|
||||
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', 'Unauthorised!');
|
||||
}
|
||||
} else {
|
||||
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*Show the list of In process tickets.
|
||||
*
|
||||
*@param $id int
|
||||
*/
|
||||
public function getInProcessTickets($id)
|
||||
{
|
||||
if (Auth::user()->role == 'admin') {
|
||||
$tickets = Tickets::where('status', '=', '1')->where('assigned_to', '>', 0)->where('dept_id', '=', $id)->get();
|
||||
} else {
|
||||
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
|
||||
$tickets = Tickets::where('status', '=', '1')->where('assigned_to', '>', 0)->where('dept_id', '=', $dept->id)->get();
|
||||
}
|
||||
|
||||
return Ttable::getTable($tickets);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -166,7 +166,7 @@ class TicketWorkflowController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//dd($form_data);
|
||||
if ($ticket_settings_details['reject'] == true) {
|
||||
return ['0' => false, '1' => false];
|
||||
@@ -287,7 +287,7 @@ class TicketWorkflowController extends Controller
|
||||
*/
|
||||
public function checkStarts($statement, $to_check)
|
||||
{
|
||||
if (substr($to_check, 0, strlen($statement)) == $statement) {
|
||||
if (substr($to_check, 0, strlen($statement)) == $statement) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -305,7 +305,7 @@ class TicketWorkflowController extends Controller
|
||||
public function checkEnds($statement, $to_check)
|
||||
{
|
||||
$to_check = strip_tags($to_check);
|
||||
if (substr($to_check, -strlen($statement)) == $statement) {
|
||||
if (substr($to_check, -strlen($statement)) == $statement) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -352,7 +352,6 @@ class TicketWorkflowController extends Controller
|
||||
$ticket_settings_details = $this->changeStatus($workflow_action, $ticket_settings_details);
|
||||
}
|
||||
}
|
||||
|
||||
return $ticket_settings_details;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -65,7 +65,7 @@ class ArticleController extends Controller
|
||||
$article = new Article();
|
||||
$articles = $article
|
||||
->select('id', 'name', 'description', 'publish_time', 'slug')
|
||||
->orderBy('publish_time', 'desc')
|
||||
->orderBy('publish_time','desc')
|
||||
->get();
|
||||
// returns chumper datatable
|
||||
return Datatable::Collection($articles)
|
||||
|
||||
@@ -77,7 +77,6 @@ class CategoryController extends Controller
|
||||
/* add column name */
|
||||
->addColumn('name', function ($model) {
|
||||
$string = strip_tags($model->name);
|
||||
|
||||
return str_limit($string, 20);
|
||||
})
|
||||
/* add column Created */
|
||||
@@ -121,7 +120,7 @@ class CategoryController extends Controller
|
||||
public function create(Category $category)
|
||||
{
|
||||
/* Get the all attributes in the category model */
|
||||
$category = $category->lists('name', 'id')->toArray();
|
||||
$category = $category->lists('name','id')->toArray();
|
||||
/* get the view page to create new category with all attributes
|
||||
of category model */
|
||||
try {
|
||||
@@ -148,7 +147,6 @@ class CategoryController extends Controller
|
||||
// send success message to index page
|
||||
try {
|
||||
$category->fill($request->input())->save();
|
||||
|
||||
return Redirect::back()->with('success', Lang::get('lang.category_inserted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return Redirect::back()->with('fails', Lang::get('lang.category_not_inserted').'<li>'.$e->getMessage().'</li>');
|
||||
@@ -167,9 +165,9 @@ class CategoryController extends Controller
|
||||
{
|
||||
/* get the atributes of the category model whose id == $id */
|
||||
$category = Category::whereId($id)->first();
|
||||
$categories = Category::lists('name', 'id')->toArray();
|
||||
$categories = Category::lists('name','id')->toArray();
|
||||
/* get the Edit page the selected category via id */
|
||||
return view('themes.default1.agent.kb.category.edit', compact('category', 'categories'));
|
||||
return view('themes.default1.agent.kb.category.edit', compact('category','categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +191,6 @@ class CategoryController extends Controller
|
||||
try {
|
||||
$category->slug = $slug;
|
||||
$category->fill($request->input())->save();
|
||||
|
||||
return redirect('category')->with('success', Lang::get('lang.category_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
//redirect to index with fails message
|
||||
|
||||
@@ -144,13 +144,11 @@ class SettingsController extends Controller
|
||||
$name = "<p>$model->name</p><br>";
|
||||
$email = "<p>$model->email</p><br>";
|
||||
$website = "<p>$model->website</p><br>";
|
||||
|
||||
return $name.$email.$website;
|
||||
})
|
||||
|
||||
|
||||
->addColumn('comment', function ($model) {
|
||||
$created = TicketController::usertimezone(date($model->created_at));
|
||||
|
||||
$created = TicketController::usertimezone(date($model->created_at));
|
||||
return $model->comment."<p>$created</p>";
|
||||
})
|
||||
->addColumn('status', function ($model) {
|
||||
@@ -161,7 +159,7 @@ class SettingsController extends Controller
|
||||
return '<p style="color:red"">'.\Lang::get('lang.not_published');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<div class="row"><div class="col-md-12"><a href=comment/delete/'.$model->id.' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a></div><div class="col-md-12"><a href=published/'.$model->id.' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a></div></div>';
|
||||
})
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController as CoreTicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
//use Illuminate\Support\Facades\Request as Value;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
//use Illuminate\Support\Facades\Request as Value;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
@@ -21,6 +20,7 @@ use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController as CoreTicketController;
|
||||
|
||||
/**
|
||||
* -----------------------------------------------------------------------------
|
||||
@@ -34,8 +34,8 @@ use Illuminate\Support\Collection;
|
||||
*
|
||||
* @version v1
|
||||
*/
|
||||
class ApiController extends Controller
|
||||
{
|
||||
class ApiController extends Controller {
|
||||
|
||||
public $user;
|
||||
public $request;
|
||||
public $ticket;
|
||||
@@ -55,8 +55,7 @@ class ApiController extends Controller
|
||||
/**
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
public function __construct(Request $request) {
|
||||
$this->request = $request;
|
||||
|
||||
$this->middleware('jwt.auth');
|
||||
@@ -65,7 +64,9 @@ class ApiController extends Controller
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$this->user = $user;
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
|
||||
|
||||
} catch (\Tymon\JWTAuth\Exceptions\JWTException $e) {
|
||||
|
||||
}
|
||||
|
||||
$ticket = new TicketController();
|
||||
@@ -120,8 +121,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function createTicket(\App\Http\Requests\helpdesk\CreateTicketRequest $request, \App\Model\helpdesk\Utility\CountryCode $code)
|
||||
{
|
||||
public function createTicket(\App\Http\Requests\helpdesk\CreateTicketRequest $request, \App\Model\helpdesk\Utility\CountryCode $code) {
|
||||
try {
|
||||
$user_id = $this->request->input('user_id');
|
||||
|
||||
@@ -148,7 +148,7 @@ class ApiController extends Controller
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$core = new CoreTicketController($PhpMailController, $NotificationController);
|
||||
$response = $core->post_newticket($request, $code, true);
|
||||
$response = $core->post_newticket($request, $code,true);
|
||||
//$response = $this->ticket->createTicket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach);
|
||||
//return $response;
|
||||
/*
|
||||
@@ -179,12 +179,11 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function ticketReply()
|
||||
{
|
||||
public function ticketReply() {
|
||||
//dd($this->request->all());
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'ticket_ID' => 'required|exists:tickets,id',
|
||||
'ticket_ID' => 'required|exists:tickets,id',
|
||||
'reply_content' => 'required',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
@@ -194,7 +193,9 @@ class ApiController extends Controller
|
||||
}
|
||||
$attach = $this->request->input('attachments');
|
||||
$result = $this->ticket->reply($this->thread, $this->request, $this->attach, $attach);
|
||||
|
||||
$result = $result->join('users','ticket_thread.user_id','=','users.id')
|
||||
->select('ticket_thread.*','users.first_name as first_name')
|
||||
->first();
|
||||
return response()->json(compact('result'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
@@ -214,15 +215,14 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function editTicket()
|
||||
{
|
||||
public function editTicket() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'ticket_id' => 'required|exists:tickets,id',
|
||||
'subject' => 'required',
|
||||
'sla_plan' => 'required|exists:sla_plan,id',
|
||||
'help_topic' => 'required|exists:help_topic,id',
|
||||
'ticket_source' => 'required|exists:ticket_source,id',
|
||||
'ticket_id' => 'required|exists:tickets,id',
|
||||
'subject' => 'required',
|
||||
'sla_plan' => 'required|exists:sla_plan,id',
|
||||
'help_topic' => 'required|exists:help_topic,id',
|
||||
'ticket_source' => 'required|exists:ticket_source,id',
|
||||
'ticket_priority' => 'required|exists:ticket_priority,priority_id',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
@@ -252,8 +252,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function deleteTicket()
|
||||
{
|
||||
public function deleteTicket() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'ticket_id' => 'required|exists:tickets,id',
|
||||
@@ -286,16 +285,15 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function openedTickets()
|
||||
{
|
||||
public function openedTickets() {
|
||||
try {
|
||||
// $result = $this->model->where('status', '=', 1)->where('isanswered', '=', 0)->where('assigned_to', '=', null)->orderBy('id', 'DESC')->get();
|
||||
// return response()->json(compact('result'));
|
||||
|
||||
$result = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->where('isanswered', '=', 0)->where('status', '=', 1)->whereNull('assigned_to');
|
||||
})
|
||||
})
|
||||
->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')
|
||||
@@ -331,17 +329,16 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function unassignedTickets()
|
||||
{
|
||||
public function unassignedTickets() {
|
||||
try {
|
||||
//dd('sdhjbc');
|
||||
// $result = $this->model->where('assigned_to', '=', null)->where('status', '1')->orderBy('id', 'DESC')->get();
|
||||
// return response()->json(compact('result'));
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$unassigned = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->whereNull('assigned_to')->where('status', '=', 1);
|
||||
})
|
||||
})
|
||||
->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')
|
||||
@@ -352,7 +349,7 @@ class ApiController extends Controller
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), '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')
|
||||
->where(function ($query) use ($user) {
|
||||
->where(function($query) use($user) {
|
||||
if ($user->role != 'admin') {
|
||||
$query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
}
|
||||
@@ -382,16 +379,15 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function closeTickets()
|
||||
{
|
||||
public function closeTickets() {
|
||||
try {
|
||||
// $result = $this->model->where('status', '>', 1)->where('status', '<', 4)->orderBy('id', 'DESC')->get();
|
||||
// return response()->json(compact('result'));
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$result = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->where('status', '=', 3)->orWhere('status', '=', 2);
|
||||
})
|
||||
})
|
||||
->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')
|
||||
@@ -402,7 +398,7 @@ class ApiController extends Controller
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), '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')
|
||||
->where(function ($query) use ($user) {
|
||||
->where(function($query) use($user) {
|
||||
if ($user->role != 'admin') {
|
||||
$query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
}
|
||||
@@ -432,8 +428,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getAgents()
|
||||
{
|
||||
public function getAgents() {
|
||||
try {
|
||||
$result = $this->faveoUser->where('role', 'agent')->orWhere('role', 'admin')->where('active', 1)->get();
|
||||
|
||||
@@ -456,8 +451,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getTeams()
|
||||
{
|
||||
public function getTeams() {
|
||||
try {
|
||||
$result = $this->team->get();
|
||||
|
||||
@@ -480,12 +474,11 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function assignTicket()
|
||||
{
|
||||
public function assignTicket() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'ticket_id' => 'required',
|
||||
'user' => 'required',
|
||||
'user' => 'required',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
$error = $v->errors();
|
||||
@@ -519,8 +512,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getCustomers()
|
||||
{
|
||||
public function getCustomers() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'search' => 'required',
|
||||
@@ -531,7 +523,7 @@ class ApiController extends Controller
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$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();
|
||||
$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'))
|
||||
->header('X-Header-One', 'Header Value');
|
||||
@@ -554,8 +546,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getCustomersWith()
|
||||
{
|
||||
public function getCustomersWith() {
|
||||
try {
|
||||
$users = $this->user
|
||||
->leftJoin('user_assign_organization', 'user_assign_organization.user_id', '=', 'users.id')
|
||||
@@ -586,8 +577,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getCustomer()
|
||||
{
|
||||
public function getCustomer() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'user_id' => 'required',
|
||||
@@ -619,8 +609,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function searchTicket()
|
||||
{
|
||||
public function searchTicket() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'search' => 'required',
|
||||
@@ -631,7 +620,7 @@ class ApiController extends Controller
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$search = $this->request->input('search');
|
||||
$result = $this->thread->select('ticket_id')->where('title', 'like', '%'.$search.'%')->orWhere('body', 'like', '%'.$search.'%')->get();
|
||||
$result = $this->thread->select('ticket_id')->where('title', 'like', '%' . $search . '%')->orWhere('body', 'like', '%' . $search . '%')->get();
|
||||
|
||||
return response()->json(compact('result'));
|
||||
} catch (Exception $e) {
|
||||
@@ -652,8 +641,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function ticketThreads()
|
||||
{
|
||||
public function ticketThreads() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'id' => 'required',
|
||||
@@ -690,8 +678,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function checkUrl()
|
||||
{
|
||||
public function checkUrl() {
|
||||
//dd($this->request);
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
@@ -708,7 +695,7 @@ class ApiController extends Controller
|
||||
$url = str_finish($url, '/');
|
||||
}
|
||||
|
||||
$url = $url.'/api/v1/helpdesk/check-url?api_key='.$this->request->input('api_key').'&token='.\Config::get('app.token');
|
||||
$url = $url . '/api/v1/helpdesk/check-url?api_key=' . $this->request->input('api_key') . '&token=' . \Config::get('app.token');
|
||||
$result = $this->CallGetApi($url);
|
||||
//dd($result);
|
||||
return response()->json(compact('result'));
|
||||
@@ -728,8 +715,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function urlResult()
|
||||
{
|
||||
public function urlResult() {
|
||||
return 'success';
|
||||
}
|
||||
|
||||
@@ -740,8 +726,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return type int|string|json
|
||||
*/
|
||||
public function callGetApi($url)
|
||||
{
|
||||
public function callGetApi($url) {
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
@@ -750,7 +735,7 @@ class ApiController extends Controller
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if (curl_errno($curl)) {
|
||||
echo 'error:'.curl_error($curl);
|
||||
echo 'error:' . curl_error($curl);
|
||||
}
|
||||
|
||||
return $response;
|
||||
@@ -765,8 +750,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return type int|string|json
|
||||
*/
|
||||
public function callPostApi($url, $data)
|
||||
{
|
||||
public function callPostApi($url, $data) {
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
@@ -776,7 +760,7 @@ class ApiController extends Controller
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if (curl_errno($curl)) {
|
||||
echo 'error:'.curl_error($curl);
|
||||
echo 'error:' . curl_error($curl);
|
||||
}
|
||||
|
||||
return $response;
|
||||
@@ -788,8 +772,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return type | json
|
||||
*/
|
||||
public function generateApiKey()
|
||||
{
|
||||
public function generateApiKey() {
|
||||
try {
|
||||
$set = $this->setting->where('id', '1')->first();
|
||||
//dd($set);
|
||||
@@ -823,8 +806,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getHelpTopic()
|
||||
{
|
||||
public function getHelpTopic() {
|
||||
try {
|
||||
$result = $this->helptopic->get();
|
||||
|
||||
@@ -847,8 +829,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getSlaPlan()
|
||||
{
|
||||
public function getSlaPlan() {
|
||||
try {
|
||||
$result = $this->slaPlan->get();
|
||||
|
||||
@@ -871,8 +852,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
public function getPriority() {
|
||||
try {
|
||||
$result = $this->priority->get();
|
||||
|
||||
@@ -895,8 +875,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getDepartment()
|
||||
{
|
||||
public function getDepartment() {
|
||||
try {
|
||||
$result = $this->department->get();
|
||||
|
||||
@@ -919,8 +898,7 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function getTickets()
|
||||
{
|
||||
public function getTickets() {
|
||||
try {
|
||||
$tickets = $this->model->orderBy('created_at', 'desc')->paginate(10);
|
||||
$tickets->toJson();
|
||||
@@ -944,14 +922,13 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function inbox()
|
||||
{
|
||||
public function inbox() {
|
||||
try {
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$inbox = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->where('status', '=', 1);
|
||||
})
|
||||
})
|
||||
->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')
|
||||
@@ -962,7 +939,7 @@ class ApiController extends Controller
|
||||
->whereNotNull('ticket_thread.title');
|
||||
})
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'ticket_thread.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', 'department.id as department_id', 'users.primary_dpt as user_dpt')
|
||||
->where(function ($query) use ($user) {
|
||||
->where(function($query) use($user) {
|
||||
if ($user->role != 'admin') {
|
||||
$query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
}
|
||||
@@ -972,7 +949,6 @@ class ApiController extends Controller
|
||||
->distinct()
|
||||
->paginate(10)
|
||||
->toJson();
|
||||
|
||||
return $inbox;
|
||||
} catch (\Exception $ex) {
|
||||
$error = $ex->getMessage();
|
||||
@@ -992,13 +968,12 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function internalNote()
|
||||
{
|
||||
public function internalNote() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'userid' => 'required|exists:users,id',
|
||||
'userid' => 'required|exists:users,id',
|
||||
'ticketid' => 'required|exists:tickets,id',
|
||||
'body' => 'required',
|
||||
'body' => 'required',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
$error = $v->errors();
|
||||
@@ -1025,14 +1000,13 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getTrash()
|
||||
{
|
||||
public function getTrash() {
|
||||
try {
|
||||
$user = \JWTAuth::parseToken()->authenticate();
|
||||
$trash = $this->user->join('tickets', function ($join) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->where('status', '=', 5);
|
||||
})
|
||||
})
|
||||
->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')
|
||||
@@ -1043,7 +1017,7 @@ class ApiController extends Controller
|
||||
->whereNotNull('title');
|
||||
})
|
||||
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), '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')
|
||||
->where(function ($query) use ($user) {
|
||||
->where(function($query) use($user) {
|
||||
if ($user->role != 'admin') {
|
||||
$query->where('tickets.dept_id', '=', $user->primary_dpt);
|
||||
}
|
||||
@@ -1068,8 +1042,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getMyTicketsAgent()
|
||||
{
|
||||
public function getMyTicketsAgent() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
@@ -1087,10 +1060,10 @@ class ApiController extends Controller
|
||||
}
|
||||
//$user = \JWTAuth::parseToken()->authenticate();
|
||||
$result = $this->user->join('tickets', function ($join) use ($id) {
|
||||
$join->on('users.id', '=', 'tickets.assigned_to')
|
||||
$join->on('users.id', '=', 'tickets.assigned_to')
|
||||
->where('status', '=', 1);
|
||||
//->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')
|
||||
@@ -1127,8 +1100,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getMyTicketsUser()
|
||||
{
|
||||
public function getMyTicketsUser() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
@@ -1145,9 +1117,9 @@ class ApiController extends Controller
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$result = $this->user->join('tickets', function ($join) use ($id) {
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->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')
|
||||
@@ -1179,8 +1151,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getTicketById()
|
||||
{
|
||||
public function getTicketById() {
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'id' => 'required|exists:tickets,id',
|
||||
@@ -1192,7 +1163,7 @@ class ApiController extends Controller
|
||||
}
|
||||
$id = $this->request->input('id');
|
||||
if (!$this->model->where('id', $id)->first()) {
|
||||
$error = 'There is no Ticket as ticket id: '.$id;
|
||||
$error = 'There is no Ticket as ticket id: ' . $id;
|
||||
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
@@ -1200,10 +1171,45 @@ class ApiController extends Controller
|
||||
$join->on('users.id', '=', 'tickets.user_id')
|
||||
->where('tickets.id', '=', $id);
|
||||
});
|
||||
$response = $this->differenciateHelpTopic($query);
|
||||
|
||||
|
||||
$response = $this->differenciateHelpTopic($query)
|
||||
->leftJoin('department','tickets.dept_id','=',"department.id")
|
||||
->leftJoin('ticket_priority','tickets.priority_id','=','ticket_priority.priority_id')
|
||||
->leftJoin('ticket_status','tickets.status','=','ticket_status.id')
|
||||
->leftJoin('sla_plan','tickets.sla','=','sla_plan.id')
|
||||
->leftJoin('ticket_source','tickets.source','=','ticket_source.id');
|
||||
//$select = 'users.email','users.user_name','users.first_name','users.last_name','tickets.id','ticket_number','num_sequence','user_id','priority_id','sla','max_open_ticket','captcha','status','lock_by','lock_at','source','isoverdue','reopened','isanswered','is_deleted', 'closed','is_transfer','transfer_at','reopened_at','duedate','closed_at','last_message_at';
|
||||
|
||||
$result = $response->addSelect('users.email', 'users.user_name', 'users.first_name', 'users.last_name', 'tickets.id', 'ticket_number', 'user_id', 'priority_id', 'sla', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'reopened_at', 'duedate', 'closed_at', 'tickets.created_at', 'tickets.updated_at')->first();
|
||||
$result = $response->addSelect(
|
||||
'users.email',
|
||||
'users.user_name',
|
||||
'users.first_name',
|
||||
'users.last_name',
|
||||
'tickets.id',
|
||||
'ticket_number',
|
||||
'user_id',
|
||||
'ticket_priority.priority_id',
|
||||
'ticket_priority.priority as priority_name',
|
||||
'department.name as dept_name',
|
||||
'ticket_status.name as status_name',
|
||||
'sla_plan.name as sla_name',
|
||||
'ticket_source.name as source_name',
|
||||
'sla_plan.id as sla',
|
||||
'ticket_status.id as status',
|
||||
'lock_by',
|
||||
'lock_at',
|
||||
'ticket_source.id as source',
|
||||
'isoverdue',
|
||||
'reopened',
|
||||
'isanswered',
|
||||
'is_deleted',
|
||||
'closed',
|
||||
'reopened_at',
|
||||
'duedate',
|
||||
'closed_at',
|
||||
'tickets.created_at',
|
||||
'tickets.updated_at')->first();
|
||||
|
||||
return response()->json(compact('result'));
|
||||
} catch (\Exception $e) {
|
||||
@@ -1219,8 +1225,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function createPagination($array, $perPage)
|
||||
{
|
||||
public function createPagination($array, $perPage) {
|
||||
try {
|
||||
//Get current page form url e.g. &page=6
|
||||
$currentPage = LengthAwarePaginator::resolveCurrentPage();
|
||||
@@ -1248,8 +1253,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function collaboratorSearch()
|
||||
{
|
||||
public function collaboratorSearch() {
|
||||
$this->validate($this->request, ['term' => 'required']);
|
||||
try {
|
||||
$emails = $this->ticket->autosearch();
|
||||
@@ -1259,7 +1263,7 @@ class ApiController extends Controller
|
||||
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]['name'] = $user_model->first_name . ' ' . $user_model->last_name;
|
||||
$users[$key]['email'] = $email;
|
||||
$users[$key]['avatar'] = $this->avatarUrl($email);
|
||||
}
|
||||
@@ -1276,13 +1280,12 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function avatarUrl($email)
|
||||
{
|
||||
public function avatarUrl($email) {
|
||||
try {
|
||||
$user = new User();
|
||||
$user = $user->where('email', $email)->first();
|
||||
if ($user->profile_pic) {
|
||||
$url = url('uploads/profilepic/'.$user->profile_pic);
|
||||
$url = url('uploads/profilepic/' . $user->profile_pic);
|
||||
} else {
|
||||
$url = \Gravatar::src($email);
|
||||
}
|
||||
@@ -1294,11 +1297,10 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function addCollaboratorForTicket()
|
||||
{
|
||||
public function addCollaboratorForTicket() {
|
||||
try {
|
||||
$v = \Validator::make(\Input::get(), [
|
||||
'email' => 'required|email|unique:users',
|
||||
'email' => 'required|email|unique:users',
|
||||
'ticket_id' => 'required',
|
||||
]
|
||||
);
|
||||
@@ -1325,8 +1327,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getCollaboratorForTicket()
|
||||
{
|
||||
public function getCollaboratorForTicket() {
|
||||
try {
|
||||
$v = \Validator::make(\Input::get(), [
|
||||
'ticket_id' => 'required',
|
||||
@@ -1355,12 +1356,11 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCollaborator()
|
||||
{
|
||||
public function deleteCollaborator() {
|
||||
try {
|
||||
$v = \Validator::make(\Input::get(), [
|
||||
'ticketid' => 'required',
|
||||
'email' => 'required',
|
||||
'email' => 'required',
|
||||
]
|
||||
);
|
||||
if ($v->fails()) {
|
||||
@@ -1380,8 +1380,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function dependency()
|
||||
{
|
||||
public function dependency() {
|
||||
try {
|
||||
$department = $this->department->select('name', 'id')->get()->toArray();
|
||||
$sla = $this->slaPlan->select('name', 'id')->get()->toArray();
|
||||
@@ -1392,7 +1391,7 @@ class ApiController extends Controller
|
||||
$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, ];
|
||||
'priorities' => $priority, 'helptopics' => $helptopic, 'status' => $status, 'sources' => $source,];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
} catch (\Exception $e) {
|
||||
@@ -1404,8 +1403,7 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function differenciateHelpTopic($query)
|
||||
{
|
||||
public function differenciateHelpTopic($query) {
|
||||
$ticket = $query->first();
|
||||
$check = 'department';
|
||||
if ($ticket) {
|
||||
@@ -1419,16 +1417,16 @@ class ApiController extends Controller
|
||||
return $query->select('tickets.dept_id');
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getSystem($check, $query)
|
||||
{
|
||||
public function getSystem($check, $query) {
|
||||
switch ($check) {
|
||||
case 'department':
|
||||
return $query->select('tickets.dept_id');
|
||||
case 'helpTopic':
|
||||
return $query->select('tickets.help_topic_id');
|
||||
default:
|
||||
default :
|
||||
return $query->select('tickets.dept_id');
|
||||
}
|
||||
}
|
||||
@@ -1440,11 +1438,10 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
public function register(Request $request) {
|
||||
try {
|
||||
$v = \Validator::make($request->all(), [
|
||||
'email' => 'required|email|unique:users',
|
||||
'email' => 'required|email|unique:users',
|
||||
'password' => 'required|min:6',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
@@ -1458,7 +1455,7 @@ class ApiController extends Controller
|
||||
$password = \Hash::make($request->input('password'));
|
||||
$role = $request->input('role');
|
||||
if ($auth->role == 'agent') {
|
||||
$role = 'user';
|
||||
$role = "user";
|
||||
}
|
||||
$user = new User();
|
||||
$user->password = $password;
|
||||
@@ -1466,7 +1463,6 @@ class ApiController extends Controller
|
||||
$user->email = $email;
|
||||
$user->role = $role;
|
||||
$user->save();
|
||||
|
||||
return response()->json(compact('user'));
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
@@ -1474,4 +1470,5 @@ class ApiController extends Controller
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class InstallerApiController extends Controller
|
||||
$ENV['QUEUE_DRIVER'] = 'sync';
|
||||
|
||||
$config = '';
|
||||
|
||||
|
||||
foreach ($ENV as $key => $val) {
|
||||
$config .= "{$key}={$val}\n";
|
||||
}
|
||||
|
||||
@@ -1,491 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
public $server;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$server = new Request();
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
$server = parse_url($url);
|
||||
$server['path'] = dirname($server['path']);
|
||||
$server = parse_url($server['path']);
|
||||
$server['path'] = dirname($server['path']);
|
||||
$this->server = 'http://'.$_SERVER['HTTP_HOST'].$server['path'].'/';
|
||||
}
|
||||
|
||||
public static function callGetApi($url)
|
||||
{
|
||||
//dd($url);
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if (curl_errno($curl)) {
|
||||
echo 'error:'.curl_error($curl);
|
||||
}
|
||||
|
||||
return $response;
|
||||
curl_close($curl);
|
||||
}
|
||||
|
||||
public static function callPostApi($url, $data)
|
||||
{
|
||||
//dd($url);
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if (curl_errno($curl)) {
|
||||
echo 'error:'.curl_error($curl);
|
||||
}
|
||||
|
||||
return $response;
|
||||
curl_close($curl);
|
||||
}
|
||||
|
||||
public function ticketReply()
|
||||
{
|
||||
|
||||
//$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
|
||||
|
||||
$data = [
|
||||
|
||||
'ticket_ID' => '1',
|
||||
'reply_content' => 'reply for the ticket id',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
// 'attachments' => [
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
// 'size' => '26398',
|
||||
// 'type' => 'png',
|
||||
// 'file' => $file,
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
// 'size' => '26398',
|
||||
// 'type' => 'png',
|
||||
// 'file' => $file,
|
||||
// ]
|
||||
// ],
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
|
||||
$url = $this->server.'helpdesk/reply?token='.\Config::get('app.token');
|
||||
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function createTicket()
|
||||
{
|
||||
|
||||
//$file = file_get_contents(base_path() . '/../lb-faveo/Img/Ladybird.png');
|
||||
|
||||
$data = [
|
||||
'user_id' => 1,
|
||||
'subject' => 'Api create via faveo api',
|
||||
'body' => 'Test me when call api',
|
||||
'helptopic' => '1',
|
||||
'sla' => '1',
|
||||
'priority' => '1',
|
||||
'headers' => [0 => 'vijaycodename47@gmail.com'],
|
||||
'dept' => '1',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
/* if attachment */
|
||||
// 'attachments' => [
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
// 'size' => '26398',
|
||||
// 'type' => 'png',
|
||||
// 'file' => $file,
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'ladybird',
|
||||
// 'size' => '26398',
|
||||
// 'type' => 'png',
|
||||
// 'file' => $file,
|
||||
// ]
|
||||
// ],
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
|
||||
$url = $this->server.'helpdesk/create?token='.\Config::get('app.token');
|
||||
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function generateToken()
|
||||
{
|
||||
$data = [
|
||||
//'email'=>'vijaycodename47@gmail.com',
|
||||
'username' => 'vijay',
|
||||
'password' => 'manjapra',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
|
||||
$url = $this->server.'authenticate';
|
||||
//dd($url);
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function createUser()
|
||||
{
|
||||
$data = [
|
||||
'email' => 'vijaycodename@gmail.com',
|
||||
'password' => 'manjapra',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server.'register';
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getAuthUser()
|
||||
{
|
||||
$url = $this->server.'authenticate/user?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function editTicket()
|
||||
{
|
||||
$data = [
|
||||
'ticket_id' => '13',
|
||||
'subject' => 'Api editing ticket via faveo api',
|
||||
'sla_plan' => '2',
|
||||
'help_topic' => '2',
|
||||
'ticket_source' => '2',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
'ticket_priority' => '2',
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server.'helpdesk/edit?token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function deleteTicket()
|
||||
{
|
||||
$data = [
|
||||
'ticket_id' => [11],
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server.'helpdesk/delete?token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function openedTickets()
|
||||
{
|
||||
$url = $this->server.'helpdesk/open?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function unassignedTickets()
|
||||
{
|
||||
//dd('dsdf');
|
||||
$url = $this->server.'helpdesk/unassigned?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
//dd($respose);
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function closeTickets()
|
||||
{
|
||||
$url = $this->server.'helpdesk/closed?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getAgents()
|
||||
{
|
||||
$url = $this->server.'helpdesk/agents?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getTeams()
|
||||
{
|
||||
$url = $this->server.'helpdesk/teams?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function assignTicket()
|
||||
{
|
||||
$data = [
|
||||
'ticket_id' => 1,
|
||||
'user' => 'vijay.sebastian@ladybirdweb.com',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server.'helpdesk/assign?token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getCustomers()
|
||||
{
|
||||
$search = [
|
||||
'search' => 'vij',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server.'helpdesk/customers?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getCustomer()
|
||||
{
|
||||
$search = [
|
||||
'user_id' => '1',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server.'helpdesk/customer?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getSearch()
|
||||
{
|
||||
$search = [
|
||||
'search' => 'api',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server.'helpdesk/ticket-search?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function ticketThreads()
|
||||
{
|
||||
$search = [
|
||||
'id' => '1',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server.'helpdesk/ticket-thread?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function url()
|
||||
{
|
||||
$search = [
|
||||
'url' => 'http://localhost/faveo-helpdesk-github/public/',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($search, '', '&');
|
||||
$url = $this->server.'helpdesk/url?token='.\Config::get('app.token');
|
||||
$url = $url.'&'.$data;
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function generateApiKey()
|
||||
{
|
||||
$url = $this->server.'helpdesk/api_key?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getHelpTopic()
|
||||
{
|
||||
$url = $this->server.'helpdesk/help-topic?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getSlaPlan()
|
||||
{
|
||||
$url = $this->server.'helpdesk/sla-plan?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getPriority()
|
||||
{
|
||||
$url = $this->server.'helpdesk/priority?api_key=clYbe1g7BYVEJznBdvCEBR0xDCLDqKgg&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getDepartment()
|
||||
{
|
||||
$url = $this->server.'helpdesk/department?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function getTickets()
|
||||
{
|
||||
$url = $this->server.'helpdesk/tickets?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function inbox()
|
||||
{
|
||||
$url = $this->server.'helpdesk/inbox?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function internalNote()
|
||||
{
|
||||
$data = [
|
||||
'ticketid' => '1',
|
||||
'userid' => 1,
|
||||
'body' => 'Testing the api internal note',
|
||||
'api_key' => '9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN',
|
||||
];
|
||||
$data = http_build_query($data, '', '&');
|
||||
$url = $this->server.'helpdesk/internal-note?token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callPostApi($url, $data);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function trash()
|
||||
{
|
||||
$url = $this->server.'helpdesk/trash?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
}
|
||||
|
||||
public function myTickets()
|
||||
{
|
||||
try {
|
||||
$url = $this->server.'helpdesk/my-tickets?user_id=1&api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
public function getTicketById()
|
||||
{
|
||||
try {
|
||||
$url = $this->server.'helpdesk/my-tickets?id=1&api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
|
||||
return $respose;
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
|
||||
public function getCustomersWith()
|
||||
{
|
||||
try {
|
||||
//dd($this->server);
|
||||
$url = $this->server.'helpdesk/customers-custom?api_key=9p41T2XFZ34YRZJUNQAdmM7iV0Rr1CjN&token='.\Config::get('app.token');
|
||||
$_this = new self();
|
||||
$respose = $_this->callGetApi($url);
|
||||
dd($respose);
|
||||
|
||||
return $respose;
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
$line = $e->getLine();
|
||||
$file = $e->getFile();
|
||||
|
||||
return response()->json(compact('error', 'file', 'line'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class TokenAuthController extends Controller
|
||||
//$credentials = $request->only('email', 'password');
|
||||
|
||||
try {
|
||||
if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password, 'active' => 1])) {
|
||||
if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password,'active'=>1])) {
|
||||
return response()->json(['error' => 'invalid_credentials', 'status_code' => 401]);
|
||||
}
|
||||
} catch (JWTException $e) {
|
||||
|
||||
@@ -3,29 +3,31 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Admin\helpdesk\SocialMedia\SocialMediaController;
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
// requests
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\LoginRequest;
|
||||
use App\Http\Requests\helpdesk\OtpVerifyRequest;
|
||||
use App\Http\Requests\helpdesk\RegisterRequest;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Plugin;
|
||||
use App\Http\Requests\helpdesk\OtpVerifyRequest;
|
||||
use App\Model\helpdesk\Settings\Security;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
// classes
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\Otp;
|
||||
use App\Model\helpdesk\Settings\Plugin;
|
||||
|
||||
// classes
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Utility\Otp;
|
||||
use Auth;
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Hash;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
use Input;
|
||||
use Lang;
|
||||
use DateTime;
|
||||
use Input;
|
||||
use Socialite;
|
||||
use App\Http\Controllers\Admin\helpdesk\SocialMedia\SocialMediaController;
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------
|
||||
@@ -37,8 +39,8 @@ use Socialite;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class AuthController extends Controller
|
||||
{
|
||||
class AuthController extends Controller {
|
||||
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
/* to redirect after login */
|
||||
|
||||
@@ -59,15 +61,14 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(PhpMailController $PhpMailController, SocialMediaController $social)
|
||||
{
|
||||
public function __construct(PhpMailController $PhpMailController, SocialMediaController $social) {
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
$social->configService();
|
||||
$this->middleware('guest', ['except' => ['getLogout', 'verifyOTP', 'redirectToProvider']]);
|
||||
}
|
||||
|
||||
public function redirectToProvider($provider, $redirect = '')
|
||||
{
|
||||
public function redirectToProvider($provider, $redirect = '') {
|
||||
|
||||
if ($redirect !== '') {
|
||||
$this->setSession($provider, $redirect);
|
||||
}
|
||||
@@ -77,8 +78,7 @@ class AuthController extends Controller
|
||||
return $s;
|
||||
}
|
||||
|
||||
public function handleProviderCallback($provider)
|
||||
{
|
||||
public function handleProviderCallback($provider) {
|
||||
try {
|
||||
//notice we are not doing any validation, you should do it
|
||||
$this->changeRedirect();
|
||||
@@ -91,24 +91,25 @@ class AuthController extends Controller
|
||||
if ($user->nickname) {
|
||||
$username = $user->nickname;
|
||||
}
|
||||
if (!$first_name) {
|
||||
if(!$first_name){
|
||||
$first_name = $username;
|
||||
}
|
||||
$data = [
|
||||
'first_name' => $first_name,
|
||||
'email' => $user->getEmail(),
|
||||
'user_name' => $username,
|
||||
'role' => 'user',
|
||||
'active' => 1,
|
||||
'email' => $user->getEmail(),
|
||||
'user_name' => $username,
|
||||
'role' => 'user',
|
||||
'active' => 1,
|
||||
];
|
||||
$user = User::where('email', $data['email'])->first();
|
||||
if (!$user) {
|
||||
$user = User::where('user_name', $data['user_name'])->first();
|
||||
$user = User::where('email',$data['email'])->first();
|
||||
if(!$user){
|
||||
$user = User::where('user_name',$data['user_name'])->first();
|
||||
}
|
||||
if (!$user) {
|
||||
$user = User::firstOrCreate($data);
|
||||
if(!$user){
|
||||
$user = User::firstOrCreate($data);
|
||||
}
|
||||
Auth::login($user);
|
||||
|
||||
}
|
||||
//after login redirecting to home page
|
||||
return redirect('/');
|
||||
@@ -122,8 +123,7 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getRegister(CommonSettings $settings)
|
||||
{
|
||||
public function getRegister(CommonSettings $settings) {
|
||||
// Event for login
|
||||
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = $settings->select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
@@ -148,63 +148,59 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postRegister(User $user, RegisterRequest $request)
|
||||
{
|
||||
public function postRegister(User $user, RegisterRequest $request) {
|
||||
try {
|
||||
$request_array = $request->input();
|
||||
$password = Hash::make($request->input('password'));
|
||||
$user->password = $password;
|
||||
$name = $request->input('full_name');
|
||||
$user->first_name = $name;
|
||||
if ($request_array['email'] == '') {
|
||||
$user->email = null;
|
||||
} else {
|
||||
$user->email = $request->input('email');
|
||||
}
|
||||
if ($request_array['mobile'] == '') {
|
||||
$user->mobile = null;
|
||||
} else {
|
||||
$user->mobile = $request->input('mobile');
|
||||
}
|
||||
if ($request_array['code'] == '') {
|
||||
$user->country_code = 0;
|
||||
} else {
|
||||
$user->country_code = $request->input('code');
|
||||
}
|
||||
if ($request_array['email'] != '') {
|
||||
$user->user_name = $request->input('email');
|
||||
} else {
|
||||
$user->user_name = $request->input('mobile');
|
||||
}
|
||||
$user->role = 'user';
|
||||
$code = str_random(60);
|
||||
$user->remember_token = $code;
|
||||
$user->save();
|
||||
$message12 = '';
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$sms = Plugin::select('status')->where('name', '=', 'SMS')->first();
|
||||
// Event for login
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
if ($request_array['email'] != '') {
|
||||
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/'.$code)]);
|
||||
}
|
||||
$request_array = $request->input();
|
||||
$password = Hash::make($request->input('password'));
|
||||
$user->password = $password;
|
||||
$name = $request->input('full_name');
|
||||
$user->first_name = $name;
|
||||
if ($request_array['email'] == '') {
|
||||
$user->email = null;
|
||||
} else {
|
||||
$user->email = $request->input('email');
|
||||
}
|
||||
if ($request_array['mobile'] == '') {
|
||||
$user->mobile = null;
|
||||
} else {
|
||||
$user->mobile = $request->input('mobile');
|
||||
}
|
||||
if ($request_array['code'] == '') {
|
||||
$user->country_code = 0;
|
||||
} else {
|
||||
$user->country_code = $request->input('code');
|
||||
}
|
||||
if ($request_array['email'] != '') {
|
||||
$user->user_name = $request->input('email');
|
||||
} else {
|
||||
$user->user_name = $request->input('mobile');
|
||||
}
|
||||
$user->role = 'user';
|
||||
$code = str_random(60);
|
||||
$user->remember_token = $code;
|
||||
$user->save();
|
||||
$message12 = '';
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$sms = Plugin::select('status')->where('name', '=', 'SMS')->first();
|
||||
// Event for login
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/' . $code)]);
|
||||
if ($settings->status == 1 || $settings->status == '1') {
|
||||
if (count($sms) > 0) {
|
||||
if ($sms->status == 1 || $sms->status == '1') {
|
||||
if(count($sms) > 0) {
|
||||
if($sms->status == 1 || $sms->status == '1') {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_and_moble');
|
||||
} else {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_sms_plugin_inactive_or_not_setup');
|
||||
}
|
||||
} else {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_sms_plugin_inactive_or_not_setup');
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
|
||||
}
|
||||
} else {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
|
||||
}
|
||||
|
||||
return redirect('home')->with('success', $message12);
|
||||
return redirect('home')->with('success', $message12);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,15 +211,13 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function accountActivate($token)
|
||||
{
|
||||
public function accountActivate($token) {
|
||||
$user = User::where('remember_token', '=', $token)->first();
|
||||
if ($user) {
|
||||
$user->active = 1;
|
||||
$user->remember_token = null;
|
||||
$user->save();
|
||||
$this->openTicketAfterVerification($user->id);
|
||||
|
||||
return redirect('/auth/login')->with('status', 'Acount activated. Login to start');
|
||||
} else {
|
||||
return redirect('/auth/login')->with('fails', 'Invalid Token');
|
||||
@@ -238,8 +232,7 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getMail($token, User $user)
|
||||
{
|
||||
public function getMail($token, User $user) {
|
||||
$user = $user->where('remember_token', $token)->where('active', 0)->first();
|
||||
if ($user) {
|
||||
$user->active = 1;
|
||||
@@ -256,10 +249,9 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
public function getLogin() {
|
||||
$directory = base_path();
|
||||
if (file_exists($directory.DIRECTORY_SEPARATOR.'.env')) {
|
||||
if (file_exists($directory . DIRECTORY_SEPARATOR . '.env')) {
|
||||
if (Auth::user()) {
|
||||
if (Auth::user()->role == 'admin' || Auth::user()->role == 'agent') {
|
||||
return \Redirect::route('dashboard');
|
||||
@@ -296,7 +288,7 @@ class AuthController extends Controller
|
||||
}
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
$result = $this->confirmIPAddress($value, $usernameinput);
|
||||
|
||||
|
||||
// If attempts > 3 and time < 30 minutes
|
||||
$security = Security::whereId('1')->first();
|
||||
if ($result == 1) {
|
||||
@@ -309,15 +301,15 @@ class AuthController extends Controller
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with(['error' => Lang::get('lang.not-registered'),
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with(['error' => Lang::get('lang.not-registered'),
|
||||
'referer' => $referer, ]);
|
||||
}
|
||||
|
||||
//if user exists
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
|
||||
|
||||
if ($settings->status == '1' || $settings->status == 1) { // check for otp verification setting
|
||||
// setting is enabled
|
||||
$sms = Plugin::select('status')->where('name', '=', 'SMS')->first();
|
||||
@@ -328,7 +320,7 @@ class AuthController extends Controller
|
||||
if (!$check_active->active) { //check account is active or not
|
||||
// account is not active show verify otp window
|
||||
if ($check_active->mobile) { //check user has mobile or not
|
||||
// user has mobile number return verify OTP screen
|
||||
// user has mobile number return verify OTP screen
|
||||
return \Redirect::route('otp-verification')
|
||||
->withInput($request->input())
|
||||
->with(['values' => $request->input(),
|
||||
@@ -337,7 +329,7 @@ class AuthController extends Controller
|
||||
'number' => $check_active->mobile,
|
||||
'code' => $check_active->country_code, ]);
|
||||
} else {
|
||||
goto a; //attenmpt login (be careful while using goto statements)
|
||||
goto a; //attenmpt login (be careful while using goto statements)
|
||||
}
|
||||
} else {
|
||||
goto a; //attenmpt login (be careful while using goto statements)
|
||||
@@ -392,15 +384,14 @@ class AuthController extends Controller
|
||||
if ($request->input('referer')) {
|
||||
return \Redirect::route($request->input('referer'));
|
||||
}
|
||||
|
||||
return \Redirect::route('/');
|
||||
} else {
|
||||
return redirect()->intended($this->redirectPath());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
@@ -418,8 +409,7 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function addLoginAttempt($value, $field)
|
||||
{
|
||||
public function addLoginAttempt($value, $field) {
|
||||
$result = DB::table('login_attempts')->where('IP', '=', $value)->first();
|
||||
$data = $result;
|
||||
$security = Security::whereId('1')->first();
|
||||
@@ -427,15 +417,15 @@ class AuthController extends Controller
|
||||
if ($data) {
|
||||
$attempts = $data->Attempts + 1;
|
||||
if ($attempts == $apt) {
|
||||
// $result = DB::select('UPDATE login_attempts SET Attempts='.$attempts.", LastLogin=NOW() WHERE IP = '$value' OR User = '$field'");
|
||||
$result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts, 'LastLogin' => date('Y-m-d H:i:s')]);
|
||||
// $result = DB::select('UPDATE login_attempts SET Attempts='.$attempts.", LastLogin=NOW() WHERE IP = '$value' OR User = '$field'");
|
||||
$result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts, 'LastLogin' => Date('Y-m-d H:i:s')]);
|
||||
} else {
|
||||
$result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts]);
|
||||
// $result = DB::select("UPDATE login_attempts SET Attempts=".$attempts." WHERE IP = '$value' OR User = '$field'");
|
||||
}
|
||||
} else {
|
||||
// $result = DB::select("INSERT INTO login_attempts (Attempts,User,IP,LastLogin) values (1,'$field','$value', NOW())");
|
||||
$result = DB::table('login_attempts')->update(['Attempts' => 1, 'User' => $field, 'IP' => $value, 'LastLogin' => date('Y-m-d H:i:s')]);
|
||||
// $result = DB::select("INSERT INTO login_attempts (Attempts,User,IP,LastLogin) values (1,'$field','$value', NOW())");
|
||||
$result = DB::table('login_attempts')->update(['Attempts' => 1, 'User' => $field, 'IP' => $value, 'LastLogin' => Date('Y-m-d H:i:s')]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,8 +436,7 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function clearLoginAttempts($value, $field)
|
||||
{
|
||||
public function clearLoginAttempts($value, $field) {
|
||||
$data = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['attempts' => '0']);
|
||||
|
||||
return $data;
|
||||
@@ -460,14 +449,13 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function confirmIPAddress($value, $field)
|
||||
{
|
||||
public function confirmIPAddress($value, $field) {
|
||||
$security = Security::whereId('1')->first();
|
||||
$time = $security->lockout_period;
|
||||
$max_attempts = $security->backlist_threshold;
|
||||
$table = 'login_attempts';
|
||||
$result = DB::select('SELECT Attempts, (CASE when LastLogin is not NULL and DATE_ADD(LastLogin, INTERVAL '.$time.' MINUTE)>NOW() then 1 else 0 end) as Denied '.
|
||||
' FROM '.$table." WHERE IP = '$value' OR User = '$field'");
|
||||
$result = DB::select('SELECT Attempts, (CASE when LastLogin is not NULL and DATE_ADD(LastLogin, INTERVAL ' . $time . ' MINUTE)>NOW() then 1 else 0 end) as Denied ' .
|
||||
' FROM ' . $table . " WHERE IP = '$value' OR User = '$field'");
|
||||
$data = $result;
|
||||
//Verify that at least one login attempt is in database
|
||||
if (!$data) {
|
||||
@@ -478,7 +466,6 @@ class AuthController extends Controller
|
||||
return 1;
|
||||
} else {
|
||||
$this->clearLoginAttempts($value, $field);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -491,20 +478,16 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
protected function getFailedLoginMessage()
|
||||
{
|
||||
protected function getFailedLoginMessage() {
|
||||
return Lang::get('lang.this_field_do_not_match_our_records');
|
||||
}
|
||||
|
||||
/**
|
||||
*@category function to show verify OTP page
|
||||
*
|
||||
*@param null
|
||||
*
|
||||
*@return response|view
|
||||
*/
|
||||
public function getVerifyOTP()
|
||||
{
|
||||
public function getVerifyOTP() {
|
||||
if (\Session::has('values')) {
|
||||
return view('auth.otp-verify');
|
||||
} else {
|
||||
@@ -514,13 +497,10 @@ class AuthController extends Controller
|
||||
|
||||
/**
|
||||
*@category function to verify OTP
|
||||
*
|
||||
*@param $request
|
||||
*
|
||||
*@return int|string
|
||||
*/
|
||||
public function verifyOTP(LoginRequest $request)
|
||||
{
|
||||
public function verifyOTP(LoginRequest $request) {
|
||||
$user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))
|
||||
->orWhere('user_name', '=', $request->input('email'))->first();
|
||||
$otp_length = strlen($request->input('otp'));
|
||||
@@ -530,10 +510,10 @@ class AuthController extends Controller
|
||||
$otp = Otp::select('otp', 'updated_at')->where('user_id', '=', $user->id)
|
||||
->first();
|
||||
if ($otp != null) {
|
||||
if (($otp_length == 6 && !preg_match('/[a-z]/i', $request->input('otp')))) {
|
||||
if (($otp_length == 6 && !preg_match("/[a-z]/i", $request->input('otp')))) {
|
||||
$otp2 = Hash::make($request->input('otp'));
|
||||
$date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
|
||||
$date2 = date('Y-m-d h:i:sa');
|
||||
$date1 = date_format($otp->updated_at, "Y-m-d h:i:sa");
|
||||
$date2 = date("Y-m-d h:i:sa");
|
||||
$time1 = new DateTime($date2);
|
||||
$time2 = new DateTime($date1);
|
||||
$interval = $time1->diff($time2);
|
||||
@@ -546,7 +526,6 @@ class AuthController extends Controller
|
||||
User::where('id', '=', $user->id)
|
||||
->update(['active' => 1]);
|
||||
$this->openTicketAfterVerification($user->id);
|
||||
|
||||
return $this->postLogin($request);
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
@@ -559,46 +538,37 @@ class AuthController extends Controller
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
}
|
||||
}
|
||||
|
||||
return \Redirect::route('otp-verification')
|
||||
->withInput($request->input())
|
||||
->with(['values' => $request->input(),
|
||||
'number' => $user->mobile,
|
||||
'name' => $user->user_name,
|
||||
'fails' => $message, ]);
|
||||
'number' => $user->mobile,
|
||||
'name' => $user->user_name,
|
||||
'fails' => $message]);
|
||||
}
|
||||
|
||||
public function resendOTP(OtpVerifyRequest $request)
|
||||
{
|
||||
public function resendOTP(OtpVerifyRequest $request) {
|
||||
if (!\Schema::hasTable('user_verification') || !\Schema::hasTable('sms')) {
|
||||
$message = Lang::get('lang.opt-can-not-be-verified');
|
||||
|
||||
return $message;
|
||||
} else {
|
||||
$sms = DB::table('sms')->get();
|
||||
$sms =DB::table('sms')->get();
|
||||
if (count($sms) > 0) {
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$message = Lang::get('lang.opt-can-not-be-verified');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @category function to change ticket status when user verifies his account
|
||||
*
|
||||
* @param int $id => user_id
|
||||
*
|
||||
* @return null
|
||||
*
|
||||
* @author manish.verma@ladybirdweb.com
|
||||
*/
|
||||
public function openTicketAfterVerification($id)
|
||||
{
|
||||
public function openTicketAfterVerification($id) {
|
||||
// dd($id);
|
||||
$ticket = Tickets::select('id')
|
||||
->where(['user_id' => $id, 'status' => 6])
|
||||
@@ -609,23 +579,23 @@ class AuthController extends Controller
|
||||
foreach ($ticket as $value) {
|
||||
$ticket_id = $value->id;
|
||||
Ticket_Thread::where('ticket_id', '=', $ticket_id)
|
||||
->update(['updated_at' => date('Y-m-d H:i:s')]);
|
||||
->update(["updated_at" => date('Y-m-d H:i:s')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function changeRedirect()
|
||||
{
|
||||
|
||||
public function changeRedirect() {
|
||||
$provider = \Session::get('provider');
|
||||
$url = \Session::get($provider.'redirect');
|
||||
$url = \Session::get($provider . 'redirect');
|
||||
\Config::set("services.$provider.redirect", $url);
|
||||
}
|
||||
|
||||
public function setSession($provider, $redirect)
|
||||
{
|
||||
public function setSession($provider, $redirect) {
|
||||
$url = url($redirect);
|
||||
\Session::set('provider', $provider);
|
||||
\Session::set($provider.'redirect', $url);
|
||||
\Session::set($provider . 'redirect', $url);
|
||||
$this->changeRedirect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// request
|
||||
use App\User;
|
||||
@@ -50,9 +51,10 @@ class PasswordController extends Controller
|
||||
*/
|
||||
public function postEmail(Request $request)
|
||||
{
|
||||
try{
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$this->validate($request, ['email' => 'required']);
|
||||
\Event::fire('reset.password', []);
|
||||
\Event::fire('reset.password',array());
|
||||
$user = User::where('email', '=', $request->only('email'))->orWhere('mobile', '=', $request->only('email'))->first();
|
||||
if (isset($user)) {
|
||||
$user1 = $user->email;
|
||||
@@ -66,9 +68,9 @@ class PasswordController extends Controller
|
||||
} 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->first_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/'.$code)], true);
|
||||
$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->first_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/'.$code)],true);
|
||||
if ($user->mobile != '' && $user->mobile != null) {
|
||||
if ($user->first_name) {
|
||||
if($user->first_name) {
|
||||
$name = $user->first_name;
|
||||
} else {
|
||||
$name = $user->user_name;
|
||||
@@ -77,25 +79,27 @@ class PasswordController extends Controller
|
||||
'url' => url('password/reset/'.$code),
|
||||
'name' => $name,
|
||||
'mobile' => $user->mobile,
|
||||
'code' => $user->country_code, ];
|
||||
\Event::fire('reset.password2', [$value]);
|
||||
'code' => $user->country_code];
|
||||
\Event::fire('reset.password2',array($value));
|
||||
}
|
||||
|
||||
return redirect()->back()->with('status', Lang::get('lang.we_have_e-mailed_your_password_reset_link'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', Lang::get("lang.we_can't_find_a_user_with_that_e-mail_address"));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the given user's password.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function reset(Request $request)
|
||||
{
|
||||
|
||||
$this->validate(
|
||||
$request,
|
||||
$this->getResetValidationRules(),
|
||||
@@ -107,25 +111,26 @@ class PasswordController extends Controller
|
||||
$email = $credentials['email'];
|
||||
$password = $credentials['password'];
|
||||
$token = $credentials['token'];
|
||||
$response = 'fails';
|
||||
$password_tokens = \DB::table('password_resets')->where('email', '=', $email)->first();
|
||||
if ($password_tokens) {
|
||||
if ($password_tokens->token == $token) {
|
||||
$response = "fails";
|
||||
$password_tokens = \DB::table('password_resets')->where('email','=',$email)->first();
|
||||
if($password_tokens){
|
||||
if($password_tokens->token == $token){
|
||||
$users = new User();
|
||||
$user = $users->where('email', $email)->first();
|
||||
if ($user) {
|
||||
$user = $users->where('email',$email)->first();
|
||||
if($user){
|
||||
$user->password = \Hash::make($password);
|
||||
$user->save();
|
||||
$response = 'success';
|
||||
$response = "success";
|
||||
} else {
|
||||
$response = 'fails';
|
||||
$response = "fails";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($response == 'success') {
|
||||
if ($response == "success") {
|
||||
return redirect('/auth/login')->with('status', Lang::get('lang.password-reset-successfully'));
|
||||
} else {
|
||||
return redirect('/home')->with('fails', Lang::get('lang.password-can-not-reset'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,14 +11,15 @@ use App\Model\helpdesk\Agent\Department;
|
||||
// models
|
||||
use App\Model\helpdesk\Form\Fields;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Ticket;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\User;
|
||||
use Exception;
|
||||
@@ -35,16 +36,15 @@ use Redirect;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class FormController extends Controller
|
||||
{
|
||||
class FormController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* Constructor to check.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController)
|
||||
{
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController) {
|
||||
$this->middleware('board');
|
||||
// creating a TicketController instance
|
||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||
@@ -57,31 +57,29 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getForm(Help_topic $topic, CountryCode $code)
|
||||
{
|
||||
public function getForm(Help_topic $topic, CountryCode $code) {
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
return \Redirect::route('licence');
|
||||
}
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||
if (!\Auth::check() && ($settings->status == 1 || $settings->status == '1')) {
|
||||
return redirect('auth/login')->with(['login_require' => 'Please login to your account for submitting a ticket', 'referer' => 'form']);
|
||||
return redirect('auth/login')->with(['login_require'=> 'Please login to your account for submitting a ticket', 'referer' => 'form']);
|
||||
}
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
if (System::first()->status == 1) {
|
||||
$topics = $topic->get();
|
||||
$codes = $code->get();
|
||||
if ($phonecode->phonecode) {
|
||||
$phonecode = $phonecode->phonecode;
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
if (System::first()->status == 1) {
|
||||
$topics = $topic->get();
|
||||
$codes = $code->get();
|
||||
if ($phonecode->phonecode) {
|
||||
$phonecode = $phonecode->phonecode;
|
||||
} else {
|
||||
$phonecode = "";
|
||||
}
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory'))->with('phonecode', $phonecode);
|
||||
} else {
|
||||
$phonecode = '';
|
||||
return \Redirect::route('home');
|
||||
}
|
||||
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory'))->with('phonecode', $phonecode);
|
||||
} else {
|
||||
return \Redirect::route('home');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,43 +90,43 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function postForm($id, Help_topic $topic)
|
||||
{
|
||||
public function postForm($id, Help_topic $topic) {
|
||||
if ($id != 0) {
|
||||
$helptopic = $topic->where('id', '=', $id)->first();
|
||||
$custom_form = $helptopic->custom_form;
|
||||
$values = Fields::where('forms_id', '=', $custom_form)->get();
|
||||
if (!$values) {
|
||||
|
||||
}
|
||||
if ($values) {
|
||||
foreach ($values as $form_data) {
|
||||
if ($form_data->type == 'select') {
|
||||
if ($form_data->type == "select") {
|
||||
$form_fields = explode(',', $form_data->value);
|
||||
$var = '';
|
||||
$var = "";
|
||||
foreach ($form_fields as $form_field) {
|
||||
$var .= '<option value="'.$form_field.'">'.$form_field.'</option>';
|
||||
$var .= '<option value="' . $form_field . '">' . $form_field . '</option>';
|
||||
}
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><select class="form-control" name="'.$form_data->name.'">'.$var.'</select>';
|
||||
} elseif ($form_data->type == 'radio') {
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><select class="form-control" name="' . $form_data->name . '">' . $var . '</select>';
|
||||
} elseif ($form_data->type == "radio") {
|
||||
$type2 = $form_data->value;
|
||||
$vals = explode(',', $type2);
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><br/>';
|
||||
foreach ($vals as $val) {
|
||||
echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'"> '.$form_data->value.' ';
|
||||
echo '<input type="' . $form_data->type . '" name="' . $form_data->name . '"> ' . $form_data->value . ' ';
|
||||
}
|
||||
echo '<br/>';
|
||||
} elseif ($form_data->type == 'textarea') {
|
||||
echo "<br/>";
|
||||
} elseif ($form_data->type == "textarea") {
|
||||
$type3 = $form_data->value;
|
||||
echo '<br/><label>'.$form_data->label.'</label></br><textarea id="unique-textarea" name="'.$form_data->name.'" class="form-control" style="height:15%;"></textarea>';
|
||||
} elseif ($form_data->type == 'checkbox') {
|
||||
echo '<br/><label>' . $form_data->label . '</label></br><textarea id="unique-textarea" name="' . $form_data->name . '" class="form-control" style="height:15%;"></textarea>';
|
||||
} elseif ($form_data->type == "checkbox") {
|
||||
$type4 = $form_data->value;
|
||||
$checks = explode(',', $type4);
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><br/>';
|
||||
foreach ($checks as $check) {
|
||||
echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'">  '.$check;
|
||||
echo '<input type="' . $form_data->type . '" name="' . $form_data->name . '">  ' . $check;
|
||||
}
|
||||
} else {
|
||||
echo '<br/><label>'.ucfirst($form_data->label).'</label><input type="'.$form_data->type.'" class="form-control" name="'.$form_data->name.'" />';
|
||||
echo '<br/><label>' . ucfirst($form_data->label) . '</label><input type="' . $form_data->type . '" class="form-control" name="' . $form_data->name . '" />';
|
||||
}
|
||||
}
|
||||
echo '<br/><br/>';
|
||||
@@ -144,16 +142,15 @@ 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, Ticket_attachments $ta, CountryCode $code)
|
||||
{
|
||||
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token', 'mobile', 'Code', 'priority');
|
||||
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta, CountryCode $code) {
|
||||
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token','mobile','Code', 'priority');
|
||||
$name = $request->input('Name');
|
||||
$phone = $request->input('Phone');
|
||||
if ($request->input('Email')) {
|
||||
if ($request->input('Email')) {
|
||||
if($request->input('Email')) {
|
||||
$email = $request->input('Email');
|
||||
} else {
|
||||
$email = null;
|
||||
$email = null;
|
||||
}
|
||||
} else {
|
||||
$email = null;
|
||||
@@ -168,18 +165,18 @@ class FormController extends Controller
|
||||
}
|
||||
$status = $ticket_settings->first()->status;
|
||||
$helptopic = $request->input('helptopic');
|
||||
$helpTopicObj = Help_topic::where('id', '=', $helptopic);
|
||||
if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
|
||||
$helpTopicObj = Help_topic::where('id','=', $helptopic);
|
||||
if($helpTopicObj->exists() && ($helpTopicObj->value('status')==1)){
|
||||
$department = $helpTopicObj->value('department');
|
||||
} else {
|
||||
$defaultHelpTopicID = Ticket::where('id', '=', '1')->first()->help_topic;
|
||||
$department = Help_topic::where('id', '=', $defaultHelpTopicID)->value('department');
|
||||
}else{
|
||||
$defaultHelpTopicID = Ticket::where('id', '=', '1')->first()->help_topic;
|
||||
$department = Help_topic::where('id','=', $defaultHelpTopicID)->value('department');
|
||||
}
|
||||
$sla = $ticket_settings->first()->sla;
|
||||
|
||||
|
||||
// $priority = $ticket_settings->first()->priority;
|
||||
$default_priority = Ticket_Priority::where('is_default', '=', 1)->first();
|
||||
$user_priority = CommonSettings::select('status')->where('option_name', '=', 'user_priority')->first();
|
||||
$default_priority = Ticket_Priority::where('is_default','=',1)->first();
|
||||
$user_priority = CommonSettings::where('option_name','=','user_priority')->first();
|
||||
if (!($request->input('priority'))) {
|
||||
$priority = $default_priority->priority_id;
|
||||
} else {
|
||||
@@ -196,8 +193,8 @@ class FormController extends Controller
|
||||
$geoipcode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
if ($phonecode == null) {
|
||||
$data = [
|
||||
'fails' => Lang::get('lang.country-code-required-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'fails' => Lang::get('lang.country-code-required-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'country_code_error' => 1,
|
||||
];
|
||||
|
||||
@@ -206,8 +203,8 @@ class FormController extends Controller
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $phonecode)->get();
|
||||
if (!count($code)) {
|
||||
$data = [
|
||||
'fails' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'fails' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'country_code_error' => 1,
|
||||
];
|
||||
|
||||
@@ -233,7 +230,7 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
// dd($result);
|
||||
return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is').' '.$result[0].'. '.Lang::get('lang.Please-save-this-for-future-reference'));
|
||||
return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is') . ' ' . $result[0] . '. ' . Lang::get('lang.Please-save-this-for-future-reference'));
|
||||
} else {
|
||||
return Redirect::back()->withInput($request->except('password'))->with('fails', Lang::get('lang.failed-to-create-user-tcket-as-mobile-has-been-taken'));
|
||||
}
|
||||
@@ -247,14 +244,14 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function post_ticket_reply($id, Request $request)
|
||||
{
|
||||
public function post_ticket_reply($id, Request $request) {
|
||||
|
||||
try {
|
||||
if ($comment != null) {
|
||||
$tickets = Tickets::where('id', '=', $id)->first();
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $tickets->id)->first();
|
||||
|
||||
$subject = $thread->title.'[#'.$tickets->ticket_number.']';
|
||||
$subject = $thread->title . '[#' . $tickets->ticket_number . ']';
|
||||
$body = $request->input('comment');
|
||||
|
||||
$user_cred = User::where('id', '=', $tickets->user_id)->first();
|
||||
@@ -288,14 +285,13 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getCustomForm(Request $request)
|
||||
{
|
||||
$html = '';
|
||||
public function getCustomForm(Request $request) {
|
||||
$html = "";
|
||||
$helptopic_id = $request->input('helptopic');
|
||||
$helptopics = new Help_topic();
|
||||
$helptopic = $helptopics->find($helptopic_id);
|
||||
if (!$helptopic) {
|
||||
throw new Exception('We can not find your request');
|
||||
throw new Exception("We can not find your request");
|
||||
}
|
||||
$custom_form = $helptopic->custom_form;
|
||||
if ($custom_form) {
|
||||
@@ -304,7 +300,7 @@ class FormController extends Controller
|
||||
$form_controller = new \App\Http\Controllers\Admin\helpdesk\FormController($fields, $forms);
|
||||
$html = $form_controller->renderForm($custom_form);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,30 +6,30 @@ namespace App\Http\Controllers\Client\helpdesk;
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\OtpVerifyRequest;
|
||||
use App\Http\Requests\helpdesk\ProfilePassword;
|
||||
use App\Http\Requests\helpdesk\ProfileRequest;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
// models
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
// models
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Http\Requests\helpdesk\OtpVerifyRequest;
|
||||
use App\Model\helpdesk\Utility\Otp;
|
||||
use App\User;
|
||||
use Auth;
|
||||
// classes
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Exception;
|
||||
use GeoIP;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Socialite;
|
||||
|
||||
/**
|
||||
@@ -37,15 +37,14 @@ use Socialite;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class GuestController extends Controller
|
||||
{
|
||||
class GuestController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public function __construct(PhpMailController $PhpMailController)
|
||||
{
|
||||
public function __construct(PhpMailController $PhpMailController) {
|
||||
$this->middleware('board');
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
// checking authentication
|
||||
@@ -57,17 +56,15 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getProfile(CountryCode $code)
|
||||
{
|
||||
public function getProfile(CountryCode $code) {
|
||||
$user = Auth::user();
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location->iso_code)->first();
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
$status = $settings->status;
|
||||
|
||||
return view('themes.default1.client.helpdesk.profile', compact('user'))
|
||||
->with(['phonecode' => $phonecode->phonecode,
|
||||
'verify' => $status, ]);
|
||||
'verify' => $status]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,8 +75,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postProfile(ProfileRequest $request)
|
||||
{
|
||||
public function postProfile(ProfileRequest $request) {
|
||||
try {
|
||||
// geet authenticated user details
|
||||
$user = Auth::user();
|
||||
@@ -89,14 +85,14 @@ class GuestController extends Controller
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
|
||||
if (!count($code)) {
|
||||
return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput();
|
||||
}
|
||||
}
|
||||
$user->country_code = $request->country_code;
|
||||
}
|
||||
$user->fill($request->except('profile_pic', 'mobile'));
|
||||
$user->gender = $request->input('gender');
|
||||
$user->save();
|
||||
if (Input::file('profile_pic')) {
|
||||
// fetching picture name
|
||||
// fetching picture name
|
||||
$name = Input::file('profile_pic')->getClientOriginalName();
|
||||
// fetching upload destination path
|
||||
$destinationPath = 'uploads/profilepic';
|
||||
@@ -113,10 +109,11 @@ class GuestController extends Controller
|
||||
$user->mobile = null;
|
||||
}
|
||||
if ($user->save()) {
|
||||
return redirect()->back()->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
|
||||
return redirect()->back()->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
|
||||
} else {
|
||||
return redirect()->back()->route('profile')->with('fails', Lang::get('lang.Profile-Updated-sucessfully'));
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->route('profile')->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -124,10 +121,8 @@ class GuestController extends Controller
|
||||
|
||||
/**
|
||||
*@category fucntion to check if mobile number is unqique or not
|
||||
*
|
||||
*@param string $mobile
|
||||
*
|
||||
*@return bool true(if mobile exists in users table)/false (if mobile does not exist in user table)
|
||||
*@return boolean true(if mobile exists in users table)/false (if mobile does not exist in user table)
|
||||
*/
|
||||
public function checkMobile($mobile)
|
||||
{
|
||||
@@ -139,7 +134,6 @@ class GuestController extends Controller
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -150,8 +144,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getTicket(Help_topic $topic)
|
||||
{
|
||||
public function getTicket(Help_topic $topic) {
|
||||
$topics = $topic->get();
|
||||
|
||||
return view('themes.default1.client.helpdesk.tickets.form', compact('topics'));
|
||||
@@ -164,8 +157,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getForm(Help_topic $topic)
|
||||
{
|
||||
public function getForm(Help_topic $topic) {
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
return \Redirect::route('licence');
|
||||
}
|
||||
@@ -187,8 +179,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getMyticket()
|
||||
{
|
||||
public function getMyticket() {
|
||||
return view('themes.default1.client.helpdesk.mytickets');
|
||||
}
|
||||
|
||||
@@ -201,8 +192,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function thread(Ticket_Thread $thread, Tickets $tickets, User $user)
|
||||
{
|
||||
public function thread(Ticket_Thread $thread, Tickets $tickets, User $user) {
|
||||
$user_id = Auth::user()->id;
|
||||
//dd($user_id);
|
||||
/* get the ticket's id == ticket_id of thread */
|
||||
@@ -219,8 +209,8 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public function ticketEdit()
|
||||
{
|
||||
public function ticketEdit() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,8 +221,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postProfilePassword(ProfilePassword $request)
|
||||
{
|
||||
public function postProfilePassword(ProfilePassword $request) {
|
||||
$user = Auth::user();
|
||||
//echo $user->password;
|
||||
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
|
||||
@@ -257,8 +246,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function reply(Ticket_Thread $thread, TicketRequest $request)
|
||||
{
|
||||
public function reply(Ticket_Thread $thread, TicketRequest $request) {
|
||||
$thread->ticket_id = $request->input('ticket_ID');
|
||||
$thread->title = $request->input('To');
|
||||
$thread->user_id = Auth::user()->id;
|
||||
@@ -269,7 +257,7 @@ class GuestController extends Controller
|
||||
$tickets = Tickets::where('id', '=', $ticket_id)->first();
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first();
|
||||
|
||||
return Redirect('thread/'.$ticket_id);
|
||||
return Redirect('thread/' . $ticket_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,8 +268,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function getCheckTicket(Tickets $ticket, User $user)
|
||||
{
|
||||
public function getCheckTicket(Tickets $ticket, User $user) {
|
||||
return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket'));
|
||||
}
|
||||
|
||||
@@ -295,10 +282,9 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function PostCheckTicket(Request $request)
|
||||
{
|
||||
public function PostCheckTicket(Request $request) {
|
||||
$validator = \Validator::make($request->all(), [
|
||||
'email' => 'required|email',
|
||||
'email' => 'required|email',
|
||||
'ticket_number' => 'required',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
@@ -318,7 +304,7 @@ class GuestController extends Controller
|
||||
if ($user->role == 'user') {
|
||||
$username = $user->first_name;
|
||||
} else {
|
||||
$username = $user->first_name.' '.$user->last_name;
|
||||
$username = $user->first_name . ' ' . $user->last_name;
|
||||
}
|
||||
if ($user->email != $Email) {
|
||||
return \Redirect::route('form')->with('fails', Lang::get("lang.email_didn't_match_with_ticket_number"));
|
||||
@@ -329,7 +315,7 @@ class GuestController extends Controller
|
||||
$company = $this->company();
|
||||
|
||||
$this->PhpMailController->sendmail(
|
||||
$from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $user->email], $message = ['subject' => 'Ticket link Request ['.$Ticket_number.']', 'scenario' => 'check-ticket'], $template_variables = ['user' => $username, 'ticket_link_with_number' => \URL::route('check_ticket', $code)]
|
||||
$from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $user->email], $message = ['subject' => 'Ticket link Request [' . $Ticket_number . ']', 'scenario' => 'check-ticket'], $template_variables = ['user' => $username, 'ticket_link_with_number' => \URL::route('check_ticket', $code)]
|
||||
);
|
||||
|
||||
return \Redirect::back()
|
||||
@@ -345,12 +331,10 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function get_ticket_email($id, CommonSettings $common_settings)
|
||||
{
|
||||
public function get_ticket_email($id, CommonSettings $common_settings) {
|
||||
$common_setting = $common_settings->select('status')
|
||||
->where('option_name', '=', 'user_set_ticket_status')
|
||||
->first();
|
||||
|
||||
return view('themes.default1.client.helpdesk.ckeckticket', compact('id', 'common_setting'));
|
||||
}
|
||||
|
||||
@@ -361,8 +345,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getTicketStat(Tickets $ticket)
|
||||
{
|
||||
public function getTicketStat(Tickets $ticket) {
|
||||
return view('themes.default1.client.helpdesk.ckeckticket', compact('ticket'));
|
||||
}
|
||||
|
||||
@@ -371,8 +354,7 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
public function company() {
|
||||
$company = Company::Where('id', '=', '1')->first();
|
||||
if ($company->company_name == null) {
|
||||
$company = 'Support Center';
|
||||
@@ -389,11 +371,10 @@ class GuestController extends Controller
|
||||
$sms = DB::table('sms')->get();
|
||||
if (count($sms) > 0) {
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return 'Plugin has not been setup successfully.';
|
||||
return "Plugin has not been setup successfully.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,19 +386,18 @@ class GuestController extends Controller
|
||||
->first();
|
||||
if ($otp != null) {
|
||||
$otp_length = strlen(Input::get('otp'));
|
||||
if (($otp_length == 6 && !preg_match('/[a-z]/i', Input::get('otp')))) {
|
||||
if(($otp_length == 6 && !preg_match("/[a-z]/i", Input::get('otp'))) ) {
|
||||
$otp2 = Hash::make(Input::get('otp'));
|
||||
$date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
|
||||
$date2 = date('Y-m-d h:i:sa');
|
||||
$date1 = date_format($otp->updated_at, "Y-m-d h:i:sa");
|
||||
$date2 = date("Y-m-d h:i:sa");
|
||||
$time1 = new DateTime($date2);
|
||||
$time2 = new DateTime($date1);
|
||||
$interval = $time1->diff($time2);
|
||||
if ($interval->i > 10 || $interval->h > 0) {
|
||||
if($interval->i >10 || $interval->h >0){
|
||||
$message = Lang::get('lang.otp-expired');
|
||||
|
||||
return $message;
|
||||
} else {
|
||||
if (Hash::check(Input::get('otp'), $otp->otp)) {
|
||||
if (Hash::check(Input::get('otp'), $otp->otp)){
|
||||
Otp::where('user_id', '=', Input::get('u_id'))
|
||||
->update(['otp' => '']);
|
||||
// User::where('id', '=', $user->id)
|
||||
@@ -426,24 +406,20 @@ class GuestController extends Controller
|
||||
return 1;
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-invalid');
|
||||
|
||||
return $message;
|
||||
}
|
||||
} else {
|
||||
$message = Lang::get('lang.otp-not-matched');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
public function sync()
|
||||
{
|
||||
public function sync() {
|
||||
try {
|
||||
$provider = $this->getProvider();
|
||||
$this->changeRedirect();
|
||||
@@ -455,67 +431,56 @@ class GuestController extends Controller
|
||||
$user['email'] = $users->email;
|
||||
$user['username'] = $users->nickname;
|
||||
$user['avatar'] = $users->avatar;
|
||||
|
||||
return redirect('client-profile')->with('success', 'Additional informations fetched');
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
|
||||
return redirect('client-profile')->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getProvider()
|
||||
{
|
||||
public function getProvider() {
|
||||
$provider = \Session::get('provider');
|
||||
|
||||
return $provider;
|
||||
}
|
||||
|
||||
public function changeRedirect()
|
||||
{
|
||||
public function changeRedirect() {
|
||||
$provider = \Session::get('provider');
|
||||
$url = \Session::get($provider.'redirect');
|
||||
$url = \Session::get($provider . 'redirect');
|
||||
\Config::set("services.$provider.redirect", $url);
|
||||
}
|
||||
|
||||
public function forgetSession()
|
||||
{
|
||||
public function forgetSession() {
|
||||
$provider = $this->getProvider();
|
||||
\Session::forget('provider');
|
||||
\Session::forget($provider.'redirect');
|
||||
\Session::forget($provider . 'redirect');
|
||||
}
|
||||
|
||||
public function checkArray($key, $array)
|
||||
{
|
||||
$value = '';
|
||||
public function checkArray($key, $array) {
|
||||
$value = "";
|
||||
if (array_key_exists($key, $array)) {
|
||||
$value = $array[$key];
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function updateUser($user = [])
|
||||
{
|
||||
public function updateUser($user = []) {
|
||||
$userid = \Auth::user()->id;
|
||||
$useremail = \Auth::user()->email;
|
||||
$email = $this->checkArray('email', $user); //$user['email'];
|
||||
if ($email !== '' && $email !== $useremail) {
|
||||
throw new Exception('Sorry! your current email and '.ucfirst($user['provider']).' email is different so system can not sync');
|
||||
if ($email !== "" && $email !== $useremail) {
|
||||
throw new Exception("Sorry! your current email and " . ucfirst($user['provider']) . " email is different so system can not sync");
|
||||
}
|
||||
$this->update($userid, $user);
|
||||
}
|
||||
|
||||
public function update($userid, $user, $provider)
|
||||
{
|
||||
public function update($userid, $user, $provider) {
|
||||
$email = $this->checkArray('email', $user);
|
||||
$this->deleteUser($userid, $user, $provider);
|
||||
$this->insertAdditional($userid, $provider, $user);
|
||||
$this->changeEmail($email);
|
||||
}
|
||||
|
||||
public function deleteUser($userid, $user, $provider)
|
||||
{
|
||||
public function deleteUser($userid, $user, $provider) {
|
||||
$info = new \App\UserAdditionalInfo();
|
||||
$infos = $info->where('owner', $userid)->where('service', $provider)->get();
|
||||
if ($infos->count() > 0 && count($user) > 0) {
|
||||
@@ -527,27 +492,27 @@ class GuestController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function insertAdditional($id, $provider, $user = [])
|
||||
{
|
||||
public function insertAdditional($id, $provider, $user = []) {
|
||||
$info = new \App\UserAdditionalInfo();
|
||||
if (count($user) > 0) {
|
||||
foreach ($user as $key => $value) {
|
||||
|
||||
$info->create([
|
||||
'owner' => $id,
|
||||
'owner' => $id,
|
||||
'service' => $provider,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function changeEmail($email)
|
||||
{
|
||||
public function changeEmail($email) {
|
||||
$user = \Auth::user();
|
||||
if ($user && $email && !$user->email) {
|
||||
$user->email = $email;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
// models
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Settings\Followup;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Settings\Followup;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Ticket\TicketToken;
|
||||
use App\User;
|
||||
@@ -320,10 +320,9 @@ class UnAuthController extends Controller
|
||||
|
||||
/**
|
||||
*@category function to change system's language
|
||||
*
|
||||
*@param string $lang //desired language's iso code
|
||||
*
|
||||
*@param string $lang //desired language's iso code
|
||||
*@return response
|
||||
*
|
||||
*/
|
||||
public static function changeLanguage($lang)
|
||||
{
|
||||
@@ -342,55 +341,54 @@ class UnAuthController extends Controller
|
||||
// dd()
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Follow up tickets
|
||||
public function followup()
|
||||
{
|
||||
$followup = Followup::whereId('1')->first();
|
||||
$condition = $followup->condition;
|
||||
{
|
||||
$followup=Followup::whereId('1')->first();
|
||||
$condition=$followup->condition;
|
||||
// dd($condition);
|
||||
|
||||
switch ($condition) {
|
||||
case 'everyMinute':
|
||||
$followup_set = ' + 1 minute';
|
||||
case "everyMinute":
|
||||
$followup_set= ' + 1 minute';
|
||||
break;
|
||||
case 'everyFiveMinutes':
|
||||
$followup_set = ' + 5 minute';
|
||||
case "everyFiveMinutes":
|
||||
$followup_set= ' + 5 minute';
|
||||
break;
|
||||
case 'everyTenMinutes':
|
||||
$followup_set = ' + 10 minute';
|
||||
case "everyTenMinutes":
|
||||
$followup_set= ' + 10 minute';
|
||||
break;
|
||||
case 'everyThirtyMinutes':
|
||||
$followup_set = ' + 30 minute';
|
||||
case "everyThirtyMinutes":
|
||||
$followup_set=' + 30 minute';
|
||||
break;
|
||||
case 'hourly':
|
||||
$followup_set = ' + 1 hours';
|
||||
case "hourly":
|
||||
$followup_set=' + 1 hours';
|
||||
break;
|
||||
case 'daily':
|
||||
$followup_set = ' + 1 day';
|
||||
case "daily":
|
||||
$followup_set=' + 1 day';
|
||||
break;
|
||||
case 'weekly':
|
||||
$followup_set = ' + 7 day';
|
||||
case "weekly":
|
||||
$followup_set=' + 7 day';
|
||||
break;
|
||||
case 'monthly':
|
||||
$followup_set = ' + 30 day';
|
||||
case "monthly":
|
||||
$followup_set=' + 30 day';
|
||||
break;
|
||||
case 'yearly':
|
||||
$followup_set = ' + 365 day';
|
||||
case "yearly":
|
||||
$followup_set=' + 365 day';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($followup->status = 1) {
|
||||
$tickets = Tickets::where('id', '>=', 1)->where('status', '!=', 5)->get();
|
||||
if($followup->status=1){
|
||||
$tickets=Tickets::where('id', '>=', 1)->where('status', '!=', 5)->get();
|
||||
// dd( $tickets);
|
||||
// $tickets=Tickets::where('id', '>=', 1)->where('status', '!=', 5)->pluck('id');
|
||||
// dd( $tickets);
|
||||
// $id=1;
|
||||
foreach ($tickets as $ticket) {
|
||||
foreach($tickets as $ticket) {
|
||||
// $id=1;
|
||||
// $id++;
|
||||
// $ticket=Tickets::where('status', '!=', 5)->get();
|
||||
@@ -398,20 +396,27 @@ class UnAuthController extends Controller
|
||||
// dd($ticket);
|
||||
// if($ticket != null){
|
||||
// dd('here');
|
||||
$ck = date('Y-m-d H:i:s', strtotime($ticket->updated_at.$followup_set));
|
||||
$ck=date('Y-m-d H:i:s', strtotime($ticket->updated_at . $followup_set));
|
||||
// dd($ck);
|
||||
$current_time = date('Y-m-d H:i:s');
|
||||
if ($current_time > $ck) {
|
||||
$ticket->follow_up = 1;
|
||||
$current_time=date('Y-m-d H:i:s');
|
||||
if($current_time>$ck){
|
||||
|
||||
$ticket->follow_up=1;
|
||||
$ticket->save();
|
||||
// Tickets::where('id', '=',$id)
|
||||
// ->update(['follow_up' => 1]);
|
||||
|
||||
|
||||
// }
|
||||
}
|
||||
// if($id=2)
|
||||
// {dd($ticket);}
|
||||
|
||||
}
|
||||
}
|
||||
// if($id=2)
|
||||
// {dd($ticket);}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,9 @@ use Lang;
|
||||
use Mail;
|
||||
use Redirect;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
class UserController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('board');
|
||||
}
|
||||
|
||||
@@ -36,20 +35,18 @@ class UserController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function getArticle(Article $article, Category $category, Settings $settings)
|
||||
{
|
||||
public function getArticle(Article $article, Category $category, Settings $settings) {
|
||||
$setting = $settings->first();
|
||||
$pagination = $setting->pagination;
|
||||
if (!Auth::check() || \Auth::user()->role == 'user') {
|
||||
$article = $article->where('status', '1');
|
||||
}
|
||||
$article = $article->where('type', '1');
|
||||
$article = $article->orderBy('publish_time', 'desc');
|
||||
$article = $article->orderBy('publish_time','desc');
|
||||
$article = $article->paginate($pagination);
|
||||
|
||||
|
||||
$article->setPath('article-list');
|
||||
$categorys = $category->get();
|
||||
|
||||
return view('themes.default1.client.kb.article-list.articles', compact('time', 'categorys', 'article'));
|
||||
}
|
||||
|
||||
@@ -62,8 +59,7 @@ class UserController extends Controller
|
||||
*
|
||||
* @return string excerpt
|
||||
*/
|
||||
public static function getExcerpt($str, $startPos = 0, $maxLength = 50)
|
||||
{
|
||||
public static function getExcerpt($str, $startPos = 0, $maxLength = 50) {
|
||||
if (strlen($str) > $maxLength) {
|
||||
$excerpt = substr($str, $startPos, $maxLength - 3);
|
||||
$lastSpace = strrpos($excerpt, ' ');
|
||||
@@ -86,14 +82,13 @@ class UserController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function search(SearchRequest $request, Category $category, Article $article, Settings $settings)
|
||||
{
|
||||
public function search(SearchRequest $request, Category $category, Article $article, Settings $settings) {
|
||||
$settings = $settings->first();
|
||||
$pagination = $settings->pagination;
|
||||
$search = $request->input('s');
|
||||
$result = $article->where('name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('slug', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('description', 'LIKE', '%'.$search.'%')
|
||||
$result = $article->where('name', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('slug', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('description', 'LIKE', '%' . $search . '%')
|
||||
->paginate($pagination);
|
||||
$result->setPath('search?s='.$search);
|
||||
$categorys = $category->get();
|
||||
@@ -106,16 +101,15 @@ class UserController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function show($slug, Article $article, Category $category)
|
||||
{
|
||||
public function show($slug, Article $article, Category $category) {
|
||||
//ArticleController::timezone();
|
||||
$tz = \App\Model\helpdesk\Settings\System::where('id', '1')->first()->time_zone;
|
||||
$tz = \App\Model\helpdesk\Utility\Timezones::where('id', $tz)->first()->name;
|
||||
date_default_timezone_set($tz);
|
||||
$date = \Carbon\Carbon::now()->toDateTimeString();
|
||||
$arti = $article->where('slug', $slug);
|
||||
|
||||
if (!Auth::check() || \Auth::user()->role == 'user') {
|
||||
|
||||
if (!Auth::check()|| \Auth::user()->role == 'user') {
|
||||
$arti = $arti->where('status', '1');
|
||||
$arti = $arti->where('publish_time', '<', $date);
|
||||
}
|
||||
@@ -131,8 +125,7 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategory($slug, Article $article, Category $category, Relationship $relation)
|
||||
{
|
||||
public function getCategory($slug, Article $article, Category $category, Relationship $relation) {
|
||||
/* get the article_id where category_id == current category */
|
||||
$catid = $category->where('slug', $slug)->first();
|
||||
if (!$catid) {
|
||||
@@ -148,8 +141,7 @@ class UserController extends Controller
|
||||
return view('themes.default1.client.kb.article-list.category', compact('all', 'id', 'categorys', 'article_id'));
|
||||
}
|
||||
|
||||
public function home(Article $article, Category $category, Relationship $relation)
|
||||
{
|
||||
public function home(Article $article, Category $category, Relationship $relation) {
|
||||
if (Config::get('database.install') == '%0%') {
|
||||
return redirect('step1');
|
||||
} else {
|
||||
@@ -161,8 +153,7 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function Faq(Faq $faq, Category $category)
|
||||
{
|
||||
public function Faq(Faq $faq, Category $category) {
|
||||
$faq = $faq->where('id', '1')->first();
|
||||
$categorys = $category->get();
|
||||
|
||||
@@ -174,8 +165,7 @@ class UserController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function contact(Category $category, Settings $settings)
|
||||
{
|
||||
public function contact(Category $category, Settings $settings) {
|
||||
$settings = $settings->whereId('1')->first();
|
||||
$categorys = $category->get();
|
||||
|
||||
@@ -187,8 +177,7 @@ class UserController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function postContact(ContactRequest $request, Contact $contact)
|
||||
{
|
||||
public function postContact(ContactRequest $request, Contact $contact) {
|
||||
$this->port();
|
||||
$this->host();
|
||||
$this->encryption();
|
||||
@@ -206,8 +195,8 @@ class UserController extends Controller
|
||||
//echo $message;
|
||||
//echo $contact->email;
|
||||
$mail = Mail::send('themes.default1.client.kb.article-list.contact-details', ['name' => $name, 'email' => $email, 'subject' => $subject, 'details' => $details], function ($message) use ($contact) {
|
||||
$message->to($contact->email, $contact->name)->subject('Contact');
|
||||
});
|
||||
$message->to($contact->email, $contact->name)->subject('Contact');
|
||||
});
|
||||
if ($mail) {
|
||||
return redirect('contact')->with('success', Lang::get('lang.your_details_send_to_system'));
|
||||
} else {
|
||||
@@ -215,8 +204,7 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function contactDetails()
|
||||
{
|
||||
public function contactDetails() {
|
||||
return view('themes.default1.client.kb.article-list.contact-details');
|
||||
}
|
||||
|
||||
@@ -230,11 +218,10 @@ class UserController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function postComment($slug, Article $article, CommentRequest $request, Comment $comment)
|
||||
{
|
||||
public function postComment($slug, Article $article, CommentRequest $request, Comment $comment) {
|
||||
$article = $article->where('slug', $slug)->first();
|
||||
if (!$article) {
|
||||
return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed'));
|
||||
if(!$article){
|
||||
return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed'));
|
||||
}
|
||||
$id = $article->id;
|
||||
$comment->article_id = $id;
|
||||
@@ -245,49 +232,42 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getPage($name, Page $page)
|
||||
{
|
||||
public function getPage($name, Page $page) {
|
||||
$page = $page->where('slug', $name)->first();
|
||||
if ($page) {
|
||||
if($page){
|
||||
return view('themes.default1.client.kb.article-list.pages', compact('page'));
|
||||
} else {
|
||||
}else{
|
||||
return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function port()
|
||||
{
|
||||
public static function port() {
|
||||
$setting = Settings::whereId('1')->first();
|
||||
Config::set('mail.port', $setting->port);
|
||||
}
|
||||
|
||||
public static function host()
|
||||
{
|
||||
public static function host() {
|
||||
$setting = Settings::whereId('1')->first();
|
||||
Config::set('mail.host', $setting->host);
|
||||
}
|
||||
|
||||
public static function encryption()
|
||||
{
|
||||
public static function encryption() {
|
||||
$setting = Settings::whereId('1')->first();
|
||||
Config::set(['mail.encryption' => $setting->encryption, 'mail.username' => $setting->email]);
|
||||
}
|
||||
|
||||
public static function email()
|
||||
{
|
||||
public static function email() {
|
||||
$setting = Settings::whereId('1')->first();
|
||||
Config::set(['mail.from' => ['address' => $setting->email, 'name' => 'asd']]);
|
||||
//dd(Config::get('mail'));
|
||||
}
|
||||
|
||||
public static function password()
|
||||
{
|
||||
public static function password() {
|
||||
$setting = Settings::whereId('1')->first();
|
||||
Config::set(['mail.password' => $setting->password, 'mail.sendmail' => $setting->email]);
|
||||
}
|
||||
|
||||
public function getCategoryList(Article $article, Category $category, Relationship $relation)
|
||||
{
|
||||
public function getCategoryList(Article $article, Category $category, Relationship $relation) {
|
||||
//$categorys = $category->get();
|
||||
$categorys = $category->get();
|
||||
// $categorys->setPath('home');
|
||||
@@ -309,15 +289,13 @@ class UserController extends Controller
|
||||
// //return substr($date, 0, -6);
|
||||
// }
|
||||
|
||||
public function clientProfile()
|
||||
{
|
||||
public function clientProfile() {
|
||||
$user = Auth::user();
|
||||
|
||||
return view('themes.default1.client.kb.article-list.profile', compact('user'));
|
||||
}
|
||||
|
||||
public function postClientProfile($id, ProfileRequest $request)
|
||||
{
|
||||
public function postClientProfile($id, ProfileRequest $request) {
|
||||
$user = Auth::user();
|
||||
$user->gender = $request->input('gender');
|
||||
$user->save();
|
||||
@@ -336,7 +314,7 @@ class UserController extends Controller
|
||||
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
|
||||
$name = Input::file('profile_pic')->getClientOriginalName();
|
||||
$destinationPath = 'lb-faveo/dist/img';
|
||||
$fileName = rand(0000, 9999).'.'.$name;
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
//echo $fileName;
|
||||
Input::file('profile_pic')->move($destinationPath, $fileName);
|
||||
$user->profile_pic = $fileName;
|
||||
@@ -350,8 +328,7 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function postClientProfilePassword($id, ProfilePassword $request)
|
||||
{
|
||||
public function postClientProfilePassword($id, ProfilePassword $request) {
|
||||
$user = Auth::user();
|
||||
//echo $user->password;
|
||||
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
|
||||
@@ -363,4 +340,5 @@ class UserController extends Controller
|
||||
return redirect()->back()->with('fails', Lang::get('lang.password_was_not_updated'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,21 +2,23 @@
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Excel;
|
||||
use Exception;
|
||||
|
||||
class ExcelController extends Controller
|
||||
{
|
||||
public function export($filename, $data)
|
||||
{
|
||||
if (count($data) == 0) {
|
||||
class ExcelController extends Controller {
|
||||
|
||||
public function export($filename, $data) {
|
||||
if(count($data)==0){
|
||||
throw new Exception('No data');
|
||||
}
|
||||
Excel::create($filename, function ($excel) use ($data) {
|
||||
$excel->sheet('sheet', function ($sheet) use ($data) {
|
||||
Excel::create($filename, function($excel) use($data){
|
||||
$excel->sheet('sheet', function($sheet) use($data) {
|
||||
$sheet->fromArray($data);
|
||||
});
|
||||
})->export('xls');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class FileuploadController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
class FileuploadController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking if role is agent
|
||||
@@ -16,8 +15,7 @@ class FileuploadController extends Controller
|
||||
|
||||
// Returns a file size limit in bytes based on the PHP upload_max_filesize
|
||||
// and post_max_size
|
||||
public function file_upload_max_size()
|
||||
{
|
||||
function file_upload_max_size() {
|
||||
static $max_size = -1;
|
||||
|
||||
if ($max_size < 0) {
|
||||
@@ -33,13 +31,11 @@ class FileuploadController extends Controller
|
||||
$max_size_in_actual = ini_get('upload_max_filesize');
|
||||
}
|
||||
}
|
||||
|
||||
return ['0' => $max_size_in_bytes, '1' => $max_size_in_actual];
|
||||
// return $max_size_in_bytes;
|
||||
}
|
||||
|
||||
public function parse_size($size)
|
||||
{
|
||||
function parse_size($size) {
|
||||
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
|
||||
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
|
||||
if ($unit) {
|
||||
@@ -49,4 +45,5 @@ class FileuploadController extends Controller
|
||||
return round($size);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,32 +4,33 @@ namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Notification\Notification;
|
||||
use App\Model\helpdesk\Notification\NotificationType;
|
||||
use App\Model\helpdesk\Notification\UserNotification;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Notification\NotificationType;
|
||||
|
||||
class NotificationController extends Controller {
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
*********************************************
|
||||
* ********************************************
|
||||
* Class Notification Controller
|
||||
*********************************************
|
||||
* ********************************************
|
||||
* This controller is used to generate in app notification
|
||||
* under the folling occurrence
|
||||
* under the folling occurrence
|
||||
* 1. Ticket Creation
|
||||
* 2. Ticket Reply
|
||||
* 3. User Creation.
|
||||
*
|
||||
* 3. User Creation
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
|
||||
$user = new User();
|
||||
$this->user = $user;
|
||||
// checking authentication
|
||||
@@ -40,7 +41,6 @@ class NotificationController extends Controller
|
||||
|
||||
/**
|
||||
* This function is used to create in app notifications.
|
||||
*
|
||||
* @param type $model_id
|
||||
* @param type $userid_created
|
||||
* @param type $type_id
|
||||
@@ -68,62 +68,49 @@ class NotificationController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is to mark all ticket to read status.
|
||||
*
|
||||
* This function is to mark all ticket to read status
|
||||
* @param type $id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function markAllRead($id)
|
||||
{
|
||||
public function markAllRead($id) {
|
||||
$markasread = UserNotification::where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->is_read = '1';
|
||||
$mark->save();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function to mark read.
|
||||
*
|
||||
* This function to mark read
|
||||
* @param type $id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function markRead($id)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to show all the notifications.
|
||||
*
|
||||
* function to show all the notifications
|
||||
* @return type
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
public function show() {
|
||||
$notifications = $this->getNotifications();
|
||||
|
||||
//dd($notifications);
|
||||
return view('notifications-all', compact('notifications'));
|
||||
}
|
||||
|
||||
/**
|
||||
* function to delete notifications.
|
||||
*
|
||||
* function to delete notifications
|
||||
* @param type $id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
public function delete($id) {
|
||||
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->delete();
|
||||
@@ -132,25 +119,36 @@ class NotificationController extends Controller
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function deleteAll() {
|
||||
try{
|
||||
$notifications = new Notification();
|
||||
if ($notifications->count()>0) {
|
||||
foreach ($notifications->get() as $notification) {
|
||||
$notification->delete();
|
||||
}
|
||||
}
|
||||
$notifications->dummyDelete();
|
||||
return redirect()->back()->with('success', 'deleted');
|
||||
} catch (\Exception $ex){
|
||||
return redirect()->back()->with('fails',$ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.user_id', '=', \Auth::user()->id)
|
||||
->select('notification_types.id as id', 'notifications.id as notification_id',
|
||||
'user_notification.user_id as user_id', 'user_notification.is_read as is_read',
|
||||
'user_notification.created_at as created_at', 'user_notification.updated_at as updated_at', 'notifications.model_id as model_id',
|
||||
'notifications.userid_created as userid_created',
|
||||
'notifications.type_id as type_id', 'notification_types.message as message',
|
||||
'notification_types.type as type', 'notification_types.icon_class as icon_class')
|
||||
->orderBy('user_notification.created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
public static function getNotifications() {
|
||||
$notifications = UserNotification::with([
|
||||
'notification.type' => function($query) {
|
||||
$query->select('id', 'message', 'type');
|
||||
}, 'users' => function($query) {
|
||||
$query->select('id', 'email', 'profile_pic');
|
||||
}, 'notification.model' => function($query) {
|
||||
$query->select('id', 'ticket_number');
|
||||
},
|
||||
]);
|
||||
return $notifications;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,16 +10,14 @@ use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Mail;
|
||||
use Exception;
|
||||
use Lang;
|
||||
use Mail;
|
||||
|
||||
class PhpMailController extends Controller
|
||||
{
|
||||
public function fetch_smtp_details($id)
|
||||
{
|
||||
class PhpMailController extends Controller {
|
||||
|
||||
public function fetch_smtp_details($id) {
|
||||
$emails = Emails::where('id', '=', $id)->first();
|
||||
|
||||
return $emails;
|
||||
}
|
||||
|
||||
@@ -28,8 +26,7 @@ class PhpMailController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
public function company() {
|
||||
$company = Company::Where('id', '=', '1')->first();
|
||||
if ($company->company_name == null) {
|
||||
$company = 'Support Center';
|
||||
@@ -48,32 +45,27 @@ class PhpMailController extends Controller
|
||||
*
|
||||
* @return type integer
|
||||
*/
|
||||
public function mailfrom($reg, $dept_id)
|
||||
{
|
||||
$email = Email::where('id', '=', '1')->first();
|
||||
if ($reg == 1) {
|
||||
return $email->sys_email;
|
||||
} elseif ($dept_id > 0) {
|
||||
$department = Department::where('id', '=', $dept_id)->first();
|
||||
if ($department->outgoing_email) {
|
||||
return $department->outgoing_email;
|
||||
} else {
|
||||
return $email->sys_email;
|
||||
}
|
||||
public function mailfrom($reg, $dept_id) {
|
||||
$email_id = "";
|
||||
$emails = Emails::where('department', '=', $dept_id)->first();
|
||||
|
||||
$email = Email::find(1);
|
||||
if ($emails && $emails->sending_status) {
|
||||
$email_id = $emails->id;
|
||||
} else {
|
||||
$email_id = $email->sys_email;
|
||||
}
|
||||
return $email_id;
|
||||
}
|
||||
|
||||
public function sendmail($from, $to, $message, $template_variables)
|
||||
{
|
||||
public function sendmail($from, $to, $message, $template_variables) {
|
||||
$this->setQueue();
|
||||
$job = new \App\Jobs\SendEmail($from, $to, $message, $template_variables);
|
||||
$dispatch = $this->dispatch($job);
|
||||
|
||||
return $dispatch;
|
||||
$this->dispatch($job);
|
||||
}
|
||||
|
||||
public function sendEmail($from, $to, $message, $template_variables)
|
||||
{
|
||||
public function sendEmail($from, $to, $message, $template_variables) {
|
||||
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
if ($from_address == null) {
|
||||
throw new Exception(Lang::get('lang.system-email-not-configured'));
|
||||
@@ -104,11 +96,11 @@ class PhpMailController extends Controller
|
||||
$ticket_link_with_number = $this->checkElement('ticket_link_with_number', $template_variables);
|
||||
|
||||
$system_from = $this->checkElement('system_from', $template_variables);
|
||||
if ($system_from === '') {
|
||||
if ($system_from === "") {
|
||||
$system_from = $this->company();
|
||||
}
|
||||
$system_link = $this->checkElement('system_link', $template_variables);
|
||||
if ($system_link === '') {
|
||||
if ($system_link === "") {
|
||||
$system_link = \Config::get('app.url');
|
||||
}
|
||||
$ticket_link = $this->checkElement('ticket_link', $template_variables);
|
||||
@@ -121,6 +113,7 @@ class PhpMailController extends Controller
|
||||
$email_address = $this->checkElement('email_address', $template_variables);
|
||||
$user = $this->checkElement('user', $template_variables);
|
||||
|
||||
|
||||
$status = \DB::table('settings_email')->first();
|
||||
|
||||
$template = TemplateType::where('name', '=', $template_type)->first();
|
||||
@@ -134,7 +127,7 @@ class PhpMailController extends Controller
|
||||
if ($template_data->subject) {
|
||||
$subject = $template_data->subject;
|
||||
if ($ticket_number != null) {
|
||||
$subject = $subject.' [#'.$ticket_number.']';
|
||||
$subject = $subject . ' [#' . $ticket_number . ']';
|
||||
}
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
@@ -147,6 +140,7 @@ class PhpMailController extends Controller
|
||||
$subject = null;
|
||||
}
|
||||
|
||||
|
||||
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}', '{!!$ticket_link!!}'];
|
||||
|
||||
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link, $ticket_link];
|
||||
@@ -156,20 +150,20 @@ class PhpMailController extends Controller
|
||||
$contents = $messagebody;
|
||||
}
|
||||
|
||||
|
||||
if ($template_type == 'ticket-reply-agent') {
|
||||
$line = '---Reply above this line--- <br/><br/>';
|
||||
$content = $line.$messagebody;
|
||||
$content = $line . $messagebody;
|
||||
} else {
|
||||
$content = $messagebody;
|
||||
}
|
||||
}
|
||||
$send = $this->laravelMail($recipants, $recipantname, $subject, $content, $cc, $attachment);
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
public function setMailConfig($from_address)
|
||||
{
|
||||
public function setMailConfig($from_address) {
|
||||
|
||||
$username = $from_address->email_address;
|
||||
$fromname = $from_address->email_name;
|
||||
$password = $from_address->password;
|
||||
@@ -186,94 +180,88 @@ class PhpMailController extends Controller
|
||||
$port = '';
|
||||
}
|
||||
$configs = [
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $fromname],
|
||||
'password' => $password,
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $fromname,],
|
||||
'password' => $password,
|
||||
'encryption' => $smtpsecure,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $protocol,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $protocol,
|
||||
];
|
||||
foreach ($configs as $key => $config) {
|
||||
if (is_array($config)) {
|
||||
foreach ($config as $from) {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
\Config::set('mail.' . $key, $config);
|
||||
}
|
||||
} else {
|
||||
\Config::set('mail.'.$key, $config);
|
||||
\Config::set('mail.' . $key, $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setServices($emailid, $protocol)
|
||||
{
|
||||
public function setServices($emailid, $protocol) {
|
||||
$service = new \App\Model\MailJob\FaveoMail();
|
||||
$services = $service->where('email_id', $emailid)->lists('value', 'key')->toArray();
|
||||
$controller = new \App\Http\Controllers\Admin\helpdesk\EmailsController();
|
||||
$controller->setServiceConfig($protocol, $services);
|
||||
}
|
||||
|
||||
public function checkElement($element, $array)
|
||||
{
|
||||
$value = '';
|
||||
public function checkElement($element, $array) {
|
||||
$value = "";
|
||||
if (is_array($array)) {
|
||||
if (array_key_exists($element, $array)) {
|
||||
if (key_exists($element, $array)) {
|
||||
$value = $array[$element];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function laravelMail($to, $toname, $subject, $data, $cc, $attach)
|
||||
{
|
||||
public function laravelMail($to, $toname, $subject, $data, $cc, $attach) {
|
||||
//dd($to, $toname, $subject, $data, $cc, $attach);
|
||||
//dd(\Config::get('mail'));
|
||||
//dd($attach);
|
||||
$mail = Mail::send('emails.mail', ['data' => $data], function ($m) use ($to, $subject, $toname, $cc, $attach) {
|
||||
$m->to($to, $toname)->subject($subject);
|
||||
$m->to($to, $toname)->subject($subject);
|
||||
|
||||
if ($cc != null) {
|
||||
foreach ($cc as $collaborator) {
|
||||
//mail to collaborators
|
||||
if ($cc != null) {
|
||||
foreach ($cc as $collaborator) {
|
||||
//mail to collaborators
|
||||
$collab_user_id = $collaborator->user_id;
|
||||
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
|
||||
$collab_email = $user_id_collab->email;
|
||||
$m->cc($collab_email);
|
||||
}
|
||||
}
|
||||
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
|
||||
$collab_email = $user_id_collab->email;
|
||||
$m->cc($collab_email);
|
||||
}
|
||||
}
|
||||
|
||||
// $mail->addBCC($bc);
|
||||
$size = count($attach);
|
||||
if ($size > 0) {
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
if (is_array($attach) && array_key_exists($i, $attach)) {
|
||||
$mode = 'normal';
|
||||
if (is_array($attach[$i]) && array_key_exists('mode', $attach[$i])) {
|
||||
$mode = $attach[$i]['mode'];
|
||||
if ($size > 0) {
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
if (is_array($attach) && array_key_exists($i, $attach)) {
|
||||
$mode = 'normal';
|
||||
if (is_array($attach[$i]) && array_key_exists('mode', $attach[$i])) {
|
||||
$mode = $attach[$i]['mode'];
|
||||
}
|
||||
$file = $attach[$i]['file_path'];
|
||||
$name = $attach[$i]['file_name'];
|
||||
$mime = $attach[$i]['mime'];
|
||||
$this->attachmentMode($m, $file, $name, $mime, $mode);
|
||||
}
|
||||
}
|
||||
$file = $attach[$i]['file_path'];
|
||||
$name = $attach[$i]['file_name'];
|
||||
$mime = $attach[$i]['mime'];
|
||||
$this->attachmentMode($m, $file, $name, $mime, $mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if (is_object($mail) || (is_object($mail) && $mail->getStatusCode() == 200)) {
|
||||
$mail = 1;
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
public function setQueue()
|
||||
{
|
||||
public function setQueue() {
|
||||
$short = 'database';
|
||||
$field = [
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'expire' => 60,
|
||||
];
|
||||
$queue = new \App\Model\MailJob\QueueService();
|
||||
@@ -286,20 +274,18 @@ class PhpMailController extends Controller
|
||||
$this->setQueueConfig($short, $field);
|
||||
}
|
||||
|
||||
public function setQueueConfig($short, $field)
|
||||
{
|
||||
public function setQueueConfig($short, $field) {
|
||||
\Config::set('queue.default', $short);
|
||||
foreach ($field as $key => $value) {
|
||||
\Config::set("queue.connections.$short.$key", $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function attachmentMode($message, $file, $name, $mime, $mode)
|
||||
{
|
||||
public function attachmentMode($message, $file, $name, $mime, $mode) {
|
||||
if ($mode == 'data') {
|
||||
return $message->attachData(base64_decode($file, true), $name, ['mime' => $mime]);
|
||||
}
|
||||
|
||||
return $message->attach($file, ['as' => $name, 'mime' => $mime]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Model\helpdesk\Email\Smtp;
|
||||
// models
|
||||
use App\Model\helpdesk\Settings\Plugin;
|
||||
use App\Model\helpdesk\Theme\Widgets;
|
||||
use App\Model\helpdesk\Utility\Version_Check;
|
||||
use Config;
|
||||
// classes
|
||||
use Crypt;
|
||||
@@ -26,15 +27,14 @@ use Lang;
|
||||
* ***************************
|
||||
* Controller to keep smtp details and fetch where ever needed.
|
||||
*/
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
class SettingsController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
@@ -44,8 +44,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function widgets()
|
||||
{
|
||||
public function widgets() {
|
||||
return view('themes.default1.admin.helpdesk.theme.widgets');
|
||||
}
|
||||
|
||||
@@ -54,8 +53,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function list_widget()
|
||||
{
|
||||
public function list_widget() {
|
||||
return \Datatable::collection(Widgets::where('id', '<', '7')->get())
|
||||
->searchColumns('name')
|
||||
->orderColumns('name', 'title', 'value')
|
||||
@@ -69,33 +67,33 @@ class SettingsController extends Controller
|
||||
return $model->value;
|
||||
})
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<span data-toggle="modal" data-target="#edit_widget'.$model->id.'"><a class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a></span>
|
||||
<div class="modal fade" id="edit_widget'.$model->id.'">
|
||||
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
|
||||
<div class="modal fade" id="edit_widget' . $model->id . '">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form action="'.url('edit-widget/'.$model->id).'" method="POST">
|
||||
<form action="' . url('edit-widget/' . $model->id) . '" method="POST">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">'.strtoupper($model->name).' </h4>
|
||||
<h4 class="modal-title">' . strtoupper($model->name) . ' </h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" style="width:100%">
|
||||
<label>'.\Lang::get('lang.title').'</label><br/>
|
||||
<input type="text" name="title" value="'.$model->title.'" class="form-control" style="width:100%">
|
||||
<label>' . \Lang::get('lang.title') . '</label><br/>
|
||||
<input type="text" name="title" value="' . $model->title . '" class="form-control" style="width:100%">
|
||||
</div>
|
||||
<br/>
|
||||
<div class="form-group" style="width:100%">
|
||||
<label>'.\Lang::get('lang.content').'</label><br/>
|
||||
<textarea name="content" class="form-control" style="width:100%" id="Content'.$model->id.'">'.$model->value.'</textarea>
|
||||
<label>' . \Lang::get('lang.content') . '</label><br/>
|
||||
<textarea name="content" class="form-control" style="width:100%" id="Content' . $model->id . '">' . $model->value . '</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button>
|
||||
<input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button>
|
||||
<input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
$("#Content'.$model->id.'").wysihtml5();
|
||||
$("#Content' . $model->id . '").wysihtml5();
|
||||
});
|
||||
</script>
|
||||
</form>
|
||||
@@ -114,15 +112,13 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function edit_widget($id, Widgets $widgets, Request $request)
|
||||
{
|
||||
public function edit_widget($id, Widgets $widgets, Request $request) {
|
||||
$widget = $widgets->where('id', '=', $id)->first();
|
||||
$widget->title = $request->title;
|
||||
$widget->value = $request->content;
|
||||
try {
|
||||
$widget->save();
|
||||
|
||||
return redirect()->back()->with('success', $widget->name.Lang::get('lang.saved_successfully'));
|
||||
return redirect()->back()->with('success', $widget->name . Lang::get('lang.saved_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -133,8 +129,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function social_buttons()
|
||||
{
|
||||
public function social_buttons() {
|
||||
return view('themes.default1.admin.helpdesk.theme.social');
|
||||
}
|
||||
|
||||
@@ -143,8 +138,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function list_social_buttons()
|
||||
{
|
||||
public function list_social_buttons() {
|
||||
return \Datatable::collection(Widgets::where('id', '>', '6')->get())
|
||||
->searchColumns('name')
|
||||
->orderColumns('name', 'value')
|
||||
@@ -155,25 +149,25 @@ class SettingsController extends Controller
|
||||
return $model->value;
|
||||
})
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<span data-toggle="modal" data-target="#edit_widget'.$model->id.'"><a class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a></span>
|
||||
<div class="modal fade" id="edit_widget'.$model->id.'">
|
||||
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
|
||||
<div class="modal fade" id="edit_widget' . $model->id . '">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form action="'.url('edit-widget/'.$model->id).'" method="POST">
|
||||
<form action="' . url('edit-widget/' . $model->id) . '" method="POST">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">'.strtoupper($model->name).' </h4>
|
||||
<h4 class="modal-title">' . strtoupper($model->name) . ' </h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<br/>
|
||||
<div class="form-group" style="width:100%">
|
||||
<label>'.\Lang::get('lang.link').'</label><br/>
|
||||
<input type="url" name="content" class="form-control" style="width:100%" value="'.$model->value.'">
|
||||
<label>' . \Lang::get('lang.link') . '</label><br/>
|
||||
<input type="url" name="content" class="form-control" style="width:100%" value="' . $model->value . '">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button>
|
||||
<input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button>
|
||||
<input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -191,15 +185,14 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function edit_social_buttons($id, Widgets $widgets, Request $request)
|
||||
{
|
||||
public function edit_social_buttons($id, Widgets $widgets, Request $request) {
|
||||
$widget = $widgets->where('id', '=', $id)->first();
|
||||
$widget->title = $request->title;
|
||||
$widget->value = $request->content;
|
||||
try {
|
||||
$widget->save();
|
||||
|
||||
return redirect()->back()->with('success', $widget->name.' Saved Successfully');
|
||||
return redirect()->back()->with('success', $widget->name . ' Saved Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
@@ -210,10 +203,8 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function getsmtp()
|
||||
{
|
||||
public function getsmtp() {
|
||||
$settings = Smtp::where('id', '=', '1')->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.smtp', compact('settings'));
|
||||
}
|
||||
|
||||
@@ -222,8 +213,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function postsmtp(SmtpRequest $request)
|
||||
{
|
||||
public function postsmtp(SmtpRequest $request) {
|
||||
$data = Smtp::where('id', '=', 1)->first();
|
||||
$data->driver = $request->input('driver');
|
||||
$data->host = $request->input('host');
|
||||
@@ -234,7 +224,6 @@ class SettingsController extends Controller
|
||||
$data->password = Crypt::encrypt($request->input('password'));
|
||||
try {
|
||||
$data->save();
|
||||
|
||||
return \Redirect::route('getsmtp')->with('success', 'success');
|
||||
} catch (Exception $e) {
|
||||
return \Redirect::route('getsmtp')->with('fails', $e->errorInfo[2]);
|
||||
@@ -249,8 +238,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function PostSettings(Settings $set, Request $request)
|
||||
{
|
||||
public function PostSettings(Settings $set, Request $request) {
|
||||
$settings = $set->where('id', '1')->first();
|
||||
$pass = $request->input('password');
|
||||
$password = Crypt::encrypt($pass);
|
||||
@@ -263,7 +251,7 @@ class SettingsController extends Controller
|
||||
if (Input::file('logo')) {
|
||||
$name = Input::file('logo')->getClientOriginalName();
|
||||
$destinationPath = 'dist/logo';
|
||||
$fileName = rand(0000, 9999).'.'.$name;
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
Input::file('logo')->move($destinationPath, $fileName);
|
||||
$settings->logo = $fileName;
|
||||
$settings->save();
|
||||
@@ -277,13 +265,11 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function Plugins()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.settings.plugins', ['info' => 1]);
|
||||
public function Plugins() {
|
||||
return view('themes.default1.admin.helpdesk.settings.plugins');
|
||||
}
|
||||
|
||||
public function GetPlugin()
|
||||
{
|
||||
public function GetPlugin() {
|
||||
$plugins = $this->fetchConfig();
|
||||
|
||||
return \Datatable::collection(new Collection($plugins))
|
||||
@@ -291,15 +277,15 @@ class SettingsController extends Controller
|
||||
->addColumn('name', function ($model) {
|
||||
if (array_has($model, 'path')) {
|
||||
if ($model['status'] == 0) {
|
||||
$activate = '<a href='.url('plugin/status/'.$model['path']).'>Activate</a>';
|
||||
$activate = '<a href=' . url('plugin/status/' . $model['path']) . '>Activate</a>';
|
||||
$settings = ' ';
|
||||
} else {
|
||||
$settings = '<a href='.url($model['settings']).'>Settings</a> | ';
|
||||
$activate = '<a href='.url('plugin/status/'.$model['path']).'>Deactivate</a>';
|
||||
$settings = '<a href=' . url($model['settings']) . '>Settings</a> | ';
|
||||
$activate = '<a href=' . url('plugin/status/' . $model['path']) . '>Deactivate</a>';
|
||||
}
|
||||
|
||||
$delete = '<a href="#" id=delete'.$model['path'].' data-toggle=modal data-target=#del'.$model['path']."><span style='color:red'>Delete</span></a>"
|
||||
."<div class='modal fade' id=del".$model['path'].">
|
||||
$delete = '<a href="#" id=delete' . $model['path'] . ' data-toggle=modal data-target=#del' . $model['path'] . "><span style='color:red'>Delete</span></a>"
|
||||
. "<div class='modal fade' id=del" . $model['path'] . ">
|
||||
<div class='modal-dialog'>
|
||||
<div class=modal-content>
|
||||
<div class=modal-header>
|
||||
@@ -308,8 +294,8 @@ class SettingsController extends Controller
|
||||
<div class=modal-body>
|
||||
<p>Are you Sure ?</p>
|
||||
<div class=modal-footer>
|
||||
<button type=button class='btn btn-default pull-left' data-dismiss=modal id=dismis>".\Lang::get('lang.close').'</button>
|
||||
<a href='.url('plugin/delete/'.$model['path'])."><button class='btn btn-danger'>Delete</button></a>
|
||||
<button type=button class='btn btn-default pull-left' data-dismiss=modal id=dismis>" . \Lang::get('lang.close') . '</button>
|
||||
<a href=' . url('plugin/delete/' . $model['path']) . "><button class='btn btn-danger'>Delete</button></a>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -317,12 +303,12 @@ class SettingsController extends Controller
|
||||
</div>
|
||||
</div>
|
||||
</div>";
|
||||
$action = '<br><br>'.$delete.' | '.$settings.$activate;
|
||||
$action = '<br><br>' . $delete . ' | ' . $settings . $activate;
|
||||
} else {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
return ucfirst($model['name']).$action;
|
||||
return ucfirst($model['name']) . $action;
|
||||
})
|
||||
->addColumn('description', function ($model) {
|
||||
return ucfirst($model['description']);
|
||||
@@ -331,7 +317,7 @@ class SettingsController extends Controller
|
||||
return ucfirst($model['author']);
|
||||
})
|
||||
->addColumn('website', function ($model) {
|
||||
return '<a href='.$model['website'].' target=_blank>'.$model['website'].'</a>';
|
||||
return '<a href=' . $model['website'] . ' target=_blank>' . $model['website'] . '</a>';
|
||||
})
|
||||
->addColumn('version', function ($model) {
|
||||
return $model['version'];
|
||||
@@ -344,9 +330,8 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function ReadPlugins()
|
||||
{
|
||||
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins';
|
||||
public function ReadPlugins() {
|
||||
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins';
|
||||
$plugins = array_diff(scandir($dir), ['.', '..']);
|
||||
|
||||
return $plugins;
|
||||
@@ -359,16 +344,15 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function PostPlugins(Request $request)
|
||||
{
|
||||
public function PostPlugins(Request $request) {
|
||||
$this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
|
||||
try {
|
||||
if (!extension_loaded('zip')) {
|
||||
if (!extension_loaded('zip')){
|
||||
throw new Exception('Please enable zip extension in your php');
|
||||
}
|
||||
$plug = new Plugin();
|
||||
$file = $request->file('plugin');
|
||||
$destination = app_path().DIRECTORY_SEPARATOR.'Plugins';
|
||||
$destination = app_path() . DIRECTORY_SEPARATOR . 'Plugins';
|
||||
$zipfile = $file->getRealPath();
|
||||
/*
|
||||
* get the file name and remove .zip
|
||||
@@ -381,32 +365,32 @@ class SettingsController extends Controller
|
||||
if (in_array($filename, $dir_check)) {
|
||||
return redirect()->back()->with('fails', Lang::get('lang.plugin-exists'));
|
||||
}
|
||||
mkdir($destination.DIRECTORY_SEPARATOR.$filename);
|
||||
mkdir($destination . DIRECTORY_SEPARATOR . $filename);
|
||||
/*
|
||||
* extract the zip file using zipper
|
||||
*/
|
||||
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination.DIRECTORY_SEPARATOR.$filename);
|
||||
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination . DIRECTORY_SEPARATOR . $filename);
|
||||
|
||||
$file = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR.$filename; // Plugin file path
|
||||
$file = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $filename; // Plugin file path
|
||||
|
||||
if (file_exists($file)) {
|
||||
$seviceporvider = $file.DIRECTORY_SEPARATOR.'ServiceProvider.php';
|
||||
$config = $file.DIRECTORY_SEPARATOR.'config.php';
|
||||
$seviceporvider = $file . DIRECTORY_SEPARATOR . 'ServiceProvider.php';
|
||||
$config = $file . DIRECTORY_SEPARATOR . 'config.php';
|
||||
if (file_exists($seviceporvider) && file_exists($config)) {
|
||||
/*
|
||||
* move to faveo config
|
||||
*/
|
||||
$faveoconfig = config_path().DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$filename.'.php';
|
||||
$faveoconfig = config_path() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $filename . '.php';
|
||||
if ($faveoconfig) {
|
||||
|
||||
//copy($config, $faveoconfig);
|
||||
/*
|
||||
* write provider list in app.php line 128
|
||||
*/
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
|
||||
chmod($app, 0644);
|
||||
$str = "\n\n\t\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 187;
|
||||
$str = "\n\n\t\t\t'App\\Plugins\\$filename" . "\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 194;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
file_put_contents($app, implode("\n", $lines));
|
||||
@@ -419,7 +403,7 @@ class SettingsController extends Controller
|
||||
*/
|
||||
$this->deleteDirectory($file);
|
||||
|
||||
return redirect()->back()->with('fails', Lang::get('no-plugin-file').$file);
|
||||
return redirect()->back()->with('fails', Lang::get('no-plugin-file') . $file);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@@ -427,7 +411,7 @@ class SettingsController extends Controller
|
||||
*/
|
||||
$this->deleteDirectory($file);
|
||||
|
||||
return redirect()->back()->with('fails', Lang::get('plugin-config-missing').$file);
|
||||
return redirect()->back()->with('fails', Lang::get('plugin-config-missing') . $file);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@@ -435,7 +419,7 @@ class SettingsController extends Controller
|
||||
*/
|
||||
$this->deleteDirectory($file);
|
||||
|
||||
return redirect()->back()->with('fails', '<b>'.Lang::get('lang.plugin-path-missing').'</b> '.$file);
|
||||
return redirect()->back()->with('fails', '<b>' . Lang::get('lang.plugin-path-missing') . '</b> ' . $file);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
@@ -449,8 +433,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteDirectory($dir)
|
||||
{
|
||||
public function deleteDirectory($dir) {
|
||||
if (!file_exists($dir)) {
|
||||
return true;
|
||||
}
|
||||
@@ -461,8 +444,8 @@ class SettingsController extends Controller
|
||||
if ($item == '.' || $item == '..') {
|
||||
continue;
|
||||
}
|
||||
chmod($dir.DIRECTORY_SEPARATOR.$item, 0777);
|
||||
if (!$this->deleteDirectory($dir.DIRECTORY_SEPARATOR.$item)) {
|
||||
chmod($dir . DIRECTORY_SEPARATOR . $item, 0777);
|
||||
if (!$this->deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -471,9 +454,8 @@ class SettingsController extends Controller
|
||||
return rmdir($dir);
|
||||
}
|
||||
|
||||
public function ReadConfigs()
|
||||
{
|
||||
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR;
|
||||
public function ReadConfigs() {
|
||||
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR;
|
||||
$directories = scandir($dir);
|
||||
$files = [];
|
||||
foreach ($directories as $key => $file) {
|
||||
@@ -481,7 +463,7 @@ class SettingsController extends Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($dir.DIRECTORY_SEPARATOR.$file)) {
|
||||
if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
|
||||
$files[$key] = $file;
|
||||
}
|
||||
}
|
||||
@@ -490,7 +472,7 @@ class SettingsController extends Controller
|
||||
$plugins = [];
|
||||
if (count($files) > 0) {
|
||||
foreach ($files as $key => $file) {
|
||||
$plugin = $dir.$file;
|
||||
$plugin = $dir . $file;
|
||||
$plugins[$key] = array_diff(scandir($plugin), ['.', '..', 'ServiceProvider.php']);
|
||||
$plugins[$key]['file'] = $plugin;
|
||||
}
|
||||
@@ -500,7 +482,7 @@ class SettingsController extends Controller
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file == 'config.php') {
|
||||
$config[] = $dir.DIRECTORY_SEPARATOR.$file;
|
||||
$config[] = $dir . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
@@ -513,8 +495,7 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function fetchConfig()
|
||||
{
|
||||
public function fetchConfig() {
|
||||
$configs = $this->ReadConfigs();
|
||||
//dd($configs);
|
||||
$plugs = new Plugin();
|
||||
@@ -550,15 +531,14 @@ class SettingsController extends Controller
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
public function DeletePlugin($slug)
|
||||
{
|
||||
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR.$slug;
|
||||
public function DeletePlugin($slug) {
|
||||
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $slug;
|
||||
$this->deleteDirectory($dir);
|
||||
/*
|
||||
* remove service provider from app.php
|
||||
*/
|
||||
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$path_to_file = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
|
||||
$path_to_file = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
|
||||
$file_contents = file_get_contents($path_to_file);
|
||||
$file_contents = str_replace($str, '//', $file_contents);
|
||||
file_put_contents($path_to_file, $file_contents);
|
||||
@@ -571,14 +551,13 @@ class SettingsController extends Controller
|
||||
return redirect()->back()->with('success', 'Deleted Successfully');
|
||||
}
|
||||
|
||||
public function StatusPlugin($slug)
|
||||
{
|
||||
public function StatusPlugin($slug) {
|
||||
$plugs = new Plugin();
|
||||
$plug = $plugs->where('name', $slug)->first();
|
||||
if (!$plug) {
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 187;
|
||||
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 194;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
file_put_contents($app, implode("\n", $lines));
|
||||
@@ -590,9 +569,9 @@ class SettingsController extends Controller
|
||||
if ($status == 0) {
|
||||
$plug->status = 1;
|
||||
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 187;
|
||||
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 194;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
file_put_contents($app, implode("\n", $lines));
|
||||
@@ -602,8 +581,8 @@ class SettingsController extends Controller
|
||||
/*
|
||||
* remove service provider from app.php
|
||||
*/
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$path_to_file = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
|
||||
$path_to_file = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
|
||||
|
||||
$file_contents = file_get_contents($path_to_file);
|
||||
$file_contents = str_replace($str, '//', $file_contents);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
use Socialite;
|
||||
|
||||
class Socialite extends Socialite
|
||||
{
|
||||
class Socialite extends Socialite{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\TemplateSetRequest;
|
||||
use App\Model\Common\Template;
|
||||
use App\Model\Common\TemplateSet;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
use Exception;
|
||||
|
||||
class TemplateSetController extends Controller
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -2,72 +2,66 @@
|
||||
|
||||
namespace App\Http\Controllers\Job;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Form;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MailController extends Controller
|
||||
{
|
||||
public function serviceForm(Request $request)
|
||||
{
|
||||
public function serviceForm(Request $request){
|
||||
$serviceid = $request->input('service');
|
||||
|
||||
$short_name = '';
|
||||
$mail_services = new \App\Model\MailJob\MailService();
|
||||
|
||||
$short_name = "";
|
||||
$mail_services = new \App\Model\MailJob\MailService();
|
||||
$mail_service = $mail_services->find($serviceid);
|
||||
if ($mail_service) {
|
||||
if($mail_service){
|
||||
$short_name = $mail_service->short_name;
|
||||
}
|
||||
$form = $this->getServiceForm($short_name);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function form($label, $name, $class)
|
||||
{
|
||||
|
||||
public function form($label,$name,$class){
|
||||
$mailid = \Input::get('emailid');
|
||||
if ($mailid) {
|
||||
$emails = new \App\Model\helpdesk\Email\Emails();
|
||||
$email = $emails->find($mailid);
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
|
||||
Form::text($name, $email->getExtraField($name), ['class' => 'form-control']).'</div>';
|
||||
} else {
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
|
||||
Form::text($name, null, ['class' => 'form-control']).'</div>';
|
||||
if($mailid){
|
||||
$emails = new \App\Model\helpdesk\Email\Emails();
|
||||
$email = $emails->find($mailid);
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label) ."<span class='text-red'> *</span>".
|
||||
Form::text($name, $email->getExtraField($name), ['class' => "form-control"])."</div>";
|
||||
}else{
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label) ."<span class='text-red'> *</span>".
|
||||
Form::text($name, NULL, ['class' => "form-control"])."</div>";
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function getServiceForm($short_name)
|
||||
{
|
||||
$form = '';
|
||||
try {
|
||||
switch ($short_name) {
|
||||
case 'smtp':
|
||||
|
||||
public function getServiceForm($short_name){
|
||||
$form = "";
|
||||
try{
|
||||
switch ($short_name){
|
||||
case "smtp":
|
||||
return $form;
|
||||
case 'mail':
|
||||
case "mail":
|
||||
return $form;
|
||||
case 'sendmail':
|
||||
case "sendmail":
|
||||
return $form;
|
||||
case 'mailgun':
|
||||
$form .= "<div class='row'>".$this->form('Domain', 'domain', 'col-md-6 form-group');
|
||||
$form .= $this->form('Secret Key', 'secret', 'col-md-6 form-group').'</div>';
|
||||
|
||||
case "mailgun":
|
||||
$form .= "<div class='row'>".$this->form('Domain', 'domain','col-md-6 form-group');
|
||||
$form .= $this->form('Secret Key', 'secret','col-md-6 form-group')."</div>";
|
||||
return $form;
|
||||
case 'mandrill':
|
||||
$form .= "<div class='row'>".$this->form('Secret Key', 'secret', 'col-md-6 form-group').'</div>';
|
||||
|
||||
case "mandrill":
|
||||
$form .= "<div class='row'>".$this->form('Secret Key', 'secret','col-md-6 form-group')."</div>";
|
||||
return $form;
|
||||
case 'log':
|
||||
case "log":
|
||||
return $form;
|
||||
case 'ses':
|
||||
$form .= "<div class='row'>".$this->form('Key', 'key', 'col-md-6 form-group');
|
||||
$form .= $this->form('Secret Key', 'secret', 'col-md-6 form-group').$this->form('Region', 'region', 'col-md-6 form-group').'</div>';
|
||||
|
||||
case "ses":
|
||||
$form .= "<div class='row'>".$this->form('Key', 'key','col-md-6 form-group');
|
||||
$form .= $this->form('Secret Key', 'secret','col-md-6 form-group').$this->form('Region', 'region','col-md-6 form-group')."</div>";
|
||||
return $form;
|
||||
default:
|
||||
default :
|
||||
return $form;
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
|
||||
@@ -2,51 +2,47 @@
|
||||
|
||||
namespace App\Http\Controllers\Job;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\Queue\QueueRequest;
|
||||
use App\Model\MailJob\FaveoQueue;
|
||||
use App\Model\MailJob\QueueService;
|
||||
use App\Model\MailJob\FaveoQueue;
|
||||
use Exception;
|
||||
use Form;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\helpdesk\Queue\QueueRequest;
|
||||
|
||||
class QueueController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
class QueueController extends Controller {
|
||||
|
||||
public function index() {
|
||||
try {
|
||||
$queue = new QueueService();
|
||||
$queues = $queue->select('id', 'name', 'status')->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.queue.index', compact('queues'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
public function edit($id) {
|
||||
try {
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($id);
|
||||
if (!$queue) {
|
||||
throw new Exception('Sorry we can not find your request');
|
||||
throw new Exception("Sorry we can not find your request");
|
||||
}
|
||||
|
||||
return view('themes.default1.admin.helpdesk.queue.edit', compact('queue'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id, QueueRequest $request)
|
||||
{
|
||||
public function update($id, QueueRequest $request) {
|
||||
|
||||
try {
|
||||
$values = $request->except('_token');
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($id);
|
||||
if (!$queue) {
|
||||
throw new Exception('Sorry we can not find your request');
|
||||
throw new Exception("Sorry we can not find your request");
|
||||
}
|
||||
$setting = new FaveoQueue();
|
||||
$settings = $setting->where('service_id', $id)->get();
|
||||
@@ -59,28 +55,26 @@ class QueueController extends Controller
|
||||
foreach ($values as $key => $value) {
|
||||
$setting->create([
|
||||
'service_id' => $id,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Updated');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function activate($id)
|
||||
{
|
||||
public function activate($id) {
|
||||
try {
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($id);
|
||||
$active_queue = $queues->where('status', 1)->first();
|
||||
if (!$queue) {
|
||||
throw new Exception('Sorry we can not find your request');
|
||||
throw new Exception("Sorry we can not find your request");
|
||||
}
|
||||
if ($queue->isActivate() == false && $id != 1 && $id != 2) {
|
||||
if ($queue->isActivate()==false&&$id!=1&&$id!=2) {
|
||||
throw new Exception("To activate $queue->name , Please configure it first");
|
||||
}
|
||||
if ($active_queue) {
|
||||
@@ -89,102 +83,89 @@ class QueueController extends Controller
|
||||
}
|
||||
$queue->status = 1;
|
||||
$queue->save();
|
||||
|
||||
return redirect()->back()->with('success', 'Activated');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getForm(Request $request)
|
||||
{
|
||||
|
||||
public function getForm(Request $request){
|
||||
$queueid = $request->input('queueid');
|
||||
$form = $this->getFormById($queueid);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function getShortNameById($queueid)
|
||||
{
|
||||
$short = '';
|
||||
public function getShortNameById($queueid) {
|
||||
$short = "";
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($queueid);
|
||||
if ($queue) {
|
||||
$short = $queue->short_name;
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
|
||||
public function getIdByShortName($short)
|
||||
{
|
||||
$id = '';
|
||||
public function getIdByShortName($short) {
|
||||
$id = "";
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->where('short_name', $short)->first();
|
||||
if ($queue) {
|
||||
$id = $queue->id;
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function getFormById($id)
|
||||
{
|
||||
public function getFormById($id) {
|
||||
$short = $this->getShortNameById($id);
|
||||
$form = '';
|
||||
$form = "";
|
||||
switch ($short) {
|
||||
case 'beanstalkd':
|
||||
case "beanstalkd":
|
||||
$form .= "<div class='row'>";
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'beanstalkd');
|
||||
$form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group', 'localhost');
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group','beanstalkd');
|
||||
$form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group','localhost');
|
||||
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'default');
|
||||
$form .= '</div>';
|
||||
|
||||
$form .= "</div>";
|
||||
return $form;
|
||||
case 'sqs':
|
||||
case "sqs":
|
||||
$form .= "<div class='row'>";
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'sqs');
|
||||
$form .= $this->form($short, 'Key', 'key', 'col-md-6 form-group', 'your-public-key');
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group','sqs');
|
||||
$form .= $this->form($short, 'Key', 'key', 'col-md-6 form-group','your-public-key');
|
||||
$form .= $this->form($short, 'Secret', 'secret', 'col-md-6 form-group', 'your-queue-url');
|
||||
$form .= $this->form($short, 'Region', 'region', 'col-md-6 form-group', 'us-east-1');
|
||||
$form .= '</div>';
|
||||
|
||||
$form .= "</div>";
|
||||
return $form;
|
||||
case 'iron':
|
||||
case "iron":
|
||||
$form .= "<div class='row'>";
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'iron');
|
||||
$form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group', 'mq-aws-us-east-1.iron.io');
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group','iron');
|
||||
$form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group','mq-aws-us-east-1.iron.io');
|
||||
$form .= $this->form($short, 'Token', 'token', 'col-md-6 form-group', 'your-token');
|
||||
$form .= $this->form($short, 'Project', 'project', 'col-md-6 form-group', 'your-project-id');
|
||||
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'your-queue-name');
|
||||
$form .= '</div>';
|
||||
|
||||
$form .= "</div>";
|
||||
return $form;
|
||||
case 'redis':
|
||||
case "redis":
|
||||
$form .= "<div class='row'>";
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'redis');
|
||||
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group','redis');
|
||||
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'default');
|
||||
$form .= '</div>';
|
||||
|
||||
$form .= "</div>";
|
||||
return $form;
|
||||
default:
|
||||
default :
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
public function form($short, $label, $name, $class, $placeholder = '')
|
||||
{
|
||||
public function form($short, $label, $name, $class, $placeholder = '') {
|
||||
$queueid = $this->getIdByShortName($short);
|
||||
$queues = new QueueService();
|
||||
$queue = $queues->find($queueid);
|
||||
if ($queue) {
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
|
||||
Form::text($name, $queue->getExtraField($name), ['class' => 'form-control', 'placeholder' => $placeholder]).'</div>';
|
||||
$form = "<div class='" . $class . "'>" . Form::label($name, $label) . "<span class='text-red'> *</span>" .
|
||||
Form::text($name, $queue->getExtraField($name), ['class' => "form-control", 'placeholder' => $placeholder]) . "</div>";
|
||||
} else {
|
||||
$form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
|
||||
Form::text($name, null, ['class' => 'form-control', 'placeholder' => $placeholder]).'</div>';
|
||||
$form = "<div class='" . $class . "'>" . Form::label($name, $label) . "<span class='text-red'> *</span>" .
|
||||
Form::text($name, NULL, ['class' => "form-control", 'placeholder' => $placeholder]) . "</div>";
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,18 +9,16 @@ use Artisan;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpgradeController extends Controller
|
||||
{
|
||||
class UpgradeController extends Controller {
|
||||
|
||||
public $dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$dir = base_path();
|
||||
$this->dir = $dir;
|
||||
}
|
||||
|
||||
public function getLatestVersion()
|
||||
{
|
||||
public function getLatestVersion() {
|
||||
try {
|
||||
$name = \Config::get('app.name');
|
||||
//dd($name);
|
||||
@@ -30,17 +28,17 @@ class UpgradeController extends Controller
|
||||
$order_number = '44596328';
|
||||
$url = env('APP_URL');
|
||||
$data = [
|
||||
'serial_key' => $serial_key,
|
||||
'serial_key' => $serial_key,
|
||||
'order_number' => $order_number,
|
||||
'name' => $name,
|
||||
'version' => Utility::getFileVersion(),
|
||||
'name' => $name,
|
||||
'version' => Utility::getFileVersion(),
|
||||
'request_type' => 'check_update',
|
||||
'url' => $url,
|
||||
'url' => $url,
|
||||
];
|
||||
$data = Utility::encryptByFaveoPublicKey(json_encode($data));
|
||||
//dd($data);
|
||||
$post_data = [
|
||||
'data' => $data,
|
||||
'data' => $data
|
||||
];
|
||||
$url = 'http://faveohelpdesk.com/billing/public/verification';
|
||||
if (str_contains($url, ' ')) {
|
||||
@@ -61,8 +59,7 @@ class UpgradeController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function downloadLatestCode()
|
||||
{
|
||||
public function downloadLatestCode() {
|
||||
$name = \Config::get('app.name');
|
||||
$durl = 'http://www.faveohelpdesk.com/billing/public/download-url';
|
||||
if (str_contains($durl, ' ')) {
|
||||
@@ -78,8 +75,7 @@ class UpgradeController extends Controller
|
||||
return $download_url;
|
||||
}
|
||||
|
||||
public function saveLatestCodeAtTemp($download_url)
|
||||
{
|
||||
public function saveLatestCodeAtTemp($download_url) {
|
||||
echo '<p>Downloading New Update</p>';
|
||||
$context = stream_context_create(
|
||||
[
|
||||
@@ -91,10 +87,10 @@ class UpgradeController extends Controller
|
||||
|
||||
$newUpdate = file_get_contents($download_url, false, $context);
|
||||
if (!is_dir("$this->dir/UPDATES/")) {
|
||||
\File::makeDirectory($this->dir.'/UPDATES/', 0777);
|
||||
\File::makeDirectory($this->dir . '/UPDATES/', 0777);
|
||||
}
|
||||
|
||||
$dlHandler = fopen($this->dir.'/UPDATES/'.'/faveo-helpdesk-master.zip', 'w');
|
||||
$dlHandler = fopen($this->dir . '/UPDATES/' . '/faveo-helpdesk-master.zip', 'w');
|
||||
if (!fwrite($dlHandler, $newUpdate)) {
|
||||
echo '<p>Could not save new update. Operation aborted.</p>';
|
||||
exit();
|
||||
@@ -103,28 +99,25 @@ class UpgradeController extends Controller
|
||||
echo '<p>Update Downloaded And Saved</p>';
|
||||
}
|
||||
|
||||
public function doUpdate()
|
||||
{
|
||||
public function doUpdate() {
|
||||
try {
|
||||
$memory_limit = ini_get('memory_limit');
|
||||
if ($memory_limit < 256) {
|
||||
echo '<ul class=list-unstyled>';
|
||||
echo "<li style='color:red;'>Sorry we can not process your request because of limited memory! You have only $memory_limit. For this you need atleast 256 MB</li>";
|
||||
echo '</ul>';
|
||||
|
||||
return 0;
|
||||
}
|
||||
if (!extension_loaded('zip')) {
|
||||
echo '<ul class=list-unstyled>';
|
||||
echo "<li style='color:red;'>Sorry we can not process your request because you don't have ZIP extension contact your system admin</li>";
|
||||
echo '</ul>';
|
||||
|
||||
return 0;
|
||||
}
|
||||
//Artisan::call('down');
|
||||
$update = $this->dir.'/UPDATES';
|
||||
$update = $this->dir . '/UPDATES';
|
||||
//Open The File And Do Stuff
|
||||
$zipHandle = zip_open($update.'/faveo-helpdesk-master.zip');
|
||||
$zipHandle = zip_open($update . '/faveo-helpdesk-master.zip');
|
||||
//dd($update . '/faveo-' . $aV . '.zip');
|
||||
|
||||
echo '<ul class=list-unstyled>';
|
||||
@@ -137,29 +130,30 @@ class UpgradeController extends Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//Make the directory if we need to...
|
||||
if (!is_dir($update.'/'.$thisFileDir.'/')) {
|
||||
\File::makeDirectory($update.'/'.$thisFileDir, 0775, true, true);
|
||||
if (!is_dir($update . '/' . $thisFileDir . '/')) {
|
||||
\File::makeDirectory($update . '/' . $thisFileDir, 0775, true, true);
|
||||
// mkdir($update.'/'. $thisFileDir, 0775);
|
||||
echo '<li style="color:white;">Created Directory '.$thisFileDir.'</li>';
|
||||
echo '<li style="color:white;">Created Directory ' . $thisFileDir . '</li>';
|
||||
}
|
||||
|
||||
//Overwrite the file
|
||||
if (!is_dir($update.'/'.$thisFileName)) {
|
||||
echo '<li style="color:white;">'.$thisFileName.'...........';
|
||||
if (!is_dir($update . '/' . $thisFileName)) {
|
||||
echo '<li style="color:white;">' . $thisFileName . '...........';
|
||||
$contents = zip_entry_read($aF, zip_entry_filesize($aF));
|
||||
$contents = str_replace("\r\n", "\n", $contents);
|
||||
$updateThis = '';
|
||||
|
||||
//If we need to run commands, then do it.
|
||||
if ($thisFileName == $thisFileDir.'/.env') {
|
||||
if (is_file($update.'/'.$thisFileDir.'/.env')) {
|
||||
unlink($update.'/'.$thisFileDir.'/.env');
|
||||
unlink($update.'/'.$thisFileDir.'/config/database.php');
|
||||
if ($thisFileName == $thisFileDir . '/.env') {
|
||||
if (is_file($update . '/' . $thisFileDir . '/.env')) {
|
||||
unlink($update . '/' . $thisFileDir . '/.env');
|
||||
unlink($update . '/' . $thisFileDir . '/config/database.php');
|
||||
}
|
||||
echo' EXECUTED</li>';
|
||||
} else {
|
||||
$updateThis = fopen($update.'/'.$thisFileName, 'w');
|
||||
$updateThis = fopen($update . '/' . $thisFileName, 'w');
|
||||
fwrite($updateThis, $contents);
|
||||
fclose($updateThis);
|
||||
unset($contents);
|
||||
@@ -172,13 +166,12 @@ class UpgradeController extends Controller
|
||||
return true;
|
||||
} catch (Exception $ex) {
|
||||
echo '<ul class=list-unstyled>';
|
||||
echo "<li style='color:red;'>".$ex->getMessage().'</li>';
|
||||
echo "<li style='color:red;'>" . $ex->getMessage() . "</li>";
|
||||
echo '</ul>';
|
||||
}
|
||||
}
|
||||
|
||||
public function copyToActualDirectory($latest_version)
|
||||
{
|
||||
public function copyToActualDirectory($latest_version) {
|
||||
try {
|
||||
echo '<ul class=list-unstyled>';
|
||||
$directory = "$this->dir/UPDATES";
|
||||
@@ -197,18 +190,17 @@ class UpgradeController extends Controller
|
||||
|
||||
$this->deleteBarNotification('new-version');
|
||||
|
||||
echo "<li style='color:green;'>» Faveo Updated to v".Utility::getFileVersion().'</li>';
|
||||
echo "<li style='color:green;'>» Faveo Updated to v" . Utility::getFileVersion() . "</li>";
|
||||
echo '</ul>';
|
||||
} catch (Exception $ex) {
|
||||
echo '<ul class=list-unstyled>';
|
||||
echo "<li style='color:red;'>".$ex->getMessage().'</li>';
|
||||
echo "<li style='color:red;'>" . $ex->getMessage() . "</li>";
|
||||
echo '</ul>';
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
public function deleteBarNotification($key)
|
||||
{
|
||||
public function deleteBarNotification($key) {
|
||||
try {
|
||||
$noti = new BarNotification();
|
||||
$notifications = $noti->where('key', $key)->get();
|
||||
@@ -220,24 +212,20 @@ class UpgradeController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function fileUpdate()
|
||||
{
|
||||
public function fileUpdate() {
|
||||
try {
|
||||
$latest_version = $this->getLatestVersion();
|
||||
if (Utility::getFileVersion() < $latest_version) {
|
||||
$url = url('file-upgrade');
|
||||
|
||||
return view('themes.default1.update.file', compact('url'));
|
||||
}
|
||||
|
||||
return redirect('dashboard')->with('fails', 'Could not find latest realeases from repository.');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function fileUpgrading(Request $request)
|
||||
{
|
||||
public function fileUpgrading(Request $request) {
|
||||
try {
|
||||
//
|
||||
$latest_version = $this->getLatestVersion();
|
||||
@@ -245,12 +233,13 @@ class UpgradeController extends Controller
|
||||
$current_version = Utility::getFileVersion();
|
||||
if ($latest_version != '') {
|
||||
if (Utility::getFileVersion() < $latest_version) {
|
||||
|
||||
return view('themes.default1.update.update', compact('latest_version', 'current_version', 'request'));
|
||||
}
|
||||
}
|
||||
|
||||
return redirect('dashboard')->with('fails', 'Could not find latest realeases from repository.');
|
||||
|
||||
|
||||
// else {
|
||||
// return redirect()->back();
|
||||
// }
|
||||
@@ -259,8 +248,7 @@ class UpgradeController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function testScroll()
|
||||
{
|
||||
public function testScroll() {
|
||||
$ex = 1000;
|
||||
echo '<ul style=list-unstyled>';
|
||||
for ($i = 0; $i < $ex; $i++) {
|
||||
@@ -269,8 +257,7 @@ class UpgradeController extends Controller
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
public function fileUpgrading1(Request $request)
|
||||
{
|
||||
public function fileUpgrading1(Request $request) {
|
||||
if (Utility::getFileVersion() < Utility::getDatabaseVersion()) {
|
||||
$latest_version = $this->getLatestVersion();
|
||||
// dd($latest_version);
|
||||
@@ -280,7 +267,7 @@ class UpgradeController extends Controller
|
||||
echo "<p>CURRENT VERSION: $current_version</p>";
|
||||
echo '<p>Reading Current Releases List</p>';
|
||||
if ($latest_version > $current_version) {
|
||||
echo '<p>New Update Found: v'.$latest_version.'</p>';
|
||||
echo '<p>New Update Found: v' . $latest_version . '</p>';
|
||||
$found = true;
|
||||
if (!is_file("$this->dir/UPDATES/faveo-helpdesk-master.zip")) {
|
||||
if ($request->get('dodownload') == true) {
|
||||
@@ -291,7 +278,7 @@ class UpgradeController extends Controller
|
||||
echo '<p>Error in you network connection.</p>';
|
||||
}
|
||||
} else {
|
||||
echo '<p>Latest code found. <a href='.url('file-upgrade?dodownload=true').'>» Download Now?</a></p>';
|
||||
echo '<p>Latest code found. <a href=' . url('file-upgrade?dodownload=true') . '>» Download Now?</a></p>';
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
@@ -300,7 +287,7 @@ class UpgradeController extends Controller
|
||||
if ($request->get('doUpdate') == true) {
|
||||
$updated = $this->doUpdate();
|
||||
} else {
|
||||
echo '<p>Update ready. <a href='.url('file-upgrade?doUpdate=true').'>» Install Now?</a></p>';
|
||||
echo '<p>Update ready. <a href=' . url('file-upgrade?doUpdate=true') . '>» Install Now?</a></p>';
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -320,18 +307,17 @@ class UpgradeController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurl($url)
|
||||
{
|
||||
public function getCurl($url) {
|
||||
try {
|
||||
$curl = Utility::_isCurl();
|
||||
if (!$curl) {
|
||||
throw new Exception('Please enable your curl function to check latest update');
|
||||
throw new Exception("Please enable your curl function to check latest update");
|
||||
}
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if (curl_exec($ch) === false) {
|
||||
echo 'Curl error: '.curl_error($ch);
|
||||
echo 'Curl error: ' . curl_error($ch);
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
@@ -342,12 +328,11 @@ class UpgradeController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function postDownloadCurl($url, $data)
|
||||
{
|
||||
public function postDownloadCurl($url, $data) {
|
||||
try {
|
||||
$curl = Utility::_isCurl();
|
||||
if (!$curl) {
|
||||
throw new Exception('Please enable your curl function to check latest update');
|
||||
throw new Exception("Please enable your curl function to check latest update");
|
||||
}
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
@@ -355,23 +340,21 @@ class UpgradeController extends Controller
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if (curl_exec($ch) === false) {
|
||||
echo 'Curl error: '.curl_error($ch);
|
||||
echo 'Curl error: ' . curl_error($ch);
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return json_decode($data, true);
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postCurl($url, $data)
|
||||
{
|
||||
public function postCurl($url, $data) {
|
||||
try {
|
||||
$curl = Utility::_isCurl();
|
||||
if (!$curl) {
|
||||
throw new Exception('Please enable your curl function to check latest update');
|
||||
throw new Exception("Please enable your curl function to check latest update");
|
||||
}
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
@@ -379,20 +362,18 @@ class UpgradeController extends Controller
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if (curl_exec($ch) === false) {
|
||||
echo 'Curl error: '.curl_error($ch);
|
||||
echo 'Curl error: ' . curl_error($ch);
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$data = Utility::decryptByFaveoPrivateKey($data);
|
||||
|
||||
return json_decode($data, true);
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function databaseUpdate()
|
||||
{
|
||||
public function databaseUpdate() {
|
||||
try {
|
||||
if (Utility::getFileVersion() > Utility::getDatabaseVersion()) {
|
||||
$url = url('database-upgrade');
|
||||
@@ -406,8 +387,7 @@ class UpgradeController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function databaseUpgrade()
|
||||
{
|
||||
public function databaseUpgrade() {
|
||||
try {
|
||||
if (Utility::getFileVersion() > Utility::getDatabaseVersion()) {
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
@@ -420,4 +400,5 @@ class UpgradeController extends Controller
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,10 +7,9 @@ use Config;
|
||||
use Exception;
|
||||
use Schema;
|
||||
|
||||
class LibraryController extends Controller
|
||||
{
|
||||
public static function getFileVersion()
|
||||
{
|
||||
class LibraryController extends Controller {
|
||||
|
||||
public static function getFileVersion() {
|
||||
try {
|
||||
$app = Config::get('app.version');
|
||||
if ($app) {
|
||||
@@ -23,8 +22,7 @@ class LibraryController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDatabaseVersion()
|
||||
{
|
||||
public static function getDatabaseVersion() {
|
||||
try {
|
||||
$database = self::isDatabaseSetup();
|
||||
if ($database == true) {
|
||||
@@ -41,8 +39,7 @@ class LibraryController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public static function isDatabaseSetup()
|
||||
{
|
||||
public static function isDatabaseSetup() {
|
||||
try {
|
||||
if (Schema::hasTable('settings_system')) {
|
||||
return true;
|
||||
@@ -52,30 +49,28 @@ class LibraryController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public static function encryptByFaveoPublicKey($data)
|
||||
{
|
||||
public static function encryptByFaveoPublicKey($data) {
|
||||
try {
|
||||
$path = storage_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'public.key';
|
||||
$path = storage_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'public.key';
|
||||
//dd($path);
|
||||
$key_content = file_get_contents($path);
|
||||
$public_key = openssl_get_publickey($key_content);
|
||||
|
||||
$encrypted = $e = null;
|
||||
openssl_seal($data, $encrypted, $e, [$public_key]);
|
||||
$encrypted = $e = NULL;
|
||||
openssl_seal($data, $encrypted, $e, array($public_key));
|
||||
|
||||
$sealed_data = base64_encode($encrypted);
|
||||
$envelope = base64_encode($e[0]);
|
||||
|
||||
$result = ['seal' => $sealed_data, 'envelope' => $envelope];
|
||||
|
||||
return json_encode($result);
|
||||
} catch (Exception $ex) {
|
||||
throw new Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function decryptByFaveoPrivateKey($encrypted)
|
||||
{
|
||||
public static function decryptByFaveoPrivateKey($encrypted) {
|
||||
|
||||
try {
|
||||
$encrypted = json_decode($encrypted);
|
||||
if ($encrypted) {
|
||||
@@ -83,12 +78,11 @@ class LibraryController extends Controller
|
||||
$envelope = $encrypted->envelope;
|
||||
$input = base64_decode($sealed_data);
|
||||
$einput = base64_decode($envelope);
|
||||
$path = storage_path('app'.DIRECTORY_SEPARATOR.'private.key');
|
||||
$path = storage_path('app' . DIRECTORY_SEPARATOR . 'private.key');
|
||||
$key_content = file_get_contents($path);
|
||||
$private_key = openssl_get_privatekey($key_content);
|
||||
$plaintext = null;
|
||||
$plaintext = NULL;
|
||||
openssl_open($input, $plaintext, $einput, $private_key);
|
||||
|
||||
return $plaintext;
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
@@ -96,8 +90,8 @@ class LibraryController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public static function _isCurl()
|
||||
{
|
||||
public static function _isCurl() {
|
||||
return function_exists('curl_version');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user