update v 1.0.7.5
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,3 +2,6 @@
|
||||
Homestead.yaml
|
||||
Homestead.json
|
||||
/nbproject/private/
|
||||
.env
|
||||
/app/Plugins/ServiceDesk/
|
||||
/app/config/
|
||||
|
1867
DB/dummy-data.sql
Normal file
1867
DB/dummy-data.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
<h3>About Faveo</h3>
|
||||
<br><img src="https://travis-ci.org/ladybirdweb/faveo-helpdesk.svg?branch=master"> <img src="https://img.shields.io/badge/License-OSL-blue.svg"> <a href="https://gitter.im/ladybirdweb/faveo-helpdesk" target="_blank"><img src="https://badges.gitter.im/ladybirdweb/faveo-helpdesk.svg"></a> <a href="https://styleci.io/repos/34716238"><img src="https://styleci.io/repos/34716238/shield" alt="StyleCI" height="19px"></a> <a href="http://squizlabs.github.io/PHP_CodeSniffer/analysis/ladybirdweb/faveo-helpdesk/index.html" target="_blank"><img src="http://squizlabs.github.io/PHP_CodeSniffer/analysis/ladybirdweb/faveo-helpdesk/grade.svg" height="20px"></a> <a href="https://scrutinizer-ci.com/g/ladybirdweb/faveo-helpdesk/?branch=master" target="_blank"><img src="https://scrutinizer-ci.com/g/ladybirdweb/faveo-helpdesk/badges/quality-score.png?b=master" height="20px"></a></br>
|
||||
<br><img src="https://travis-ci.org/ladybirdweb/faveo-helpdesk.svg?branch=master"> <img src="https://img.shields.io/badge/License-OSL-blue.svg"> <a href="https://gitter.im/ladybirdweb/faveo-helpdesk" target="_blank"><img src="https://badges.gitter.im/ladybirdweb/faveo-helpdesk.svg"></a> <a href="https://styleci.io/repos/34716238"><img src="https://styleci.io/repos/34716238/shield" alt="StyleCI" height="19px"></a> <a href="http://squizlabs.github.io/PHP_CodeSniffer/analysis/ladybirdweb/faveo-helpdesk/index.html" target="_blank"><img src="http://squizlabs.github.io/PHP_CodeSniffer/analysis/ladybirdweb/faveo-helpdesk/grade.svg" height="20px"></a> <a href="https://scrutinizer-ci.com/g/ladybirdweb/faveo-helpdesk/?branch=master" target="_blank"><img src="https://scrutinizer-ci.com/g/mverma16/faveo-helpdesk/badges/quality-score.png?b=master" height="20px"></a></br>
|
||||
<p>Headquartered in Bangalore, Faveo HELPDESK provides Businesses with an automated Helpdesk system to manage customer support.
|
||||
<br/><br/>
|
||||
The word Faveo comes from Latin which means to be favourable. Which truly highlights vision and the scope as well as the functionality of the product that Faveo is. It is specifically designed to cater the needs of startups and SME’s empowering them with state of art, ticket based support system. In today’s competitive startup scenario customer retention is one of the major challenges. Handling client query diligently is all the difference between retaining or losing a long lasting relationship. The company is driven with passion of providing tools for managing consumer queries for strategic insights and helping companies take those decisive decisions.
|
||||
@@ -28,8 +28,6 @@ Faveo is designed & developed by <a href="http://www.ladybirdweb.com/" target="_
|
||||
<li> Database: MySQL(5.0+) or Postgres or SQLite or SQL Server</li>
|
||||
<li> Web Server Extension: Pretty URLs or Search Engine Friendly URL's have to be enabled in your web server configuration</li>
|
||||
</ul>
|
||||
<p><small><b>Note:</b> php5 dependencies for <em>nginx/php-fpm</em> setup are as follow</small></p>
|
||||
```php5-curl php5-mysql php5-mcrypt php5-cli php5-gd php5-imap```
|
||||
|
||||
<h3>Faveo Web Hosting</h3>
|
||||
<p><a href="http://www.store.ladybirdwebhost.com/" target="_blank">Ladybird Web Host</a> Offers hosting with minimum requirement to host Faveo web application. Faveo has been tested on Ladybird Web Host servers & works very well in their server environment. All web hosting packages offered by Ladybird Web Host come with 30 day money back gurantee.</p>
|
||||
|
33
app/BaseModel.php
Normal file
33
app/BaseModel.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use File;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* ======================================
|
||||
* Attchment Model
|
||||
* ======================================
|
||||
* This is a model representing the attachment table.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class BaseModel extends Model
|
||||
{
|
||||
public function setAttribute($property, $value)
|
||||
{
|
||||
require_once base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
|
||||
$path = base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier'.DIRECTORY_SEPARATOR.'DefinitionCache'.DIRECTORY_SEPARATOR.'Serializer');
|
||||
if (!File::exists($path)) {
|
||||
File::makeDirectory($path, $mode = 0777, true, true);
|
||||
}
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
//dd($config);
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
if ($value != strip_tags($value)) {
|
||||
$value = $purifier->purify($value);
|
||||
}
|
||||
parent::setAttribute($property, $value);
|
||||
}
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
abstract class Command
|
||||
{
|
||||
//
|
||||
}
|
@@ -29,10 +29,8 @@ class Kernel extends ConsoleKernel
|
||||
->hourly();
|
||||
|
||||
$schedule->call(function () {
|
||||
|
||||
$user = new User();
|
||||
$user->save();
|
||||
|
||||
})->everyFiveMinutes();
|
||||
})->everyFiveMinutes();
|
||||
}
|
||||
}
|
||||
|
@@ -3,13 +3,19 @@
|
||||
namespace App\Exceptions;
|
||||
|
||||
// controller
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
//use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Foundation\Validation\ValidationException;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
// use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
// use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler;
|
||||
use Bugsnag;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
public $phpmailer;
|
||||
class Handler extends ExceptionHandler {
|
||||
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
@@ -17,9 +23,27 @@ class Handler extends ExceptionHandler
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
'Symfony\Component\HttpKernel\Exception\HttpException',
|
||||
// 'Symfony\Component\HttpKernel\Exception\HttpException',
|
||||
// 'Illuminate\Http\Exception\HttpResponseException',
|
||||
ValidationException::class,
|
||||
AuthorizationException::class,
|
||||
HttpResponseException ::class,
|
||||
ModelNotFoundException::class,
|
||||
\Symfony\Component\HttpKernel\Exception\HttpException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
* 1. php mailer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
// public function __construct(PhpMailController $PhpMailController)
|
||||
// {
|
||||
// $this->PhpMailController = $PhpMailController;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
@@ -29,8 +53,14 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
public function report(Exception $e) {
|
||||
$debug = \Config::get('app.bugsnag_reporting');
|
||||
$debug = ($debug) ? 'true' : 'false';
|
||||
if ($debug == 'false') {
|
||||
Bugsnag::setBeforeNotifyFunction(function ($error) {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return parent::report($e);
|
||||
}
|
||||
|
||||
@@ -42,51 +72,42 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
//dd($e);
|
||||
$phpmail = new PhpMailController();
|
||||
$this->PhpMailController = $phpmail;
|
||||
if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
|
||||
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
||||
} elseif ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
|
||||
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
||||
}
|
||||
// This is to check if the debug is true or false
|
||||
if (config('app.debug') == false) {
|
||||
// checking if the error is actually an error page or if its an system error page
|
||||
if ($this->isHttpException($e) && $e->getStatusCode() == 404) {
|
||||
return response()->view('errors.404', []);
|
||||
} else {
|
||||
// checking if the application is installed
|
||||
if (\Config::get('database.install') == 1) {
|
||||
// checking if the error log send to Ladybirdweb is enabled or not
|
||||
if (\Config::get('app.ErrorLog') == '1') {
|
||||
try {
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => 'faveo logger', 'email' => 'faveoerrorlogger@gmail.com'], $message = ['subject' => 'Faveo downloaded from github has occured error', 'scenario' => 'error-report'], $template_variables = ['system_error' => "<pre style='background-color: #FFC7C7;/* border-color: red; */border: 1px solid red;border-radius: 3px;'> <b>Message:</b>".$e->getMessage().'<br/> <b>Code:</b>'.$e->getCode().'<br/> <b>File:</b>'.$e->getFile().'<br/> <b>Line:</b>'.$e->getLine().'</pre>']);
|
||||
} catch (Exception $exx) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response()->view('errors.500', []);
|
||||
}
|
||||
}
|
||||
// returns non oops error message
|
||||
return parent::render($request, $e);
|
||||
// checking if the error is related to http error i.e. page not found
|
||||
if ($this->isHttpException($e)) {
|
||||
// returns error for page not found
|
||||
return $this->renderHttpException($e);
|
||||
}
|
||||
// checking if the config app sebug is enabled or not
|
||||
if (config('app.debug')) {
|
||||
// returns oops error page i.e. colour full error page
|
||||
return $this->renderExceptionWithWhoops($e);
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
// public function render($request, Exception $e) {
|
||||
// if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
|
||||
// return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
||||
// } elseif ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
|
||||
// return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
||||
// }
|
||||
// This is to check if the debug is true or false
|
||||
// if (config('app.debug') == false) {
|
||||
// // checking if the error is actually an error page or if its an system error page
|
||||
// if ($this->isHttpException($e) && $e->getStatusCode() == 404) {
|
||||
// return response()->view('errors.404', []);
|
||||
// } else {
|
||||
// // checking if the application is installed
|
||||
// if (\Config::get('database.install') == 1) {
|
||||
// // checking if the error log send to Ladybirdweb is enabled or not
|
||||
// if (\Config::get('app.ErrorLog') == '1') {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// return response()->view('errors.500', []);
|
||||
// }
|
||||
// }
|
||||
// returns non oops error message
|
||||
// return parent::render($request, $e);
|
||||
// checking if the error is related to http error i.e. page not found
|
||||
// if ($this->isHttpException($e)) {
|
||||
// // returns error for page not found
|
||||
// return $this->renderHttpException($e);
|
||||
// }
|
||||
// // checking if the config app sebug is enabled or not
|
||||
// if (config('app.debug')) {
|
||||
// // returns oops error page i.e. colour full error page
|
||||
// return $this->renderExceptionWithWhoops($e);
|
||||
// }
|
||||
//return parent::render($request, $e);
|
||||
// }
|
||||
|
||||
/**
|
||||
* function to generate oops error page.
|
||||
@@ -95,14 +116,78 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function renderExceptionWithWhoops(Exception $e)
|
||||
{
|
||||
// new instance of whoops class to display customized error page
|
||||
$whoops = new \Whoops\Run();
|
||||
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
|
||||
// protected function renderExceptionWithWhoops(Exception $e) {
|
||||
// // new instance of whoops class to display customized error page
|
||||
// $whoops = new \Whoops\Run();
|
||||
// $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
|
||||
//
|
||||
// return new \Illuminate\Http\Response(
|
||||
// $whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()
|
||||
// );
|
||||
// }
|
||||
|
||||
return new \Illuminate\Http\Response(
|
||||
$whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()
|
||||
);
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
* @param type $request
|
||||
* @param Exception $e
|
||||
* @return type mixed
|
||||
*/
|
||||
public function render($request, Exception $e) {
|
||||
|
||||
switch ($e) {
|
||||
case $e instanceof \Illuminate\Http\Exception\HttpResponseException :
|
||||
return parent::render($request, $e);
|
||||
case $e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException :
|
||||
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
||||
case $e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException :
|
||||
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
||||
default :
|
||||
return $this->common($request, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to render 500 error page
|
||||
* @param type $request
|
||||
* @param type $e
|
||||
* @return type mixed
|
||||
*/
|
||||
public function render500($request, $e) {
|
||||
if (config('app.debug') == true) {
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
return redirect()->route('error500', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to render 404 error page
|
||||
* @param type $request
|
||||
* @param type $e
|
||||
* @return type mixed
|
||||
*/
|
||||
public function render404($request, $e) {
|
||||
if (config('app.debug') == true) {
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
return redirect()->route('error404', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common finction to render both types of codes
|
||||
* @param type $request
|
||||
* @param type $e
|
||||
* @return type mixed
|
||||
*/
|
||||
public function common($request, $e) {
|
||||
switch ($e) {
|
||||
case $e instanceof HttpException :
|
||||
return $this->render404($request, $e);
|
||||
case $e instanceof NotFoundHttpException :
|
||||
return $this->render404($request, $e);
|
||||
default :
|
||||
return $this->render500($request, $e);
|
||||
}
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,12 +13,15 @@ use App\Model\helpdesk\Agent\Assign_team_agent;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Agent\Groups;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use App\User;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use GeoIP;
|
||||
use Hash;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* AgentController
|
||||
@@ -72,7 +75,7 @@ class AgentController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create(Timezones $timezone, Groups $group, Department $department, Teams $team_all)
|
||||
public function create(Timezones $timezone, Groups $group, Department $department, Teams $team_all, CountryCode $code)
|
||||
{
|
||||
try {
|
||||
// gte all the teams
|
||||
@@ -84,9 +87,11 @@ class AgentController extends Controller
|
||||
// get all department
|
||||
$departments = $department->get();
|
||||
// list all the teams in a single variable
|
||||
$teams = $team->lists('id', 'name');
|
||||
$teams = $team->lists('id', 'name')->toArray();
|
||||
$location = GeoIP::getLocation('');
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
// returns to the page with all the variables and their datas
|
||||
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team'));
|
||||
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team'))->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
// returns if try fails with exception meaagse
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
@@ -104,13 +109,24 @@ class AgentController extends Controller
|
||||
*/
|
||||
public function store(User $user, AgentRequest $request)
|
||||
{
|
||||
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
||||
return redirect()->back()->with(['fails2' => Lang::get('lang.country-code-required-error'), 'country_code' => 1])->withInput();
|
||||
} else {
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
|
||||
if (!count($code)) {
|
||||
return redirect()->back()->with(['fails2' => Lang::get('lang.incorrect-country-code-error'), 'country_code' => 1])->withInput();
|
||||
}
|
||||
}
|
||||
// fixing the user role to agent
|
||||
$user->fill($request->input())->save();
|
||||
$user->fill($request->except(['group', 'primary_department', 'agent_time_zone']))->save();
|
||||
$user->assign_group = $request->group;
|
||||
$user->primary_dpt = $request->primary_department;
|
||||
$user->agent_tzone = $request->agent_time_zone;
|
||||
// generate password and has immediately to store
|
||||
$password = $this->generateRandomString();
|
||||
$user->password = Hash::make($password);
|
||||
// fetching all the team details checked for this user
|
||||
$requests = $request->input('team_id');
|
||||
$requests = $request->input('team');
|
||||
// get user id of the inserted user detail
|
||||
$id = $user->id;
|
||||
// insert team
|
||||
@@ -128,13 +144,13 @@ class AgentController extends Controller
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $email], $message = ['subject' => 'Password', 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $email, 'user_password' => $password]);
|
||||
} catch (Exception $e) {
|
||||
// returns if try fails
|
||||
return redirect('agents')->with('fails', 'Some error occurred while sending mail to the agent. Please check email settings and try again');
|
||||
return redirect('agents')->with('warning', Lang::get('lang.agent_send_mail_error_on_agent_creation'));
|
||||
}
|
||||
// returns for the success case
|
||||
return redirect('agents')->with('success', 'Agent Created sucessfully');
|
||||
return redirect('agents')->with('success', Lang::get('lang.agent_creation_success'));
|
||||
} else {
|
||||
// returns if fails
|
||||
return redirect('agents')->with('fails', 'Agent can not Create');
|
||||
return redirect('agents')->with('fails', Lang::get('lang.failed_to_create_agent'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,9 +167,11 @@ class AgentController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team)
|
||||
public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team, CountryCode $code)
|
||||
{
|
||||
try {
|
||||
$location = GeoIP::getLocation('');
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
$user = $user->whereId($id)->first();
|
||||
$team = $team->get();
|
||||
$teams1 = $team->lists('name', 'id');
|
||||
@@ -161,12 +179,12 @@ class AgentController extends Controller
|
||||
$groups = $group->get();
|
||||
$departments = $department->get();
|
||||
$table = $team_assign_agent->where('agent_id', $id)->first();
|
||||
$teams = $team->lists('id', 'name');
|
||||
$assign = $team_assign_agent->where('agent_id', $id)->lists('team_id');
|
||||
$teams = $team->lists('id', 'name')->toArray();
|
||||
$assign = $team_assign_agent->where('agent_id', $id)->lists('team_id')->toArray();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.agents.edit', compact('teams', 'assign', 'table', 'teams1', 'selectedTeams', 'user', 'timezones', 'groups', 'departments', 'team', 'exp', 'counted'));
|
||||
return view('themes.default1.admin.helpdesk.agent.agents.edit', compact('teams', 'assign', 'table', 'teams1', 'selectedTeams', 'user', 'timezones', 'groups', 'departments', 'team', 'exp', 'counted'))->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
return redirect('agents')->with('fail', 'No such file');
|
||||
return redirect('agents')->with('fail', Lang::get('lang.failed_to_edit_agent'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +200,14 @@ class AgentController extends Controller
|
||||
*/
|
||||
public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent)
|
||||
{
|
||||
|
||||
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
||||
return redirect()->back()->with(['fails2' => Lang::get('lang.country-code-required-error'), 'country_code' => 1])->withInput();
|
||||
} else {
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
|
||||
if (!count($code)) {
|
||||
return redirect()->back()->with(['fails2' => Lang::get('lang.incorrect-country-code-error'), 'country_code' => 1])->withInput();
|
||||
}
|
||||
}
|
||||
// storing all the details
|
||||
$user = $user->whereId($id)->first();
|
||||
$daylight_save = $request->input('daylight_save');
|
||||
@@ -192,18 +217,25 @@ class AgentController extends Controller
|
||||
//==============================================
|
||||
$table = $team_assign_agent->where('agent_id', $id);
|
||||
$table->delete();
|
||||
$requests = $request->input('team_id');
|
||||
$requests = $request->input('team');
|
||||
// inserting team details
|
||||
foreach ($requests as $req) {
|
||||
DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]);
|
||||
}
|
||||
//Todo For success and failure conditions
|
||||
try {
|
||||
if ($request->input('country_code') != '' or $request->input('country_code') != null) {
|
||||
$user->country_code = $request->input('country_code');
|
||||
}
|
||||
$user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save();
|
||||
$user->assign_group = $request->group;
|
||||
$user->primary_dpt = $request->primary_department;
|
||||
$user->agent_tzone = $request->agent_time_zone;
|
||||
$user->save();
|
||||
|
||||
return redirect('agents')->with('success', 'Agent Updated sucessfully');
|
||||
return redirect('agents')->with('success', Lang::get('lang.agent_updated_sucessfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('agents')->with('fails', 'Agent did not update'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('agents')->with('fails', Lang::get('lang.unable_to_update_agent').'<li>'.$e->errorInfo[2].'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,12 +258,12 @@ class AgentController extends Controller
|
||||
$team_assign_agent->delete();
|
||||
$user = $user->whereId($id)->first();
|
||||
try {
|
||||
$error = 'This staff is related to some tickets';
|
||||
$error = Lang::get('lang.this_staff_is_related_to_some_tickets');
|
||||
$user->id;
|
||||
$user->delete();
|
||||
throw new \Exception($error);
|
||||
|
||||
return redirect('agents')->with('success', 'Agent Deleted sucessfully');
|
||||
return redirect('agents')->with('success', Lang::get('lang.agent_deleted_sucessfully'));
|
||||
} catch (\Exception $e) {
|
||||
return redirect('agents')->with('fails', $error);
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ use App\Model\helpdesk\Email\Banlist;
|
||||
use App\User;
|
||||
//classes
|
||||
use Exception;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* BanlistController
|
||||
@@ -50,7 +51,7 @@ class BanlistController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.banlist.index', compact('bans'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ class BanlistController extends Controller
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.emails.banlist.create');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ class BanlistController extends Controller
|
||||
$use->internal_note = $request->input('internal_note');
|
||||
$use->save();
|
||||
// $user->create($request->input())->save();
|
||||
return redirect('banlist')->with('success', 'Email Banned sucessfully');
|
||||
return redirect('banlist')->with('success', Lang::get('lang.email_banned_sucessfully'));
|
||||
} else {
|
||||
$user = new User();
|
||||
$user->email = $adban;
|
||||
@@ -96,10 +97,10 @@ class BanlistController extends Controller
|
||||
$user->internal_note = $request->input('internal_note');
|
||||
$user->save();
|
||||
|
||||
return redirect('banlist')->with('success', 'Email Banned sucessfully');
|
||||
return redirect('banlist')->with('success', Lang::get('lang.email_banned_sucessfully'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return redirect('banlist')->with('fails', 'Email can not Ban');
|
||||
return redirect('banlist')->with('fails', Lang::get('lang.email_can_not_ban'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +119,7 @@ class BanlistController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.banlist.edit', compact('bans'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,12 +139,33 @@ class BanlistController extends Controller
|
||||
$bans->internal_note = $request->input('internal_note');
|
||||
$bans->ban = $request->input('ban');
|
||||
if ($bans->save()) {
|
||||
return redirect('banlist')->with('success', 'Banned Email Updated sucessfully');
|
||||
return redirect('banlist')->with('success', Lang::get('lang.banned_email_updated_sucessfully'));
|
||||
} else {
|
||||
return redirect('banlist')->with('fails', 'Banned Email not Updated');
|
||||
return redirect('banlist')->with('fails', Lang::get('lang.banned_email_not_updated'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return redirect('banlist')->with('fails', 'Banned Email not Updated');
|
||||
return redirect('banlist')->with('fails', Lang::get('lang.banned_email_not_updated'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete the banned users.
|
||||
*
|
||||
* @param type $id
|
||||
* @param \App\User $ban
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function delete($id, User $ban)
|
||||
{
|
||||
try {
|
||||
$ban_user = $ban->where('id', '=', $id)->first();
|
||||
$ban_user->ban = 0;
|
||||
$ban_user->save();
|
||||
|
||||
return redirect('banlist')->with('success', Lang::get('lang.banned_removed_sucessfully'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect('banlist')->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\WorkflowCloseRequest;
|
||||
use App\Model\helpdesk\Workflow\WorkflowClose;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* |=================================================
|
||||
* | CloseWrokflowController
|
||||
* |=================================================
|
||||
* In this controller the functionalities fo close ticket workflow defined.
|
||||
*/
|
||||
class CloseWrokflowController extends Controller
|
||||
{
|
||||
private $security;
|
||||
|
||||
public function __construct(WorkflowClose $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the workflow settings page.
|
||||
*
|
||||
* @param \App\Model\helpdesk\Workflow\WorkflowClose $securitys
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index(WorkflowClose $securitys)
|
||||
{
|
||||
try {
|
||||
$security = $securitys->whereId('1')->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.close-workflow.index', compact('security'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* updating the workflow settings for closing ticket.
|
||||
*
|
||||
* @param type $id
|
||||
* @param \App\Http\Requests\helpdesk\WorkflowCloseRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function update($id, WorkflowCloseRequest $request)
|
||||
{
|
||||
try {
|
||||
$security = new WorkflowClose();
|
||||
$securitys = $security->whereId($id)->first();
|
||||
$securitys->days = $request->input('days');
|
||||
$securitys->condition = $request->input('condition');
|
||||
$securitys->send_email = $request->input('send_email');
|
||||
$securitys->status = $request->input('status');
|
||||
$securitys->save();
|
||||
|
||||
return \Redirect::back()->with('success', Lang::get('lang.successfully_saved_your_settings'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,6 +22,7 @@ use App\User;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* DepartmentController.
|
||||
@@ -76,7 +77,7 @@ class DepartmentController extends Controller
|
||||
{
|
||||
try {
|
||||
$slas = $sla->get();
|
||||
$user = $user->where('role', 'agent')->get();
|
||||
$user = $user->where('role', 'agent2')->get();
|
||||
$emails = $email->get();
|
||||
$templates = $template->get();
|
||||
$department = $department->get();
|
||||
@@ -84,7 +85,7 @@ class DepartmentController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.departments.create', compact('department', 'templates', 'slas', 'user', 'emails', 'groups'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +100,12 @@ class DepartmentController extends Controller
|
||||
public function store(Department $department, DepartmentRequest $request)
|
||||
{
|
||||
try {
|
||||
$department->fill($request->except('group_id', 'manager'))->save();
|
||||
$department->fill($request->except('group_id', 'manager', 'sla'))->save();
|
||||
if ($request->sla) {
|
||||
$department->sla = $request->input('sla');
|
||||
} else {
|
||||
$department->sla = null;
|
||||
}
|
||||
$requests = $request->input('group_id');
|
||||
$id = $department->id;
|
||||
if ($request->manager) {
|
||||
@@ -107,18 +113,15 @@ class DepartmentController extends Controller
|
||||
} else {
|
||||
$department->manager = null;
|
||||
}
|
||||
// foreach ($requests as $req) {
|
||||
// DB::insert('insert into group_assign_department(group_id, department_id) values (?,?)', [$req, $id]);
|
||||
// }
|
||||
/* Succes And Failure condition */
|
||||
/* Check Whether the function Success or Fail */
|
||||
if ($department->save() == true) {
|
||||
return redirect('departments')->with('success', 'Department Created sucessfully');
|
||||
return redirect('departments')->with('success', Lang::get('lang.department_created_sucessfully'));
|
||||
} else {
|
||||
return redirect('departments')->with('fails', 'Department can not Create');
|
||||
return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return redirect('departments')->with('fails', 'Department can not Create');
|
||||
return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,17 +143,21 @@ class DepartmentController extends Controller
|
||||
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();
|
||||
$user = $user->where('role', 'agent')->get();
|
||||
$user = $user->where('primary_dpt', $id)->get();
|
||||
$emails = $email->get();
|
||||
$templates = $template->get();
|
||||
$departments = $department->whereId($id)->first();
|
||||
$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'));
|
||||
return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'groups', 'sys_department'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect('departments')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +175,7 @@ class DepartmentController extends Controller
|
||||
{
|
||||
// dd($id);
|
||||
try {
|
||||
|
||||
$table = $group_assign_department->where('department_id', $id);
|
||||
$table->delete();
|
||||
$requests = $request->input('group_id');
|
||||
@@ -182,14 +190,25 @@ class DepartmentController extends Controller
|
||||
$departments->manager = null;
|
||||
}
|
||||
$departments->save();
|
||||
|
||||
if ($departments->fill($request->except('group_access', 'manager'))->save()) {
|
||||
return redirect('departments')->with('success', 'Department Updated sucessfully');
|
||||
if ($request->sla) {
|
||||
$departments->sla = $request->input('sla');
|
||||
$departments->save();
|
||||
} else {
|
||||
return redirect('departments')->with('fails', 'Department not Updated');
|
||||
$departments->sla = null;
|
||||
$departments->save();
|
||||
}
|
||||
if ($request->input('sys_department') == 'on') {
|
||||
DB::table('settings_system')
|
||||
->where('id', 1)
|
||||
->update(['department' => $id]);
|
||||
}
|
||||
if ($departments->fill($request->except('group_access', 'manager', 'sla'))->save()) {
|
||||
return redirect('departments')->with('success', Lang::get('lang.department_updated_sucessfully'));
|
||||
} else {
|
||||
return redirect('departments')->with('fails', Lang::get('lang.department_not_updated'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return redirect('departments')->with('fails', 'Department not Updated');
|
||||
return redirect('departments')->with('fails', Lang::get('lang.department_not_updated'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +226,7 @@ class DepartmentController extends Controller
|
||||
// try {
|
||||
$system = $system->where('id', '=', '1')->first();
|
||||
if ($system->department == $id) {
|
||||
return redirect('departments')->with('fails', 'You cannot delete default department');
|
||||
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
|
||||
} else {
|
||||
$tickets = DB::table('tickets')->where('dept_id', '=', $id)->update(['dept_id' => $system->department]);
|
||||
if ($tickets > 0) {
|
||||
@@ -216,7 +235,7 @@ class DepartmentController extends Controller
|
||||
} else {
|
||||
$text_tickets = 'Ticket';
|
||||
}
|
||||
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default department</li>';
|
||||
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_department').'</li>';
|
||||
} else {
|
||||
$ticket = '';
|
||||
}
|
||||
@@ -227,7 +246,7 @@ class DepartmentController extends Controller
|
||||
} else {
|
||||
$text_user = 'User';
|
||||
}
|
||||
$user = '<li>'.$users.' '.$text_user.' have been moved to default department</li>';
|
||||
$user = '<li>'.$users.' '.$text_user.Lang::get('lang.have_been_moved_to_default_department').'</li>';
|
||||
} else {
|
||||
$user = '';
|
||||
}
|
||||
@@ -238,13 +257,13 @@ class DepartmentController extends Controller
|
||||
} else {
|
||||
$text_emails = 'Email';
|
||||
}
|
||||
$email = '<li>'.$emails.' System '.$text_emails.' 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>The associated helptopic has been deactivated</li>';
|
||||
$helptopic = '<li>'.Lang::get('lang.the_associated_helptopic_has_been_deactivated').'</li>';
|
||||
} else {
|
||||
$helptopic = '';
|
||||
}
|
||||
@@ -255,9 +274,9 @@ class DepartmentController extends Controller
|
||||
$departments = $department->whereId($id)->first();
|
||||
/* Check the function is Success or Fail */
|
||||
if ($departments->delete() == true) {
|
||||
return redirect('departments')->with('success', 'Department Deleted sucessfully'.$message);
|
||||
return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully').$message);
|
||||
} else {
|
||||
return redirect('departments')->with('fails', 'Department can not Delete');
|
||||
return redirect('departments')->with('fails', Lang::get('lang.department_can_not_delete'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ use Crypt;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* ======================================
|
||||
@@ -27,15 +28,14 @@ use Illuminate\Http\Request;
|
||||
*
|
||||
* @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 +47,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,8 +68,7 @@ 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();
|
||||
@@ -95,18 +93,16 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettings(Request $request)
|
||||
{
|
||||
public function validatingEmailSettings(Request $request) {
|
||||
$validator = \Validator::make(
|
||||
[
|
||||
'email_address' => $request->email_address,
|
||||
'email_name' => $request->email_name,
|
||||
'password' => $request->password,
|
||||
],
|
||||
[
|
||||
[
|
||||
'email_address' => $request->input('email_address'),
|
||||
'email_name' => $request->input('email_name'),
|
||||
'password' => $request->input('password'),
|
||||
], [
|
||||
'email_address' => 'required|email|unique:emails',
|
||||
'email_name' => 'required',
|
||||
'password' => 'required',
|
||||
'email_name' => 'required',
|
||||
'password' => 'required',
|
||||
]
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
@@ -119,32 +115,31 @@ class EmailsController extends Controller
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
if ($request->validate == 'on') {
|
||||
if ($request->input('imap_validate') == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} else {
|
||||
} elseif (!$request->input('imap_validate')) {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->fetching_status == 'on') {
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
if ($imap_check[0] == 0) {
|
||||
return 'Incoming email connection failed';
|
||||
return Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
|
||||
}
|
||||
$need_to_check_imap = 1;
|
||||
} else {
|
||||
$imap_check = 0;
|
||||
$need_to_check_imap = 0;
|
||||
}
|
||||
if ($request->sending_status == 'on') {
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$smtp_check = $this->getSmtp($request);
|
||||
if ($smtp_check == 0) {
|
||||
return 'Outgoing email connection failed';
|
||||
return Lang::get('lang.outgoing_email_connection_failed');
|
||||
}
|
||||
$need_to_check_smtp = 1;
|
||||
} else {
|
||||
$smtp_check = 0;
|
||||
$need_to_check_smtp = 0;
|
||||
}
|
||||
|
||||
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check != 0 && $smtp_check != 0) {
|
||||
$this->store($request, $imap_check[1]);
|
||||
@@ -178,55 +173,69 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store($request, $imap_check)
|
||||
{
|
||||
// dd($request);
|
||||
public function store($request, $imap_check) {
|
||||
$email = new Emails();
|
||||
try {
|
||||
// getConnection($request->input('email_name'), $request->input('email_address'), $request->input('email_address'))
|
||||
// saving all the fields to the database
|
||||
if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save() == true) {
|
||||
if ($request->fetching_status == 'on') {
|
||||
$email->fetching_status = 1;
|
||||
} else {
|
||||
$email->fetching_status = 0;
|
||||
}
|
||||
if ($request->sending_status == 'on') {
|
||||
$email->sending_status = 1;
|
||||
} else {
|
||||
$email->sending_status = 0;
|
||||
}
|
||||
if ($request->auto_response == 'on') {
|
||||
$email->auto_response = 1;
|
||||
} else {
|
||||
$email->auto_response = 0;
|
||||
}
|
||||
if ($imap_check !== null) {
|
||||
$email->fetching_encryption = $imap_check;
|
||||
} else {
|
||||
$email->fetching_encryption = $request->fetching_encryption;
|
||||
}
|
||||
// fetching department value
|
||||
$email->department = $this->departmentValue($request->input('department'));
|
||||
// fetching priority value
|
||||
$email->priority = $this->priorityValue($request->input('priority'));
|
||||
// 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
|
||||
// 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();
|
||||
// returns success message for successful email creation
|
||||
// return redirect('emails')->with('success', 'Email Created sucessfully');
|
||||
return 1;
|
||||
} else {
|
||||
// returns fail message for unsuccessful save execution
|
||||
// return redirect('emails')->with('fails', 'Email can not Create');
|
||||
return 0;
|
||||
// if ($email->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save() == true) {
|
||||
$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 = $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;
|
||||
}
|
||||
if ($imap_check !== null) {
|
||||
$email->fetching_encryption = $imap_check;
|
||||
} 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
|
||||
// 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();
|
||||
// returns success message for successful email creation
|
||||
// return redirect('emails')->with('success', 'Email Created sucessfully');
|
||||
return 1;
|
||||
// } else {
|
||||
// returns fail message for unsuccessful save execution
|
||||
// return redirect('emails')->with('fails', 'Email can not Create');
|
||||
// return 0;
|
||||
// }
|
||||
} catch (Exception $e) {
|
||||
// returns if try fails
|
||||
// return redirect()->back()->with('fails', $e->getMessage());
|
||||
@@ -246,13 +255,16 @@ 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);
|
||||
// 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
|
||||
@@ -260,7 +272,7 @@ class EmailsController extends Controller
|
||||
// get all the mailbox protocols
|
||||
$mailbox_protocols = $mailbox_protocol->get();
|
||||
// return if the execution is succeeded
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails'));
|
||||
return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails', 'sys_email'))->with('count', $count);
|
||||
} catch (Exception $e) {
|
||||
// return if try fails
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
@@ -274,18 +286,16 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettingsUpdate($id, Request $request)
|
||||
{
|
||||
public function validatingEmailSettingsUpdate($id, Request $request) {
|
||||
$validator = \Validator::make(
|
||||
[
|
||||
'email_address' => $request->email_address,
|
||||
'email_name' => $request->email_name,
|
||||
'password' => $request->password,
|
||||
],
|
||||
[
|
||||
[
|
||||
'email_address' => $request->input('email_address'),
|
||||
'email_name' => $request->input('email_name'),
|
||||
'password' => $request->input('password'),
|
||||
], [
|
||||
'email_address' => 'email',
|
||||
'email_name' => 'required',
|
||||
'password' => 'required',
|
||||
'email_name' => 'required',
|
||||
'password' => 'required',
|
||||
]
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
@@ -299,32 +309,31 @@ class EmailsController extends Controller
|
||||
return $return_data;
|
||||
}
|
||||
// return $request;
|
||||
if ($request->validate == 'on') {
|
||||
if ($request->input('imap_validate') == 'on') {
|
||||
$validate = '/validate-cert';
|
||||
} else {
|
||||
} elseif (!$request->input('imap_validate')) {
|
||||
$validate = '/novalidate-cert';
|
||||
}
|
||||
if ($request->fetching_status == 'on') {
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$imap_check = $this->getImapStream($request, $validate);
|
||||
if ($imap_check[0] == 0) {
|
||||
return 'Incoming email connection failed';
|
||||
return Lang::get('lang.incoming_email_connection_failed_please_check_email_credentials_or_imap_settings');
|
||||
}
|
||||
$need_to_check_imap = 1;
|
||||
} else {
|
||||
$imap_check = 0;
|
||||
$need_to_check_imap = 0;
|
||||
}
|
||||
if ($request->sending_status == 'on') {
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$smtp_check = $this->getSmtp($request);
|
||||
if ($smtp_check == 0) {
|
||||
return 'Outgoing email connection failed';
|
||||
return Lang::get('lang.outgoing_email_connection_failed');
|
||||
}
|
||||
$need_to_check_smtp = 1;
|
||||
} else {
|
||||
$smtp_check = 0;
|
||||
$need_to_check_smtp = 0;
|
||||
}
|
||||
|
||||
if ($need_to_check_imap == 1 && $need_to_check_smtp == 1) {
|
||||
if ($imap_check != 0 && $smtp_check != 0) {
|
||||
$this->update($id, $request, $imap_check[1]);
|
||||
@@ -359,36 +368,45 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, $request, $imap_check)
|
||||
{
|
||||
// try {
|
||||
// dd($id);
|
||||
// dd($request);
|
||||
// dd($imap_check);
|
||||
public function update($id, $request, $imap_check) {
|
||||
try {
|
||||
// fetch the selected emails
|
||||
$emails = Emails::whereId($id)->first();
|
||||
// insert all the requested parameters with except
|
||||
$emails->fill($request->except('password', 'department', 'priority', 'help_topic', 'fetching_status', 'fetching_encryption', 'sending_status', 'auto_response'))->save();
|
||||
if ($request->fetching_status == 'on') {
|
||||
$emails->fetching_status = 1;
|
||||
} else {
|
||||
$emails->fetching_status = 0;
|
||||
}
|
||||
if ($request->sending_status == 'on') {
|
||||
$emails->sending_status = 1;
|
||||
} else {
|
||||
$emails->sending_status = 0;
|
||||
}
|
||||
if ($request->auto_response == 'on') {
|
||||
$emails->auto_response = 1;
|
||||
} else {
|
||||
$emails->auto_response = 0;
|
||||
}
|
||||
if ($imap_check !== null) {
|
||||
$emails->fetching_encryption = $imap_check;
|
||||
} else {
|
||||
$emails->fetching_encryption = $request->fetching_encryption;
|
||||
}
|
||||
$emails->email_address = $request->email_address;
|
||||
$emails->email_name = $request->email_name;
|
||||
$emails->fetching_host = $request->fetching_host;
|
||||
$emails->fetching_port = $request->fetching_port;
|
||||
$emails->fetching_protocol = $request->fetching_protocol;
|
||||
$emails->sending_host = $request->sending_host;
|
||||
$emails->sending_port = $request->sending_port;
|
||||
$emails->sending_protocol = $request->sending_protocol;
|
||||
$emails->sending_encryption = $request->sending_encryption;
|
||||
if ($request->smtp_validate == 'on') {
|
||||
$emails->smtp_validate = $request->smtp_validate;
|
||||
}
|
||||
|
||||
if ($request->input('fetching_status') == 'on') {
|
||||
$emails->fetching_status = 1;
|
||||
} else {
|
||||
$emails->fetching_status = 0;
|
||||
}
|
||||
if ($request->input('sending_status') == 'on') {
|
||||
$emails->sending_status = 1;
|
||||
} else {
|
||||
$emails->sending_status = 0;
|
||||
}
|
||||
if ($request->input('auto_response') == 'on') {
|
||||
$emails->auto_response = 1;
|
||||
} else {
|
||||
$emails->auto_response = 0;
|
||||
}
|
||||
if ($imap_check !== null) {
|
||||
$emails->fetching_encryption = $imap_check;
|
||||
} else {
|
||||
$emails->fetching_encryption = $request->fetching_encryption;
|
||||
}
|
||||
$emails->password = Crypt::encrypt($request->input('password'));
|
||||
// dd($email->fetching_encryption);
|
||||
// fetching department value
|
||||
$emails->department = $this->departmentValue($request->input('department'));
|
||||
@@ -397,14 +415,25 @@ class EmailsController extends Controller
|
||||
// fetching helptopic value
|
||||
$emails->help_topic = $this->helpTopicValue($request->input('help_topic'));
|
||||
// inserting the encrypted value of password
|
||||
$emails->password = Crypt::encrypt($request->input('password'));
|
||||
$emails->save();
|
||||
// $emails->password = Crypt::encrypt($request->input('password'));
|
||||
$emails->save();
|
||||
//dd($request->sys_email);
|
||||
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]);
|
||||
}
|
||||
// returns success message for successful email update
|
||||
$return = 1;
|
||||
// } catch (Exception $e) {
|
||||
// // returns if try fails
|
||||
// $return = $e->getMessage();
|
||||
// }
|
||||
} catch (Exception $e) {
|
||||
// // returns if try fails
|
||||
$return = $e->getMessage();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -416,14 +445,13 @@ 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) {
|
||||
// checking if the default system email is the passed email
|
||||
if ($id == $default_system_email->sys_email) {
|
||||
return redirect('emails')->with('fails', 'You cannot delete system default Email');
|
||||
return redirect('emails')->with('fails', Lang::get('lang.you_cannot_delete_system_default_email'));
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -431,9 +459,9 @@ class EmailsController extends Controller
|
||||
$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', 'Email Deleted sucessfully');
|
||||
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
|
||||
} else {
|
||||
return redirect('emails')->with('fails', 'Email can not Delete ');
|
||||
return redirect('emails')->with('fails', Lang::get('lang.email_can_not_delete'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// returns if the try fails
|
||||
@@ -448,28 +476,26 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function getImapStream($request, $validate)
|
||||
{
|
||||
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');
|
||||
$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.$mailbox_protocol.'}INBOX';
|
||||
$mailbox = '{' . $host . ':' . $port . $mailbox_protocol . '}INBOX';
|
||||
} else {
|
||||
$mailbox_protocol = $fetching_protocol.$fetching_encryption;
|
||||
$mailbox_protocol = $fetching_protocol . $fetching_encryption;
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$mailbox = '{'.$host.':'.$port.$mailbox_protocol.$validate.'}INBOX';
|
||||
$mailbox_protocol = $fetching_encryption.$validate;
|
||||
$mailbox = '{' . $host . ':' . $port . $mailbox_protocol . $validate . '}INBOX';
|
||||
$mailbox_protocol = $fetching_encryption . $validate;
|
||||
}
|
||||
|
||||
try {
|
||||
$imap_stream = imap_open($mailbox, $username, $password);
|
||||
} catch (\Exception $ex) {
|
||||
@@ -492,8 +518,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;
|
||||
@@ -511,22 +536,43 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSmtp($request)
|
||||
{
|
||||
public function getSmtp($request) {
|
||||
$sending_status = $request->input('sending_status');
|
||||
$mail = new \PHPMailer();
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $request->input('sending_host');
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $request->input('email_address');
|
||||
$mail->Password = $request->input('password');
|
||||
$mail->SMTPSecure = $request->input('sending_encryption');
|
||||
$mail->Port = $request->input('sending_port');
|
||||
if ($mail->smtpConnect() == true) {
|
||||
$mail->smtpClose();
|
||||
// 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;
|
||||
} else {
|
||||
$return = 0;
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -539,8 +585,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function departmentValue($dept)
|
||||
{
|
||||
public function departmentValue($dept) {
|
||||
if ($dept) {
|
||||
$email_department = $dept;
|
||||
} else {
|
||||
@@ -557,8 +602,7 @@ class EmailsController extends Controller
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function priorityValue($priority)
|
||||
{
|
||||
public function priorityValue($priority) {
|
||||
if ($priority) {
|
||||
$email_priority = $priority;
|
||||
} else {
|
||||
@@ -575,8 +619,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 {
|
||||
@@ -585,4 +628,5 @@ class EmailsController extends Controller
|
||||
|
||||
return $email_help_topic;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controller
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// request
|
||||
|
||||
use Exception;
|
||||
use Lang;
|
||||
use File;
|
||||
|
||||
/**
|
||||
* ErrorAndDebuggingController
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class ErrorAndDebuggingController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// $this->smtp();
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* function to show error and debugging setting page
|
||||
* @param void
|
||||
* @return response
|
||||
*/
|
||||
public function showSettings()
|
||||
{
|
||||
$debug = \Config::get('app.debug');
|
||||
$bugsnag = \Config::get('app.bugsnag_reporting');
|
||||
return view('themes.default1.admin.helpdesk.settings.error-and-logs.error-debug')->with(['debug'=> $debug, 'bugsnag' => $bugsnag]);
|
||||
}
|
||||
|
||||
/**
|
||||
* funtion to update error and debugging settings
|
||||
* @param void
|
||||
* @return
|
||||
*/
|
||||
public function postSettings()
|
||||
{
|
||||
try{
|
||||
$debug = \Config::get('app.debug');
|
||||
$debug = ($debug) ? 'true' : 'false';
|
||||
$bugsnag_debug = \Config::get('app.bugsnag_reporting');
|
||||
$bugsnag_debug = ($bugsnag_debug) ? 'true' : 'false';
|
||||
if ($debug != \Input::get('debug') || $bugsnag_debug != \Input::get('bugsnag')) {
|
||||
// dd($request->input());
|
||||
$debug_new = base_path()
|
||||
.DIRECTORY_SEPARATOR.
|
||||
'config'
|
||||
.DIRECTORY_SEPARATOR.
|
||||
'app.php';
|
||||
$datacontent = File::get($debug_new);
|
||||
$datacontent = str_replace("'debug' => ".$debug,
|
||||
"'debug' => ".\Input::get('debug'),
|
||||
$datacontent);
|
||||
File::put($debug_new, $datacontent);
|
||||
|
||||
// dd($request->input());
|
||||
$bugsnag_debug_new = base_path()
|
||||
.DIRECTORY_SEPARATOR.
|
||||
'config'
|
||||
.DIRECTORY_SEPARATOR.
|
||||
'app.php';
|
||||
$datacontent2 = File::get($bugsnag_debug_new);
|
||||
$datacontent2 = str_replace("'bugsnag_reporting' => ".$bugsnag_debug,
|
||||
"'bugsnag_reporting' => ".\Input::get('bugsnag'),
|
||||
$datacontent2);
|
||||
File::put($bugsnag_debug_new, $datacontent2);
|
||||
return redirect()->back()->with('success',
|
||||
Lang::get('lang.error-debug-settings-saved-message'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails',
|
||||
Lang::get('lang.error-debug-settings-error-message'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to show error log table page
|
||||
* @param void
|
||||
* @return response view
|
||||
*/
|
||||
public function showErrorLogs()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.settings.error-and-logs.log-table');
|
||||
}
|
||||
}
|
@@ -12,6 +12,7 @@ use App\Model\helpdesk\Manage\Help_topic;
|
||||
use Illuminate\Http\Request;
|
||||
// Class
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
@@ -29,7 +30,7 @@ class FormController extends Controller
|
||||
{
|
||||
$this->fields = $fields;
|
||||
$this->forms = $forms;
|
||||
// $this->middleware('auth');
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,21 +52,29 @@ class FormController extends Controller
|
||||
*/
|
||||
public function index(Forms $forms)
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms'));
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* create a new form.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.manage.form.form');
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.form.form');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
* Show a new form.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
@@ -73,18 +82,22 @@ class FormController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('id'));
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('id'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* Store a new form.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Forms $forms)
|
||||
{
|
||||
if (!Input::get('formname')) {
|
||||
return Redirect::back()->with('fails', 'Please fill Form name');
|
||||
return Redirect::back()->with('fails', Lang::get('lang.please_fill_form_name'));
|
||||
}
|
||||
$required = Input::get('required');
|
||||
$count = count($required);
|
||||
@@ -112,9 +125,19 @@ class FormController extends Controller
|
||||
}
|
||||
Fields::insert($fields);
|
||||
|
||||
return Redirect::back()->with('success', 'Successfully created Form');
|
||||
return Redirect::back()->with('success', Lang::get('lang.successfully_created_form'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Form.
|
||||
*
|
||||
* @param type $id
|
||||
* @param \App\Model\helpdesk\Form\Forms $forms
|
||||
* @param type $field
|
||||
* @param type $help_topic
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic)
|
||||
{
|
||||
$fields = $field->where('forms_id', $id)->get();
|
||||
@@ -129,6 +152,6 @@ class FormController extends Controller
|
||||
$forms = $forms->where('id', $id)->first();
|
||||
$forms->delete();
|
||||
|
||||
return redirect()->back()->with('success', 'Deleted Successfully');
|
||||
return redirect()->back()->with('success', Lang::get('lang.form_deleted_successfully'));
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Admin\helpdesk;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\GroupRequest;
|
||||
use App\Http\Requests\helpdesk\GroupUpdateRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Group_assign_department;
|
||||
@@ -15,6 +16,7 @@ use Exception;
|
||||
// classes
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* GroupController.
|
||||
@@ -51,7 +53,7 @@ class GroupController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.groups.index', compact('departments', 'group_assign_department', 'groups'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', Lang::get('lang.failed_to_load_the_page'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +67,7 @@ class GroupController extends Controller
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.agent.groups.create');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', Lang::get('lang.failed_to_load_the_page'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +85,10 @@ class GroupController extends Controller
|
||||
/* Check Whether function success or not */
|
||||
$group->fill($request->input())->save();
|
||||
|
||||
return redirect('groups')->with('success', 'Group Created Successfully');
|
||||
return redirect('groups')->with('success', Lang::get('lang.group_created_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('groups')->with('fails', Lang::get('lang.group_can_not_create').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +107,7 @@ class GroupController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.groups.edit', compact('groups'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('groups')->with('fails', Lang::get('lang.group_can_not_update').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,56 +120,59 @@ class GroupController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, Groups $group, Request $request)
|
||||
public function update($id, Groups $group, GroupUpdateRequest $request)
|
||||
{
|
||||
// Database instannce to the current id
|
||||
$var = $group->whereId($id)->first();
|
||||
// Updating Name
|
||||
$var->name = $request->input('name');
|
||||
//Updating Status
|
||||
$status = $request->Input('group_status');
|
||||
$status = $request->input('group_status');
|
||||
$var->group_status = $status;
|
||||
//Updating can_create_ticket field
|
||||
$createTicket = $request->Input('can_create_ticket');
|
||||
$createTicket = $request->input('can_create_ticket');
|
||||
$var->can_create_ticket = $createTicket;
|
||||
//Updating can_edit_ticket field
|
||||
$editTicket = $request->Input('can_edit_ticket');
|
||||
$editTicket = $request->input('can_edit_ticket');
|
||||
$var->can_edit_ticket = $editTicket;
|
||||
//Updating can_post_ticket field
|
||||
$postTicket = $request->Input('can_post_ticket');
|
||||
$postTicket = $request->input('can_post_ticket');
|
||||
$var->can_post_ticket = $postTicket;
|
||||
//Updating can_close_ticket field
|
||||
$closeTicket = $request->Input('can_close_ticket');
|
||||
$closeTicket = $request->input('can_close_ticket');
|
||||
$var->can_close_ticket = $closeTicket;
|
||||
//Updating can_assign_ticket field
|
||||
$assignTicket = $request->Input('can_assign_ticket');
|
||||
$assignTicket = $request->input('can_assign_ticket');
|
||||
$var->can_assign_ticket = $assignTicket;
|
||||
//Updating can_delete_ticket field
|
||||
$deleteTicket = $request->Input('can_delete_ticket');
|
||||
$deleteTicket = $request->input('can_delete_ticket');
|
||||
$var->can_delete_ticket = $deleteTicket;
|
||||
//Updating can_ban_email field
|
||||
$banEmail = $request->Input('can_ban_email');
|
||||
$banEmail = $request->input('can_ban_email');
|
||||
$var->can_ban_email = $banEmail;
|
||||
//Updating can_manage_canned field
|
||||
$manageCanned = $request->Input('can_manage_canned');
|
||||
$manageCanned = $request->input('can_manage_canned');
|
||||
$var->can_manage_canned = $manageCanned;
|
||||
//Updating can_manage_faq field
|
||||
$manageFaq = $request->Input('can_manage_faq');
|
||||
$manageFaq = $request->input('can_manage_faq');
|
||||
$var->can_manage_faq = $manageFaq;
|
||||
//Updating can_view_agent_stats field
|
||||
$viewAgentStats = $request->Input('can_view_agent_stats');
|
||||
$viewAgentStats = $request->input('can_view_agent_stats');
|
||||
$var->can_view_agent_stats = $viewAgentStats;
|
||||
//Updating department_access field
|
||||
$departmentAccess = $request->Input('department_access');
|
||||
$departmentAccess = $request->input('department_access');
|
||||
$var->department_access = $departmentAccess;
|
||||
//Updating admin_notes field
|
||||
$adminNotes = $request->Input('admin_notes');
|
||||
$adminNotes = $request->input('admin_notes');
|
||||
$var->admin_notes = $adminNotes;
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
$var->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('groups')->with('success', 'Group Updated Successfully');
|
||||
return redirect('groups')->with('success', Lang::get('lang.group_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('groups')->with('fails', 'Groups can not Create'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('groups')->with('fails', Lang::get('lang.group_can_not_update').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +189,9 @@ class GroupController extends Controller
|
||||
{
|
||||
$users = User::where('assign_group', '=', $id)->first();
|
||||
if ($users) {
|
||||
$user = '<li>There are agents assigned to this group. Please unassign them from this group to delete</li>';
|
||||
$user = '<li>'.Lang::get('lang.there_are_agents_assigned_to_this_group_please_unassign_them_from_this_group_to_delete').'</li>';
|
||||
|
||||
return redirect('groups')->with('fails', 'Group cannot Delete '.$user);
|
||||
return redirect('groups')->with('fails', Lang('lang.group_cannot_delete').$user);
|
||||
}
|
||||
$group_assign_department->where('group_id', $id)->delete();
|
||||
$groups = $group->whereId($id)->first();
|
||||
@@ -194,10 +199,10 @@ class GroupController extends Controller
|
||||
try {
|
||||
$groups->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('groups')->with('success', 'Group Deleted Successfully');
|
||||
return redirect('groups')->with('success', Lang::get('lang.group_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('groups')->with('fails', 'Groups cannot Create'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('groups')->with('fails', Lang::get('lang.group_cannot_delete').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ use App\User;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* HelptopicController.
|
||||
@@ -52,7 +53,7 @@ class HelptopicController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.helptopic.index', compact('topics'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ class HelptopicController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,10 +120,10 @@ class HelptopicController extends Controller
|
||||
$topic->fill($request->except('custom_form', 'auto_assign'))->save();
|
||||
// $topics->fill($request->except('custom_form','auto_assign'))->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('helptopic')->with('success', 'Helptopic Created Successfully');
|
||||
return redirect('helptopic')->with('success', Lang::get('lang.helptopic_created_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('helptopic')->with('fails', 'Helptopic can not Create'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('helptopic')->with('fails', Lang::get('lang.helptopic_can_not_create').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,10 +149,13 @@ class HelptopicController extends Controller
|
||||
$forms = $form->get();
|
||||
$slas = $sla->get();
|
||||
$priority = $priority->get();
|
||||
$sys_help_topic = \DB::table('settings_ticket')
|
||||
->select('help_topic')
|
||||
->where('id', '=', 1)->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
|
||||
return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas', 'sys_help_topic'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('helptopic')->with('fails', '<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('helptopic')->with('fails', '<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +170,6 @@ class HelptopicController extends Controller
|
||||
*/
|
||||
public function update($id, Help_topic $topic, HelptopicUpdate $request)
|
||||
{
|
||||
// dd($request);
|
||||
try {
|
||||
$topics = $topic->whereId($id)->first();
|
||||
if ($request->custom_form) {
|
||||
@@ -184,11 +187,16 @@ class HelptopicController extends Controller
|
||||
$topics->custom_form = $custom_form;
|
||||
$topics->auto_assign = $auto_assign;
|
||||
$topics->save();
|
||||
if ($request->input('sys_help_tpoic') == 'on') {
|
||||
\DB::table('settings_ticket')
|
||||
->where('id', '=', 1)
|
||||
->update(['help_topic' => $id]);
|
||||
}
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('helptopic')->with('success', 'Helptopic Updated Successfully');
|
||||
return redirect('helptopic')->with('success', Lang::get('lang.helptopic_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('helptopic')->with('fails', 'Helptopic can not Update'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('helptopic')->with('fails', Lang::get('lang.helptopic_can_not_update').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,45 +212,40 @@ class HelptopicController extends Controller
|
||||
{
|
||||
$ticket_settings = $ticket_setting->where('id', '=', '1')->first();
|
||||
if ($ticket_settings->help_topic == $id) {
|
||||
return redirect('departments')->with('fails', 'You cannot delete default department');
|
||||
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
|
||||
} else {
|
||||
$tickets = DB::table('tickets')->where('help_topic_id', '=', $id)->update(['help_topic_id' => $ticket_settings->help_topic]);
|
||||
|
||||
if ($tickets > 0) {
|
||||
if ($tickets > 1) {
|
||||
$text_tickets = 'Tickets';
|
||||
} else {
|
||||
$text_tickets = 'Ticket';
|
||||
}
|
||||
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default Help Topic</li>';
|
||||
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_help_topic').' </li>';
|
||||
} else {
|
||||
$ticket = '';
|
||||
}
|
||||
|
||||
$emails = DB::table('emails')->where('help_topic', '=', $id)->update(['help_topic' => $ticket_settings->help_topic]);
|
||||
|
||||
if ($emails > 0) {
|
||||
if ($emails > 1) {
|
||||
$text_emails = 'Emails';
|
||||
} else {
|
||||
$text_emails = 'Email';
|
||||
}
|
||||
$email = '<li>'.$emails.' System '.$text_emails.' have been moved to default Help Topic</li>';
|
||||
$email = '<li>'.$emails.' System '.$text_emails.Lang::get('lang.have_been_moved_to_default_help_topic').' </li>';
|
||||
} else {
|
||||
$email = '';
|
||||
}
|
||||
|
||||
$message = $ticket.$email;
|
||||
|
||||
$topics = $topic->whereId($id)->first();
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
$topics->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('helptopic')->with('success', 'Helptopic Deleted Successfully'.$message);
|
||||
return redirect('helptopic')->with('success', Lang::get('lang.helptopic_deleted_successfully').$message);
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('helptopic')->with('fails', 'Helptopic can not Delete'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('helptopic')->with('fails', Lang::get('lang.helptopic_can_not_update').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
121
app/Http/Controllers/Admin/helpdesk/SecurityController.php
Normal file
121
app/Http/Controllers/Admin/helpdesk/SecurityController.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// Controller
|
||||
use App\Http\Controllers\Controller;
|
||||
// Model
|
||||
use App\Http\Requests\helpdesk\SecurityRequest;
|
||||
use App\Model\helpdesk\Settings\Security;
|
||||
// Request
|
||||
use Illuminate\Http\Request;
|
||||
// Class
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
* FormController
|
||||
* This controller is used to CRUD Custom Security.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class SecurityController extends Controller
|
||||
{
|
||||
private $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
* list of securitys.
|
||||
*
|
||||
* @param type Security $securitys
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index(Security $securitys)
|
||||
{
|
||||
try {
|
||||
$security = $securitys->whereId('1')->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.security.index', compact('security'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create security setting.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.setting.security.security');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show security.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.setting.security.preview', compact('id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update security details.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update($id, SecurityRequest $request)
|
||||
{
|
||||
try {
|
||||
$security = new Security();
|
||||
$securitys = $security->whereId($id)->first();
|
||||
$securitys->lockout_message = $request->input('lockout_message');
|
||||
$securitys->backlist_offender = $request->input('backlist_offender');
|
||||
$securitys->backlist_threshold = $request->input('backlist_threshold');
|
||||
$securitys->lockout_period = $request->input('lockout_period');
|
||||
$securitys->days_to_keep_logs = $request->input('days_to_keep_logs');
|
||||
$securitys->save();
|
||||
|
||||
return Redirect::back()->with('success', Lang::get('lang.security_settings_saved_successfully'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete security details.
|
||||
*
|
||||
* @param type $id
|
||||
* @param \App\Model\helpdesk\Settings\Security $securitys
|
||||
* @param type $field
|
||||
* @param \App\Http\Controllers\Admin\helpdesk\Help_topic $help_topic
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function delete($id, Security $securitys, Fields $field, Help_topic $help_topic)
|
||||
{
|
||||
$fields = $field->where('securitys_id', $id)->get();
|
||||
$help_topics = $help_topic->where('custom_security', '=', $id)->get();
|
||||
foreach ($help_topics as $help_topic) {
|
||||
$help_topic->custom_security = null;
|
||||
$help_topic->save();
|
||||
}
|
||||
foreach ($fields as $field) {
|
||||
$field->delete();
|
||||
}
|
||||
$securitys = $securitys->where('id', $id)->first();
|
||||
$securitys->delete();
|
||||
|
||||
return redirect()->back()->with('success', 'Deleted Successfully');
|
||||
}
|
||||
}
|
@@ -7,6 +7,8 @@ use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CompanyRequest;
|
||||
use App\Http\Requests\helpdesk\EmailRequest;
|
||||
use App\Http\Requests\helpdesk\RatingUpdateRequest;
|
||||
use App\Http\Requests\helpdesk\StatusRequest;
|
||||
use App\Http\Requests\helpdesk\SystemRequest;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
@@ -14,7 +16,8 @@ use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Email\Template;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Manage\Sla_plan;
|
||||
use App\Model\helpdesk\Settings\Access;
|
||||
use App\Model\helpdesk\Notification\UserNotification;
|
||||
use App\Model\helpdesk\Ratings\Rating;
|
||||
use App\Model\helpdesk\Settings\Alert;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
@@ -26,9 +29,11 @@ use App\Model\helpdesk\Utility\Date_format;
|
||||
use App\Model\helpdesk\Utility\Date_time_format;
|
||||
use App\Model\helpdesk\Utility\Time_format;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use DateTime;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use File;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
@@ -52,16 +57,6 @@ class SettingsController extends Controller
|
||||
$this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Main Settings Page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.setting');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param $compant instance of company table
|
||||
@@ -109,10 +104,10 @@ class SettingsController extends Controller
|
||||
try {
|
||||
$companys->fill($request->except('logo'))->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getcompany')->with('success', 'Company Updated Successfully');
|
||||
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', 'Company can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +153,9 @@ class SettingsController extends Controller
|
||||
$departments = $department->get();
|
||||
/* Fetch the values from Timezones table */
|
||||
$timezones = $timezone->get();
|
||||
|
||||
//$debug = \Config::get('app.debug');
|
||||
//dd($value);
|
||||
/* Direct to System Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time'));
|
||||
} catch (Exception $e) {
|
||||
@@ -184,10 +182,13 @@ class SettingsController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$systems->fill($request->input())->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getsystem')->with('success', 'System Updated Successfully');
|
||||
|
||||
// dd($datacontent);
|
||||
//\Config::set('app.debug', $request->input('debug'));
|
||||
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', 'System can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated').'<br>'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,10 +246,10 @@ class SettingsController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$tickets->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getticket')->with('success', 'Ticket Updated Successfully');
|
||||
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', 'Ticket can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,10 +304,10 @@ class SettingsController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$emails->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getemail')->with('success', 'Email Updated Successfully');
|
||||
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', 'Email can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,16 +323,15 @@ class SettingsController extends Controller
|
||||
public function getSchedular(Email $email, Template $template, Emails $email1)
|
||||
{
|
||||
// try {
|
||||
/* fetch the values of email from Email table */
|
||||
$emails = $email->whereId('1')->first();
|
||||
/* Fetch the values from Template table */
|
||||
$templates = $template->get();
|
||||
/* Fetch the values from Emails table */
|
||||
$emails1 = $email1->get();
|
||||
/* fetch the values of email from Email table */
|
||||
$emails = $email->whereId('1')->first();
|
||||
/* Fetch the values from Template table */
|
||||
$templates = $template->get();
|
||||
/* Fetch the values from Emails table */
|
||||
$emails1 = $email1->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.crone', compact('emails', 'templates', 'emails1'));
|
||||
// } catch {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -368,57 +368,6 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for Access setting page.
|
||||
*
|
||||
* @param type Access $access
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
// public function getaccess(Access $access) {
|
||||
// try {
|
||||
// /* fetch the values of access from access table */
|
||||
// $accesses = $access->whereId('1')->first();
|
||||
// // Direct to Access Settings Page
|
||||
// return view('themes.default1.admin.helpdesk.settings.access', compact('accesses'));
|
||||
// } catch (Exception $e) {
|
||||
// return view('404');
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type Access $access
|
||||
* @param type Request $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
// public function postaccess(Access $access, Request $request) {
|
||||
// try {
|
||||
// /* fetch the values of access request */
|
||||
// $accesses = $access->whereId('1')->first();
|
||||
// /* fill the values to access table */
|
||||
// $accesses->fill($request->except('password_reset', 'bind_agent_ip', 'reg_require', 'quick_access'))->save();
|
||||
// /* insert checkbox value to DB */
|
||||
// $accesses->password_reset = $request->input('password_reset');
|
||||
// $accesses->bind_agent_ip = $request->input('bind_agent_ip');
|
||||
// $accesses->reg_require = $request->input('reg_require');
|
||||
// $accesses->quick_access = $request->input('quick_access');
|
||||
// /* Check whether function success or not */
|
||||
// if ($accesses->save() == true) {
|
||||
// /* redirect to Index page with Success Message */
|
||||
// return redirect('getaccess')->with('success', 'Access Updated Successfully');
|
||||
// } else {
|
||||
// /* redirect to Index page with Fails Message */
|
||||
// return redirect('getaccess')->with('fails', 'Access can not Updated');
|
||||
// }
|
||||
// } catch (Exception $e) {
|
||||
// /* redirect to Index page with Fails Message */
|
||||
// return redirect('getaccess')->with('fails', 'Access can not Updated');
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* get the form for Responder setting page.
|
||||
*
|
||||
@@ -461,10 +410,10 @@ class SettingsController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$responders->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getresponder')->with('success', 'Responder Updated Successfully');
|
||||
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', 'Responder can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,52 +498,13 @@ class SettingsController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$alerts->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getalert')->with('success', 'Alert Updated Successfully');
|
||||
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', 'Alert can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To display the list of ratings in the system.
|
||||
*
|
||||
* @return type View
|
||||
*/
|
||||
public function RatingSettings()
|
||||
{
|
||||
$ratings = DB::table('settings_ratings')->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.ratings', compact('ratings'));
|
||||
}
|
||||
|
||||
/**
|
||||
* To store rating data.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function PostRatingSettings($slug)
|
||||
{
|
||||
$name = Input::get('rating_name');
|
||||
$publish = Input::get('publish');
|
||||
$modify = Input::get('modify');
|
||||
DB::table('settings_ratings')->whereSlug($slug)->update(['rating_name' => $name, 'publish' => $publish, 'modify' => $modify]);
|
||||
|
||||
return redirect()->back()->with('success', 'Successfully updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* To delete a type of rating.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function RatingDelete($slug)
|
||||
{
|
||||
DB::table('settings_ratings')->whereSlug($slug)->delete();
|
||||
|
||||
return redirect()->back()->with('success', 'Successfully Deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Api key.
|
||||
*
|
||||
@@ -606,4 +516,297 @@ class SettingsController extends Controller
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main Settings Page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.setting');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param $compant instance of company table
|
||||
*
|
||||
* get the form for company setting page
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getStatuses()
|
||||
{
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$statuss = \DB::table('ticket_status')->get();
|
||||
/* Direct to Company Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.status', compact('statuss'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param $compant instance of company table
|
||||
*
|
||||
* get the form for company setting page
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getEditStatuses($id)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$status = \DB::table('ticket_status')->where('id', '=', $id)->first();
|
||||
/* Direct to Company Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.status-edit', compact('status'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param $compant instance of company table
|
||||
*
|
||||
* get the form for company setting page
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
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();
|
||||
$statuss->name = $request->input('name');
|
||||
$statuss->icon_class = $request->input('icon_class');
|
||||
$statuss->email_user = $request->input('email_user');
|
||||
$statuss->sort = $request->input('sort');
|
||||
$delete = $request->input('deleted');
|
||||
if ($delete == 'yes') {
|
||||
$statuss->state = 'delete';
|
||||
} else {
|
||||
$statuss->state = $request->input('state');
|
||||
}
|
||||
$statuss->sort = $request->input('sort');
|
||||
$statuss->save();
|
||||
/* Direct to Company Settings Page */
|
||||
return redirect()->back()->with('success', Lang::get('lang.status_has_been_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* create a status.
|
||||
*
|
||||
* @param \App\Model\helpdesk\Ticket\Ticket_Status $statuss
|
||||
* @param \App\Http\Requests\helpdesk\StatusRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
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');
|
||||
$statuss->icon_class = $request->input('icon_class');
|
||||
$statuss->email_user = $request->input('email_user');
|
||||
$statuss->sort = $request->input('sort');
|
||||
$delete = $request->input('delete');
|
||||
if ($delete == 'yes') {
|
||||
$statuss->state = 'deleted';
|
||||
} else {
|
||||
$statuss->state = $request->input('state');
|
||||
}
|
||||
$statuss->sort = $request->input('sort');
|
||||
$statuss->save();
|
||||
/* Direct to Company Settings Page */
|
||||
return redirect()->back()->with('success', Lang::get('lang.status_has_been_created_successfully'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a status.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function deleteStatuses($id)
|
||||
{
|
||||
try {
|
||||
if ($id > 5) {
|
||||
/* fetch the values of company from company table */
|
||||
\App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->delete();
|
||||
/* Direct to Company Settings Page */
|
||||
return redirect()->back()->with('success', Lang::get('lang.status_has_been_deleted'));
|
||||
} else {
|
||||
return redirect()->back()->with('failed', Lang::get('lang.you_cannot_delete_this_status'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the page of notification settings.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function notificationSettings()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.settings.notification');
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a notification.
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function deleteReadNoti()
|
||||
{
|
||||
$markasread = UserNotification::where('is_read', '=', 1)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->delete();
|
||||
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_read_notifications'));
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a notification log.
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
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');
|
||||
$formatted_date = $date->format('Y-m-d H:i:s');
|
||||
$markasread = UserNotification::where('created_at', '<=', $formatted_date)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->delete();
|
||||
\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.');
|
||||
}
|
||||
|
||||
/**
|
||||
* To display the list of ratings in the system.
|
||||
*
|
||||
* @return type View
|
||||
*/
|
||||
public function RatingSettings()
|
||||
{
|
||||
try {
|
||||
$ratings = Rating::orderBy('display_order', 'asc')->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.ratings', compact('ratings'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* edit a rating.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function editRatingSettings($id)
|
||||
{
|
||||
try {
|
||||
$rating = Rating::whereId($id)->first();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.edit-ratings', compact('rating'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To store rating data.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request)
|
||||
{
|
||||
try {
|
||||
$rating = $ratings->whereId($id)->first();
|
||||
$rating->name = $request->input('name');
|
||||
$rating->display_order = $request->input('display_order');
|
||||
$rating->allow_modification = $request->input('allow_modification');
|
||||
$rating->rating_scale = $request->input('rating_scale');
|
||||
// $rating->rating_area = $request->input('rating_area');
|
||||
$rating->restrict = $request->input('restrict');
|
||||
$rating->save();
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.ratings_updated_successfully'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the create rating page.
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
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>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* store a rating value.
|
||||
*
|
||||
* @param \App\Model\helpdesk\Ratings\Rating $rating
|
||||
* @param \App\Model\helpdesk\Ratings\RatingRef $ratingrefs
|
||||
* @param \App\Http\Requests\helpdesk\RatingRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
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');
|
||||
$rating->rating_scale = $request->input('rating_scale');
|
||||
$rating->rating_area = $request->input('rating_area');
|
||||
$rating->restrict = $request->input('restrict');
|
||||
$rating->save();
|
||||
$ratingrefs->rating_id = $rating->id;
|
||||
$ratingrefs->save();
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.successfully_created_this_rating'));
|
||||
}
|
||||
|
||||
/**
|
||||
* To delete a type of rating.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
743
app/Http/Controllers/Admin/helpdesk/SettingsController2.php
Normal file
743
app/Http/Controllers/Admin/helpdesk/SettingsController2.php
Normal file
@@ -0,0 +1,743 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CompanyRequest;
|
||||
use App\Http\Requests\helpdesk\EmailRequest;
|
||||
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;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Manage\Sla_plan;
|
||||
use App\Model\helpdesk\Notification\UserNotification;
|
||||
use App\Model\helpdesk\Settings\Access;
|
||||
use App\Model\helpdesk\Settings\Alert;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Settings\Responder;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Ticket;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
use App\Model\helpdesk\Utility\Date_format;
|
||||
use App\Model\helpdesk\Utility\Date_time_format;
|
||||
use App\Model\helpdesk\Utility\Time_format;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use DateTime;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* SettingsController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class SettingsController2 extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// $this->smtp();
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Main Settings Page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.setting');
|
||||
}
|
||||
|
||||
public function notificationSettings()
|
||||
{
|
||||
return view('themes.default1.admin.helpdesk.settings.notification');
|
||||
}
|
||||
|
||||
public function deleteReadNoti()
|
||||
{
|
||||
$markasread = UserNotification::where('is_read', '=', 1)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->delete();
|
||||
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'You have deleted all the read notifications');
|
||||
}
|
||||
|
||||
public function deleteNotificationLog()
|
||||
{
|
||||
$days = Input::get('no_of_days');
|
||||
$date = new DateTime();
|
||||
$date->modify($days.' day');
|
||||
$formatted_date = $date->format('Y-m-d H:i:s');
|
||||
$markasread = DB::table('user_notification')->where('created_at', '<=', $formatted_date)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->delete();
|
||||
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'You have deleted all the notification records since '.$days.' days.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param $compant instance of company table
|
||||
*
|
||||
* get the form for company setting page
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getStatuses()
|
||||
{
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$statuss = \DB::table('ticket_status')->get();
|
||||
/* Direct to Company Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.status', compact('statuss'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param $compant instance of company table
|
||||
*
|
||||
* get the form for company setting page
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function editStatuses($id)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first();
|
||||
$statuss->name = Input::get('name');
|
||||
$statuss->icon_class = Input::get('icon_class');
|
||||
$statuss->email_user = Input::get('email_user');
|
||||
$statuss->sort = Input::get('sort');
|
||||
$delete = Input::get('delete');
|
||||
if ($delete == 'yes') {
|
||||
$statuss->state = 'delete';
|
||||
} else {
|
||||
$statuss->state = Input::get('state');
|
||||
}
|
||||
$statuss->sort = Input::get('sort');
|
||||
$statuss->save();
|
||||
/* Direct to Company Settings Page */
|
||||
return redirect()->back()->with('success', 'Status has been updated!');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss)
|
||||
{
|
||||
// try {
|
||||
/* fetch the values of company from company table */
|
||||
$statuss->name = Input::get('name');
|
||||
$statuss->icon_class = Input::get('icon_class');
|
||||
$statuss->email_user = Input::get('email_user');
|
||||
$statuss->sort = Input::get('sort');
|
||||
$delete = Input::get('delete');
|
||||
if ($delete == 'yes') {
|
||||
$statuss->state = 'delete';
|
||||
} else {
|
||||
$statuss->state = Input::get('state');
|
||||
}
|
||||
$statuss->sort = Input::get('sort');
|
||||
$statuss->save();
|
||||
/* Direct to Company Settings Page */
|
||||
return redirect()->back()->with('success', 'Status has been created!');
|
||||
// } catch (Exception $ex) {
|
||||
// return redirect()->back()->with('fails', $ex->errorInfo[2]);
|
||||
// }
|
||||
}
|
||||
|
||||
public function deleteStatuses($id)
|
||||
{
|
||||
try {
|
||||
if ($id > 5) {
|
||||
/* fetch the values of company from company table */
|
||||
\App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->delete();
|
||||
/* Direct to Company Settings Page */
|
||||
return redirect()->back()->with('success', 'Status has been deleted');
|
||||
} else {
|
||||
return redirect()->back()->with('failed', 'You cannot delete this status');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param $compant instance of company table
|
||||
*
|
||||
* get the form for company setting page
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getcompany(Company $company)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of company from company table */
|
||||
$companys = $company->whereId('1')->first();
|
||||
/* Direct to Company Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.company', compact('companys'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Company $company
|
||||
* @param type CompanyRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
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 = 'lb-faveo/media/company/';
|
||||
$fileName = rand(0000, 9999).'.'.$name;
|
||||
Input::file('logo')->move($destinationPath, $fileName);
|
||||
$companys->logo = $fileName;
|
||||
}
|
||||
if ($request->input('use_logo') == null) {
|
||||
$companys->use_logo = '0';
|
||||
}
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
$companys->fill($request->except('logo'))->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getcompany')->with('success', 'Company Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getcompany')->with('fails', 'Company can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function to delete system logo.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function deleteLogo()
|
||||
{
|
||||
$path = $_GET['data1']; //get file path of logo image
|
||||
if (!unlink($path)) {
|
||||
return 'false';
|
||||
} else {
|
||||
$companys = Company::where('id', '=', 1)->first();
|
||||
$companys->logo = null;
|
||||
$companys->use_logo = '0';
|
||||
$companys->save();
|
||||
|
||||
return 'true';
|
||||
}
|
||||
// return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for System setting page.
|
||||
*
|
||||
* @param type System $system
|
||||
* @param type Department $department
|
||||
* @param type Timezones $timezone
|
||||
* @param type Date_format $date
|
||||
* @param type Date_time_format $date_time
|
||||
* @param type Time_format $time
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of system from system table */
|
||||
$systems = $system->whereId('1')->first();
|
||||
/* Fetch the values from Department table */
|
||||
$departments = $department->get();
|
||||
/* Fetch the values from Timezones table */
|
||||
$timezones = $timezone->get();
|
||||
/* Direct to System Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type System $system
|
||||
* @param type SystemRequest $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postsystem($id, System $system, SystemRequest $request)
|
||||
{
|
||||
try {
|
||||
// dd($request);
|
||||
/* fetch the values of system request */
|
||||
$systems = $system->whereId('1')->first();
|
||||
/* fill the values to coompany table */
|
||||
/* Check whether function success or not */
|
||||
$systems->fill($request->input())->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getsystem')->with('success', 'System Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getsystem')->with('fails', 'System can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for Ticket setting page.
|
||||
*
|
||||
* @param type Ticket $ticket
|
||||
* @param type Sla_plan $sla
|
||||
* @param type Help_topic $topic
|
||||
* @param type Priority $priority
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
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();
|
||||
/* Fetch the values from SLA Plan table */
|
||||
$slas = $sla->get();
|
||||
/* Fetch the values from Help_topic table */
|
||||
$topics = $topic->get();
|
||||
/* Direct to Ticket Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Ticket $ticket
|
||||
* @param type Request $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postticket($id, Ticket $ticket, Request $request)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of ticket request */
|
||||
$tickets = $ticket->whereId('1')->first();
|
||||
/* fill the values to coompany table */
|
||||
$tickets->fill($request->except('captcha', 'claim_response', 'assigned_ticket', 'answered_ticket', 'agent_mask', 'html', 'client_update'))->save();
|
||||
/* insert checkbox to Database */
|
||||
$tickets->captcha = $request->input('captcha');
|
||||
$tickets->claim_response = $request->input('claim_response');
|
||||
$tickets->assigned_ticket = $request->input('assigned_ticket');
|
||||
$tickets->answered_ticket = $request->input('answered_ticket');
|
||||
$tickets->agent_mask = $request->input('agent_mask');
|
||||
$tickets->html = $request->input('html');
|
||||
$tickets->client_update = $request->input('client_update');
|
||||
$tickets->collision_avoid = $request->input('collision_avoid');
|
||||
/* Check whether function success or not */
|
||||
$tickets->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getticket')->with('success', 'Ticket Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getticket')->with('fails', 'Ticket can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for Email setting page.
|
||||
*
|
||||
* @param type Email $email
|
||||
* @param type Template $template
|
||||
* @param type Emails $email1
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getemail(Email $email, Template $template, Emails $email1)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of email from Email table */
|
||||
$emails = $email->whereId('1')->first();
|
||||
/* Fetch the values from Template table */
|
||||
$templates = $template->get();
|
||||
/* Fetch the values from Emails table */
|
||||
$emails1 = $email1->get();
|
||||
/* Direct to Email Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.email', compact('emails', 'templates', 'emails1'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Email $email
|
||||
* @param type EmailRequest $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postemail($id, Email $email, EmailRequest $request)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of email request */
|
||||
$emails = $email->whereId('1')->first();
|
||||
/* fill the values to email table */
|
||||
$emails->fill($request->except('email_fetching', 'all_emails', 'email_collaborator', 'strip', 'attachment'))->save();
|
||||
/* insert checkboxes to database */
|
||||
// $emails->email_fetching = $request->input('email_fetching');
|
||||
// $emails->notification_cron = $request->input('notification_cron');
|
||||
$emails->all_emails = $request->input('all_emails');
|
||||
$emails->email_collaborator = $request->input('email_collaborator');
|
||||
$emails->strip = $request->input('strip');
|
||||
$emails->attachment = $request->input('attachment');
|
||||
/* Check whether function success or not */
|
||||
$emails->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getemail')->with('success', 'Email Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getemail')->with('fails', 'Email can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for cron job setting page.
|
||||
*
|
||||
* @param type Email $email
|
||||
* @param type Template $template
|
||||
* @param type Emails $email1
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getSchedular(Email $email, Template $template, Emails $email1)
|
||||
{
|
||||
// try {
|
||||
/* fetch the values of email from Email table */
|
||||
$emails = $email->whereId('1')->first();
|
||||
/* Fetch the values from Template table */
|
||||
$templates = $template->get();
|
||||
/* Fetch the values from Emails table */
|
||||
$emails1 = $email1->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.crone', compact('emails', 'templates', 'emails1'));
|
||||
// } catch {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage for cron job.
|
||||
*
|
||||
* @param type Email $email
|
||||
* @param type EmailRequest $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postSchedular(Email $email, Template $template, Emails $email1, Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
try {
|
||||
/* fetch the values of email request */
|
||||
$emails = $email->whereId('1')->first();
|
||||
if ($request->email_fetching) {
|
||||
$emails->email_fetching = $request->email_fetching;
|
||||
} else {
|
||||
$emails->email_fetching = 0;
|
||||
}
|
||||
if ($request->notification_cron) {
|
||||
$emails->notification_cron = $request->notification_cron;
|
||||
} else {
|
||||
$emails->notification_cron = 0;
|
||||
}
|
||||
$emails->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for Access setting page.
|
||||
*
|
||||
* @param type Access $access
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
// public function getaccess(Access $access) {
|
||||
// try {
|
||||
// /* fetch the values of access from access table */
|
||||
// $accesses = $access->whereId('1')->first();
|
||||
// // Direct to Access Settings Page
|
||||
// return view('themes.default1.admin.helpdesk.settings.access', compact('accesses'));
|
||||
// } catch (Exception $e) {
|
||||
// return view('404');
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type Access $access
|
||||
* @param type Request $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
// public function postaccess(Access $access, Request $request) {
|
||||
// try {
|
||||
// /* fetch the values of access request */
|
||||
// $accesses = $access->whereId('1')->first();
|
||||
// /* fill the values to access table */
|
||||
// $accesses->fill($request->except('password_reset', 'bind_agent_ip', 'reg_require', 'quick_access'))->save();
|
||||
// /* insert checkbox value to DB */
|
||||
// $accesses->password_reset = $request->input('password_reset');
|
||||
// $accesses->bind_agent_ip = $request->input('bind_agent_ip');
|
||||
// $accesses->reg_require = $request->input('reg_require');
|
||||
// $accesses->quick_access = $request->input('quick_access');
|
||||
// /* Check whether function success or not */
|
||||
// if ($accesses->save() == true) {
|
||||
// /* redirect to Index page with Success Message */
|
||||
// return redirect('getaccess')->with('success', 'Access Updated Successfully');
|
||||
// } else {
|
||||
// /* redirect to Index page with Fails Message */
|
||||
// return redirect('getaccess')->with('fails', 'Access can not Updated');
|
||||
// }
|
||||
// } catch (Exception $e) {
|
||||
// /* redirect to Index page with Fails Message */
|
||||
// return redirect('getaccess')->with('fails', 'Access can not Updated');
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* get the form for Responder setting page.
|
||||
*
|
||||
* @param type Responder $responder
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getresponder(Responder $responder)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of responder from responder table */
|
||||
$responders = $responder->whereId('1')->first();
|
||||
/* Direct to Responder Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.responder', compact('responders'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type Responder $responder
|
||||
* @param type Request $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function postresponder(Responder $responder, Request $request)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of responder request */
|
||||
$responders = $responder->whereId('1')->first();
|
||||
/* insert Checkbox value to DB */
|
||||
$responders->new_ticket = $request->input('new_ticket');
|
||||
$responders->agent_new_ticket = $request->input('agent_new_ticket');
|
||||
$responders->submitter = $request->input('submitter');
|
||||
$responders->participants = $request->input('participants');
|
||||
$responders->overlimit = $request->input('overlimit');
|
||||
/* fill the values to coompany table */
|
||||
/* Check whether function success or not */
|
||||
$responders->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getresponder')->with('success', 'Responder Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getresponder')->with('fails', 'Responder can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the form for Alert setting page.
|
||||
*
|
||||
* @param type Alert $alert
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getalert(Alert $alert)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of alert from alert table */
|
||||
$alerts = $alert->whereId('1')->first();
|
||||
/* Direct to Alert Settings Page */
|
||||
return view('themes.default1.admin.helpdesk.settings.alert', compact('alerts'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Alert $alert
|
||||
* @param type Request $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postalert($id, Alert $alert, Request $request)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of alert request */
|
||||
$alerts = $alert->whereId('1')->first();
|
||||
/* Insert Checkbox to DB */
|
||||
$alerts->assignment_status = $request->input('assignment_status');
|
||||
$alerts->ticket_status = $request->input('ticket_status');
|
||||
$alerts->overdue_department_member = $request->input('overdue_department_member');
|
||||
$alerts->sql_error = $request->input('sql_error');
|
||||
$alerts->excessive_failure = $request->input('excessive_failure');
|
||||
$alerts->overdue_status = $request->input('overdue_status');
|
||||
$alerts->overdue_assigned_agent = $request->input('overdue_assigned_agent');
|
||||
$alerts->overdue_department_manager = $request->input('overdue_department_manager');
|
||||
$alerts->internal_status = $request->input('internal_status');
|
||||
$alerts->internal_last_responder = $request->input('internal_last_responder');
|
||||
$alerts->internal_assigned_agent = $request->input('internal_assigned_agent');
|
||||
$alerts->internal_department_manager = $request->input('internal_department_manager');
|
||||
$alerts->assignment_assigned_agent = $request->input('assignment_assigned_agent');
|
||||
$alerts->assignment_team_leader = $request->input('assignment_team_leader');
|
||||
$alerts->assignment_team_member = $request->input('assignment_team_member');
|
||||
$alerts->system_error = $request->input('system_error');
|
||||
$alerts->transfer_department_member = $request->input('transfer_department_member');
|
||||
$alerts->transfer_department_manager = $request->input('transfer_department_manager');
|
||||
$alerts->transfer_assigned_agent = $request->input('transfer_assigned_agent');
|
||||
$alerts->transfer_status = $request->input('transfer_status');
|
||||
$alerts->message_organization_accmanager = $request->input('message_organization_accmanager');
|
||||
$alerts->message_department_manager = $request->input('message_department_manager');
|
||||
$alerts->message_assigned_agent = $request->input('message_assigned_agent');
|
||||
$alerts->message_last_responder = $request->input('message_last_responder');
|
||||
$alerts->message_status = $request->input('message_status');
|
||||
$alerts->ticket_organization_accmanager = $request->input('ticket_organization_accmanager');
|
||||
$alerts->ticket_department_manager = $request->input('ticket_department_manager');
|
||||
$alerts->ticket_department_member = $request->input('ticket_department_member');
|
||||
$alerts->ticket_admin_email = $request->input('ticket_admin_email');
|
||||
|
||||
if ($request->input('system_error') == null) {
|
||||
$str = '%0%';
|
||||
$path = app_path('../config/app.php');
|
||||
$content = \File::get($path);
|
||||
$content = str_replace('%1%', $str, $content);
|
||||
\File::put($path, $content);
|
||||
} else {
|
||||
$str = '%1%';
|
||||
$path = app_path('../config/app.php');
|
||||
$content = \File::get($path);
|
||||
$content = str_replace('%0%', $str, $content);
|
||||
\File::put($path, $content);
|
||||
}
|
||||
/* fill the values to coompany table */
|
||||
/* Check whether function success or not */
|
||||
$alerts->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('getalert')->with('success', 'Alert Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('getalert')->with('fails', 'Alert can not Updated'.'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To display the list of ratings in the system.
|
||||
*
|
||||
* @return type View
|
||||
*/
|
||||
public function RatingSettings()
|
||||
{
|
||||
$ratings = DB::table('settings_ratings')->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.settings.ratings', compact('ratings'));
|
||||
}
|
||||
|
||||
/**
|
||||
* To store rating data.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function PostRatingSettings($slug)
|
||||
{
|
||||
$name = Input::get('rating_name');
|
||||
$publish = Input::get('publish');
|
||||
$modify = Input::get('modify');
|
||||
DB::table('settings_ratings')->whereSlug($slug)->update(['rating_name' => $name, 'publish' => $publish, 'modify' => $modify]);
|
||||
|
||||
return redirect()->back()->with('success', 'Successfully updated');
|
||||
}
|
||||
|
||||
public function createRating()
|
||||
{
|
||||
$name = Input::get('rating_name');
|
||||
$publish = Input::get('publish');
|
||||
$modify = Input::get('modify');
|
||||
DB::table('settings_ratings')->insert(['rating_name' => $name, 'publish' => $publish, 'modify' => $modify]);
|
||||
|
||||
return redirect()->back()->with('success', 'Successfully created this rating');
|
||||
}
|
||||
|
||||
/**
|
||||
* To delete a type of rating.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function RatingDelete($slug)
|
||||
{
|
||||
DB::table('settings_ratings')->whereSlug($slug)->delete();
|
||||
|
||||
return redirect()->back()->with('success', 'Successfully Deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Api key.
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function generateApiKey()
|
||||
{
|
||||
$key = str_random(32);
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
@@ -13,6 +13,7 @@ use App\Model\helpdesk\Settings\Ticket;
|
||||
//classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* SlaController.
|
||||
@@ -47,7 +48,7 @@ class SlaController extends Controller
|
||||
/* Listing the values From Sla_plan Table */
|
||||
return view('themes.default1.admin.helpdesk.manage.sla.index', compact('slas'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ class SlaController extends Controller
|
||||
/* Direct to Create Page */
|
||||
return view('themes.default1.admin.helpdesk.manage.sla.create');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +82,10 @@ class SlaController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$sla->fill($request->input())->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('sla')->with('success', 'SLA Plan Created Successfully');
|
||||
return redirect('sla')->with('success', Lang::get('lang.sla_plan_created_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('sla')->with('fails', 'SLA Plan can not Create'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('sla')->with('fails', Lang::get('lang.sla_plan_can_not_create').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,16 +97,16 @@ class SlaController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, Sla_plan $sla)
|
||||
public function edit($id)
|
||||
{
|
||||
try {
|
||||
/* Direct to edit page along values of perticular field using Id */
|
||||
$slas = $sla->whereId($id)->first();
|
||||
$slas = Sla_plan::whereId($id)->first();
|
||||
$slas->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas'));
|
||||
$sla = \DB::table('settings_ticket')->select('sla')->where('id', '=', 1)->first();
|
||||
return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas','sla'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,11 +119,11 @@ class SlaController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, Sla_plan $sla, SlaUpdate $request)
|
||||
public function update($id, SlaUpdate $request)
|
||||
{
|
||||
try {
|
||||
/* Fill values to selected field using Id except Check box */
|
||||
$slas = $sla->whereId($id)->first();
|
||||
$slas = Sla_plan::whereId($id)->first();
|
||||
$slas->fill($request->except('transient', 'ticket_overdue'))->save();
|
||||
/* Update transient checkox field */
|
||||
$slas->transient = $request->input('transient');
|
||||
@@ -131,10 +132,15 @@ class SlaController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$slas->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('sla')->with('success', 'SLA Plan Updated Successfully');
|
||||
if ($request->input('sys_sla') == 'on') {
|
||||
\DB::table('settings_ticket')
|
||||
->where('id', '=', 1)
|
||||
->update(['sla' => $id]);
|
||||
}
|
||||
return redirect('sla')->with('success', Lang::get('lang.sla_plan_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('sla')->with('fails', 'SLA Plan can not Update'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('sla')->with('fails', Lang::get('lang.sla_plan_can_not_update').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,11 +152,11 @@ class SlaController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function destroy($id, Sla_plan $sla)
|
||||
public function destroy($id)
|
||||
{
|
||||
$default_sla = Ticket::where('id', '=', '1')->first();
|
||||
if ($default_sla->sla == $id) {
|
||||
return redirect('departments')->with('fails', 'You cannot delete default department');
|
||||
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
|
||||
} else {
|
||||
$tickets = DB::table('tickets')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]);
|
||||
if ($tickets > 0) {
|
||||
@@ -159,7 +165,7 @@ class SlaController extends Controller
|
||||
} else {
|
||||
$text_tickets = 'Ticket';
|
||||
}
|
||||
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default SLA</li>';
|
||||
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_sla').'</li>';
|
||||
} else {
|
||||
$ticket = '';
|
||||
}
|
||||
@@ -170,7 +176,7 @@ class SlaController extends Controller
|
||||
} else {
|
||||
$text_dept = 'Email';
|
||||
}
|
||||
$dept = '<li>Associated department have been moved to default SLA</li>';
|
||||
$dept = '<li>'.Lang::get('lang.associated_department_have_been_moved_to_default_sla').'</li>';
|
||||
} else {
|
||||
$dept = '';
|
||||
}
|
||||
@@ -181,21 +187,21 @@ class SlaController extends Controller
|
||||
} else {
|
||||
$text_topic = 'Email';
|
||||
}
|
||||
$topic = '<li>Associated Help Topic have been moved to default SLA</li>';
|
||||
$topic = '<li>'.Lang::get('lang.associated_help_topic_have_been_moved_to_default_sla').'</li>';
|
||||
} else {
|
||||
$topic = '';
|
||||
}
|
||||
$message = $ticket.$dept.$topic;
|
||||
/* Delete a perticular field from the database by delete() using Id */
|
||||
$slas = $sla->whereId($id)->first();
|
||||
$slas = Sla_plan::whereId($id)->first();
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
$slas->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('sla')->with('success', 'SLA Plan Deleted Successfully'.$message);
|
||||
return redirect('sla')->with('success', Lang::get('lang.sla_plan_deleted_successfully').$message);
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('sla')->with('fails', 'SLA Plan can not Delete'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('sla')->with('fails', Lang::get('lang.sla_plan_can_not_delete').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ use App\User;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* TeamController.
|
||||
@@ -51,7 +52,7 @@ class TeamController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.teams.index', compact('assign_team_agent', 'teams'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +70,7 @@ class TeamController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,10 +94,10 @@ class TeamController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$team->fill($request->except('team_lead'))->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('teams')->with('success', 'Teams Created Successfully');
|
||||
return redirect('teams')->with('success', Lang::get('lang.teams_created_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('teams')->with('fails', 'Teams can not Create'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_create').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ class TeamController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.teams.edit', compact('agent_id', 'user', 'teams', 'allagents'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,10 +154,10 @@ class TeamController extends Controller
|
||||
try {
|
||||
$teams->fill($request->except('team_lead'))->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('teams')->with('success', 'Teams Updated Successfully');
|
||||
return redirect('teams')->with('success', Lang::get('lang.teams_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('teams')->with('fails', 'Teams can not Update'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_update').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,10 +179,10 @@ class TeamController extends Controller
|
||||
/* Check whether function success or not */
|
||||
$teams->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('teams')->with('success', 'Teams Deleted Successfully');
|
||||
return redirect('teams')->with('success', Lang::get('lang.teams_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('teams')->with('fails', 'Teams can not Delete'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_delete').'<li>'.$e->getMessage().'</li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@ namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\DiagnosRequest;
|
||||
use App\Http\Requests\helpdesk\TemplateRequest;
|
||||
use App\Http\Requests\helpdesk\TemplateUdate;
|
||||
// models
|
||||
@@ -17,24 +17,22 @@ use App\Model\helpdesk\Utility\Languages;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Mail;
|
||||
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;
|
||||
SettingsController::smtp();
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
@@ -46,14 +44,13 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function index(Template $template)
|
||||
{
|
||||
public function index(Template $template) {
|
||||
try {
|
||||
$templates = $template->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.template.index', compact('templates'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +62,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();
|
||||
@@ -85,8 +81,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) {
|
||||
@@ -109,8 +104,7 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
public function show($id) {
|
||||
//
|
||||
}
|
||||
|
||||
@@ -123,41 +117,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";
|
||||
@@ -169,7 +159,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 === '..') {
|
||||
@@ -177,29 +167,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!');
|
||||
@@ -208,7 +196,7 @@ class TemplateController extends Controller
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != '.' && $object != '..') {
|
||||
unlink($dir.'/'.$object);
|
||||
unlink($dir . '/' . $object);
|
||||
}
|
||||
}
|
||||
rmdir($dir);
|
||||
@@ -219,15 +207,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();
|
||||
@@ -247,8 +233,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();
|
||||
@@ -274,8 +259,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 */
|
||||
@@ -299,14 +283,13 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function formDiagno(Emails $email)
|
||||
{
|
||||
public function formDiagno(Emails $email) {
|
||||
try {
|
||||
$emails = $email->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.emails.template.formDiagno', compact('emails'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,19 +300,56 @@ class TemplateController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function postDiagno(Request $request)
|
||||
{
|
||||
$email = $request->input('to');
|
||||
if ($email == null) {
|
||||
return redirect('getdiagno')->with('fails', 'Please provide E-mail address !');
|
||||
}
|
||||
// sending mail via php mailer
|
||||
$mail = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['email' => $email], $message = ['subject' => 'Checking the connection', 'scenario' => 'error-report', 'content' => 'Email Received Successfully'], $template_variables = ['system_error' => 'Email Received Successfully']);
|
||||
|
||||
if ($mail == null) {
|
||||
return redirect('getdiagno')->with('fails', 'Please check your E-mail settings. Unable to send mails');
|
||||
} else {
|
||||
return redirect('getdiagno')->with('success', 'Please check your mail. An E-mail has been sent to your E-mail address');
|
||||
public function postDiagno(DiagnosRequest $request) {
|
||||
try {
|
||||
$email_details = Emails::where('id', '=', $request->from)->first();
|
||||
if ($email_details->sending_protocol == 'mail') {
|
||||
$mail = new \PHPMailer(); // defaults to using php "mail()"
|
||||
$mail->IsSendmail(); // telling the class to use SendMail transport
|
||||
$mail->SetFrom($email_details->email_address, $email_details->email_name); // sender details
|
||||
$address = $request->to; // receiver email
|
||||
$mail->AddAddress($address);
|
||||
$mail->Subject = $request->subject; // subject of the email
|
||||
$body = $request->message; // body of the email
|
||||
$mail->MsgHTML($body);
|
||||
if (!$mail->Send()) {
|
||||
$return = Lang::get('lang.mailer_error') . ': ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
$return = Lang::get('lang.message_has_been_sent');
|
||||
}
|
||||
} elseif ($email_details->sending_protocol == 'smtp') {
|
||||
$mail = new \PHPMailer();
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
if ($email_details->smtp_validate == '1') {
|
||||
$mail->SMTPOptions = [
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
$mail->Host = $email_details->sending_host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $email_details->email_address; // SMTP username
|
||||
$mail->Password = \Crypt::decrypt($email_details->password); // SMTP password
|
||||
$mail->SMTPSecure = $email_details->sending_encryption; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $email_details->sending_port; // TCP port to connect to
|
||||
$mail->setFrom($email_details->email_address, $email_details->email_name);
|
||||
$mail->addAddress($request->to, ''); // Add a recipient
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
$mail->Subject = $request->subject;
|
||||
$mail->Body = utf8_decode($request->message);
|
||||
if (!$mail->send()) {
|
||||
$return = Lang::get('lang.mailer_error') . ': ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
$return = Lang::get('lang.message_has_been_sent');
|
||||
}
|
||||
}
|
||||
return redirect()->back()->with('success', $return);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ use Datatable;
|
||||
//classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* WorkflowController
|
||||
@@ -60,7 +61,7 @@ class WorkflowController extends Controller
|
||||
try {
|
||||
return view('themes.default1.admin.helpdesk.manage.workflow.index');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,18 +144,14 @@ class WorkflowController extends Controller
|
||||
*/
|
||||
public function create(Emails $emails)
|
||||
{
|
||||
// dd($emails);
|
||||
foreach ($emails->lists('email_address', 'id') as $key => $email) {
|
||||
$email_data["E-$key"] = $email;
|
||||
}
|
||||
// dd($email_data);
|
||||
// dd($emails->lists('email_address' , 'id'));
|
||||
$emails = $email_data;
|
||||
try {
|
||||
// $emails = $emails->get();
|
||||
return view('themes.default1.admin.helpdesk.manage.workflow.create', compact('emails'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,10 +164,9 @@ class WorkflowController extends Controller
|
||||
*/
|
||||
public function store(WorkflowCreateRequest $request)
|
||||
{
|
||||
//dd($request);
|
||||
try {
|
||||
// store a new workflow credentials in to the system
|
||||
$workflow_name = new WorkflowName();
|
||||
$workflow_name = new WorkflowName;
|
||||
$workflow_name->name = $request->name;
|
||||
$workflow_name->status = $request->status;
|
||||
$workflow_name->order = $request->execution_order;
|
||||
@@ -198,7 +194,7 @@ class WorkflowController extends Controller
|
||||
$workflow_action->save();
|
||||
}
|
||||
|
||||
return redirect('workflow')->with('success', 'Workflow Created Successfully');
|
||||
return redirect('workflow')->with('success', Lang::get('lang.workflow_created_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -222,7 +218,7 @@ class WorkflowController extends Controller
|
||||
|
||||
return view('themes.default1.admin.helpdesk.manage.workflow.edit', compact('id', 'workflow', 'emails', 'workflow_rules', 'workflow_actions'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +265,7 @@ class WorkflowController extends Controller
|
||||
$workflow_action->save();
|
||||
}
|
||||
|
||||
return redirect('workflow')->with('success', 'Workflow Updated Successfully');
|
||||
return redirect('workflow')->with('success', Lang::get('lang.workflow_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
@@ -288,7 +284,7 @@ class WorkflowController extends Controller
|
||||
$workflow_rules = WorkflowRules::where('workflow_id', '=', $id)->delete();
|
||||
$workflow = WorkflowName::whereId($id)->delete();
|
||||
|
||||
return redirect('workflow')->with('success', 'Workflow Deleted Successfully');
|
||||
return redirect('workflow')->with('success', Lang::get('lang.workflow_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ use App\Model\helpdesk\Agent_panel\Canned;
|
||||
use App\User;
|
||||
// classes
|
||||
use Exception;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* CannedController.
|
||||
@@ -46,7 +47,11 @@ class CannedController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('themes.default1.agent.helpdesk.canned.index');
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.canned.index');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +61,11 @@ class CannedController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('themes.default1.agent.helpdesk.canned.create');
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.canned.create');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,17 +78,17 @@ class CannedController extends Controller
|
||||
*/
|
||||
public function store(CannedRequest $request, Canned $canned)
|
||||
{
|
||||
// fetching all the requested inputs
|
||||
$canned->user_id = \Auth::user()->id;
|
||||
$canned->title = $request->input('title');
|
||||
$canned->message = $request->input('message');
|
||||
try {
|
||||
// fetching all the requested inputs
|
||||
$canned->user_id = \Auth::user()->id;
|
||||
$canned->title = $request->input('title');
|
||||
$canned->message = $request->input('message');
|
||||
// saving inputs
|
||||
$canned->save();
|
||||
|
||||
return redirect()->route('canned.list')->with('success', 'Added Successfully');
|
||||
return redirect()->route('canned.list')->with('success', Lang::get('lang.added_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->route('canned.list')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,10 +102,14 @@ class CannedController extends Controller
|
||||
*/
|
||||
public function edit($id, Canned $canned)
|
||||
{
|
||||
// fetching requested canned response
|
||||
$canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id', '=', $id)->first();
|
||||
try {
|
||||
// fetching requested canned response
|
||||
$canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id', '=', $id)->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.canned.edit', compact('canned'));
|
||||
return view('themes.default1.agent.helpdesk.canned.edit', compact('canned'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,19 +123,19 @@ class CannedController extends Controller
|
||||
*/
|
||||
public function update($id, CannedUpdateRequest $request, Canned $canned)
|
||||
{
|
||||
/* select the field where id = $id(request Id) */
|
||||
$canned = $canned->where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
|
||||
// fetching all the requested inputs
|
||||
$canned->user_id = \Auth::user()->id;
|
||||
$canned->title = $request->input('title');
|
||||
$canned->message = $request->input('message');
|
||||
try {
|
||||
/* select the field where id = $id(request Id) */
|
||||
$canned = $canned->where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first();
|
||||
// fetching all the requested inputs
|
||||
$canned->user_id = \Auth::user()->id;
|
||||
$canned->title = $request->input('title');
|
||||
$canned->message = $request->input('message');
|
||||
// saving inputs
|
||||
$canned->save();
|
||||
|
||||
return redirect()->route('canned.list')->with('success', 'Updated Successfully');
|
||||
return redirect()->route('canned.list')->with('success', Lang::get('lang.updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->route('canned.list')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,17 +149,17 @@ class CannedController extends Controller
|
||||
*/
|
||||
public function destroy($id, Canned $canned)
|
||||
{
|
||||
/* select the field where id = $id(request Id) */
|
||||
$canned = $canned->whereId($id)->first();
|
||||
/* delete the selected field */
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
/* select the field where id = $id(request Id) */
|
||||
$canned = $canned->whereId($id)->first();
|
||||
/* delete the selected field */
|
||||
/* Check whether function success or not */
|
||||
$canned->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect()->route('canned.list')->with('success', 'User Deleted Successfully');
|
||||
return redirect()->route('canned.list')->with('success', Lang::get('lang.user_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->route('canned.list')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -100,4 +100,52 @@ class DashboardController extends Controller
|
||||
// ->get();
|
||||
// return $ticketlist;
|
||||
}
|
||||
|
||||
public function userChartData($id, $date111 = '', $date122 = '')
|
||||
{
|
||||
$date11 = strtotime($date122);
|
||||
$date12 = strtotime($date111);
|
||||
if ($date11 && $date12) {
|
||||
$date2 = $date12;
|
||||
$date1 = $date11;
|
||||
} else {
|
||||
// generating current date
|
||||
$date2 = strtotime(date('Y-m-d'));
|
||||
$date3 = date('Y-m-d');
|
||||
$format = 'Y-m-d';
|
||||
// generating a date range of 1 month
|
||||
$date1 = strtotime(date($format, strtotime('-1 month'.$date3)));
|
||||
}
|
||||
$return = '';
|
||||
$last = '';
|
||||
for ($i = $date1; $i <= $date2; $i = $i + 86400) {
|
||||
$thisDate = date('Y-m-d', $i);
|
||||
$user = User::whereId($id)->first();
|
||||
if ($user->role == 'user') {
|
||||
$created = \DB::table('tickets')->select('created_at')->where('user_id', '=', $id)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('user_id', '=', $id)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('user_id', '=', $id)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
} else {
|
||||
$created = \DB::table('tickets')->select('created_at')->where('assigned_to', '=', $id)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('assigned_to', '=', $id)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('assigned_to', '=', $id)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
}
|
||||
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
$last = rtrim($return, ',');
|
||||
$users = User::whereId($id)->first();
|
||||
|
||||
return '['.$last.']';
|
||||
|
||||
// $ticketlist = DB::table('tickets')
|
||||
// ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),DB::raw('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'),
|
||||
// DB::raw('count(*) as totaltickets'))
|
||||
// ->groupBy('month')
|
||||
// ->orderBy('month', 'asc')
|
||||
// ->get();
|
||||
// return $ticketlist;
|
||||
}
|
||||
}
|
||||
|
103
app/Http/Controllers/Agent/helpdesk/DashboardController2.php
Normal file
103
app/Http/Controllers/Agent/helpdesk/DashboardController2.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// models
|
||||
use App\User;
|
||||
// classes
|
||||
use Auth;
|
||||
use DB;
|
||||
use Exception;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* DashboardController
|
||||
* This controlleris used to fetch dashboard in the agent panel.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class DashboardController2 extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// checking for authentication
|
||||
$this->middleware('auth');
|
||||
// checking if the role is agent
|
||||
$this->middleware('role.agent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dashboard page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// if(Auth::user()->role == "user"){
|
||||
// return \Redirect::route('home');
|
||||
// }
|
||||
try {
|
||||
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
|
||||
} catch (Exception $e) {
|
||||
return View::make('themes.default1.agent.helpdesk.dashboard.dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetching dashboard graph data to implement graph.
|
||||
*
|
||||
* @return type Json
|
||||
*/
|
||||
public function ChartData($date111 = '', $date122 = '')
|
||||
{
|
||||
$date11 = strtotime($date122);
|
||||
$date12 = strtotime($date111);
|
||||
if ($date11 && $date12) {
|
||||
$date2 = $date12;
|
||||
$date1 = $date11;
|
||||
} else {
|
||||
// generating current date
|
||||
$date2 = strtotime(date('Y-m-d'));
|
||||
$date3 = date('Y-m-d');
|
||||
$format = 'Y-m-d';
|
||||
// generating a date range of 1 month
|
||||
$date1 = strtotime(date($format, strtotime('-1 month'.$date3)));
|
||||
}
|
||||
$return = '';
|
||||
$last = '';
|
||||
for ($i = $date1; $i <= $date2; $i = $i + 86400) {
|
||||
$thisDate = date('Y-m-d', $i);
|
||||
|
||||
$created = \DB::table('tickets')->select('created_at')->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
|
||||
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
$last = rtrim($return, ',');
|
||||
|
||||
return '['.$last.']';
|
||||
|
||||
// $ticketlist = DB::table('tickets')
|
||||
// ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),DB::raw('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'),
|
||||
// DB::raw('count(*) as totaltickets'))
|
||||
// ->groupBy('month')
|
||||
// ->orderBy('month', 'asc')
|
||||
// ->get();
|
||||
// return $ticketlist;
|
||||
}
|
||||
}
|
@@ -27,16 +27,16 @@ use PhpImap\Mailbox as ImapMailbox;
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,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) {
|
||||
// $path_url = $system->first()->url;
|
||||
if ($settings_email->first()->email_fetching == 1) {
|
||||
if ($settings_email->first()->all_emails == 1) {
|
||||
@@ -81,7 +80,7 @@ class MailController extends Controller
|
||||
$protocol = $fetching_encryption2;
|
||||
} else {
|
||||
if ($e_mail->fetching_protocol) {
|
||||
$fetching_protocol = '/'.$e_mail->fetching_protocol;
|
||||
$fetching_protocol = '/' . $e_mail->fetching_protocol;
|
||||
} else {
|
||||
$fetching_protocol = '';
|
||||
}
|
||||
@@ -90,13 +89,13 @@ class MailController extends Controller
|
||||
} else {
|
||||
$fetching_encryption = '';
|
||||
}
|
||||
$protocol = $fetching_protocol.$fetching_encryption;
|
||||
$protocol = $fetching_protocol . $fetching_encryption;
|
||||
}
|
||||
$imap_config = '{'.$host.':'.$port.$protocol.'}INBOX';
|
||||
$imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX';
|
||||
$password = Crypt::decrypt($e_mail->password);
|
||||
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
|
||||
$mails = [];
|
||||
$mailsIds = $mailbox->searchMailBox('SINCE '.date('d-M-Y', strtotime('-1 day')));
|
||||
$mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime('-1 day')));
|
||||
if (!$mailsIds) {
|
||||
die('Mailbox is empty');
|
||||
}
|
||||
@@ -111,14 +110,32 @@ class MailController extends Controller
|
||||
$collaborator = null;
|
||||
}
|
||||
$body = $mail->textHtml;
|
||||
if ($body == null) {
|
||||
$body = $mailbox->backup_getmail($mailId);
|
||||
$body = str_replace('\r\n', '<br/>', $body);
|
||||
if ($body != null) {
|
||||
$body = self::trimTableTag($body);
|
||||
}
|
||||
// if mail body has no messages fetch backup mail
|
||||
if ($body == null) {
|
||||
$body = $mail->textPlain;
|
||||
}
|
||||
if ($body == null) {
|
||||
$attach = $mail->getAttachments();
|
||||
$path = $attach['html-body']->filePath;
|
||||
if ($path == null) {
|
||||
$path = $attach['text-body']->filePath;
|
||||
}
|
||||
|
||||
$body = file_get_contents($path);
|
||||
//dd($body);
|
||||
$body = self::trimTableTag($body);
|
||||
}
|
||||
// if ($body == null) {
|
||||
// $body = $mailbox->backup_getmail($mailId);
|
||||
// $body = str_replace('\r\n', '<br/>', $body);
|
||||
// }
|
||||
$date = $mail->date;
|
||||
$datetime = $overview[0]->date;
|
||||
$date_time = explode(' ', $datetime);
|
||||
$date = $date_time[1].'-'.$date_time[2].'-'.$date_time[3].' '.$date_time[4];
|
||||
$date = $date_time[1] . '-' . $date_time[2] . '-' . $date_time[3] . ' ' . $date_time[4];
|
||||
$date = date('Y-m-d H:i:s', strtotime($date));
|
||||
if (isset($mail->subject)) {
|
||||
$subject = $mail->subject;
|
||||
@@ -130,19 +147,19 @@ class MailController extends Controller
|
||||
$ticket_source = Ticket_source::where('name', '=', 'email')->first();
|
||||
$source = $ticket_source->id;
|
||||
$phone = '';
|
||||
|
||||
$phonecode = '';
|
||||
$mobile_number = '';
|
||||
$assign = $get_helptopic->auto_assign;
|
||||
$form_data = null;
|
||||
$team_assign = null;
|
||||
$ticket_status = null;
|
||||
$result = $this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
|
||||
$result = $this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
|
||||
// dd($result);
|
||||
if ($result[1] == true) {
|
||||
$ticket_table = Tickets::where('ticket_number', '=', $result[0])->first();
|
||||
$thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
|
||||
// $thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
|
||||
$thread_id = $thread_id;
|
||||
|
||||
foreach ($mail->getAttachments() as $attachment) {
|
||||
$support = 'support';
|
||||
// echo $_SERVER['DOCUMENT_ROOT'];
|
||||
@@ -153,7 +170,7 @@ class MailController extends Controller
|
||||
// var_dump($attachment->filePath);
|
||||
// dd($filepath);
|
||||
// $path = $dir_img_path[0]."/code/public/".$filepath[1];
|
||||
$path = public_path().$filepath[1];
|
||||
$path = public_path() . $filepath[1];
|
||||
// dd($path);
|
||||
$filesize = filesize($path);
|
||||
$file_data = file_get_contents($path);
|
||||
@@ -162,9 +179,8 @@ class MailController extends Controller
|
||||
$string = str_replace('-', '', $attachment->name);
|
||||
$filename = explode('src', $attachment->filePath);
|
||||
$filename = str_replace('\\', '', $filename);
|
||||
$body = str_replace('cid:'.$imageid, $filepath[1], $body);
|
||||
$body = str_replace('cid:' . $imageid, $filepath[1], $body);
|
||||
$pos = strpos($body, $filepath[1]);
|
||||
|
||||
if ($pos == false) {
|
||||
if ($settings_email->first()->attachment == 1) {
|
||||
$upload = new Ticket_attachments();
|
||||
@@ -208,8 +224,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];
|
||||
|
||||
@@ -223,8 +238,7 @@ class MailController extends Controller
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function decode_imap_text($str)
|
||||
{
|
||||
public function decode_imap_text($str) {
|
||||
$result = '';
|
||||
$decode_header = imap_mime_header_decode($str);
|
||||
foreach ($decode_header as $obj) {
|
||||
@@ -239,8 +253,7 @@ class MailController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function fetch_attachments()
|
||||
{
|
||||
public function fetch_attachments() {
|
||||
$uploads = Upload::all();
|
||||
foreach ($uploads as $attachment) {
|
||||
$image = @imagecreatefromstring($attachment->file);
|
||||
@@ -248,8 +261,8 @@ class MailController extends Controller
|
||||
imagejpeg($image, null, 80);
|
||||
$data = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,'.base64_encode($data).'"/></a>';
|
||||
echo '<br/><span class="mailbox-attachment-icon has-img">'.$var.'</span>';
|
||||
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
|
||||
echo '<br/><span class="mailbox-attachment-icon has-img">' . $var . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,14 +273,42 @@ class MailController extends Controller
|
||||
*
|
||||
* @return type file
|
||||
*/
|
||||
public function get_data($id)
|
||||
{
|
||||
public function get_data($id) {
|
||||
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
|
||||
foreach ($attachments as $attachment) {
|
||||
header('Content-type: application/'.$attachment->type.'');
|
||||
header('Content-Disposition: inline; filename='.$attachment->name.'');
|
||||
header('Content-type: application/' . $attachment->type . '');
|
||||
header('Content-Disposition: inline; filename=' . $attachment->name . '');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
echo $attachment->file;
|
||||
}
|
||||
}
|
||||
|
||||
public static function trimTableTag($html) {
|
||||
if (strpos('<table>', $html) != false) {
|
||||
$first_pos = strpos($html, '<table');
|
||||
$fist_string = substr_replace($html, '', 0, $first_pos);
|
||||
$last_pos = strrpos($fist_string, '</table>', -1);
|
||||
$total = strlen($fist_string);
|
||||
$diff = $total - $last_pos;
|
||||
$str = substr_replace($fist_string, '', $last_pos, -1);
|
||||
$final_str = str_finish($str, '</table>');
|
||||
return $final_str;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function trim3D($html) {
|
||||
$body = str_replace('=3D', '', $html);
|
||||
return $body;
|
||||
}
|
||||
|
||||
public static function trimInjections($html, $tags = ['<script>', '</script>', '<style>', '</style>', '<?php', '?>']) {
|
||||
$replace = [];
|
||||
foreach ($tags as $key => $tag) {
|
||||
$replace[$key] = htmlspecialchars($tag);
|
||||
}
|
||||
$body = str_replace($tags, $replace, $html);
|
||||
return $body;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,10 +11,12 @@ use App\Http\Requests\helpdesk\OrganizationUpdate;
|
||||
// models
|
||||
/* Define OrganizationRequest to validate the create form */
|
||||
use App\Model\helpdesk\Agent_panel\Organization;
|
||||
/* Define OrganizationUpdate to validate the create form */
|
||||
use App\Model\helpdesk\Agent_panel\User_org;
|
||||
/* Define OrganizationUpdate to validate the create form */
|
||||
use App\User;
|
||||
// classes
|
||||
use Exception;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* OrganizationController
|
||||
@@ -54,7 +56,7 @@ class OrganizationController extends Controller
|
||||
/* get all values of table organization */
|
||||
return view('themes.default1.agent.helpdesk.organization.index');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +133,7 @@ class OrganizationController extends Controller
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.organization.create');
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,14 +152,14 @@ class OrganizationController extends Controller
|
||||
/* Check whether function success or not */
|
||||
if ($org->fill($request->input())->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Created Successfully');
|
||||
return redirect('organizations')->with('success', Lang::get('lang.organization_created_successfully'));
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Create');
|
||||
return redirect('organizations')->with('fails', Lang::get('lang.organization_can_not_create'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Create');
|
||||
return redirect('organizations')->with('fails', Lang::get('lang.organization_can_not_create'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +179,7 @@ class OrganizationController extends Controller
|
||||
/* To view page */
|
||||
return view('themes.default1.agent.helpdesk.organization.show', compact('orgs'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +199,7 @@ class OrganizationController extends Controller
|
||||
/* To view page */
|
||||
return view('themes.default1.agent.helpdesk.organization.edit', compact('orgs'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,22 +214,22 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function update($id, Organization $org, OrganizationUpdate $request)
|
||||
{
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
/* update the organization table */
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
/* update the organization table */
|
||||
/* Check whether function success or not */
|
||||
if ($orgs->fill($request->input())->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Updated Successfully');
|
||||
return redirect('organizations')->with('success', Lang::get('lang.organization_updated_successfully'));
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', 'Organization can not Update');
|
||||
return redirect('organizations')->with('fails', Lang::get('lang.organization_can_not_update'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// dd($e);
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('organizations')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,22 +242,21 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function destroy($id, Organization $org, User_org $user_org)
|
||||
{
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
$user_orgs = $user_org->where('org_id', '=', $id)->get();
|
||||
foreach ($user_orgs as $user_org) {
|
||||
$user_org->delete();
|
||||
}
|
||||
/* Delete the field selected from the table */
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
$user_orgs = $user_org->where('org_id', '=', $id)->get();
|
||||
foreach ($user_orgs as $user_org) {
|
||||
$user_org->delete();
|
||||
}
|
||||
/* Delete the field selected from the table */
|
||||
/* Check whether function success or not */
|
||||
$orgs->delete();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('organizations')->with('success', 'Organization Deleted Successfully');
|
||||
return redirect('organizations')->with('success', Lang::get('lang.organization_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('organizations')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('organizations')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,4 +279,53 @@ class OrganizationController extends Controller
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the report of organizations.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type $date111
|
||||
* @param type $date122
|
||||
*
|
||||
* @return type array
|
||||
*/
|
||||
public function orgChartData($id, $date111 = '', $date122 = '')
|
||||
{
|
||||
$date11 = strtotime($date122);
|
||||
$date12 = strtotime($date111);
|
||||
if ($date11 && $date12) {
|
||||
$date2 = $date12;
|
||||
$date1 = $date11;
|
||||
} else {
|
||||
// generating current date
|
||||
$date2 = strtotime(date('Y-m-d'));
|
||||
$date3 = date('Y-m-d');
|
||||
$format = 'Y-m-d';
|
||||
// generating a date range of 1 month
|
||||
$date1 = strtotime(date($format, strtotime('-1 month'.$date3)));
|
||||
}
|
||||
$return = '';
|
||||
$last = '';
|
||||
for ($i = $date1; $i <= $date2; $i = $i + 86400) {
|
||||
$thisDate = date('Y-m-d', $i);
|
||||
|
||||
$user_orga_relation_id = '';
|
||||
$user_orga_relations = User_org::where('org_id', '=', $id)->get();
|
||||
foreach ($user_orga_relations as $user_orga_relation) {
|
||||
$user_orga_relation_id[] = $user_orga_relation->user_id;
|
||||
}
|
||||
$created = \DB::table('tickets')->select('created_at')->whereIn('user_id', $user_orga_relation_id)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$closed = \DB::table('tickets')->select('closed_at')->whereIn('user_id', $user_orga_relation_id)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
$reopened = \DB::table('tickets')->select('reopened_at')->whereIn('user_id', $user_orga_relation_id)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
|
||||
|
||||
$value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened];
|
||||
$array = array_map('htmlentities', $value);
|
||||
$json = html_entity_decode(json_encode($array));
|
||||
$return .= $json.',';
|
||||
}
|
||||
$last = rtrim($return, ',');
|
||||
$users = User::whereId($id)->first();
|
||||
|
||||
return '['.$last.']';
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@ use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CreateTicketRequest;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Form\Fields;
|
||||
@@ -28,14 +28,18 @@ 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;
|
||||
@@ -160,6 +164,11 @@ class TicketController extends Controller
|
||||
return view('themes.default1.agent.helpdesk.ticket.overdue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax response overdue tickets.
|
||||
*
|
||||
* @return type json
|
||||
*/
|
||||
public function getOverdueTickets()
|
||||
{
|
||||
if (Auth::user()->role == 'agent') {
|
||||
@@ -242,9 +251,12 @@ class TicketController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function newticket()
|
||||
public function newticket(CountryCode $code)
|
||||
{
|
||||
return view('themes.default1.agent.helpdesk.ticket.new');
|
||||
$location = GeoIP::getLocation();
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.ticket.new')->with('phonecode', $phonecode->phonecode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,7 +266,7 @@ class TicketController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function post_newticket(CreateTicketRequest $request)
|
||||
public function post_newticket(CreateTicketRequest $request, CountryCode $code)
|
||||
{
|
||||
try {
|
||||
$email = $request->input('email');
|
||||
@@ -271,15 +283,41 @@ class TicketController extends Controller
|
||||
$body = $request->input('body');
|
||||
$priority = $request->input('priority');
|
||||
$phone = $request->input('phone');
|
||||
$phonecode = $request->input('code');
|
||||
$mobile_number = $request->input('mobile');
|
||||
$source = Ticket_source::where('name', '=', 'agent')->first();
|
||||
$headers = null;
|
||||
$help = Help_topic::where('id', '=', $helptopic)->first();
|
||||
$form_data = null;
|
||||
$auto_response = 0;
|
||||
$status = 1;
|
||||
if ($phone != null || $mobile_number != null) {
|
||||
$location = GeoIP::getLocation();
|
||||
$geoipcode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
if ($phonecode == null) {
|
||||
$data = [
|
||||
'fails' => Lang::get('lang.country-code-required-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'country_code_error' => 1,
|
||||
];
|
||||
|
||||
return Redirect()->back()->with($data)->withInput($request->except('password'));
|
||||
} else {
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $phonecode)->get();
|
||||
if (!count($code)) {
|
||||
$data = [
|
||||
'fails' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'country_code_error' => 1,
|
||||
];
|
||||
|
||||
return Redirect()->back()->with($data)->withInput($request->except('password'));
|
||||
}
|
||||
}
|
||||
}
|
||||
//create user
|
||||
if ($this->create_user($email, $fullname, $subject, $body, $phone, $helptopic, $sla, $priority, $source->id, $headers, $help->department, $assignto, $form_data, $auto_response, $status)) {
|
||||
return Redirect('newticket')->with('success', 'Ticket created successfully!');
|
||||
if ($this->create_user($email, $fullname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source->id, $headers, $help->department, $assignto, $form_data, $auto_response, $status)) {
|
||||
return Redirect('newticket')->with('success', Lang::get('lang.Ticket-created-successfully'));
|
||||
} else {
|
||||
return Redirect('newticket')->with('fails', 'fails');
|
||||
}
|
||||
@@ -549,12 +587,11 @@ class TicketController extends Controller
|
||||
*
|
||||
* @return type bool
|
||||
*/
|
||||
public function create_user($emailadd, $username, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $from_data, $auto_response, $status)
|
||||
public function create_user($emailadd, $username, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $from_data, $auto_response, $status)
|
||||
{
|
||||
// define global variables
|
||||
$email;
|
||||
$username;
|
||||
|
||||
// check emails
|
||||
$ticket_creator = $username;
|
||||
$checkemail = $this->checkEmail($emailadd);
|
||||
@@ -571,6 +608,7 @@ class TicketController extends Controller
|
||||
$user->email = $emailadd;
|
||||
$user->password = Hash::make($password);
|
||||
$user->phone_number = $phone;
|
||||
$user->country_code = $phonecode;
|
||||
$user->role = 'user';
|
||||
$user->active = '1';
|
||||
// mail user his/her password
|
||||
@@ -607,7 +645,6 @@ class TicketController extends Controller
|
||||
} else {
|
||||
$sign = $company;
|
||||
}
|
||||
|
||||
if ($source == 3) {
|
||||
try {
|
||||
if ($auto_response == 0) {
|
||||
@@ -667,7 +704,7 @@ class TicketController extends Controller
|
||||
$emails_to_be_sent = array_unique($set_mails, SORT_REGULAR);
|
||||
foreach ($emails_to_be_sent as $email_data) {
|
||||
try {
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $email_data['to_user'], 'email' => $email_data['to_email']], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $email_data['to_user_name'], 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $email_data['to_user_name'], 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]);
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $email_data['to_user'], 'email' => $email_data['to_email']], $message = ['subject' => $updated_subject, 'body' => Encoding::fixUTF8($body), 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $email_data['to_user_name'], 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $email_data['to_user_name'], 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
@@ -870,6 +907,7 @@ class TicketController extends Controller
|
||||
$thread->title = $subject;
|
||||
$thread->body = $body;
|
||||
if ($thread->save()) {
|
||||
\Event::fire('ticket.details', ['ticket' => $thread]); //get the ticket details
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -925,7 +963,6 @@ class TicketController extends Controller
|
||||
$ticket_number = $ticket_status->ticket_number;
|
||||
|
||||
$system_from = $this->company();
|
||||
|
||||
$sending_emails = Emails::where('department', '=', $ticket_status->dept_id)->first();
|
||||
if ($sending_emails == null) {
|
||||
$from_email = $this->system_mail();
|
||||
@@ -1409,9 +1446,9 @@ class TicketController extends Controller
|
||||
$ticket_collaborator->role = 'ccc';
|
||||
$ticket_collaborator->save();
|
||||
|
||||
return '<div id="alert11" class="alert alert-dismissable" style="color:#60B23C;background-color:#F2F2F2;"><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-check"></i>Success!</h4><h4><i class="icon fa fa-user"></i>'.$data->user_name.'</h4><div id="message-success1">'.$data->email.'</div></div>';
|
||||
return '<div id="alert11" class="alert alert-dismissable" style="color:#60B23C;background-color:#F2F2F2;"><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-check"></i>Success!</h4><h4><i class="icon fa fa-user"></i>'.$data->user_name.'</h4><div id="message-success1">'.$data->email.'</div></div>';
|
||||
} else {
|
||||
return '<div id="alert11" class="alert alert-warning alert-dismissable"><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-warning"></i>'.$data->user_name.'</h4><div id="message-success1">'.$data->email.'<br/>This user already Collaborated</div></div>';
|
||||
return '<div id="alert11" class="alert alert-warning alert-dismissable"><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-warning"></i>'.$data->user_name.'</h4><div id="message-success1">'.$data->email.'<br/>This user already Collaborated</div></div>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1429,7 +1466,7 @@ class TicketController extends Controller
|
||||
$ticket_id = Input::get('ticket_id');
|
||||
$user_search = User::where('email', '=', $email)->first();
|
||||
if (isset($user_serach)) {
|
||||
return '<div id="alert11" class="alert alert-warning alert-dismissable" ><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-alert"></i>Alert!</h4><div id="message-success1">This user already Exists</div></div>';
|
||||
return '<div id="alert11" class="alert alert-warning alert-dismissable" ><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-alert"></i>Alert!</h4><div id="message-success1">This user already Exists</div></div>';
|
||||
} else {
|
||||
$company = $this->company();
|
||||
$user = new User();
|
||||
@@ -1451,7 +1488,7 @@ class TicketController extends Controller
|
||||
$ticket_collaborator->role = 'ccc';
|
||||
$ticket_collaborator->save();
|
||||
|
||||
return '<div id="alert11" class="alert alert-dismissable" style="color:#60B23C;background-color:#F2F2F2;"><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-user"></i>'.$user->user_name.'</h4><div id="message-success1">'.$user->email.'</div></div>';
|
||||
return '<div id="alert11" class="alert alert-dismissable" style="color:#60B23C;background-color:#F2F2F2;"><button id="dismiss11" type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-user"></i>'.$user->user_name.'</h4><div id="message-success1">'.$user->email.'</div></div>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1495,7 +1532,7 @@ class TicketController extends Controller
|
||||
$ticket->closed = 0;
|
||||
$ticket->closed_at = null;
|
||||
$ticket->save();
|
||||
} elseif ($value == 'Clean up') {
|
||||
} elseif ($value == 'Delete forever') {
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $ticket->id)->get();
|
||||
foreach ($thread as $th_id) {
|
||||
// echo $th_id->id." ";
|
||||
@@ -1560,9 +1597,9 @@ class TicketController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*adding offset to updated_at time.
|
||||
* adding offset to updated_at time.
|
||||
*
|
||||
*@return date
|
||||
* @return date
|
||||
*/
|
||||
public static function timeOffset($utc)
|
||||
{
|
||||
@@ -1578,7 +1615,7 @@ class TicketController extends Controller
|
||||
/**
|
||||
* to get user date time format.
|
||||
*
|
||||
*@return string
|
||||
* @return string
|
||||
*/
|
||||
public static function getDateTimeFormat()
|
||||
{
|
||||
@@ -1664,9 +1701,32 @@ class TicketController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function rating($id, $rating)
|
||||
public function rating($id, Request $request, \App\Model\helpdesk\Ratings\RatingRef $rating_ref)
|
||||
{
|
||||
Tickets::where('id', $id)->update(['rating' => $rating]);
|
||||
foreach ($request->all() as $key => $value) {
|
||||
if (strpos($key, '_') !== false) {
|
||||
$ratName = str_replace('_', ' ', $key);
|
||||
} else {
|
||||
$ratName = $key;
|
||||
}
|
||||
$ratID = \App\Model\helpdesk\Ratings\Rating::where('name', '=', $ratName)->first();
|
||||
$ratingrefs = $rating_ref->where('rating_id', '=', $ratID->id)->where('ticket_id', '=', $id)->first();
|
||||
if ($ratingrefs !== null) {
|
||||
$ratingrefs->rating_id = $ratID->id;
|
||||
$ratingrefs->ticket_id = $id;
|
||||
|
||||
$ratingrefs->thread_id = '0';
|
||||
$ratingrefs->rating_value = $value;
|
||||
$ratingrefs->save();
|
||||
} else {
|
||||
$rating_ref->rating_id = $ratID->id;
|
||||
$rating_ref->ticket_id = $id;
|
||||
|
||||
$rating_ref->thread_id = '0';
|
||||
$rating_ref->rating_value = $value;
|
||||
$rating_ref->save();
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back()->with('Success', 'Thank you for your rating!');
|
||||
}
|
||||
@@ -1676,17 +1736,37 @@ class TicketController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function ratingReply($id, $rating)
|
||||
public function ratingReply($id, Request $request, \App\Model\helpdesk\Ratings\RatingRef $rating_ref)
|
||||
{
|
||||
$thread = Ticket_Thread::whereId($id)->first();
|
||||
// $last_average = $thread->reply_rating;
|
||||
//$total_numbers = $thread->rating_count;
|
||||
//$new_number = $rating;
|
||||
//$new_average = (($last_average * $total_numbers) + $new_number) / ($total_numbers + 1);
|
||||
//$thread->rating_count += 1;
|
||||
$thread->reply_rating = $rating;
|
||||
$thread->save();
|
||||
// $thread->set('rating_count', 'rating_count+1', FALSE)->update(['ratingreply' => $new_average]);
|
||||
foreach ($request->all() as $key => $value) {
|
||||
$key1 = explode(',', $key);
|
||||
if (strpos($key1[0], '_') !== false) {
|
||||
$ratName = str_replace('_', ' ', $key1[0]);
|
||||
} else {
|
||||
$ratName = $key1[0];
|
||||
}
|
||||
|
||||
$ratID = \App\Model\helpdesk\Ratings\Rating::where('name', '=', $ratName)->first();
|
||||
$ratingrefs = $rating_ref->where('rating_id', '=', $ratID->id)->where('thread_id', '=', $key1[1])->first();
|
||||
|
||||
if ($ratingrefs !== null) {
|
||||
$ratingrefs->rating_id = $ratID->id;
|
||||
$ratingrefs->ticket_id = $id;
|
||||
|
||||
$ratingrefs->thread_id = $key1[1];
|
||||
$ratingrefs->rating_value = $value;
|
||||
$ratingrefs->save();
|
||||
} else {
|
||||
$rating_ref->rating_id = $ratID->id;
|
||||
$rating_ref->ticket_id = $id;
|
||||
|
||||
$rating_ref->thread_id = $key1[1];
|
||||
$rating_ref->rating_value = $value;
|
||||
$rating_ref->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return redirect()->back()->with('Success', 'Thank you for your rating!');
|
||||
}
|
||||
|
||||
@@ -1721,7 +1801,14 @@ $thread->reply_rating = $rating;
|
||||
$diff = round(abs($to_time - $from_time) / 60, 2);
|
||||
|
||||
if ($diff < $cad && Auth::user()->id != $ticket->lock_by) {
|
||||
return 0; //ticket is locked
|
||||
$user_data = User::select('user_name', 'first_name', 'last_name')->where('id', '=', $ticket->lock_by)->first();
|
||||
if ($user_data->first_name != '') {
|
||||
$name = $user_data->first_name.' '.$user_data->last_name;
|
||||
} else {
|
||||
$name = $user_data->username;
|
||||
}
|
||||
|
||||
return Lang::get('lang.locked-ticket')." <a href='".route('user.show', $ticket->lock_by)."'>".$name.'</a> '.$diff.' '.Lang::get('lang.minutes-ago'); //ticket is locked
|
||||
} elseif ($diff < $cad && Auth::user()->id == $ticket->lock_by) {
|
||||
$ticket = Tickets::where('id', '=', $id)->first();
|
||||
$ticket->lock_at = date('Y-m-d H:i:s');
|
||||
@@ -1798,8 +1885,8 @@ $thread->reply_rating = $rating;
|
||||
if (Alert::first()->internal_status == 1 || Alert::first()->internal_assigned_agent == 1) {
|
||||
// ticket assigned send mail
|
||||
Mail::send('emails.Ticket_assign', ['agent' => $agent, 'ticket_number' => $ticket_number, 'from' => $company, 'master' => $master, 'system' => $system], function ($message) use ($agent_email, $agent, $ticket_number, $ticket_subject) {
|
||||
$message->to($agent_email, $agent)->subject($ticket_subject.'[#'.$ticket_number.']');
|
||||
});
|
||||
$message->to($agent_email, $agent)->subject($ticket_subject.'[#'.$ticket_number.']');
|
||||
});
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -1821,15 +1908,14 @@ $thread->reply_rating = $rating;
|
||||
$email = $email;
|
||||
$ticket_id = $ticket_id;
|
||||
$validator = \Validator::make(
|
||||
['email' => $email,
|
||||
'name' => $name, ],
|
||||
['email' => 'required|email',
|
||||
]
|
||||
['email' => $email,
|
||||
'name' => $name, ], ['email' => 'required|email',
|
||||
]
|
||||
);
|
||||
$user = User::where('email', '=', $email)->first();
|
||||
$count = count($user);
|
||||
if ($count === 1) {
|
||||
return 0;
|
||||
return 0;
|
||||
} elseif ($validator->fails()) {
|
||||
return 2;
|
||||
} else {
|
||||
@@ -1863,7 +1949,7 @@ $thread->reply_rating = $rating;
|
||||
} else {
|
||||
$ticket = Tickets::select('user_id')->where('id', '=', $id)->first();
|
||||
$ticket_data = Tickets::select('ticket_number', 'id')
|
||||
->where('user_id', '=', $ticket->user_id)->where('id', '!=', $id)->where('status', '=', 1)->get();
|
||||
->where('user_id', '=', $ticket->user_id)->where('id', '!=', $id)->where('status', '=', 1)->get();
|
||||
foreach ($ticket_data as $value) {
|
||||
$title = Ticket_Thread::select('title')->where('ticket_id', '=', $value->id)->first();
|
||||
echo "<option value='$value->id'>".$title->title.'</option>';
|
||||
@@ -1896,9 +1982,9 @@ $thread->reply_rating = $rating;
|
||||
} else {
|
||||
$ticket = Tickets::select('user_id')->where('id', '=', $id)->first();
|
||||
$ticket_data = Tickets::select('ticket_number', 'id')
|
||||
->where('user_id', '=', $ticket->user_id)
|
||||
->where('id', '!=', $id)
|
||||
->where('status', '=', 1)->get();
|
||||
->where('user_id', '=', $ticket->user_id)
|
||||
->where('id', '!=', $id)
|
||||
->where('status', '=', 1)->get();
|
||||
if (isset($ticket_data) && count($ticket_data) >= 1) {
|
||||
return 1;
|
||||
} else {
|
||||
@@ -1936,13 +2022,13 @@ $thread->reply_rating = $rating;
|
||||
$thread = Ticket_thread::where('ticket_id', '=', $value)->first();
|
||||
$ticket = Tickets::select('ticket_number')->where('id', '=', $value)->first();
|
||||
Ticket_thread::where('ticket_id', '=', $value)
|
||||
->update(['ticket_id' => $p_id]);
|
||||
->update(['ticket_id' => $p_id]);
|
||||
Ticket_Form_Data::where('ticket_id', '=', $value)
|
||||
->update(['ticket_id' => $p_id]);
|
||||
->update(['ticket_id' => $p_id]);
|
||||
Ticket_Collaborator::where('ticket_id', '=', $value)
|
||||
->update(['ticket_id' => $p_id]);
|
||||
->update(['ticket_id' => $p_id]);
|
||||
Tickets::where('id', '=', $value)
|
||||
->update(['status' => 3]);
|
||||
->update(['status' => 3]);
|
||||
if (!empty(Input::get('reason'))) {
|
||||
$reason = Input::get('reason');
|
||||
} else {
|
||||
@@ -1950,7 +2036,7 @@ $thread->reply_rating = $rating;
|
||||
}
|
||||
if (!empty(Input::get('title'))) {
|
||||
Ticket_thread::where('ticket_id', '=', $p_id)->first()
|
||||
->update(['title' => Input::get('title')]);
|
||||
->update(['title' => Input::get('title')]);
|
||||
}
|
||||
|
||||
$new_thread = new Ticket_thread();
|
||||
@@ -1961,8 +2047,8 @@ $thread->reply_rating = $rating;
|
||||
$new_thread->is_internal = 0;
|
||||
$new_thread->title = $thread->title;
|
||||
$new_thread->body = Lang::get('lang.get_merge_message').
|
||||
" <a href='".route('ticket.thread', [$p_id]).
|
||||
"'>#".$parent_ticket->ticket_number.'</a><br><br><b>'.Lang::get('lang.merge-reason').'</b>'.$reason;
|
||||
" <a href='".route('ticket.thread', [$p_id]).
|
||||
"'>#".$parent_ticket->ticket_number.'</a><br><br><b>'.Lang::get('lang.merge-reason').':</b> '.$reason;
|
||||
$new_thread->format = $thread->format;
|
||||
$new_thread->ip_address = $thread->ip_address;
|
||||
|
||||
@@ -1973,7 +2059,7 @@ $thread->reply_rating = $rating;
|
||||
$new_parent_thread->source = $parent_thread->source;
|
||||
$new_parent_thread->is_internal = 1;
|
||||
$new_parent_thread->title = $thread->title;
|
||||
$new_parent_thread->body = Lang::get('lang.ticket')." <a href='".route('ticket.thread', [$value])."'>#".$ticket->ticket_number.'</a> '.Lang::get('lang.ticket_merged').'<br><br><b>'.Lang::get('lang.merge-reason').'</b>'.$reason;
|
||||
$new_parent_thread->body = Lang::get('lang.ticket')." <a href='".route('ticket.thread', [$value])."'>#".$ticket->ticket_number.'</a> '.Lang::get('lang.ticket_merged').'<br><br><b>'.Lang::get('lang.merge-reason').':</b> '.$reason;
|
||||
$new_parent_thread->format = $parent_thread->format;
|
||||
$new_parent_thread->ip_address = $parent_thread->ip_address;
|
||||
if ($new_thread->save() && $new_parent_thread->save()) {
|
||||
@@ -1998,16 +2084,17 @@ $thread->reply_rating = $rating;
|
||||
}
|
||||
|
||||
/*
|
||||
*chumper's function to return data to chumper datatable.
|
||||
*@param Array-object $tickets
|
||||
* chumper's function to return data to chumper datatable.
|
||||
* @param Array-object $tickets
|
||||
*
|
||||
*@return Array-object
|
||||
* @return Array-object
|
||||
*/
|
||||
|
||||
public static function getTable($tickets)
|
||||
{
|
||||
return \Datatable::collection(new Collection($tickets))
|
||||
->addColumn('id', function ($ticket) {
|
||||
return "<input type='checkbox' name='select_all[]' id='".$ticket->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$ticket->id."'></input>";
|
||||
return "<input type='checkbox' name='select_all[]' id='".$ticket->id."' onclick='someFunction(this.id)' class='selectval icheckbox_flat-blue' value='".$ticket->id."'></input>";
|
||||
})
|
||||
->addColumn('subject', function ($ticket) {
|
||||
$subject = DB::table('ticket_thread')->select('title')->where('ticket_id', '=', $ticket->id)->first();
|
||||
@@ -2063,8 +2150,9 @@ $thread->reply_rating = $rating;
|
||||
})
|
||||
->addColumn('from', function ($ticket) {
|
||||
$from = DB::table('users')->select('user_name')->where('id', '=', $ticket->user_id)->first();
|
||||
$url = route('user.show', $ticket->user_id);
|
||||
|
||||
return "<a href='../user/".$ticket->user_id."' title='".Lang::get('lang.see-profile1').' '.ucfirst($from->user_name).'''.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".ucfirst($from->user_name).'</span></a>';
|
||||
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.ucfirst($from->user_name).'''.Lang::get('lang.see-profile2')."'><span style='color:#508983'>".ucfirst($from->user_name).'</span></a>';
|
||||
})
|
||||
// ->addColumn('Last Replier', function ($ticket) {
|
||||
// $TicketData = Ticket_Thread::where('ticket_id', '=', $ticket->id)->where('is_internal', '=', 0)->max('id');
|
||||
@@ -2080,7 +2168,6 @@ $thread->reply_rating = $rating;
|
||||
// $username = $LastResponse->user_name;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return "<a href='' title=''><span style='color:".$rep."'>".ucfirst($username).'</span></a>';
|
||||
// })
|
||||
->addColumn('assigned_to', function ($ticket) {
|
||||
@@ -2088,8 +2175,9 @@ $thread->reply_rating = $rating;
|
||||
return "<span style='color:red'>Unassigned</span>";
|
||||
} else {
|
||||
$assign = DB::table('users')->where('id', '=', $ticket->assigned_to)->first();
|
||||
$url = route('user.show', $ticket->assigned_to);
|
||||
|
||||
return "<a href='../user/".$ticket->assigned_to."' title='".Lang::get('lang.see-profile1').' '.ucfirst($assign->first_name).'''.Lang::get('lang.see-profile2')."'><span style='color:green'>".ucfirst($assign->first_name).' '.ucfirst($assign->last_name).'</span></a>';
|
||||
return "<a href='".$url."' title='".Lang::get('lang.see-profile1').' '.ucfirst($assign->first_name).'''.Lang::get('lang.see-profile2')."'><span style='color:green'>".ucfirst($assign->first_name).' '.ucfirst($assign->last_name).'</span></a>';
|
||||
}
|
||||
})
|
||||
->addColumn('Last', function ($ticket) {
|
||||
@@ -2103,4 +2191,42 @@ $thread->reply_rating = $rating;
|
||||
->orderColumns('subject', 'from', 'assigned_to', 'Last Replier', 'ticket_number', 'priority', 'Last')
|
||||
->make();
|
||||
}
|
||||
|
||||
//Auto-close tickets
|
||||
public function autoCloseTickets()
|
||||
{
|
||||
$workflow = \App\Model\helpdesk\Workflow\WorkflowClose::whereId(1)->first();
|
||||
|
||||
if ($workflow->condition == 1) {
|
||||
$overdues = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->orderBy('id', 'DESC')->get();
|
||||
if (count($overdues) == 0) {
|
||||
$tickets = null;
|
||||
} else {
|
||||
$i = 0;
|
||||
foreach ($overdues as $overdue) {
|
||||
// $sla_plan = Sla_plan::where('id', '=', $overdue->sla)->first();
|
||||
|
||||
$ovadate = $overdue->created_at;
|
||||
$new_date = date_add($ovadate, date_interval_create_from_date_string($workflow->days.' days')).'<br/><br/>';
|
||||
if (date('Y-m-d H:i:s') > $new_date) {
|
||||
$i++;
|
||||
$overdue->status = 3;
|
||||
$overdue->closed = 1;
|
||||
$overdue->closed_at = date('Y-m-d H:i:s');
|
||||
$overdue->save();
|
||||
// if($workflow->send_email == 1) {
|
||||
// $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $overdue->dept_id), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'scenario' => 'close-ticket'], $template_variables = ['ticket_number' => $ticket_number]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
// dd(count($value));
|
||||
// if ($i > 0) {
|
||||
// $tickets = new collection($value);
|
||||
// } else {
|
||||
// $tickets = null;
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ class TicketWorkflowController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function workflow($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response)
|
||||
public function workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response)
|
||||
{
|
||||
$contact_details = ['email' => $fromaddress, 'email_name' => $fromname, 'subject' => $subject, 'message' => $body];
|
||||
$ticket_settings_details = ['help_topic' => $helptopic, 'sla' => $sla, 'priority' => $priority, 'source' => $source, 'dept' => $dept, 'assign' => $assign, 'team' => $team_assign, 'status' => $ticket_status, 'reject' => false];
|
||||
@@ -169,7 +169,7 @@ class TicketWorkflowController extends Controller
|
||||
if ($ticket_settings_details['reject'] == true) {
|
||||
return ['0' => false, '1' => false];
|
||||
} else {
|
||||
$create_ticket = $this->TicketController->create_user($contact_details['email'], $contact_details['email_name'], $contact_details['subject'], $contact_details['message'], $phone, $ticket_settings_details['help_topic'], $ticket_settings_details['sla'], $ticket_settings_details['priority'], $source, $collaborator, $ticket_settings_details['dept'], $ticket_settings_details['assign'], $form_data, $auto_response, $ticket_settings_details['status']);
|
||||
$create_ticket = $this->TicketController->create_user($contact_details['email'], $contact_details['email_name'], $contact_details['subject'], $contact_details['message'], $phone, $phonecode, $mobile_number, $ticket_settings_details['help_topic'], $ticket_settings_details['sla'], $ticket_settings_details['priority'], $source, $collaborator, $ticket_settings_details['dept'], $ticket_settings_details['assign'], $form_data, $auto_response, $ticket_settings_details['status']);
|
||||
|
||||
return $create_ticket;
|
||||
}
|
||||
|
@@ -16,12 +16,15 @@ use App\Http\Requests\helpdesk\Sys_userUpdate;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent_panel\Organization;
|
||||
use App\Model\helpdesk\Agent_panel\User_org;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\User;
|
||||
// classes
|
||||
use Auth;
|
||||
use Exception;
|
||||
use GeoIP;
|
||||
use Hash;
|
||||
use Input;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
@@ -62,7 +65,7 @@ class UserController extends Controller
|
||||
/* get all values in Sys_user */
|
||||
return view('themes.default1.agent.helpdesk.user.index');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,24 +78,24 @@ class UserController extends Controller
|
||||
{
|
||||
// displaying list of users with chumper datatables
|
||||
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
|
||||
/* searchable column username and email*/
|
||||
/* searchable column username and email */
|
||||
->searchColumns('user_name', 'email', 'phone')
|
||||
/* order column username and email */
|
||||
->orderColumns('user_name', 'email')
|
||||
/* column username */
|
||||
->addColumn('user_name', function ($model) {
|
||||
if (strlen($model->user_name) > 20) {
|
||||
$username = substr($model->user_name, 0, 30);
|
||||
$username = substr($username, 0, strrpos($username, ' ')).' ...';
|
||||
$string = strip_tags($model->user_name);
|
||||
if (strlen($string) > 10) {
|
||||
// truncate string
|
||||
$stringCut = substr($string, 0, 10);
|
||||
} else {
|
||||
$username = "<a href='".route('user.edit', $model->id)."'>".$model->user_name.'</a>';
|
||||
$stringCut = $model->user_name;
|
||||
}
|
||||
|
||||
return $username;
|
||||
return $stringCut;
|
||||
})
|
||||
/* column email */
|
||||
->addColumn('email', function ($model) {
|
||||
$email = "<a href='".route('user.edit', $model->id)."'>".$model->email.'</a>';
|
||||
$email = "<a href='".route('user.show', $model->id)."'>".$model->email.'</a>';
|
||||
|
||||
return $email;
|
||||
})
|
||||
@@ -150,10 +153,13 @@ class UserController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create()
|
||||
public function create(CountryCode $code)
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.create');
|
||||
$location = GeoIP::getLocation('');
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.create')->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
@@ -176,16 +182,25 @@ class UserController extends Controller
|
||||
$user->mobile = $request->input('mobile');
|
||||
$user->ext = $request->input('ext');
|
||||
$user->phone_number = $request->input('phone_number');
|
||||
$user->country_code = $request->input('country_code');
|
||||
$user->active = $request->input('active');
|
||||
$user->internal_note = $request->input('internal_note');
|
||||
$user->role = 'user';
|
||||
try {
|
||||
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
||||
return redirect()->back()->with(['fails' => Lang::get('lang.country-code-required-error'), 'country_code_error' => 1])->withInput();
|
||||
} else {
|
||||
$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->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('user')->with('success', 'User Created Successfully');
|
||||
return redirect('user')->with('success', Lang::get('lang.User-Created-Successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('user')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,15 +212,16 @@ class UserController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function show($id, User $user)
|
||||
public function show($id)
|
||||
{
|
||||
try {
|
||||
$user = new User();
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,15 +233,18 @@ class UserController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, User $user)
|
||||
public function edit($id, CountryCode $code)
|
||||
{
|
||||
try {
|
||||
$user = new User();
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
$location = GeoIP::getLocation('');
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
|
||||
return view('themes.default1.agent.helpdesk.user.edit', compact('users'))->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,19 +257,31 @@ class UserController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, User $user, Sys_userUpdate $request)
|
||||
public function update($id, Sys_userUpdate $request)
|
||||
{
|
||||
$user = new User();
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
/* Update the value by selected field */
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
||||
return redirect()->back()->with(['fails' => Lang::get('lang.country-code-required-error'), 'country_code_error' => 1])->withInput();
|
||||
} else {
|
||||
$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();
|
||||
} else {
|
||||
$users->country_code = $request->country_code;
|
||||
}
|
||||
}
|
||||
// dd($request->input());
|
||||
$users->fill($request->input())->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('user')->with('success', 'User Updated Successfully');
|
||||
return redirect('user')->with('success', Lang::get('lang.User-profile-Updated-Successfully'));
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +296,7 @@ class UserController extends Controller
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,13 +305,15 @@ class UserController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function getProfileedit()
|
||||
public function getProfileedit(CountryCode $code)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$location = GeoIP::getLocation('');
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'))->with('phonecode', $phonecode->phonecode);
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,15 +357,24 @@ class UserController extends Controller
|
||||
$user->profile_pic = $fileName;
|
||||
} else {
|
||||
try {
|
||||
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
||||
return redirect()->back()->with(['fails' => Lang::get('lang.country-code-required-error'), 'country_code_error' => 1])->withInput();
|
||||
} else {
|
||||
$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', 'gender'))->save();
|
||||
|
||||
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
|
||||
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
|
||||
} catch (Exception $e) {
|
||||
return Redirect::route('profile')->with('success', $e->errorInfo[2]);
|
||||
return Redirect::route('profile')->with('success', $e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($user->fill($request->except('profile_pic'))->save()) {
|
||||
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
|
||||
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,12 +396,12 @@ class UserController extends Controller
|
||||
try {
|
||||
$user->save();
|
||||
|
||||
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
|
||||
return redirect('profile-edit')->with('success1', Lang::get('lang.password_updated_sucessfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('profile-edit')->with('fails', $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
|
||||
return redirect('profile-edit')->with('fails1', Lang::get('lang.password_was_not_updated_incorrect_old_password'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,6 +423,25 @@ class UserController extends Controller
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function orgAssignUser($id)
|
||||
{
|
||||
$org = Input::get('org');
|
||||
$user_org = new User_org();
|
||||
$user_org->org_id = $id;
|
||||
$user_org->user_id = $org;
|
||||
$user_org->save();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function removeUserOrg($id)
|
||||
{
|
||||
$user_org = User_org::where('org_id', '=', $id)->first();
|
||||
$user_org->delete();
|
||||
|
||||
return redirect()->back()->with('success1', Lang::get('lang.the_user_has_been_removed_from_this_organization'));
|
||||
}
|
||||
|
||||
/**
|
||||
* creating an organization in user profile page via modal popup.
|
||||
*
|
||||
|
427
app/Http/Controllers/Agent/helpdesk/UserController2.php
Normal file
427
app/Http/Controllers/Agent/helpdesk/UserController2.php
Normal file
@@ -0,0 +1,427 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
/* Include Sys_user Model */
|
||||
use App\Http\Requests\helpdesk\ProfilePassword;
|
||||
/* For validation include Sys_userRequest in create */
|
||||
use App\Http\Requests\helpdesk\ProfileRequest;
|
||||
/* For validation include Sys_userUpdate in update */
|
||||
use App\Http\Requests\helpdesk\Sys_userRequest;
|
||||
/* include guest_note model */
|
||||
use App\Http\Requests\helpdesk\Sys_userUpdate;
|
||||
// models
|
||||
use App\Model\helpdesk\Agent_panel\Organization;
|
||||
use App\Model\helpdesk\Agent_panel\User_org;
|
||||
use App\User;
|
||||
// classes
|
||||
use Auth;
|
||||
use Exception;
|
||||
use Hash;
|
||||
use Input;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
* UserController
|
||||
* This controller is used to CRUD an User details, and proile management of an agent.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class UserController2 extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking if role is agent
|
||||
$this->middleware('role.agent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display all list of the users.
|
||||
*
|
||||
* @param type User $user
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
/* get all values in Sys_user */
|
||||
return view('themes.default1.agent.helpdesk.user.index');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to display the list of users using chumper datatables.
|
||||
*
|
||||
* @return datatable
|
||||
*/
|
||||
public function user_list()
|
||||
{
|
||||
// displaying list of users with chumper datatables
|
||||
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
|
||||
/* searchable column username and email*/
|
||||
->searchColumns('user_name', 'email', 'phone')
|
||||
/* order column username and email */
|
||||
->orderColumns('user_name', 'email')
|
||||
/* column username */
|
||||
->addColumn('user_name', function ($model) {
|
||||
if (strlen($model->user_name) > 20) {
|
||||
$username = substr($model->user_name, 0, 30);
|
||||
$username = substr($username, 0, strrpos($username, ' ')).' ...';
|
||||
} else {
|
||||
$username = "<a href='".route('user.edit', $model->id)."'>".$model->user_name.'</a>';
|
||||
}
|
||||
|
||||
return $username;
|
||||
})
|
||||
/* column email */
|
||||
->addColumn('email', function ($model) {
|
||||
$email = "<a href='".route('user.edit', $model->id)."'>".$model->email.'</a>';
|
||||
|
||||
return $email;
|
||||
})
|
||||
/* column phone */
|
||||
->addColumn('phone', function ($model) {
|
||||
$phone = '';
|
||||
if ($model->phone_number) {
|
||||
$phone = $model->ext.' '.$model->phone_number;
|
||||
}
|
||||
$mobile = '';
|
||||
if ($model->mobile) {
|
||||
$mobile = $model->mobile;
|
||||
}
|
||||
$phone = $phone.' '.$mobile;
|
||||
|
||||
return $phone;
|
||||
})
|
||||
/* column account status */
|
||||
->addColumn('status', function ($model) {
|
||||
$status = $model->active;
|
||||
if ($status == 1) {
|
||||
$stat = '<button class="btn btn-success btn-xs">Active</button>';
|
||||
} else {
|
||||
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
|
||||
}
|
||||
|
||||
return $stat;
|
||||
})
|
||||
/* column ban status */
|
||||
->addColumn('ban', function ($model) {
|
||||
$status = $model->ban;
|
||||
if ($status == 1) {
|
||||
$stat = '<button class="btn btn-danger btn-xs">Banned</button>';
|
||||
} else {
|
||||
$stat = '<button class="btn btn-success btn-xs">Active</button>';
|
||||
}
|
||||
|
||||
return $stat;
|
||||
})
|
||||
/* column last login date */
|
||||
->addColumn('lastlogin', function ($model) {
|
||||
$t = $model->updated_at;
|
||||
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
/* column actions */
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new users.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.create');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created users in storage.
|
||||
*
|
||||
* @param type User $user
|
||||
* @param type Sys_userRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function store(User $user, Sys_userRequest $request)
|
||||
{
|
||||
/* insert the input request to sys_user table */
|
||||
/* Check whether function success or not */
|
||||
$user->email = $request->input('email');
|
||||
$user->user_name = $request->input('full_name');
|
||||
$user->mobile = $request->input('mobile');
|
||||
$user->ext = $request->input('ext');
|
||||
$user->phone_number = $request->input('phone_number');
|
||||
$user->active = $request->input('active');
|
||||
$user->internal_note = $request->input('internal_note');
|
||||
$user->role = 'user';
|
||||
try {
|
||||
$user->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('user')->with('success', 'User Created Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('user')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified users.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function show($id, User $user)
|
||||
{
|
||||
try {
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, User $user)
|
||||
{
|
||||
try {
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified user in storage.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @param type Sys_userUpdate $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, User $user, Sys_userUpdate $request)
|
||||
{
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
/* Update the value by selected field */
|
||||
/* Check whether function success or not */
|
||||
try {
|
||||
$users->fill($request->input())->save();
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('user')->with('success', 'User Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get agent profile page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
$user = Auth::user();
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get profile edit page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function getProfileedit()
|
||||
{
|
||||
$user = Auth::user();
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* post profile edit.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type ProfileRequest $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function postProfileedit(ProfileRequest $request)
|
||||
{
|
||||
// geet authenticated user details
|
||||
$user = Auth::user();
|
||||
$user->gender = $request->input('gender');
|
||||
$user->save();
|
||||
// checking availability of agent profile ppicture
|
||||
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
|
||||
if ($request->input('gender') == 1) {
|
||||
$name = 'avatar5.png';
|
||||
$destinationPath = 'lb-faveo/media/profilepic';
|
||||
$user->profile_pic = $name;
|
||||
} elseif ($request->input('gender') == 0) {
|
||||
$name = 'avatar2.png';
|
||||
$destinationPath = 'lb-faveo/media/profilepic';
|
||||
$user->profile_pic = $name;
|
||||
}
|
||||
}
|
||||
// checking if the post system includes agent profile picture upload
|
||||
if (Input::file('profile_pic')) {
|
||||
// fetching picture name
|
||||
$name = Input::file('profile_pic')->getClientOriginalName();
|
||||
// fetching upload destination path
|
||||
$destinationPath = 'lb-faveo/media/profilepic';
|
||||
// adding a random value to profile picture filename
|
||||
$fileName = rand(0000, 9999).'.'.$name;
|
||||
// moving the picture to a destination folder
|
||||
Input::file('profile_pic')->move($destinationPath, $fileName);
|
||||
// saving filename to database
|
||||
$user->profile_pic = $fileName;
|
||||
} else {
|
||||
try {
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
|
||||
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
|
||||
} catch (Exception $e) {
|
||||
return Redirect::route('profile')->with('success', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
if ($user->fill($request->except('profile_pic'))->save()) {
|
||||
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post profile password.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type ProfilePassword $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function postProfilePassword($id, ProfilePassword $request)
|
||||
{
|
||||
// get authenticated user
|
||||
$user = Auth::user();
|
||||
// checking if the old password matches the new password
|
||||
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
|
||||
$user->password = Hash::make($request->input('new_password'));
|
||||
try {
|
||||
$user->save();
|
||||
|
||||
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
} else {
|
||||
return redirect('profile-edit')->with('fails1', 'Password was not Updated. Incorrect old password');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigning an user to an organization.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type boolean
|
||||
*/
|
||||
public function UserAssignOrg($id)
|
||||
{
|
||||
$org = Input::get('org');
|
||||
$user_org = new User_org();
|
||||
$user_org->org_id = $org;
|
||||
$user_org->user_id = $id;
|
||||
$user_org->save();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* creating an organization in user profile page via modal popup.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function User_Create_Org($id)
|
||||
{
|
||||
// checking if the entered value for website is available in database
|
||||
if (Input::get('website') != null) {
|
||||
// checking website
|
||||
$check = Organization::where('website', '=', Input::get('website'))->first();
|
||||
} else {
|
||||
$check = null;
|
||||
}
|
||||
// checking if the name is unique
|
||||
$check2 = Organization::where('name', '=', Input::get('name'))->first();
|
||||
// if any of the fields is not available then return false
|
||||
if (\Input::get('name') == null) {
|
||||
return 'Name is required';
|
||||
} elseif ($check2 != null) {
|
||||
return 'Name should be Unique';
|
||||
} elseif ($check != null) {
|
||||
return 'Website should be Unique';
|
||||
} else {
|
||||
// storing organization details and assigning the current user to that organization
|
||||
$org = new Organization();
|
||||
$org->name = Input::get('name');
|
||||
$org->phone = Input::get('phone');
|
||||
$org->website = Input::get('website');
|
||||
$org->address = Input::get('address');
|
||||
$org->internal_notes = Input::get('internal');
|
||||
$org->save();
|
||||
|
||||
$user_org = new User_org();
|
||||
$user_org->org_id = $org->id;
|
||||
$user_org->user_id = $id;
|
||||
$user_org->save();
|
||||
// for success return 0
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// Controllers
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// Requests
|
||||
use App\Http\Requests\kb\ArticleRequest;
|
||||
@@ -21,16 +20,17 @@ use Datatable;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
* ArticleController
|
||||
* This controller is used to CRUD Articles.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
class ArticleController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
@@ -40,8 +40,7 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking roles
|
||||
@@ -49,8 +48,7 @@ class ArticleController extends Controller
|
||||
SettingsController::language();
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
public function test() {
|
||||
//$table = $this->setDatatable();
|
||||
return view('themes.default1.agent.kb.article.test');
|
||||
}
|
||||
@@ -60,29 +58,37 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
public function getData() {
|
||||
$article = new Article();
|
||||
// returns chumper datatable
|
||||
return Datatable::collection(Article::All())
|
||||
return Datatable::query($article)
|
||||
/* searcable column name */
|
||||
->searchColumns('name')
|
||||
/* order column name and description */
|
||||
->orderColumns('name', 'description')
|
||||
/* add column name */
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
|
||||
$string = strip_tags($model->name);
|
||||
if (strlen($string) > 40) {
|
||||
// truncate string
|
||||
$stringCut = substr($string, 0, 40);
|
||||
} else {
|
||||
$stringCut = $model->name;
|
||||
}
|
||||
return $stringCut . '...';
|
||||
})
|
||||
/* add column Created */
|
||||
->addColumn('Created', function ($model) {
|
||||
$t = $model->created_at;
|
||||
->addColumn('publish_time', function ($model) {
|
||||
$t = $model->publish_time;
|
||||
|
||||
return TicketController::usertimezone($t);
|
||||
return $t;
|
||||
})
|
||||
/* add column action */
|
||||
->addColumn('Actions', function ($model) {
|
||||
/* here are all the action buttons and modal popup to delete articles with confirmations */
|
||||
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').' </button></span> <a href=article/'.$model->id.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href=show/'.$model->slug.' class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletearticle'.$model->id.'">
|
||||
return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span> <a href=article/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href=show/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletearticle' . $model->id . '">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -90,11 +96,11 @@ class ArticleController extends Controller
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->name.'
|
||||
' . $model->name . '
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="article/delete/'.$model->slug.'"><button class="btn btn-danger">delete</button></a>
|
||||
<a href="article/delete/' . $model->slug . '"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
@@ -108,13 +114,12 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
/* show article list */
|
||||
try {
|
||||
return view('themes.default1.agent.kb.article.index');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,15 +130,14 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create(Category $category)
|
||||
{
|
||||
public function create(Category $category) {
|
||||
/* get the attributes of the category */
|
||||
$category = $category->lists('id', 'name');
|
||||
/* get the create page */
|
||||
try {
|
||||
return view('themes.default1.agent.kb.article.create', compact('category'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,12 +149,11 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function store(Article $article, ArticleRequest $request)
|
||||
{
|
||||
public function store(Article $article, ArticleRequest $request) {
|
||||
// requesting the values to store article data
|
||||
$publishTime = $request->input('year').'-'.$request->input('month').'-'.$request->input('day').' '.$request->input('hour').':'.$request->input('minute').':00';
|
||||
$publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
|
||||
|
||||
$sl = $request->input('slug');
|
||||
$sl = $request->input('name');
|
||||
$slug = str_slug($sl, '-');
|
||||
$article->slug = $slug;
|
||||
$article->publish_time = $publishTime;
|
||||
@@ -166,9 +169,9 @@ class ArticleController extends Controller
|
||||
try {
|
||||
$article->fill($request->except('slug'))->save();
|
||||
|
||||
return redirect('article')->with('success', 'Article Inserted Successfully');
|
||||
return redirect('article')->with('success', Lang::get('lang.article_inserted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('article')->with('fails', 'Article Not Inserted'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('article')->with('fails', Lang::get('lang.article_not_inserted') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,8 +185,10 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return view
|
||||
*/
|
||||
public function edit($slug, Article $article, Relationship $relation, Category $category)
|
||||
{
|
||||
public function edit($slug) {
|
||||
$article = new Article();
|
||||
$relation = new Relationship();
|
||||
$category = new Category();
|
||||
$aid = $article->where('id', $slug)->first();
|
||||
$id = $aid->id;
|
||||
/* define the selected fields */
|
||||
@@ -197,7 +202,7 @@ class ArticleController extends Controller
|
||||
try {
|
||||
return view('themes.default1.agent.kb.article.edit', compact('assign', 'article', 'category'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,10 +216,11 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update($slug, Article $article, Relationship $relation, ArticleUpdate $request)
|
||||
{
|
||||
public function update($slug, ArticleUpdate $request) {
|
||||
$article = new Article();
|
||||
$relation = new Relationship();
|
||||
$aid = $article->where('id', $slug)->first();
|
||||
$publishTime = $request->input('year').'-'.$request->input('month').'-'.$request->input('day').' '.$request->input('hour').':'.$request->input('minute').':00';
|
||||
$publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
|
||||
|
||||
$id = $aid->id;
|
||||
$sl = $request->input('slug');
|
||||
@@ -239,9 +245,9 @@ class ArticleController extends Controller
|
||||
$article->publish_time = $publishTime;
|
||||
$article->save();
|
||||
|
||||
return redirect('article')->with('success', 'Article Updated Successfully');
|
||||
return redirect('article')->with('success', Lang::get('lang.article_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('article')->with('fails', 'Article Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('article')->with('fails', Lang::get('lang.article_not_updated') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,8 +259,7 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($slug, Article $article, Relationship $relation, Comment $comment)
|
||||
{
|
||||
public function destroy($slug, Article $article, Relationship $relation, Comment $comment) {
|
||||
/* delete the selected article from the table */
|
||||
$article = $article->where('slug', $slug)->first(); //get the selected article via id
|
||||
$id = $article->id;
|
||||
@@ -271,12 +276,12 @@ class ArticleController extends Controller
|
||||
}
|
||||
if ($article) {
|
||||
if ($article->delete()) {//true:redirect to index page with success message
|
||||
return Redirect::back()->with('success', 'Article Deleted Successfully');
|
||||
return Redirect::back()->with('success', Lang::get('lang.article_deleted_successfully'));
|
||||
} else { //redirect to index page with fails message
|
||||
return Redirect::back()->with('fails', 'Article Not Deleted');
|
||||
return Redirect::back()->with('fails', Lang::get('lang.article_not_deleted'));
|
||||
}
|
||||
} else {
|
||||
return Redirect::back()->with('fails', 'Article can Not Deleted');
|
||||
return Redirect::back()->with('fails', Lang::get('lang.article_can_not_deleted'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,8 +293,7 @@ class ArticleController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public static function usertimezone($utc)
|
||||
{
|
||||
public static function usertimezone($utc) {
|
||||
$user = Auth::user();
|
||||
$tz = $user->timezone;
|
||||
$set = Settings::whereId('1')->first();
|
||||
@@ -300,4 +304,5 @@ class ArticleController extends Controller
|
||||
$date = date($format, strtotime($utc) + $offset);
|
||||
echo $date;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -14,16 +14,17 @@ use App\Model\kb\Relationship;
|
||||
// Classes
|
||||
use Datatable;
|
||||
use Exception;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
* CategoryController
|
||||
* This controller is used to CRUD category.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
class CategoryController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
@@ -33,8 +34,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking roles
|
||||
@@ -49,14 +49,13 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
/* get the view of index of the catogorys with all attributes
|
||||
of category model */
|
||||
try {
|
||||
return view('themes.default1.agent.kb.category.index');
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +64,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return type chumper datatable
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
public function getData() {
|
||||
/* fetching chumper datatables */
|
||||
return Datatable::collection(Category::All())
|
||||
/* search column name */
|
||||
@@ -75,7 +73,15 @@ class CategoryController extends Controller
|
||||
->orderColumns('name', 'description')
|
||||
/* add column name */
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
|
||||
$string = strip_tags($model->name);
|
||||
if (strlen($string) > 40) {
|
||||
// truncate string
|
||||
$stringCut = substr($string, 0, 40);
|
||||
} else {
|
||||
$stringCut = $model->name;
|
||||
}
|
||||
return $stringCut.'...';
|
||||
})
|
||||
/* add column Created */
|
||||
->addColumn('Created', function ($model) {
|
||||
@@ -86,20 +92,20 @@ class CategoryController extends Controller
|
||||
/* add column Actions */
|
||||
/* there are action buttons and modal popup to delete a data column */
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<span data-toggle="modal" data-target="#deletecategory'.$model->slug.'"><a href="#" ><button class="btn btn-danger btn-xs"></a>'.\Lang::get('lang.delete').'</button></span> <a href=category/'.$model->id.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href=article-list class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletecategory'.$model->slug.'">
|
||||
return '<span data-toggle="modal" data-target="#deletecategory' . $model->slug . '"><a href="#" ><button class="btn btn-danger btn-xs"></a>' . \Lang::get('lang.delete') . '</button></span> <a href=category/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href=article-list class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletecategory' . $model->slug . '">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<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">Are You Sure ?</h4>
|
||||
<h4 class="modal-title">' . Lang::get('lang.are_you_sure_you_want_to_delete') . '</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->name.'
|
||||
' . $model->name . '
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="category/delete/'.$model->id.'"><button class="btn btn-danger">delete</button></a>
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . Lang::get('lang.close') . '</button>
|
||||
<a href="category/delete/' . $model->id . '"><button class="btn btn-danger">' . Lang::get('lang.delete') . '</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -115,8 +121,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create(Category $category)
|
||||
{
|
||||
public function create(Category $category) {
|
||||
/* Get the all attributes in the category model */
|
||||
$category = $category->get();
|
||||
/* get the view page to create new category with all attributes
|
||||
@@ -124,7 +129,7 @@ class CategoryController extends Controller
|
||||
try {
|
||||
return view('themes.default1.agent.kb.category.create', compact('category'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +141,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store(Category $category, CategoryRequest $request)
|
||||
{
|
||||
public function store(Category $category, CategoryRequest $request) {
|
||||
/* Get the whole request from the form and insert into table via model */
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, '-');
|
||||
@@ -146,9 +150,9 @@ class CategoryController extends Controller
|
||||
try {
|
||||
$category->fill($request->except('slug'))->save();
|
||||
|
||||
return Redirect::back()->with('success', 'Category Inserted Successfully');
|
||||
return Redirect::back()->with('success', Lang::get('lang.category_inserted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return Redirect::back()->with('fails', 'Category Not Inserted'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return Redirect::back()->with('fails', Lang::get('lang.category_not_inserted') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,13 +164,12 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($slug, Category $category)
|
||||
{
|
||||
public function edit($slug) {
|
||||
// fetch the category
|
||||
$cid = $category->where('id', $slug)->first();
|
||||
$cid = Category::where('id', $slug)->first();
|
||||
$id = $cid->id;
|
||||
/* get the atributes of the category model whose id == $id */
|
||||
$category = $category->whereId($id)->first();
|
||||
$category = Category::whereId($id)->first();
|
||||
/* get the Edit page the selected category via id */
|
||||
return view('themes.default1.agent.kb.category.edit', compact('category'));
|
||||
}
|
||||
@@ -180,11 +183,10 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function update($slug, Category $category, CategoryUpdate $request)
|
||||
{
|
||||
public function update($slug, CategoryUpdate $request) {
|
||||
|
||||
/* Edit the selected category via id */
|
||||
$category = $category->where('id', $slug)->first();
|
||||
$category = Category::where('id', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, '-');
|
||||
// dd($slug);
|
||||
@@ -195,11 +197,10 @@ class CategoryController extends Controller
|
||||
$category->fill($request->all())->save();
|
||||
$category->slug = $slug;
|
||||
$category->save();
|
||||
|
||||
return redirect('category')->with('success', 'Category Updated Successfully');
|
||||
return redirect('category')->with('success', Lang::get('lang.category_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
//redirect to index with fails message
|
||||
return redirect('category')->with('fails', 'Category Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return redirect('category')->with('fails', Lang::get('lang.category_not_updated') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,11 +213,10 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Category $category, Relationship $relation)
|
||||
{
|
||||
public function destroy($id, Category $category, Relationship $relation) {
|
||||
$relation = $relation->where('category_id', $id)->first();
|
||||
if ($relation != null) {
|
||||
return Redirect::back()->with('fails', 'Category Not Deleted');
|
||||
return Redirect::back()->with('fails', Lang::get('lang.category_not_deleted'));
|
||||
} else {
|
||||
/* delete the category selected, id == $id */
|
||||
$category = $category->whereId($id)->first();
|
||||
@@ -224,10 +224,11 @@ class CategoryController extends Controller
|
||||
try {
|
||||
$category->delete();
|
||||
|
||||
return Redirect::back()->with('success', 'Category Deleted Successfully');
|
||||
return Redirect::back()->with('success', Lang::get('lang.category_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return Redirect::back()->with('fails', 'Category Not Deleted'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
return Redirect::back()->with('fails', Lang::get('lang.category_not_deleted') . '<li>' . $e->getMessage() . '</li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// controllersuse App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// request
|
||||
use App\Http\Requests\kb\PageRequest;
|
||||
@@ -13,15 +13,16 @@ use Datatable;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* PageController
|
||||
* This controller is used to CRUD Pages.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PageController extends Controller
|
||||
{
|
||||
class PageController extends Controller {
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
@@ -31,8 +32,7 @@ class PageController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Page $page)
|
||||
{
|
||||
public function __construct(Page $page) {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking roles
|
||||
@@ -46,14 +46,13 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
$pages = $this->page->paginate(3);
|
||||
$pages->setPath('page');
|
||||
try {
|
||||
return view('themes.default1.agent.kb.pages.index', compact('pages'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +61,7 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
public function getData() {
|
||||
/* fetching chumper datatables */
|
||||
return Datatable::collection(Page::All())
|
||||
/* search column name */
|
||||
@@ -83,8 +81,8 @@ class PageController extends Controller
|
||||
/* add column Actions */
|
||||
/* there are action buttons and modal popup to delete a data column */
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<span data-toggle="modal" data-target="#deletepage'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').'</button></span> <a href=page/'.$model->slug.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href=pages/'.$model->slug.' class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletepage'.$model->id.'">
|
||||
return '<span data-toggle="modal" data-target="#deletepage' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . '</button></span> <a href=page/' . $model->slug . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href=pages/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletepage' . $model->id . '">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -92,11 +90,11 @@ class PageController extends Controller
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
'.$model->name.'
|
||||
' . $model->name . '
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="page/delete/'.$model->id.'"><button class="btn btn-danger">delete</button></a>
|
||||
<a href="page/delete/' . $model->id . '"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -110,8 +108,7 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
public function create() {
|
||||
return view('themes.default1.agent.kb.pages.create');
|
||||
}
|
||||
|
||||
@@ -122,17 +119,16 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function store(PageRequest $request)
|
||||
{
|
||||
public function store(PageRequest $request) {
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, '-');
|
||||
$this->page->slug = $slug;
|
||||
try {
|
||||
$this->page->fill($request->except('slug'))->save();
|
||||
|
||||
return redirect('page')->with('success', 'Page created successfully');
|
||||
return redirect('page')->with('success', Lang::get('lang.page_created_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('page')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,14 +139,13 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($slug)
|
||||
{
|
||||
public function edit($slug) {
|
||||
try {
|
||||
$page = $this->page->where('slug', $slug)->first();
|
||||
|
||||
return view('themes.default1.agent.kb.pages.edit', compact('page'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('page')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,8 +157,7 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function update($slug, PageUpdate $request)
|
||||
{
|
||||
public function update($slug, PageUpdate $request) {
|
||||
// get pages with respect to slug
|
||||
$pages = $this->page->where('slug', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
@@ -174,9 +168,9 @@ class PageController extends Controller
|
||||
$pages->slug = $slug;
|
||||
$pages->save();
|
||||
|
||||
return redirect('page')->with('success', 'Your Page Updated Successfully');
|
||||
return redirect('page')->with('success', Lang::get('lang.your_page_updated_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('page')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,16 +181,16 @@ class PageController extends Controller
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
public function destroy($id) {
|
||||
try {
|
||||
// get the page to be deleted
|
||||
$page = $this->page->whereId($id)->first();
|
||||
$page->delete();
|
||||
|
||||
return redirect('page')->with('success', 'Page Deleted Successfully');
|
||||
return redirect('page')->with('success', Lang::get('lang.page_deleted_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
return redirect('page')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,12 +22,13 @@ use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Image;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* SettingsController
|
||||
* This controller is used to perform settings in the setting page of knowledgebase.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
@@ -106,14 +107,14 @@ class SettingsController extends Controller
|
||||
/* Check whether function success or not */
|
||||
if ($settings->fill($request->except('logo', 'background'))->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
return redirect('settings')->with('success', 'Settings Updated Successfully');
|
||||
return redirect()->back()->with('success', Lang::get('lang.settings_updated_successfully'));
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('settings')->with('fails', 'Settings can not Updated');
|
||||
return redirect()->back()->with('fails', Lang::get('lang.settings_can_not_updated'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
/* redirect to Index page with Fails Message */
|
||||
return redirect('settings')->with('fails', 'Settings can not Updated');
|
||||
return redirect()->back()->with('fails', Lang::get('lang.settings_can_not_updated'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,9 +182,9 @@ class SettingsController extends Controller
|
||||
$comment = $comment->whereId($id)->first();
|
||||
$comment->status = 1;
|
||||
if ($comment->save()) {
|
||||
return redirect('comment')->with('success', $comment->name.'-'.'Comment Published');
|
||||
return redirect('comment')->with('success', $comment->name.'-'.Lang::get('lang.comment_published'));
|
||||
} else {
|
||||
return redirect('comment')->with('fails', 'Can not Process');
|
||||
return redirect('comment')->with('fails', Lang::get('lang.can_not_process'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,9 +200,9 @@ class SettingsController extends Controller
|
||||
{
|
||||
$comment = $comment->whereId($id)->first();
|
||||
if ($comment->delete()) {
|
||||
return redirect('comment')->with('success', $comment->name."'s!".'Comment Deleted');
|
||||
return redirect('comment')->with('success', $comment->name."'s!".Lang::get('lang.comment_deleted'));
|
||||
} else {
|
||||
return redirect('comment')->with('fails', 'Can not Process');
|
||||
return redirect('comment')->with('fails', Lang::get('lang.can_not_process'));
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
app/Http/Controllers/Api.zip
Normal file
BIN
app/Http/Controllers/Api.zip
Normal file
Binary file not shown.
@@ -191,6 +191,7 @@ class ApiController extends Controller
|
||||
*/
|
||||
public function ticketReply()
|
||||
{
|
||||
//dd($this->request->all());
|
||||
try {
|
||||
$v = \Validator::make($this->request->all(), [
|
||||
'ticket_ID' => 'required|exists:tickets,id',
|
||||
@@ -302,9 +303,9 @@ class ApiController extends Controller
|
||||
// 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')
|
||||
@@ -347,9 +348,9 @@ class ApiController extends Controller
|
||||
// $result = $this->model->where('assigned_to', '=', null)->where('status', '1')->orderBy('id', 'DESC')->get();
|
||||
// return response()->json(compact('result'));
|
||||
$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')
|
||||
@@ -392,9 +393,9 @@ class ApiController extends Controller
|
||||
// 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)->where('status', '<', 4);
|
||||
})
|
||||
})
|
||||
->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')
|
||||
@@ -1019,9 +1020,9 @@ class ApiController extends Controller
|
||||
{
|
||||
try {
|
||||
$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')
|
||||
@@ -1070,9 +1071,9 @@ class ApiController extends Controller
|
||||
return response()->json(compact('error'));
|
||||
}
|
||||
$result = $this->user->join('tickets', function ($join) use ($id) {
|
||||
$join->on('users.id', '=', 'tickets.assigned_to')
|
||||
$join->on('users.id', '=', 'tickets.assigned_to')
|
||||
->where('user_id', '=', $id);
|
||||
})
|
||||
})
|
||||
->join('department', 'department.id', '=', 'tickets.dept_id')
|
||||
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
|
||||
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
|
||||
@@ -1121,9 +1122,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')
|
||||
|
@@ -63,6 +63,17 @@ class InstallerApiController extends Controller
|
||||
|
||||
return ['response' => 'fail', 'reason' => $return_data, 'status' => '0'];
|
||||
}
|
||||
$path1 = base_path().DIRECTORY_SEPARATOR.'.env';
|
||||
$path2 = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'database.php';
|
||||
$path3 = base_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Http'.DIRECTORY_SEPARATOR.'routes.php';
|
||||
$path4 = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'lfm.php';
|
||||
$f1 = substr(sprintf('%o', fileperms($path1)), -3);
|
||||
$f2 = substr(sprintf('%o', fileperms($path2)), -3);
|
||||
$f3 = substr(sprintf('%o', fileperms($path3)), -3);
|
||||
$f4 = substr(sprintf('%o', fileperms($path4)), -3);
|
||||
if ($f1 != '777' || $f2 != '777' || $f3 != '777' || $f4 != '777') {
|
||||
return ['response' => 'fail', 'reason' => 'File permission issue.', 'status' => '0'];
|
||||
}
|
||||
// dd($validator->messages());
|
||||
// error_reporting(E_ALL & ~E_NOTICE);
|
||||
// Check for pre install
|
||||
@@ -214,9 +225,16 @@ class InstallerApiController extends Controller
|
||||
$content24 = File::get($path23);
|
||||
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
|
||||
$content24 = str_replace("'%url%'", $lfmpath, $content24);
|
||||
$link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$pos = strpos($link, 'api/v1/system-config');
|
||||
$link = substr($link, 0, $pos);
|
||||
$app_url = app_path('../config/app.php');
|
||||
$datacontent2 = File::get($app_url);
|
||||
$datacontent2 = str_replace('http://localhost', $link, $datacontent2);
|
||||
File::put($app_url, $datacontent2);
|
||||
File::put($path22, $content23);
|
||||
File::put($path23, $content24);
|
||||
|
||||
Artisan::call('key:generate');
|
||||
// If user created return success
|
||||
if ($user) {
|
||||
return ['response' => 'success', 'status' => '1'];
|
||||
|
@@ -269,11 +269,16 @@ class TicketController extends Controller
|
||||
try {
|
||||
$check_attachment = null;
|
||||
$eventthread = $thread->where('ticket_id', $request->input('ticket_ID'))->first();
|
||||
//dd($request->input('ticket_ID'));
|
||||
//dd($eventthread);
|
||||
$eventuserid = $eventthread->user_id;
|
||||
$emailadd = User::where('id', $eventuserid)->first()->email;
|
||||
//dd($emailadd);
|
||||
$source = $eventthread->source;
|
||||
|
||||
$form_data = $request->except('reply_content', 'ticket_ID', 'attachment');
|
||||
\Event::fire(new \App\Events\ClientTicketFormPost($form_data, $emailadd, $source));
|
||||
//dd('yes');
|
||||
$reply_content = $request->input('reply_content');
|
||||
$thread->ticket_id = $request->input('ticket_ID');
|
||||
$thread->poster = 'support';
|
||||
@@ -333,10 +338,16 @@ class TicketController extends Controller
|
||||
// // }
|
||||
// // }
|
||||
// }, true);
|
||||
|
||||
//dd('reply');
|
||||
/*
|
||||
* Getting the subject of the thread
|
||||
*/
|
||||
//dd($eventthread);
|
||||
try {
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket-by-agent', 'body' => $body], $template_variables = ['agent_sign' => Auth::user()->agent_sign, 'ticket_number' => $ticket_number2]);
|
||||
$re = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $tickets->dept_id), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => $eventthread->title, 'scenario' => 'create-ticket-by-agent', 'body' => $thread->body], $template_variables = ['agent_sign' => Auth::user()->agent_sign, 'ticket_number' => $tickets->number]);
|
||||
//dd($re);
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception($e->getMessage());
|
||||
}
|
||||
|
||||
$collaborators = Ticket_Collaborator::where('ticket_id', '=', $ticket_id)->get();
|
||||
@@ -368,6 +379,7 @@ class TicketController extends Controller
|
||||
|
||||
return $thread;
|
||||
} catch (\Exception $e) {
|
||||
//dd($e);
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
@@ -9,12 +9,12 @@ use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\LoginRequest;
|
||||
use App\Http\Requests\helpdesk\RegisterRequest;
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Settings\Security;
|
||||
// classes
|
||||
use App\User;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Hash;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\Registrar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
use Lang;
|
||||
use Mail;
|
||||
@@ -29,8 +29,8 @@ use Mail;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class AuthController extends Controller
|
||||
{
|
||||
class AuthController extends Controller {
|
||||
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
/* to redirect after login */
|
||||
|
||||
@@ -50,12 +50,9 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, Registrar $registrar, PhpMailController $PhpMailController)
|
||||
{
|
||||
public function __construct(PhpMailController $PhpMailController) {
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
SettingsController::smtp();
|
||||
$this->auth = $auth;
|
||||
$this->registrar = $registrar;
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
}
|
||||
|
||||
@@ -64,8 +61,7 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getRegister()
|
||||
{
|
||||
public function getRegister() {
|
||||
// Event for login
|
||||
\Event::fire(new \App\Events\FormRegisterEvent());
|
||||
if (Auth::user()) {
|
||||
@@ -87,32 +83,40 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postRegister(User $user, RegisterRequest $request)
|
||||
{
|
||||
public function postRegister(User $user, RegisterRequest $request) {
|
||||
// Event for login
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
|
||||
$password = Hash::make($request->input('password'));
|
||||
$user->password = $password;
|
||||
$name = $request->input('full_name');
|
||||
$user->user_name = $name;
|
||||
$user->email = $request->input('email');
|
||||
// $user->first_name = $request->input('first_name');
|
||||
// $user->last_nmae = $request->input('last_nmae');
|
||||
// $user->phone_number = $request->input('phone_number');
|
||||
// $user->company = $request->input('company');
|
||||
|
||||
$user->role = 'user';
|
||||
$code = str_random(60);
|
||||
$user->remember_token = $code;
|
||||
$user->save();
|
||||
// send mail for successful registration
|
||||
// $mail = Mail::send('auth.activate', array('link' => url('getmail', $code), 'username' => $name), function ($message) use ($user) {
|
||||
// $message->to($user->email, $user->full_name)->subject('active your account');
|
||||
// });
|
||||
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => 'password', 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('password/reset/'.$code)]);
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => 'Activate your Account', 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/' . $code)]);
|
||||
|
||||
return redirect('home')->with('success', 'Activate Your Account ! Click on Link that send to your mail');
|
||||
return redirect('home')->with('success', Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to activate account
|
||||
* @param type $token
|
||||
* @return type redirect
|
||||
*/
|
||||
public function accountActivate($token) {
|
||||
$user = User::where('remember_token', '=', $token)->first();
|
||||
if ($user) {
|
||||
$user->active = 1;
|
||||
$user->remember_token = NULL;
|
||||
$user->save();
|
||||
return redirect('/auth/login')->with('status', 'Acount activated. Login to start');
|
||||
} else {
|
||||
return redirect('/auth/login')->with('fails', 'Invalid Token');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,8 +127,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;
|
||||
@@ -141,8 +144,7 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
public function getLogin() {
|
||||
if (Auth::user()) {
|
||||
if (Auth::user()->role == 'admin' || Auth::user()->role == 'agent') {
|
||||
return \Redirect::route('dashboard');
|
||||
@@ -161,37 +163,66 @@ class AuthController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postLogin(LoginRequest $request)
|
||||
{
|
||||
public function postLogin(LoginRequest $request) {
|
||||
// Set login attempts and login time
|
||||
$loginAttempts = 1;
|
||||
$value = $_SERVER['REMOTE_ADDR'];
|
||||
$usernameinput = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
$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();
|
||||
//dd($security->lockout_message);
|
||||
if ($result == 1) {
|
||||
return redirect()->back()->withErrors('email', 'Incorrect details')->with('error', $security->lockout_message);
|
||||
}
|
||||
//dd($request->input('email'));
|
||||
$check_active = User::where('email', '=', $request->input('email'))->orwhere('user_name', '=', $request->input('email'))->first();
|
||||
if (!$check_active) {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.this_account_is_currently_inactive'));
|
||||
}
|
||||
if ($check_active->active == 0) {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.this_account_is_currently_inactive'));
|
||||
}
|
||||
$loginAttempts = 1;
|
||||
// If session has login attempts, retrieve attempts counter and attempts time
|
||||
if (\Session::has('loginAttempts')) {
|
||||
$loginAttempts = \Session::get('loginAttempts');
|
||||
$loginAttemptTime = \Session::get('loginAttemptTime');
|
||||
$this->addLoginAttempt($value, $usernameinput);
|
||||
// $credentials = $request->only('email', 'password');
|
||||
$usernameinput = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
// If attempts > 3 and time < 10 minutes
|
||||
if ($loginAttempts > 4 && (time() - $loginAttemptTime <= 600)) {
|
||||
return redirect()->back()->withErrors('email', 'incorrect email')->with('error', 'Maximum login attempts reached. Try again in a while');
|
||||
}
|
||||
// if ($loginAttempts > $security->backlist_threshold && (time() - $loginAttemptTime <= ($security->lockout_period * 60))) {
|
||||
//
|
||||
// return redirect()->back()->withErrors('email', 'incorrect email')->with('error', $security->lockout_message);
|
||||
// }
|
||||
// If time > 10 minutes, reset attempts counter and time in session
|
||||
if (time() - $loginAttemptTime > 600) {
|
||||
if (time() - $loginAttemptTime > ($security->lockout_period * 60)) {
|
||||
\Session::put('loginAttempts', 1);
|
||||
\Session::put('loginAttemptTime', time());
|
||||
}
|
||||
} else { // If no login attempts stored, init login attempts and time
|
||||
\Session::put('loginAttempts', $loginAttempts);
|
||||
\Session::put('loginAttemptTime', time());
|
||||
$this->clearLoginAttempts($value, $usernameinput);
|
||||
}
|
||||
// If auth ok, redirect to restricted area
|
||||
\Session::put('loginAttempts', $loginAttempts + 1);
|
||||
if ($this->auth->attempt([$field => $usernameinput, 'password' => $password], $request->has('remember'))) {
|
||||
\Event::fire('auth.login.event', []); //added 5/5/2016
|
||||
if (Auth::Attempt([$field => $usernameinput, 'password' => $password], $request->has('remember'))) {
|
||||
if (Auth::user()->role == 'user') {
|
||||
return \Redirect::route('/');
|
||||
} else {
|
||||
@@ -202,19 +233,89 @@ class AuthController extends Controller
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.invalid'));
|
||||
])->with('error', Lang::get('lang.invalid'));
|
||||
// Increment login attempts
|
||||
}
|
||||
|
||||
/**
|
||||
* Add login attempt.
|
||||
*
|
||||
* @param type IPaddress $value
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function addLoginAttempt($value, $field) {
|
||||
$result = DB::table('login_attempts')->where('IP', '=', $value)->first();
|
||||
$data = $result;
|
||||
$security = Security::whereId('1')->first();
|
||||
$apt = $security->backlist_threshold;
|
||||
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'");
|
||||
} 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())");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear login attempt.
|
||||
*
|
||||
* @param type IPaddress $value
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function clearLoginAttempts($value, $field) {
|
||||
$data = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['attempts' => '0']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Confiem IP.
|
||||
*
|
||||
* @param type IPaddress $value
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
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'");
|
||||
$data = $result;
|
||||
//Verify that at least one login attempt is in database
|
||||
if (!$data) {
|
||||
return 0;
|
||||
}
|
||||
if ($data[0]->Attempts >= $max_attempts) {
|
||||
if ($data[0]->Denied == 1) {
|
||||
return 1;
|
||||
} else {
|
||||
$this->clearLoginAttempts($value, $field);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Failed login message.
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
protected function getFailedLoginMessage()
|
||||
{
|
||||
return 'This Field do not match our records.';
|
||||
protected function getFailedLoginMessage() {
|
||||
return Lang::get('lang.this_field_do_not_match_our_records');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,9 +9,7 @@ use App\Http\Controllers\Controller;
|
||||
// request
|
||||
use App\User;
|
||||
// model
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
// classes
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -27,16 +25,11 @@ class PasswordController extends Controller
|
||||
/**
|
||||
* Create a new password controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, PasswordBroker $passwords, PhpMailController $PhpMailController)
|
||||
public function __construct(PhpMailController $PhpMailController)
|
||||
{
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
$this->auth = $auth;
|
||||
$this->passwords = $passwords;
|
||||
$this->middleware('guest');
|
||||
SettingsController::smtp();
|
||||
}
|
||||
@@ -73,12 +66,11 @@ 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->user_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/'.$code)]);
|
||||
|
||||
return redirect()->back()->with('status', 'We have e-mailed your password reset link!');
|
||||
return redirect()->back()->with('status', Lang::get('lang.we_have_e-mailed_your_password_reset_link'));
|
||||
} else {
|
||||
return redirect()->back()->with('errors', "We can't find a user with that e-mail address.");
|
||||
return redirect()->back()->with('errors', Lang::get("lang.we_can't_find_a_user_with_that_e-mail_address"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers\Client\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
@@ -12,14 +12,14 @@ use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\User;
|
||||
use Auth;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* TicketController2.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class ClientTicketController extends Controller
|
||||
{
|
||||
@@ -28,11 +28,12 @@ class ClientTicketController extends Controller
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController)
|
||||
{
|
||||
SettingsController::smtp();
|
||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||
// $this->middleware('auth');
|
||||
// $this->middleware('role.user');
|
||||
$this->middleware('board');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,29 +58,34 @@ class ClientTicketController extends Controller
|
||||
*/
|
||||
public function reply($id, Request $request)
|
||||
{
|
||||
$comment = $request->input('comment');
|
||||
if ($comment != null) {
|
||||
$tickets = Tickets::where('id', '=', $id)->first();
|
||||
$tickets->closed_at = null;
|
||||
$tickets->closed = 0;
|
||||
$tickets->reopened_at = date('Y-m-d H:i:s');
|
||||
$tickets->reopened = 1;
|
||||
$tickets->isanswered = 0;
|
||||
$threads = new Ticket_Thread();
|
||||
$threads->user_id = Auth::user()->id;
|
||||
$threads->ticket_id = $tickets->id;
|
||||
$threads->poster = 'client';
|
||||
$threads->body = $comment;
|
||||
try {
|
||||
$threads->save();
|
||||
$tickets->save();
|
||||
$tickets = Tickets::where('id', '=', $id)->first();
|
||||
$thread = Ticket_Thread::where('ticket_id', '=', $tickets->id)->first();
|
||||
|
||||
return \Redirect::back()->with('success1', 'Successfully replied');
|
||||
} catch (Exception $e) {
|
||||
return \Redirect::back()->with('fails1', $e->errorInfo[2]);
|
||||
}
|
||||
} else {
|
||||
return \Redirect::back()->with('fails1', 'Please fill some data!');
|
||||
}
|
||||
$subject = $thread->title.'[#'.$tickets->ticket_number.']';
|
||||
$body = $request->input('comment');
|
||||
|
||||
$user_cred = User::where('id', '=', $tickets->user_id)->first();
|
||||
|
||||
$fromaddress = $user_cred->email;
|
||||
$fromname = $user_cred->user_name;
|
||||
$phone = '';
|
||||
$phonecode = '';
|
||||
$mobile_number = '';
|
||||
|
||||
$helptopic = $tickets->help_topic_id;
|
||||
$sla = $tickets->sla;
|
||||
$priority = $tickets->priority_id;
|
||||
$source = $tickets->source;
|
||||
$collaborator = '';
|
||||
$dept = $tickets->dept_id;
|
||||
$assign = $tickets->assigned_to;
|
||||
$form_data = null;
|
||||
$team_assign = null;
|
||||
$ticket_status = null;
|
||||
$auto_response = 0;
|
||||
|
||||
$this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
|
||||
|
||||
return \Redirect::back()->with('success1', Lang::get('lang.successfully_replied'));
|
||||
}
|
||||
}
|
||||
|
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Client\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// models
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
|
||||
// classes
|
||||
|
||||
/**
|
||||
* EmailController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class EmailController extends Controller
|
||||
{
|
||||
/**
|
||||
* post port.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function port()
|
||||
{
|
||||
$port = Emails::where('id', '=', '1')->first();
|
||||
$portvalue = $port->option_value;
|
||||
|
||||
return $portvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* post host.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function host()
|
||||
{
|
||||
$host = Option::where('option_name', '=', 'host')->first();
|
||||
$hostvalue = $host->option_value;
|
||||
|
||||
return $hostvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* post username.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function username()
|
||||
{
|
||||
$username = Option::where('option_name', '=', 'username')->first();
|
||||
$uservalue = $username->option_value;
|
||||
|
||||
return $uservalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* post passowrd.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function password()
|
||||
{
|
||||
$password = Option::where('option_name', '=', 'password')->first();
|
||||
$passvalue = $password->option_value;
|
||||
|
||||
return $passvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* post encryption.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function encryption()
|
||||
{
|
||||
$encryption = Option::where('option_name', '=', 'encryption')->first();
|
||||
$encryptvalue = $encryption->option_value;
|
||||
|
||||
return $encryptvalue;
|
||||
}
|
||||
}
|
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Client\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\ClientRequest;
|
||||
@@ -18,13 +17,15 @@ use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Utility\CountryCode;
|
||||
use App\User;
|
||||
use Exception;
|
||||
// classes
|
||||
use Form;
|
||||
use GeoIP;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Mail;
|
||||
use Lang;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
@@ -32,18 +33,16 @@ 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)
|
||||
{
|
||||
// mail smtp settings
|
||||
// SettingsController::smtp();
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController) {
|
||||
$this->middleware('board');
|
||||
// creating a TicketController instance
|
||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||
}
|
||||
@@ -55,15 +54,17 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getForm(Help_topic $topic)
|
||||
{
|
||||
public function getForm(Help_topic $topic, CountryCode $code) {
|
||||
if (\Config::get('database.install') == '%0%') {
|
||||
return \Redirect::route('license');
|
||||
}
|
||||
$location = GeoIP::getLocation('');
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
if (System::first()->status == 1) {
|
||||
$topics = $topic->get();
|
||||
$codes = $code->get();
|
||||
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics'));
|
||||
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes'))->with('phonecode', $phonecode->phonecode);
|
||||
} else {
|
||||
return \Redirect::route('home');
|
||||
}
|
||||
@@ -77,14 +78,13 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function postForm($id, Help_topic $topic)
|
||||
{
|
||||
// dd($id);
|
||||
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 $value) {
|
||||
@@ -93,29 +93,29 @@ class FormController extends Controller
|
||||
$value = explode(',', $data);
|
||||
echo '<select class="form-control">';
|
||||
foreach ($value as $option) {
|
||||
echo '<option>'.$option.'</option>';
|
||||
echo '<option>' . $option . '</option>';
|
||||
}
|
||||
echo '</select></br>';
|
||||
} elseif ($value->type == 'radio') {
|
||||
$type2 = $value->value;
|
||||
$val = explode(',', $type2);
|
||||
echo '<label class="radio-inline">'.$value->label.'</label>   <input type="'.$value->type.'" name="'.$value->name.'"> '.$val[0].'
|
||||
   <input type="'.$value->type.'" name="'.$value->name.'"> '.$val[1].'</br>';
|
||||
echo '<label class="radio-inline">' . $value->label . '</label>   <input type="' . $value->type . '" name="' . $value->name . '"> ' . $val[0] . '
|
||||
   <input type="' . $value->type . '" name="' . $value->name . '"> ' . $val[1] . '</br>';
|
||||
} elseif ($value->type == 'textarea') {
|
||||
$type3 = $value->value;
|
||||
$v = explode(',', $type3);
|
||||
//dd($v);
|
||||
if (array_key_exists(1, $v)) {
|
||||
echo '<label>'.$value->label.'</label></br><textarea class=form-control rows="'.$v[0].'" cols="'.$v[1].'"></textarea></br>';
|
||||
echo '<label>' . $value->label . '</label></br><textarea class=form-control rows="' . $v[0] . '" cols="' . $v[1] . '"></textarea></br>';
|
||||
} else {
|
||||
echo '<label>'.$value->label.'</label></br><textarea class=form-control rows="10" cols="60"></textarea></br>';
|
||||
echo '<label>' . $value->label . '</label></br><textarea class=form-control rows="10" cols="60"></textarea></br>';
|
||||
}
|
||||
} elseif ($value->type == 'checkbox') {
|
||||
$type4 = $value->value;
|
||||
$check = explode(',', $type4);
|
||||
echo '<label class="radio-inline">'.$value->label.'   <input type="'.$value->type.'" name="'.$value->name.'">  '.$check[0].'</label><label class="radio-inline"><input type="'.$value->type.'" name="'.$value->name.'">  '.$check[1].'</label></br>';
|
||||
echo '<label class="radio-inline">' . $value->label . '   <input type="' . $value->type . '" name="' . $value->name . '">  ' . $check[0] . '</label><label class="radio-inline"><input type="' . $value->type . '" name="' . $value->name . '">  ' . $check[1] . '</label></br>';
|
||||
} else {
|
||||
echo '<label>'.$value->label.'</label><input type="'.$value->type.'" class="form-control" name="'.$value->name.'" /></br>';
|
||||
echo '<label>' . $value->label . '</label><input type="' . $value->type . '" class="form-control" name="' . $value->name . '" /></br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,8 +130,8 @@ 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)
|
||||
{
|
||||
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');
|
||||
|
||||
$name = $request->input('Name');
|
||||
@@ -139,24 +139,46 @@ class FormController extends Controller
|
||||
$email = $request->input('Email');
|
||||
$subject = $request->input('Subject');
|
||||
$details = $request->input('Details');
|
||||
|
||||
$phonecode = $request->input('Code');
|
||||
$System = System::where('id', '=', 1)->first();
|
||||
$departments = Department::where('id', '=', $System->department)->first();
|
||||
$department = $departments->id;
|
||||
|
||||
$mobile_number = $request->input('Mobile');
|
||||
$status = $ticket_settings->first()->status;
|
||||
$helptopic = $ticket_settings->first()->help_topic;
|
||||
$sla = $ticket_settings->first()->sla;
|
||||
$priority = $ticket_settings->first()->priority;
|
||||
$source = $ticket_source->where('name', '=', 'web')->first()->id;
|
||||
$attachments = $request->file('attachment');
|
||||
|
||||
$collaborator = null;
|
||||
$assignto = null;
|
||||
$auto_response = 0;
|
||||
$team_assign = null;
|
||||
if ($phone != null || $mobile_number != null) {
|
||||
$location = GeoIP::getLocation();
|
||||
$geoipcode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
if ($phonecode == null) {
|
||||
$data = [
|
||||
'fails' => Lang::get('lang.country-code-required-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'country_code_error' => 1,
|
||||
];
|
||||
|
||||
$result = $this->TicketWorkflowController->workflow($email, $name, $subject, $details, $phone, $helptopic, $sla, $priority, $source, $collaborator, $department, $assignto, $team_assign, $status, $form_extras, $auto_response);
|
||||
return Redirect::back()->with($data)->withInput($request->except('password'));
|
||||
} else {
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $phonecode)->get();
|
||||
if (!count($code)) {
|
||||
$data = [
|
||||
'fails' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'phonecode' => $geoipcode->phonecode,
|
||||
'country_code_error' => 1,
|
||||
];
|
||||
|
||||
return Redirect::back()->with($data)->withInput($request->except('password'));
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = $this->TicketWorkflowController->workflow($email, $name, $subject, $details, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $department, $assignto, $team_assign, $status, $form_extras, $auto_response);
|
||||
|
||||
if ($result[1] == 1) {
|
||||
$ticketId = Tickets::where('ticket_number', '=', $result[0])->first();
|
||||
@@ -174,7 +196,7 @@ class FormController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect::route('guest.getform')->with('success', 'Ticket has been created successfully, your ticket number is <b>'.$result[0].'</b> Please save this for future reference.');
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,30 +207,68 @@ class FormController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function post_ticket_reply($id, Request $request)
|
||||
{
|
||||
$comment = $request->input('comment');
|
||||
if ($comment != null) {
|
||||
$tickets = Tickets::where('id', '=', $id)->first();
|
||||
$threads = new Ticket_Thread();
|
||||
$tickets->closed_at = null;
|
||||
$tickets->closed = 0;
|
||||
$tickets->reopened_at = date('Y-m-d H:i:s');
|
||||
$tickets->reopened = 1;
|
||||
$threads->user_id = $tickets->user_id;
|
||||
$threads->ticket_id = $tickets->id;
|
||||
$threads->poster = 'client';
|
||||
$threads->body = $comment;
|
||||
try {
|
||||
$threads->save();
|
||||
$tickets->save();
|
||||
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();
|
||||
|
||||
return \Redirect::back()->with('success1', 'Successfully replied');
|
||||
} catch (Exception $e) {
|
||||
return \Redirect::back()->with('fails1', $e->errorInfo[2]);
|
||||
$subject = $thread->title . '[#' . $tickets->ticket_number . ']';
|
||||
$body = $request->input('comment');
|
||||
|
||||
$user_cred = User::where('id', '=', $tickets->user_id)->first();
|
||||
|
||||
$fromaddress = $user_cred->email;
|
||||
$fromname = $user_cred->user_name;
|
||||
$phone = '';
|
||||
$phonecode = '';
|
||||
$mobile_number = '';
|
||||
|
||||
$helptopic = $tickets->help_topic_id;
|
||||
$sla = $tickets->sla;
|
||||
$priority = $tickets->priority_id;
|
||||
$source = $tickets->source;
|
||||
$collaborator = '';
|
||||
$dept = $tickets->dept_id;
|
||||
$assign = $tickets->assigned_to;
|
||||
$form_data = null;
|
||||
$team_assign = null;
|
||||
$ticket_status = null;
|
||||
$auto_response = 0;
|
||||
|
||||
$this->TicketWorkflowController->workflow($fromaddress, $fromname, $subject, $body, $phone, $phonecode, $mobile_number, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $team_assign, $ticket_status, $form_data, $auto_response);
|
||||
|
||||
return \Redirect::back()->with('success1', Lang::get('lang.successfully_replied'));
|
||||
} else {
|
||||
return \Redirect::back()->with('fails1', Lang::get('lang.please_fill_some_data'));
|
||||
}
|
||||
} else {
|
||||
return \Redirect::back()->with('fails1', 'Please fill some data!');
|
||||
} catch (Exception $e) {
|
||||
return \Redirect::back()->with('fails1', $e->getMessage());
|
||||
}
|
||||
//
|
||||
// $comment = $request->input('comment');
|
||||
// if ($comment != null) {
|
||||
// $tickets = Tickets::where('id', '=', $id)->first();
|
||||
// $threads = new Ticket_Thread();
|
||||
// $tickets->closed_at = null;
|
||||
// $tickets->closed = 0;
|
||||
// $tickets->reopened_at = date('Y-m-d H:i:s');
|
||||
// $tickets->reopened = 1;
|
||||
// $threads->user_id = $tickets->user_id;
|
||||
// $threads->ticket_id = $tickets->id;
|
||||
// $threads->poster = 'client';
|
||||
// $threads->body = $comment;
|
||||
// try {
|
||||
// $threads->save();
|
||||
// $tickets->save();
|
||||
//
|
||||
// return \Redirect::back()->with('success1', Lang::get('lang.successfully_replied'));
|
||||
// } catch (Exception $e) {
|
||||
// return \Redirect::back()->with('fails1', $e->getMessage());
|
||||
// }
|
||||
// } else {
|
||||
// return \Redirect::back()->with('fails1', Lang::get('lang.please_fill_some_data'));
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,25 +4,27 @@ namespace App\Http\Controllers\Client\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CheckTicket;
|
||||
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;
|
||||
// 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\User;
|
||||
// classes
|
||||
use Auth;
|
||||
// classes
|
||||
use Exception;
|
||||
use GeoIP;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* GuestController.
|
||||
@@ -38,23 +40,25 @@ class GuestController extends Controller
|
||||
*/
|
||||
public function __construct(PhpMailController $PhpMailController)
|
||||
{
|
||||
$this->middleware('board');
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
SettingsController::smtp();
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile.
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
$user = Auth::user();
|
||||
/**
|
||||
* Get profile.
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getProfile(CountryCode $code)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$location = GeoIP::getLocation('');
|
||||
$phonecode = $code->where('iso', '=', $location['isoCode'])->first();
|
||||
|
||||
return view('themes.default1.client.helpdesk.profile', compact('user'));
|
||||
}
|
||||
return view('themes.default1.client.helpdesk.profile', compact('user'))->with('phonecode', $phonecode->phonecode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save profile data.
|
||||
@@ -89,12 +93,24 @@ class GuestController extends Controller
|
||||
Input::file('profile_pic')->move($destinationPath, $fileName);
|
||||
$user->profile_pic = $fileName;
|
||||
} else {
|
||||
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
||||
return redirect()->back()->with(['fails1' => Lang::get('lang.country-code-required-error'),
|
||||
'country_code' => 1, ])->withInput();
|
||||
} else {
|
||||
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
|
||||
if (!count($code)) {
|
||||
return redirect()->back()->with(['fails1' => Lang::get('lang.incorrect-country-code-error'),
|
||||
'country_code' => 1, ])->withInput();
|
||||
} else {
|
||||
$user->country_code = $request->input('country_code');
|
||||
}
|
||||
}
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
|
||||
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
|
||||
return redirect()->back()->with('success1', Lang::get('lang.profile_updated_sucessfully'));
|
||||
}
|
||||
if ($user->fill($request->except('profile_pic'))->save()) {
|
||||
return redirect()->back()->with('success1', 'Profile Updated sucessfully');
|
||||
return redirect()->back()->with('success1', Lang::get('lang.profile_updated_sucessfully'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,12 +211,12 @@ class GuestController extends Controller
|
||||
try {
|
||||
$user->save();
|
||||
|
||||
return redirect()->back()->with('success2', 'Password Updated sucessfully');
|
||||
return redirect()->back()->with('success2', Lang::get('lang.password_updated_sucessfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails2', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails2', $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('fails2', 'Password was not Updated. Incorrect old password');
|
||||
return redirect()->back()->with('fails2', Lang::get('lang.password_was_not_updated_incorrect_old_password'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,26 +266,33 @@ class GuestController extends Controller
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function PostCheckTicket()
|
||||
public function PostCheckTicket(Request $request)
|
||||
{
|
||||
$Email = \Input::get('email');
|
||||
$Ticket_number = \Input::get('ticket_number');
|
||||
|
||||
$validator = \Validator::make($request->all(), [
|
||||
'email' => 'required|email',
|
||||
'ticket_number' => 'required',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()
|
||||
->withErrors($validator)
|
||||
->withInput()
|
||||
->with('check', '1');
|
||||
}
|
||||
$Email = $request->input('email');
|
||||
$Ticket_number = $request->input('ticket_number');
|
||||
$ticket = Tickets::where('ticket_number', '=', $Ticket_number)->first();
|
||||
if ($ticket == null) {
|
||||
return \Redirect::route('form')->with('fails', 'There is no such Ticket Number');
|
||||
return \Redirect::route('form')->with('fails', Lang::get('lang.there_is_no_such_ticket_number'));
|
||||
} else {
|
||||
$userId = $ticket->user_id;
|
||||
$user = User::where('id', '=', $userId)->first();
|
||||
|
||||
if ($user->role == 'user') {
|
||||
$username = $user->user_name;
|
||||
} else {
|
||||
$username = $user->first_name.' '.$user->last_name;
|
||||
}
|
||||
|
||||
if ($user->email != $Email) {
|
||||
return \Redirect::route('form')->with('fails', "Email didn't match with Ticket Number");
|
||||
return \Redirect::route('form')->with('fails', Lang::get("lang.email_didn't_match_with_ticket_number"));
|
||||
} else {
|
||||
$code = $ticket->id;
|
||||
$code = \Crypt::encrypt($code);
|
||||
@@ -281,7 +304,7 @@ class GuestController extends Controller
|
||||
);
|
||||
|
||||
return \Redirect::back()
|
||||
->with('success', 'We have sent you a link by Email. Please click on that link to view ticket');
|
||||
->with('success', Lang::get('lang.we_have_sent_you_a_link_by_email_please_click_on_that_link_to_view_ticket'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
278
app/Http/Controllers/Client/helpdesk/UnAuthController.php
Normal file
278
app/Http/Controllers/Client/helpdesk/UnAuthController.php
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Client\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Common\PhpMailController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
// models
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Ticket\TicketToken;
|
||||
use App\User;
|
||||
use Hash;
|
||||
// classes
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* GuestController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class UnAuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public function __construct(PhpMailController $PhpMailController)
|
||||
{
|
||||
$this->middleware('board');
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post Check ticket.
|
||||
*
|
||||
* @param type CheckTicket $request
|
||||
* @param type User $user
|
||||
* @param type Tickets $ticket
|
||||
* @param type Ticket_Thread $thread
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function PostCheckTicket(Request $request)
|
||||
{
|
||||
try {
|
||||
$validator = \Validator::make($request->all(), [
|
||||
'email_address' => 'required|email',
|
||||
'ticket_number' => 'required',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()
|
||||
->withErrors($validator)
|
||||
->withInput()
|
||||
->with('check', '1');
|
||||
}
|
||||
$email = $request->input('email_address');
|
||||
$ticket_number = $request->input('ticket_number');
|
||||
// get user details
|
||||
$user_details = User::where('email', '=', $email)->first();
|
||||
// get ticket details
|
||||
$ticket = Tickets::where('ticket_number', '=', $ticket_number)->first();
|
||||
if ($ticket == null) {
|
||||
return \Redirect::route('form')->with('fails', Lang::get('lang.there_is_no_such_ticket_number'));
|
||||
}
|
||||
if ($ticket->user_id == $user_details->id) {
|
||||
if ($user_details->role == 'user') {
|
||||
$username = $user_details->user_name;
|
||||
} else {
|
||||
$username = $user_details->first_name.' '.$user_details->last_name;
|
||||
}
|
||||
// check for preentered ticket token
|
||||
$ticket_token = TicketToken::where('ticket_id', '=', $ticket->id)->first();
|
||||
if ($ticket_token) {
|
||||
$token = $this->generate_random_ticket_token();
|
||||
$hashed_token = \Hash::make($token);
|
||||
$ticket_token->token = $hashed_token;
|
||||
$ticket_token->save();
|
||||
} else {
|
||||
$ticket_token = new TicketToken();
|
||||
$ticket_token->ticket_id = $ticket->id;
|
||||
$token = $this->generate_random_ticket_token();
|
||||
$hashed_token = \Hash::make($token);
|
||||
$ticket_token->token = $hashed_token;
|
||||
$ticket_token->save();
|
||||
}
|
||||
try {
|
||||
$this->PhpMailController->sendmail(
|
||||
$from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $user_details->email], $message = ['subject' => 'Ticket link Request ['.$ticket_number.']', 'scenario' => 'check-ticket'], $template_variables = ['user' => $username, 'ticket_link_with_number' => url('show-ticket/'.$ticket->id.'/'.$token)]
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
return redirect()->back()
|
||||
->with('success', Lang::get('lang.we_have_sent_you_a_link_by_email_please_click_on_that_link_to_view_ticket'));
|
||||
} else {
|
||||
return \Redirect::route('form')->with('fails', Lang::get("lang.email_didn't_match_with_ticket_number"));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return \Redirect::route('form')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generate random string token for ticket.
|
||||
*
|
||||
* @param type $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generate_random_ticket_token($length = 10)
|
||||
{
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check the ticket without loggin In.
|
||||
*
|
||||
* @param type $ticket_id
|
||||
* @param type $token
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function showTicketCode($ticket_id, $token)
|
||||
{
|
||||
try {
|
||||
$check_token = TicketToken::where('ticket_id', '=', $ticket_id)->first();
|
||||
if (Hash::check($token, $check_token->token) == true) {
|
||||
$token_time = CommonSettings::where('option_name', '=', 'ticket_token_time_duration')->first();
|
||||
$time = $token_time->option_value;
|
||||
$new_time = date_add($check_token->updated_at, date_interval_create_from_date_string($time.' Hours'));
|
||||
if (date('Y-m-d H:i:s') > $new_time) {
|
||||
return redirect()->route('form')->with('fails', Lang::get('lang.sorry_your_ticket_token_has_expired_please_try_to_resend_the_ticket_link_request'));
|
||||
}
|
||||
$tickets = Tickets::where('id', '=', $ticket_id)->first();
|
||||
|
||||
return view('themes.default1.client.helpdesk.unauth.showticket', compact('tickets', 'token'));
|
||||
} else {
|
||||
return redirect()->route('form')->with('fails', Lang::get('lang.sorry_you_are_not_allowed_token_expired'));
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->route('form')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store ratings of the user.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function rating($id, Request $request, \App\Model\helpdesk\Ratings\RatingRef $rating_ref)
|
||||
{
|
||||
foreach ($request->all() as $key => $value) {
|
||||
if (strpos($key, '_') !== false) {
|
||||
$ratName = str_replace('_', ' ', $key);
|
||||
} else {
|
||||
$ratName = $key;
|
||||
}
|
||||
$ratID = \App\Model\helpdesk\Ratings\Rating::where('name', '=', $ratName)->first();
|
||||
$ratingrefs = $rating_ref->where('rating_id', '=', $ratID->id)->where('ticket_id', '=', $id)->first();
|
||||
if ($ratingrefs !== null) {
|
||||
$ratingrefs->rating_id = $ratID->id;
|
||||
$ratingrefs->ticket_id = $id;
|
||||
|
||||
$ratingrefs->thread_id = '0';
|
||||
$ratingrefs->rating_value = $value;
|
||||
$ratingrefs->save();
|
||||
} else {
|
||||
$rating_ref->rating_id = $ratID->id;
|
||||
$rating_ref->ticket_id = $id;
|
||||
|
||||
$rating_ref->thread_id = '0';
|
||||
$rating_ref->rating_value = $value;
|
||||
$rating_ref->save();
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back()->with('Success', Lang::get('lang.thank_you_for_your_rating'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Client rating about reply of agent quality.
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function ratingReply($id, Request $request, \App\Model\helpdesk\Ratings\RatingRef $rating_ref)
|
||||
{
|
||||
foreach ($request->all() as $key => $value) {
|
||||
$key1 = explode(',', $key);
|
||||
if (strpos($key1[0], '_') !== false) {
|
||||
$ratName = str_replace('_', ' ', $key1[0]);
|
||||
} else {
|
||||
$ratName = $key1[0];
|
||||
}
|
||||
$ratID = \App\Model\helpdesk\Ratings\Rating::where('name', '=', $ratName)->first();
|
||||
$ratingrefs = $rating_ref->where('rating_id', '=', $ratID->id)->where('thread_id', '=', $key1[1])->first();
|
||||
if ($ratingrefs !== null) {
|
||||
$ratingrefs->rating_id = $ratID->id;
|
||||
$ratingrefs->ticket_id = $id;
|
||||
$ratingrefs->thread_id = $key1[1];
|
||||
$ratingrefs->rating_value = $value;
|
||||
$ratingrefs->save();
|
||||
} else {
|
||||
$rating_ref->rating_id = $ratID->id;
|
||||
$rating_ref->ticket_id = $id;
|
||||
$rating_ref->thread_id = $key1[1];
|
||||
$rating_ref->rating_value = $value;
|
||||
$rating_ref->save();
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back()->with('Success', Lang::get('lang.thank_you_for_your_rating'));
|
||||
}
|
||||
|
||||
/**
|
||||
* function to change the status of the ticket.
|
||||
*
|
||||
* @param type $status
|
||||
* @param type $id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function changeStatus($status, $id)
|
||||
{
|
||||
$tickets = Tickets::where('id', '=', $id)->first();
|
||||
$tickets->status = $status;
|
||||
$ticket_status = Ticket_Status::where('id', '=', $status)->first();
|
||||
if ($ticket_status->state == 'closed') {
|
||||
$tickets->closed = $ticket_status->id;
|
||||
$tickets->closed_at = date('Y-m-d H:i:s');
|
||||
}
|
||||
$tickets->save();
|
||||
$ticket_thread = Ticket_Thread::where('ticket_id', '=', $ticket_status->id)->first();
|
||||
$ticket_subject = $ticket_thread->title;
|
||||
|
||||
$user = User::where('id', '=', $tickets->user_id)->first();
|
||||
|
||||
$thread = new Ticket_Thread();
|
||||
$thread->ticket_id = $tickets->id;
|
||||
$thread->user_id = $tickets->user_id;
|
||||
$thread->is_internal = 1;
|
||||
$thread->body = $ticket_status->message.' '.$user->user_name;
|
||||
$thread->save();
|
||||
|
||||
$email = $user->email;
|
||||
$user_name = $user->user_name;
|
||||
|
||||
$ticket_number = $tickets->ticket_number;
|
||||
|
||||
$sending_emails = Emails::where('department', '=', $ticket_status->dept_id)->first();
|
||||
if ($sending_emails == null) {
|
||||
$from_email = $this->system_mail();
|
||||
} else {
|
||||
$from_email = $sending_emails->id;
|
||||
}
|
||||
try {
|
||||
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $tickets->dept_id), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => $ticket_subject.'[#'.$ticket_number.']', 'scenario' => 'close-ticket'], $template_variables = ['ticket_number' => $ticket_number]);
|
||||
} catch (\Exception $e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Lang::get('lang.your_ticket_has_been').' '.$ticket_status->state;
|
||||
}
|
||||
}
|
@@ -15,15 +15,18 @@ use Redirect;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class WelcomepageController extends Controller
|
||||
{
|
||||
class WelcomepageController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
// $this->middleware('board');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function get(System $note)
|
||||
{
|
||||
public function get(System $note) {
|
||||
if (Config::get('database.install') == '%0%') {
|
||||
return Redirect::route('licence');
|
||||
}
|
||||
@@ -35,12 +38,12 @@ class WelcomepageController extends Controller
|
||||
return view('themes.default1.client.guest-user.guest', compact('heading', 'content'));
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
public function index() {
|
||||
if (Config::get('database.install') == '%0%') {
|
||||
return Redirect::route('licence');
|
||||
}
|
||||
|
||||
return view('themes.default1.client.helpdesk.guest-user.index');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ use Auth;
|
||||
use Config;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
use Mail;
|
||||
use Redirect;
|
||||
|
||||
@@ -27,6 +28,7 @@ class UserController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('board');
|
||||
//$this->middleware('auth');
|
||||
//SettingsController::language();
|
||||
// $this->port();
|
||||
@@ -45,8 +47,14 @@ class UserController extends Controller
|
||||
{
|
||||
$settings = $settings->first();
|
||||
$pagination = $settings->pagination;
|
||||
// $article = $article->where('status', '1');
|
||||
// $article = $article->where('type', '1');
|
||||
if (Auth::check()) {
|
||||
if (\Auth::user()->role == 'user') {
|
||||
$article = $article->where('status', '1');
|
||||
}
|
||||
} else {
|
||||
$article = $article->where('status', '1');
|
||||
}
|
||||
$article = $article->where('type', '1');
|
||||
$article = $article->paginate($pagination);
|
||||
// dd($article);
|
||||
$article->setPath('article-list');
|
||||
@@ -78,14 +86,26 @@ class UserController extends Controller
|
||||
return $excerpt;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to search an article.
|
||||
*
|
||||
* @param \App\Http\Requests\kb\SearchRequest $request
|
||||
* @param \App\Model\kb\Category $category
|
||||
* @param \App\Model\kb\Article $article
|
||||
* @param \App\Model\kb\Settings $settings
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function search(SearchRequest $request, Category $category, Article $article, Settings $settings)
|
||||
{
|
||||
$settings = $settings->first();
|
||||
$pagination = $settings->pagination;
|
||||
$search = $request->input('s');
|
||||
$result = $article->search($search)->paginate($pagination);
|
||||
$result = $article->where('name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('slug', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('description', 'LIKE', '%'.$search.'%')
|
||||
->paginate($pagination);
|
||||
$result->setPath('search');
|
||||
//dd($result);
|
||||
$categorys = $category->get();
|
||||
|
||||
return view('themes.default1.client.kb.article-list.search', compact('categorys', 'result'));
|
||||
@@ -103,11 +123,22 @@ class UserController extends Controller
|
||||
$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)->where('status', '1')->where('type', '1')->where('publish_time', '<', $date)->first();
|
||||
$arti = $article->where('slug', $slug);
|
||||
if (Auth::check()) {
|
||||
if (\Auth::user()->role == 'user') {
|
||||
$arti = $arti->where('status', '1');
|
||||
}
|
||||
} else {
|
||||
$arti = $arti->where('status', '1');
|
||||
}
|
||||
$arti = $arti->where('type', '1');
|
||||
$arti = $arti->where('publish_time', '<', $date);
|
||||
$arti = $arti->first();
|
||||
|
||||
if ($arti) {
|
||||
return view('themes.default1.client.kb.article-list.show', compact('arti'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', 'No records on publish time');
|
||||
return redirect()->back()->with('fails', Lang::get('lang.no_records_on_publish_time'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,12 +214,12 @@ 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', 'Your details send to System');
|
||||
return redirect('contact')->with('success', Lang::get('lang.your_details_send_to_system'));
|
||||
} else {
|
||||
return redirect('contact')->with('fails', 'Your details can not send to System');
|
||||
return redirect('contact')->with('fails', Lang::get('lang.your_details_can_not_send_to_system'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,9 +244,9 @@ class UserController extends Controller
|
||||
$id = $article->id;
|
||||
$comment->article_id = $id;
|
||||
if ($comment->fill($request->input())->save()) {
|
||||
return Redirect::back()->with('success', 'Your comment posted');
|
||||
return Redirect::back()->with('success', Lang::get('lang.your_comment_posted'));
|
||||
} else {
|
||||
return Redirect::back()->with('fails', 'Sorry not processed');
|
||||
return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,10 +345,10 @@ class UserController extends Controller
|
||||
} else {
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
|
||||
return redirect('guest')->with('success', 'Profile Updated sucessfully');
|
||||
return redirect('guest')->with('success', Lang::get('lang.profile_updated_sucessfully'));
|
||||
}
|
||||
if ($user->fill($request->except('profile_pic'))->save()) {
|
||||
return redirect('guest')->with('success', 'Profile Updated sucessfully');
|
||||
return redirect('guest')->with('success', Lang::get('lang.sorry_not_proprofile_updated_sucessfullycessed'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,9 +360,9 @@ class UserController extends Controller
|
||||
$user->password = Hash::make($request->input('new_password'));
|
||||
$user->save();
|
||||
|
||||
return redirect()->back()->with('success', 'Password Updated sucessfully');
|
||||
return redirect()->back()->with('success', Lang::get('lang.password_updated_sucessfully'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', 'Password was not Updated');
|
||||
return redirect()->back()->with('fails', Lang::get('lang.password_was_not_updated'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
116
app/Http/Controllers/Common/ApiSettings.php
Normal file
116
app/Http/Controllers/Common/ApiSettings.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\Api\ApiSetting;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
class ApiSettings extends Controller
|
||||
{
|
||||
public $api;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth', ['except' => ['ticketDetailEvent', 'postHook', 'postForm']]);
|
||||
$this->middleware('roles', ['except' => ['ticketDetailEvent', 'postHook', 'postForm']]);
|
||||
|
||||
$api = new ApiSetting();
|
||||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
try {
|
||||
$details = [];
|
||||
$ticket_detail = '';
|
||||
$settings = $this->api;
|
||||
if ($settings->get()->count() > 0) {
|
||||
$details = $this->api->lists('value', 'key')->toArray();
|
||||
}
|
||||
if (array_key_exists('ticket_detail', $details)) {
|
||||
$ticket_detail = $details['ticket_detail'];
|
||||
}
|
||||
|
||||
return view('themes.default1.common.api.settings', compact('ticket_detail'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postSettings(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'ticket_detail' => 'url',
|
||||
]);
|
||||
try {
|
||||
$settings = $this->api;
|
||||
if ($settings->get()->count() > 0) {
|
||||
foreach ($settings->get() as $set) {
|
||||
$set->delete();
|
||||
}
|
||||
}
|
||||
foreach ($request->except('_token') as $key => $value) {
|
||||
$settings->create(['key' => $key, 'value' => $value]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Updated Successfully');
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function ticketDetailEvent($detail)
|
||||
{
|
||||
try {
|
||||
$ticket = new Tickets();
|
||||
$ticketid = $detail->ticket_id;
|
||||
$data = $ticket
|
||||
->join('ticket_thread', function ($join) use ($ticketid) {
|
||||
$join->on('tickets.id', '=', 'ticket_thread.ticket_id')
|
||||
->where('ticket_thread.ticket_id', '=', $ticketid);
|
||||
})
|
||||
->join('users', 'ticket_thread.user_id', '=', 'users.id')
|
||||
->select('ticket_thread.title', 'ticket_thread.body', 'users.first_name', 'users.last_name', 'users.email', 'ticket_thread.created_at')
|
||||
->get()
|
||||
->toJson();
|
||||
$this->postHook($data);
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
throw new Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postHook($data)
|
||||
{
|
||||
try {
|
||||
$set = $this->api->where('key', 'ticket_detail')->first();
|
||||
if ($set) {
|
||||
if ($set->value) {
|
||||
$this->postForm($data, $set->value);
|
||||
}
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
throw new Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function postForm($data, $url)
|
||||
{
|
||||
try {
|
||||
$post_data = [
|
||||
'data' => $data,
|
||||
];
|
||||
$upgrade_controller = new \App\Http\Controllers\Update\UpgradeController();
|
||||
$upgrade_controller->postCurl($url, $post_data);
|
||||
Log::info('ticket details has send to : '.$url.' and details are : '.$data);
|
||||
} catch (Exception $ex) {
|
||||
throw new Exception($ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@@ -26,9 +26,8 @@ class NotificationController extends Controller
|
||||
{
|
||||
$notifications = UserNotification::join('notifications', 'user_notification.notification_id', '=', 'notifications.id')
|
||||
->join('notification_types', 'notifications.type_id', '=', 'notification_types.id')
|
||||
->where('user_notification.is_read', '=', '0')
|
||||
->where('user_notification.user_id', '=', \Auth::user()->id)
|
||||
->get();
|
||||
->paginate(10);
|
||||
|
||||
return $notifications;
|
||||
}
|
||||
@@ -41,7 +40,7 @@ class NotificationController extends Controller
|
||||
}
|
||||
//dd($forwhome);
|
||||
//system notification
|
||||
$notification = new Notification();
|
||||
$notification = new Notification();
|
||||
$UN = new UserNotification();
|
||||
|
||||
$notify = $notification->create(['model_id' => $model_id, 'userid_created' => $userid_created, 'type_id' => $type_id]);
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\Common\TemplateType;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
@@ -10,10 +11,9 @@ use App\Model\helpdesk\Settings\Email;
|
||||
use App\User;
|
||||
use Auth;
|
||||
|
||||
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();
|
||||
if ($emails->sending_status == 1) {
|
||||
return $emails;
|
||||
@@ -29,8 +29,7 @@ class PhpMailController extends Controller
|
||||
*
|
||||
* @return Mail
|
||||
*/
|
||||
public function sendmail($from, $to, $message, $template_variables)
|
||||
{
|
||||
public function sendmail($from, $to, $message, $template_variables) {
|
||||
// dd($from);
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
if ($from_address == null) {
|
||||
@@ -43,6 +42,7 @@ class PhpMailController extends Controller
|
||||
$smtpsecure = $from_address->sending_encryption;
|
||||
$host = $from_address->sending_host;
|
||||
$port = $from_address->sending_port;
|
||||
$protocol = $from_address->sending_protocol;
|
||||
|
||||
if (isset($to['email'])) {
|
||||
$recipants = $to['email'];
|
||||
@@ -64,11 +64,11 @@ class PhpMailController extends Controller
|
||||
} else {
|
||||
$bc = null;
|
||||
}
|
||||
if (isset($message['subject'])) {
|
||||
$subject = $message['subject'];
|
||||
} else {
|
||||
$subject = null;
|
||||
}
|
||||
// if (isset($message['subject'])) {
|
||||
// $subject = $message['subject'];
|
||||
// } else {
|
||||
// $subject = null;
|
||||
// }
|
||||
if (isset($message['body'])) {
|
||||
$content = $message['body'];
|
||||
} else {
|
||||
@@ -182,11 +182,28 @@ class PhpMailController extends Controller
|
||||
|
||||
$path2 = \Config::get('view.paths');
|
||||
|
||||
$directory = $path2[0].DIRECTORY_SEPARATOR.'emails'.DIRECTORY_SEPARATOR.$status->template.DIRECTORY_SEPARATOR;
|
||||
// $directory = $path2[0].DIRECTORY_SEPARATOR.'emails'.DIRECTORY_SEPARATOR.$status->template.DIRECTORY_SEPARATOR;
|
||||
//
|
||||
// $handle = fopen($directory.$template.'.blade.php', 'r');
|
||||
// $contents = fread($handle, filesize($directory.$template.'.blade.php'));
|
||||
// fclose($handle);
|
||||
|
||||
$handle = fopen($directory.$template.'.blade.php', 'r');
|
||||
$contents = fread($handle, filesize($directory.$template.'.blade.php'));
|
||||
fclose($handle);
|
||||
$template = TemplateType::where('name', '=', $template)->first();
|
||||
|
||||
$set = \App\Model\Common\TemplateSet::where('name', '=', $status->template)->first();
|
||||
|
||||
if (isset($set['id'])) {
|
||||
$template_data = \App\Model\Common\Template::where('set_id', '=', $set->id)->where('type', '=', $template->id)->first();
|
||||
$contents = $template_data->message;
|
||||
if ($template_data->subject) {
|
||||
$subject = $template_data->subject;
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
}
|
||||
} else {
|
||||
$contents = null;
|
||||
$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!!}'];
|
||||
|
||||
@@ -203,22 +220,30 @@ class PhpMailController extends Controller
|
||||
}
|
||||
|
||||
// dd($messagebody);
|
||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||
if ($protocol == "smtp") {
|
||||
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $username; // SMTP username
|
||||
$mail->Password = $password; // SMTP password
|
||||
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $port; // TCP port to connect to
|
||||
|
||||
$mail->setFrom($username, $fromname);
|
||||
$mail->addAddress($recipants); // Add a recipient
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $username; // SMTP username
|
||||
$mail->Password = $password; // SMTP password
|
||||
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $port; // TCP port to connect to
|
||||
$mail->setFrom($username, $fromname);
|
||||
} elseif ($protocol == "mail") {
|
||||
$mail->IsSendmail(); // telling the class to use SendMail transport
|
||||
if ($username == $fromname) {
|
||||
$mail->setFrom($username);
|
||||
} else {
|
||||
$mail->setFrom($username, $fromname);
|
||||
}
|
||||
}
|
||||
$mail->addAddress($recipants); // Add a recipient
|
||||
// Name is optional
|
||||
// $mail->addReplyTo('sada059@gmail.com', 'Information');
|
||||
// Optional name
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
if ($cc != null) {
|
||||
foreach ($cc as $collaborator) {
|
||||
//mail to collaborators
|
||||
@@ -229,7 +254,7 @@ class PhpMailController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$mail->addBCC($bc);
|
||||
// $mail->addBCC($bc);
|
||||
|
||||
if ($attachment != null) {
|
||||
$size = count($message['attachments']);
|
||||
@@ -244,9 +269,9 @@ class PhpMailController extends Controller
|
||||
$mail->Subject = $subject;
|
||||
if ($template == 'ticket-reply-agent') {
|
||||
$line = '---Reply above this line--- <br/><br/>';
|
||||
$mail->Body = $line.$messagebody;
|
||||
$mail->Body = utf8_decode($line . $messagebody);
|
||||
} else {
|
||||
$mail->Body = $messagebody;
|
||||
$mail->Body = utf8_decode($messagebody);
|
||||
}
|
||||
|
||||
// $mail->AltBody = $altbody;
|
||||
@@ -267,8 +292,7 @@ class PhpMailController extends Controller
|
||||
*
|
||||
* @return MailNotification
|
||||
*/
|
||||
public function sendEmail($from, $to, $message)
|
||||
{
|
||||
public function sendEmail($from, $to, $message) {
|
||||
// dd($from);
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
|
||||
@@ -394,8 +418,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';
|
||||
@@ -457,8 +480,7 @@ class PhpMailController extends Controller
|
||||
*
|
||||
* @return type integer
|
||||
*/
|
||||
public function mailfrom($reg, $dept_id)
|
||||
{
|
||||
public function mailfrom($reg, $dept_id) {
|
||||
$email = Email::where('id', '=', '1')->first();
|
||||
if ($reg == 1) {
|
||||
return $email->sys_email;
|
||||
@@ -471,4 +493,5 @@ class PhpMailController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Input;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* ***************************
|
||||
@@ -130,9 +131,9 @@ class SettingsController extends Controller
|
||||
try {
|
||||
$widget->save();
|
||||
|
||||
return redirect()->back()->with('success', $widget->name.' Saved Successfully');
|
||||
return redirect()->back()->with('success', $widget->name.Lang::get('lang.saved_successfully'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +462,6 @@ class SettingsController extends Controller
|
||||
public function GetPlugin()
|
||||
{
|
||||
$plugins = $this->fetchConfig();
|
||||
//dd($plugins);
|
||||
|
||||
return \Datatable::collection(new Collection($plugins))
|
||||
->searchColumns('name')
|
||||
@@ -683,24 +683,37 @@ class SettingsController extends Controller
|
||||
{
|
||||
$configs = $this->ReadConfigs();
|
||||
//dd($configs);
|
||||
$plug = new Plugin();
|
||||
$plug = $plug->select('path', 'status')->orderBy('name')->get()->toArray();
|
||||
//$fields = [];
|
||||
if ($configs !== 'null') {
|
||||
$plugs = new Plugin();
|
||||
$fields = [];
|
||||
$attributes = [];
|
||||
if ($configs != 'null') {
|
||||
foreach ($configs as $key => $config) {
|
||||
$fields[$key] = include $config;
|
||||
|
||||
if ($plug != null) {
|
||||
$fields[$key]['path'] = $plug[$key]['path'];
|
||||
$fields[$key]['status'] = $plug[$key]['status'];
|
||||
} else {
|
||||
$fields[$key]['path'] = $fields[$key]['name'];
|
||||
$fields[$key]['status'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
//dd($fields);
|
||||
if (count($fields) > 0) {
|
||||
foreach ($fields as $key => $field) {
|
||||
$plug = $plugs->where('name', $field['name'])->select('path', 'status')->orderBy('name')->get()->toArray();
|
||||
if ($plug) {
|
||||
foreach ($plug as $i => $value) {
|
||||
$attributes[$key]['path'] = $plug[$i]['path'];
|
||||
$attributes[$key]['status'] = $plug[$i]['status'];
|
||||
}
|
||||
} else {
|
||||
$attributes[$key]['path'] = $field['name'];
|
||||
$attributes[$key]['status'] = 0;
|
||||
}
|
||||
$attributes[$key]['name'] = $field['name'];
|
||||
$attributes[$key]['settings'] = $field['settings'];
|
||||
$attributes[$key]['description'] = $field['description'];
|
||||
$attributes[$key]['website'] = $field['website'];
|
||||
$attributes[$key]['version'] = $field['version'];
|
||||
$attributes[$key]['author'] = $field['author'];
|
||||
}
|
||||
}
|
||||
//dd($attributes);
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
public function DeletePlugin($slug)
|
||||
@@ -730,7 +743,7 @@ class SettingsController extends Controller
|
||||
$plug = $plugs->where('name', $slug)->first();
|
||||
if (!$plug) {
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
@@ -744,7 +757,7 @@ class SettingsController extends Controller
|
||||
$plug->status = 1;
|
||||
|
||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
@@ -755,7 +768,7 @@ class SettingsController extends Controller
|
||||
/*
|
||||
* remove service provider from app.php
|
||||
*/
|
||||
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||
$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);
|
||||
@@ -766,4 +779,8 @@ class SettingsController extends Controller
|
||||
|
||||
return redirect()->back()->with('success', 'Status has changed');
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
258
app/Http/Controllers/Common/TemplateController.php
Normal file
258
app/Http/Controllers/Common/TemplateController.php
Normal file
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\TemplateRequest;
|
||||
use App\Http\Requests\helpdesk\TemplateUdate;
|
||||
use App\Model\Common\Template;
|
||||
use App\Model\Common\TemplateType;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
/**
|
||||
* |======================================================
|
||||
* | Class Template Controller
|
||||
* |======================================================
|
||||
* This controller is for CRUD email templates.
|
||||
*/
|
||||
class TemplateController extends Controller
|
||||
{
|
||||
public $template;
|
||||
public $type;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
|
||||
$template = new Template();
|
||||
$this->template = $template;
|
||||
|
||||
$type = new TemplateType();
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the list of templates.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.common.template.inbox');
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show template
|
||||
* This template to show a particular template.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function showTemplate($id)
|
||||
{
|
||||
try {
|
||||
$templates = Template::where('set_id', '=', $id)->get();
|
||||
|
||||
return view('themes.default1.common.template.list-templates', compact('templates'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to display chumper datatables of the template list.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return type datatable
|
||||
*/
|
||||
public function GetTemplates(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
|
||||
return \Datatable::collection($this->template->where('set_id', '=', $id)->select('id', 'name', 'type')->get())
|
||||
->showColumns('name')
|
||||
->addColumn('type', function ($model) {
|
||||
return $this->type->where('id', $model->type)->first()->name;
|
||||
})
|
||||
->addColumn('action', function ($model) {
|
||||
return '<a href='.url('templates/'.$model->id.'/edit')." class='btn btn-sm btn-primary'>Edit</a>";
|
||||
})
|
||||
->searchColumns('name')
|
||||
->orderColumns('name')
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
try {
|
||||
$i = $this->template->orderBy('created_at', 'desc')->first()->id + 1;
|
||||
$type = $this->type->lists('name', 'id')->toArray();
|
||||
|
||||
return view('themes.default1.common.template.create', compact('type'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To store a set of templates.
|
||||
*
|
||||
* @param \App\Http\Requests\helpdesk\TemplateRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function store(TemplateRequest $request)
|
||||
{
|
||||
try {
|
||||
//dd($request);
|
||||
$this->template->fill($request->input())->save();
|
||||
|
||||
return redirect('templates')->with('success', Lang::get('lang.template_saved_successfully'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
try {
|
||||
$i = $this->template->orderBy('created_at', 'desc')->first()->id + 1;
|
||||
$template = $this->template->where('id', $id)->first();
|
||||
$type = $this->type->lists('name', 'id')->toArray();
|
||||
|
||||
return view('themes.default1.common.template.edit', compact('type', 'template'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id, TemplateUdate $request)
|
||||
{
|
||||
try {
|
||||
//dd($request);
|
||||
$template = $this->template->where('id', $id)->first();
|
||||
$template->fill($request->input())->save();
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.template_updated_successfully'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
try {
|
||||
$ids = $request->input('select');
|
||||
if (!empty($ids)) {
|
||||
foreach ($ids as $id) {
|
||||
$template = $this->template->where('id', $id)->first();
|
||||
if ($template) {
|
||||
$template->delete();
|
||||
} else {
|
||||
echo "<div class='alert alert-danger alert-dismissable'>
|
||||
<i class='fa fa-ban'></i>
|
||||
<b>".\Lang::get('message.alert').'!</b>
|
||||
<button type=button class=close data-dismiss=alert aria-hidden=true>×</button>
|
||||
'.\Lang::get('message.no-record').'
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
echo "<div class='alert alert-success alert-dismissable'>
|
||||
<i class='fa fa-ban'></i>
|
||||
<b>
|
||||
<button type=button class=close data-dismiss=alert aria-hidden=true>×</button>
|
||||
".\Lang::get('message.deleted-successfully').'
|
||||
</div>';
|
||||
} else {
|
||||
echo "<div class='alert alert-danger alert-dismissable'>
|
||||
<i class='fa fa-ban'></i>
|
||||
<b>".\Lang::get('message.alert').'!</b>
|
||||
<button type=button class=close data-dismiss=alert aria-hidden=true>×</button>
|
||||
'.\Lang::get('message.select-a-row').'
|
||||
</div>';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo "<div class='alert alert-danger alert-dismissable'>
|
||||
<i class='fa fa-ban'></i>
|
||||
<b>".\Lang::get('message.alert').'!</b>
|
||||
<button type=button class=close data-dismiss=alert aria-hidden=true>×</button>
|
||||
'.$e->getMessage().'
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
//dd($currency);
|
||||
try {
|
||||
if ($this->template->where('type', 3)->where('id', $id)->first()) {
|
||||
$data = $this->template->where('type', 3)->where('id', $id)->first()->data;
|
||||
$products = $this->product->where('id', '!=', 1)->take(4)->get();
|
||||
if (count($products) > 0) {
|
||||
$template = '';
|
||||
foreach ($products as $product) {
|
||||
//dd($this->checkPriceWithTaxClass($product->id, $currency));
|
||||
$url = $product->shoping_cart_link;
|
||||
$title = $product->name;
|
||||
if ($product->description) {
|
||||
$description = str_replace('</ul>', '', str_replace('<ul>', '', $product->description));
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
$currency = \Session::get('currency');
|
||||
if ($this->price->where('product_id', $product->id)->where('currency', $currency)->first()) {
|
||||
$product_currency = $this->price->where('product_id', $product->id)->where('currency', $currency)->first();
|
||||
$code = $product_currency->currency;
|
||||
$currency = $this->currency->where('code', $code)->first();
|
||||
if ($currency->symbol) {
|
||||
$currency = $currency->symbol;
|
||||
} else {
|
||||
$currency = $currency->code;
|
||||
}
|
||||
$price = \App\Http\Controllers\Front\CartController::calculateTax($product->id, $product_currency->currency, 1, 0, 1);
|
||||
|
||||
$subscription = $this->plan->where('id', $product_currency->subscription)->first()->name;
|
||||
} else {
|
||||
return redirect('/')->with('fails', \Lang::get('message.no-such-currency-in-system'));
|
||||
}
|
||||
|
||||
$array1 = ['{{title}}', '{{currency}}', '{{price}}', '{{subscription}}', '<li>{{feature}}</li>', '{{url}}'];
|
||||
$array2 = [$title, $currency, $price, $subscription, $description, $url];
|
||||
$template .= str_replace($array1, $array2, $data);
|
||||
}
|
||||
|
||||
//dd($template);
|
||||
return view('themes.default1.common.template.shoppingcart', compact('template'));
|
||||
} else {
|
||||
$template = '<p>No Products</p>';
|
||||
|
||||
return view('themes.default1.common.template.shoppingcart', compact('template'));
|
||||
}
|
||||
} else {
|
||||
return redirect('/')->with('fails', 'no such record');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
|
||||
return redirect('/')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
151
app/Http/Controllers/Common/TemplateSetController.php
Normal file
151
app/Http/Controllers/Common/TemplateSetController.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\TemplateSetRequest;
|
||||
use App\Model\Common\Template;
|
||||
use App\Model\Common\TemplateSet;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
|
||||
class TemplateSetController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$tempcon = new TemplateController();
|
||||
$this->tempcon = $tempcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the list of template sets.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$sets = TemplateSet::all();
|
||||
|
||||
return view('themes.default1.common.template.sets', compact('sets'));
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(TemplateSet $sets, TemplateSetRequest $request)
|
||||
{
|
||||
try {
|
||||
$sets->name = $request->input('name');
|
||||
$sets->save();
|
||||
$templates = Template::where('set_id', '=', '1')->get();
|
||||
foreach ($templates as $template) {
|
||||
\DB::table('templates')->insert(['set_id' => $sets->id, 'name' => $template->name, 'variable' => $template->variable, 'type' => $template->type, 'subject' => $template->subject, 'message' => $template->message]);
|
||||
}
|
||||
|
||||
return redirect('template-sets')->with('success', Lang::get('lang.you_have_created_a_new_template_set'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect('template-sets')->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function activateSet($id)
|
||||
{
|
||||
try {
|
||||
if (strpos($id, '_') !== false) {
|
||||
$ratName = str_replace('_', ' ', $id);
|
||||
} else {
|
||||
$ratName = $id;
|
||||
}
|
||||
\DB::table('settings_email')->update(['template' => $ratName]);
|
||||
|
||||
return \Redirect::back()->with('success', Lang::get('lang.you_have_successfully_activated_this_set'));
|
||||
} catch (Exception $ex) {
|
||||
return \Redirect::back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
try {
|
||||
$this->tempcon->showTemplate($id);
|
||||
} catch (\Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function deleteSet($id)
|
||||
{
|
||||
try {
|
||||
$templates = Template::where('set_id', '=', $id)->get();
|
||||
foreach ($templates as $template) {
|
||||
$template->delete();
|
||||
}
|
||||
TemplateSet::whereId($id)->delete();
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.template_set_deleted_successfully'));
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,12 +3,13 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
// classes
|
||||
use Illuminate\Foundation\Bus\DispatchesCommands;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
abstract class Controller extends BaseController
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use DispatchesCommands,
|
||||
use AuthorizesRequests, DispatchesJobs,
|
||||
ValidatesRequests;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ use App\Http\Controllers\Controller;
|
||||
/**
|
||||
* ErrorController.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class ErrorController extends Controller
|
||||
{
|
||||
@@ -19,6 +19,6 @@ class ErrorController extends Controller
|
||||
*/
|
||||
public function error404()
|
||||
{
|
||||
return view('404');
|
||||
return view('errors.404');
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ use App\User;
|
||||
// classes
|
||||
use Artisan;
|
||||
use Config;
|
||||
use DB;
|
||||
use Exception;
|
||||
use File;
|
||||
use Hash;
|
||||
@@ -303,10 +304,16 @@ class InstallController extends Controller
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
if ($request->input('dummy-data') == 'on') {
|
||||
$path = base_path().'/DB/dummy-data.sql';
|
||||
// dd($path);
|
||||
DB::unprepared(file_get_contents($path));
|
||||
} else {
|
||||
// migrate database
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
Artisan::call('db:seed', ['--force' => true]);
|
||||
}
|
||||
|
||||
// migrate database
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
Artisan::call('db:seed', ['--force' => true]);
|
||||
// create user
|
||||
$firstname = $request->input('firstname');
|
||||
$lastname = $request->input('Lastname');
|
||||
@@ -391,6 +398,13 @@ class InstallController extends Controller
|
||||
$content24 = File::get($path23);
|
||||
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
|
||||
$content24 = str_replace("'%url%'", $lfmpath, $content24);
|
||||
$link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$pos = strpos($link, 'final');
|
||||
$link = substr($link, 0, $pos);
|
||||
$app_url = app_path('../config/app.php');
|
||||
$datacontent2 = File::get($app_url);
|
||||
$datacontent2 = str_replace('http://localhost', $link, $datacontent2);
|
||||
File::put($app_url, $datacontent2);
|
||||
File::put($path22, $content23);
|
||||
File::put($path23, $content24);
|
||||
try {
|
||||
@@ -400,6 +414,7 @@ class InstallController extends Controller
|
||||
Session::forget('step4');
|
||||
Session::forget('step5');
|
||||
Session::forget('step6');
|
||||
Artisan::call('key:generate');
|
||||
|
||||
return View::make('themes/default1/installer/helpdesk/view6');
|
||||
} catch (Exception $e) {
|
||||
@@ -424,4 +439,30 @@ class InstallController extends Controller
|
||||
return redirect('/auth/login');
|
||||
}
|
||||
}
|
||||
|
||||
public function changeFilePermission()
|
||||
{
|
||||
$path1 = base_path().DIRECTORY_SEPARATOR.'.env';
|
||||
$path2 = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'database.php';
|
||||
$path3 = base_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Http'.DIRECTORY_SEPARATOR.'routes.php';
|
||||
$path4 = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'lfm.php';
|
||||
if (chmod($path1, 0644) && chmod($path2, 0644) && chmod($path3, 0644) && chmod($path4, 0644)) {
|
||||
$f1 = substr(sprintf('%o', fileperms($path1)), -3);
|
||||
$f2 = substr(sprintf('%o', fileperms($path2)), -3);
|
||||
$f3 = substr(sprintf('%o', fileperms($path3)), -3);
|
||||
$f4 = substr(sprintf('%o', fileperms($path4)), -3);
|
||||
if ($f1 >= '644' && $f2 >= '644' && $f3 >= '644' && $f4 >= '644') {
|
||||
return Redirect::back();
|
||||
} else {
|
||||
return Redirect::back()->with('fail_to_change', 'We are unable to change file permission on your server please try to change permission manually.');
|
||||
}
|
||||
} else {
|
||||
return Redirect::back()->with('fail_to_change', 'We are unable to change file permission on your server please try to change permission manually.');
|
||||
}
|
||||
}
|
||||
|
||||
public function jsDisabled()
|
||||
{
|
||||
return view('themes/default1/installer/helpdesk/check-js')->with('url', $_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
}
|
||||
|
349
app/Http/Controllers/Update/UpgradeController.php
Normal file
349
app/Http/Controllers/Update/UpgradeController.php
Normal file
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Update;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Utility\LibraryController as Utility;
|
||||
use App\Model\Update\BarNotification;
|
||||
use Artisan;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpgradeController extends Controller
|
||||
{
|
||||
public $dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$dir = base_path();
|
||||
$this->dir = $dir;
|
||||
}
|
||||
|
||||
public function getLatestVersion()
|
||||
{
|
||||
$name = \Config::get('app.name');
|
||||
//serial key should be encrypted data
|
||||
$serial_key = Utility::encryptByFaveoPublicKey('O5Y647RJF8QHLDOE');
|
||||
//order number should be encrypted data
|
||||
$order_number = Utility::encryptByFaveoPublicKey('23540755');
|
||||
$url = url('/');
|
||||
//dd($url);
|
||||
$post_data = [
|
||||
'serial_key' => $serial_key,
|
||||
'order_number' => $order_number,
|
||||
'name' => $name,
|
||||
'version' => Utility::getFileVersion(),
|
||||
'request_type' => 'check_update',
|
||||
'url' => $url,
|
||||
];
|
||||
$url = 'http://www.faveohelpdesk.com/billing/verification';
|
||||
if (str_contains($url, ' ')) {
|
||||
$url = str_replace(' ', '%20', $url);
|
||||
}
|
||||
$curl = $this->postCurl($url, $post_data);
|
||||
//dd($curl);
|
||||
if (is_array($curl)) {
|
||||
if (array_key_exists('status', $curl)) {
|
||||
if ($curl['status'] == 'success') {
|
||||
if (array_key_exists('version', $curl)) {
|
||||
return $curl['version'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function downloadLatestCode()
|
||||
{
|
||||
$name = \Config::get('app.name');
|
||||
$url = 'http://www.faveohelpdesk.com/billing/download-url';
|
||||
if (str_contains($url, ' ')) {
|
||||
$url = str_replace(' ', '%20', $url);
|
||||
}
|
||||
$data = [
|
||||
'name' => $name,
|
||||
];
|
||||
$download = $this->postCurl($url, $data);
|
||||
|
||||
$url = $download['zipball_url'];
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function saveLatestCodeAtTemp($download_url)
|
||||
{
|
||||
echo '<p>Downloading New Update</p>';
|
||||
$context = stream_context_create(
|
||||
[
|
||||
'http' => [
|
||||
'header' => 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$newUpdate = file_get_contents($download_url, false, $context);
|
||||
if (!is_dir("$this->dir/UPDATES/")) {
|
||||
\File::makeDirectory($this->dir.'/UPDATES/', 0777);
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
fclose($dlHandler);
|
||||
echo '<p>Update Downloaded And Saved</p>';
|
||||
}
|
||||
|
||||
public function doUpdate()
|
||||
{
|
||||
Artisan::call('down');
|
||||
$update = $this->dir.'/UPDATES';
|
||||
//Open The File And Do Stuff
|
||||
$zipHandle = zip_open($update.'/faveo-helpdesk-master.zip');
|
||||
//dd($update . '/faveo-' . $aV . '.zip');
|
||||
|
||||
echo '<ul class=list-unstyled>';
|
||||
while ($aF = zip_read($zipHandle)) {
|
||||
$thisFileName = zip_entry_name($aF);
|
||||
$thisFileDir = dirname($thisFileName);
|
||||
|
||||
//Continue if its not a file
|
||||
if (substr($thisFileName, -1, 1) == '/') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//Make the directory if we need to...
|
||||
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>';
|
||||
}
|
||||
|
||||
//Overwrite the file
|
||||
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');
|
||||
}
|
||||
echo' EXECUTED</li>';
|
||||
} else {
|
||||
$updateThis = fopen($update.'/'.$thisFileName, 'w');
|
||||
fwrite($updateThis, $contents);
|
||||
fclose($updateThis);
|
||||
unset($contents);
|
||||
echo' UPDATED</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</ul>';
|
||||
|
||||
Artisan::call('up');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function copyToActualDirectory($latest_version)
|
||||
{
|
||||
$directory = "$this->dir/UPDATES";
|
||||
$destination = $this->dir;
|
||||
// $destination = "/Applications/AMPPS/www/test/new";
|
||||
$directories = \File::directories($directory);
|
||||
|
||||
// echo "current directory => $directory <br>";
|
||||
// echo "Destination Directory => $destination <br>";
|
||||
foreach ($directories as $source) {
|
||||
$success = \File::copyDirectory($source, $destination);
|
||||
echo '<p class="success">» </p>';
|
||||
}
|
||||
|
||||
\File::deleteDirectory($directory);
|
||||
|
||||
$this->deleteBarNotification('new-version');
|
||||
|
||||
echo '<p class="success">» Faveo Updated to v'.Utility::getFileVersion().'</p>';
|
||||
}
|
||||
|
||||
public function deleteBarNotification($key)
|
||||
{
|
||||
try {
|
||||
$noti = new BarNotification();
|
||||
$notifications = $noti->where('key', $key)->get();
|
||||
foreach ($notifications as $notify) {
|
||||
$notify->delete();
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
}
|
||||
}
|
||||
|
||||
public function fileUpdate()
|
||||
{
|
||||
try {
|
||||
if (Utility::getFileVersion() < Utility::getDatabaseVersion()) {
|
||||
$url = url('file-upgrade');
|
||||
//$string = "Your Database is outdated please upgrade <a href=$url>Now !</a>";
|
||||
return view('themes.default1.update.file', compact('url'));
|
||||
} else {
|
||||
return redirect()->back();
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
}
|
||||
}
|
||||
|
||||
public function fileUpgrading(Request $request)
|
||||
{
|
||||
try {
|
||||
if (Utility::getFileVersion() < Utility::getDatabaseVersion()) {
|
||||
$latest_version = $this->getLatestVersion();
|
||||
//dd($latest_version);
|
||||
$current_version = Utility::getFileVersion();
|
||||
if ($latest_version != '') {
|
||||
$_this = new self();
|
||||
|
||||
return view('themes.default1.update.test', compact('latest_version', 'current_version', 'request'));
|
||||
} else {
|
||||
return redirect()->back()->with('fails', 'Could not find latest realeases from repository.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back();
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testScroll()
|
||||
{
|
||||
$ex = 1000;
|
||||
echo '<ul style=list-unstyled>';
|
||||
for ($i = 0; $i < $ex; $i++) {
|
||||
echo "<li style='color:white;'>updated</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
public function fileUpgrading1(Request $request)
|
||||
{
|
||||
if (Utility::getFileVersion() < Utility::getDatabaseVersion()) {
|
||||
$latest_version = $this->getLatestVersion();
|
||||
// dd($latest_version);
|
||||
$current_version = Utility::getFileVersion();
|
||||
//dd($current_version);
|
||||
if ($latest_version != '') {
|
||||
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>';
|
||||
$found = true;
|
||||
if (!is_file("$this->dir/UPDATES/faveo-helpdesk-master.zip")) {
|
||||
if ($request->get('dodownload') == true) {
|
||||
$download_url = $this->downloadLatestCode();
|
||||
if ($download_url != null) {
|
||||
$this->saveLatestCodeAtTemp($download_url);
|
||||
} else {
|
||||
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>';
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
echo '<p>Update already downloaded.</p>';
|
||||
}
|
||||
if ($request->get('doUpdate') == true) {
|
||||
$updated = $this->doUpdate();
|
||||
} else {
|
||||
echo '<p>Update ready. <a href='.url('file-upgrade?doUpdate=true').'>» Install Now?</a></p>';
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($updated == true) {
|
||||
$this->copyToActualDirectory($latest_version);
|
||||
} elseif ($found != true) {
|
||||
echo '<p>» No update is available.</p>';
|
||||
}
|
||||
} else {
|
||||
echo '<p>Could not find latest realeases.</p>';
|
||||
}
|
||||
} else {
|
||||
echo '<p>Could not find latest realeases from repository.</p>';
|
||||
}
|
||||
} else {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurl($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
//curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if (curl_exec($ch) === false) {
|
||||
echo 'Curl error: '.curl_error($ch);
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
dd($data);
|
||||
curl_close($ch);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function postCurl($url, $data)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if (curl_exec($ch) === false) {
|
||||
echo 'Curl error: '.curl_error($ch);
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return json_decode($data, true);
|
||||
}
|
||||
|
||||
public function databaseUpdate()
|
||||
{
|
||||
try {
|
||||
if (Utility::getFileVersion() > Utility::getDatabaseVersion()) {
|
||||
$url = url('database-upgrade');
|
||||
//$string = "Your Database is outdated please upgrade <a href=$url>Now !</a>";
|
||||
return view('themes.default1.update.database', compact('url'));
|
||||
} else {
|
||||
return redirect()->back();
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
}
|
||||
}
|
||||
|
||||
public function databaseUpgrade()
|
||||
{
|
||||
try {
|
||||
if (Utility::getFileVersion() > Utility::getDatabaseVersion()) {
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
|
||||
return redirect('dashboard')->with('success', 'Database updated');
|
||||
} else {
|
||||
return redirect()->back();
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
}
|
||||
}
|
||||
}
|
129
app/Http/Controllers/Utility/LibraryController.php
Normal file
129
app/Http/Controllers/Utility/LibraryController.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Utility;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Config;
|
||||
use Exception;
|
||||
use Schema;
|
||||
|
||||
class LibraryController extends Controller
|
||||
{
|
||||
public static function getFileVersion()
|
||||
{
|
||||
try {
|
||||
$app = Config::get('app.version');
|
||||
if ($app) {
|
||||
return preg_replace('/[^0-9,.]/', '', $app);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDatabaseVersion()
|
||||
{
|
||||
try {
|
||||
$database = self::isDatabaseSetup();
|
||||
if ($database == true) {
|
||||
if (Schema::hasColumn('settings_system', 'version')) {
|
||||
return \DB::table('settings_system')->where('id', '=', '1')->first()->version;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function isDatabaseSetup()
|
||||
{
|
||||
try {
|
||||
if (Schema::hasTable('settings_system')) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function encryptByFaveoPublicKey($plaintext)
|
||||
{
|
||||
try {
|
||||
// Compress the data to be sent
|
||||
$plaintext = gzcompress($plaintext);
|
||||
|
||||
// Get the public Key of the recipient
|
||||
$path = storage_path('app'.DIRECTORY_SEPARATOR.'faveo-public.key');
|
||||
$key_content = file_get_contents($path);
|
||||
|
||||
//dd($path);
|
||||
$publicKey = openssl_pkey_get_public($key_content);
|
||||
//dd($publicKey);
|
||||
$a_key = openssl_pkey_get_details($publicKey);
|
||||
|
||||
// Encrypt the data in small chunks and then combine and send it.
|
||||
$chunkSize = ceil($a_key['bits'] / 8) - 11;
|
||||
$output = '';
|
||||
|
||||
while ($plaintext) {
|
||||
$chunk = substr($plaintext, 0, $chunkSize);
|
||||
$plaintext = substr($plaintext, $chunkSize);
|
||||
$encrypted = '';
|
||||
if (!openssl_public_encrypt($chunk, $encrypted, $publicKey)) {
|
||||
throw new Exception('Failed to encrypt data');
|
||||
}
|
||||
$output .= $encrypted;
|
||||
}
|
||||
openssl_free_key($publicKey);
|
||||
|
||||
// This is the final encrypted data to be sent to the recipient
|
||||
$encrypted = $output;
|
||||
|
||||
return $encrypted;
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static function decryptByFaveoPrivateKey($encrypted)
|
||||
{
|
||||
try {
|
||||
//$encrypted = p¥Ùn¿olÓ¥9)OÞݸÔvh§=Ìtt1rkC‰É§%YœfÐS\BâkHW€mùÌØg¹+VŠ¥²?áÙ{/<¶¡£e¡ˆr°(V)Öíàr„Ž]K9¤ÿÖ¡Åmž”üÈoò״µºŽ06¼e€rœ['4çhH¾ö:¨œ–S„œ¦,|¤ÇqÂrÈŸd+ml‡ uötφûóŽ&›áyÙ(ÆŒÁ$‘¥±Zj*îàÒöL‘ˆD†aÉö_§è¶°·V„Þú]%ÅR*B=žéršæñ*i+á±èç|c¹ÑߟF$;
|
||||
// Get the private Key
|
||||
$path = storage_path('app'.DIRECTORY_SEPARATOR.'faveo-private.key');
|
||||
$key_content = file_get_contents($path);
|
||||
if (!$privateKey = openssl_pkey_get_private($key_content)) {
|
||||
die('Private Key failed');
|
||||
}
|
||||
$a_key = openssl_pkey_get_details($privateKey);
|
||||
|
||||
// Decrypt the data in the small chunks
|
||||
$chunkSize = ceil($a_key['bits'] / 8);
|
||||
$output = '';
|
||||
|
||||
while ($encrypted) {
|
||||
$chunk = substr($encrypted, 0, $chunkSize);
|
||||
$encrypted = substr($encrypted, $chunkSize);
|
||||
$decrypted = '';
|
||||
if (!openssl_private_decrypt($chunk, $decrypted, $privateKey)) {
|
||||
die('Failed to decrypt data');
|
||||
}
|
||||
$output .= $decrypted;
|
||||
}
|
||||
openssl_free_key($privateKey);
|
||||
|
||||
// Uncompress the unencrypted data.
|
||||
$output = gzuncompress($output);
|
||||
|
||||
echo '<br /><br /> Unencrypted Data: '.$output;
|
||||
} catch (Exception $ex) {
|
||||
dd($ex);
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,13 +15,13 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
|
||||
'Illuminate\Cookie\Middleware\EncryptCookies',
|
||||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
||||
'Illuminate\Session\Middleware\StartSession',
|
||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||
//'App\Http\Middleware\VerifyCsrfToken',
|
||||
'App\Http\Middleware\LanguageMiddleware',
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
//\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\App\Http\Middleware\LanguageMiddleware::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -30,14 +30,17 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => 'App\Http\Middleware\Authenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
||||
'roles' => 'App\Http\Middleware\CheckRole',
|
||||
'role.agent' => 'App\Http\Middleware\CheckRoleAgent',
|
||||
'role.user' => 'App\Http\Middleware\CheckRoleUser',
|
||||
'api' => 'App\Http\Middleware\ApiKey',
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'roles' => \App\Http\Middleware\CheckRole::class,
|
||||
'role.agent' => \App\Http\Middleware\CheckRoleAgent::class,
|
||||
'role.user' => \App\Http\Middleware\CheckRoleUser::class,
|
||||
'api' => \App\Http\Middleware\ApiKey::class,
|
||||
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
|
||||
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
|
||||
'update' => \App\Http\Middleware\CheckUpdate::class,
|
||||
'board' => \App\Http\Middleware\CheckBoard::class,
|
||||
];
|
||||
}
|
||||
|
43
app/Http/Middleware/CheckBoard.php
Normal file
43
app/Http/Middleware/CheckBoard.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* CheckBoard.
|
||||
* Checking if the system board is online or offline
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class CheckBoard {
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return type Mixed
|
||||
*/
|
||||
public function handle($request, Closure $next) {
|
||||
if ($this->checkBoard() == '1') {
|
||||
return $next($request);
|
||||
} else {
|
||||
return redirect()->route('board.offline')->with('offline', 'the system seems to be offline please try later');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the system offline details
|
||||
* @return type Mixed
|
||||
*/
|
||||
public function checkBoard() {
|
||||
$res = 0;
|
||||
$system = new System;
|
||||
if ($system->first()) {
|
||||
$res = $system->first()->status;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
125
app/Http/Middleware/CheckUpdate.php
Normal file
125
app/Http/Middleware/CheckUpdate.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Http\Controllers\Update\UpgradeController;
|
||||
use App\Http\Controllers\Utility\LibraryController as Utility;
|
||||
use App\Model\Update\BarNotification;
|
||||
use Closure;
|
||||
|
||||
class CheckUpdate
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$check = $this->process();
|
||||
//dd($check);
|
||||
if ($check == true) {
|
||||
//$this->notificationBar();
|
||||
$this->checkNewUpdate();
|
||||
if (Utility::getFileVersion() > Utility::getDatabaseVersion()) {
|
||||
return redirect('database-update');
|
||||
}
|
||||
if (Utility::getFileVersion() < Utility::getDatabaseVersion()) {
|
||||
return redirect('file-update');
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
public function notificationBar()
|
||||
{
|
||||
$notify = new BarNotification();
|
||||
$path = base_path('UPDATES');
|
||||
if (is_dir($path)) {
|
||||
$notify->create(['key' => 'update-ready', 'value' => 'New version has downloaded, click <a href='.url('file-update').'>here</a> to update now']);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkNewUpdate()
|
||||
{
|
||||
$notify = new BarNotification();
|
||||
if(!\Schema::hasTable('bar_notifications')){
|
||||
$url = url('database-upgrade');
|
||||
//$string = "Your Database is outdated please upgrade <a href=$url>Now !</a>";
|
||||
echo view('themes.default1.update.database', compact('url'));
|
||||
exit;
|
||||
}
|
||||
$not = $notify->get();
|
||||
if ($not->count() > 0) {
|
||||
$now = \Carbon\Carbon::now();
|
||||
$yesterday = \Carbon\Carbon::now(-24);
|
||||
$notifications = $notify->whereBetween('created_at', [$yesterday, $now])->lists('value', 'key');
|
||||
$todelete = $notify->where('created_at', '<', $yesterday)->get();
|
||||
if ($todelete->count() > 0) {
|
||||
foreach ($todelete as $delete) {
|
||||
$delete->delete();
|
||||
}
|
||||
}
|
||||
if (count($notifications) > 0) {
|
||||
if (!array_key_exists('new-version', $notifications)) {
|
||||
$check_version = $this->checkNewVersion();
|
||||
if ($check_version == true) {
|
||||
$notify->create(['key' => 'new-version', 'value' => 'new version found please click <a href='.url('file-update').'><b>here to download</b></a>']);
|
||||
}
|
||||
} else {
|
||||
$n = $notify->where('key', 'new-version')->first();
|
||||
$last = $n->created_at;
|
||||
$now = \Carbon\Carbon::now();
|
||||
$difference = $now->diffInHours($last);
|
||||
if ($difference >= 24) {
|
||||
$n->delete();
|
||||
$this->checkNewUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$check_version = $this->checkNewVersion();
|
||||
|
||||
if ($check_version == true) {
|
||||
//dd('if');
|
||||
$notify->create(['key' => 'new-version', 'value' => 'new version found please click <a href='.url('file-update').'><b>here to download</b></a>', 'created_at' => \Carbon\Carbon::now()]);
|
||||
} else {
|
||||
//dd('else');
|
||||
$notify->create(['key' => 'new-version', 'value' => '', 'created_at' => \Carbon\Carbon::now()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkNewVersion()
|
||||
{
|
||||
$controller = new UpgradeController();
|
||||
$version_from_billing = $controller->getLatestVersion();
|
||||
$app_version = Utility::getFileVersion();
|
||||
if ($version_from_billing > $app_version) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
$notify = new BarNotification();
|
||||
$not = $notify->get();
|
||||
if ($not->count() > 0) {
|
||||
$n = $notify->where('key', 'new-version')->first();
|
||||
|
||||
if ($n) {
|
||||
$now = \Carbon\Carbon::now();
|
||||
$yesterday = \Carbon\Carbon::now(-24);
|
||||
$notifications = $notify->where('key', 'new-version')->whereBetween('created_at', [$yesterday, $now])->lists('value', 'key');
|
||||
if ($notifications->count() > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
|
||||
|
||||
class EncryptCookies extends BaseEncrypter
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
@@ -4,11 +4,11 @@ namespace App\Http\Middleware;
|
||||
|
||||
use Cache;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Routing\Middleware;
|
||||
// use Illuminate\Contracts\Routing\Middleware;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class LanguageMiddleware implements Middleware
|
||||
class LanguageMiddleware
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
@@ -4,7 +4,6 @@ namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
@@ -38,7 +37,7 @@ class RedirectIfAuthenticated
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check()) {
|
||||
return new RedirectResponse(url('dashboard'));
|
||||
return redirect(url('dashboard'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@@ -29,18 +29,18 @@ class AgentRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'user_name' => 'required|unique:users',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'user_name' => 'required|unique:users|max:30',
|
||||
'first_name' => 'required|max:30',
|
||||
'last_name' => 'required|max:30',
|
||||
'email' => 'required|unique:users',
|
||||
'active' => 'required',
|
||||
// 'account_status' => 'required',
|
||||
'assign_group' => 'required',
|
||||
'primary_dpt' => 'required',
|
||||
'agent_tzone' => 'required',
|
||||
'group' => 'required',
|
||||
'primary_department' => 'required',
|
||||
'agent_time_zone' => 'required',
|
||||
// 'phone_number' => 'phone:IN',
|
||||
// 'mobile' => 'phone:IN',
|
||||
'team_id' => 'required',
|
||||
'team' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -29,17 +29,16 @@ class AgentUpdate extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'active' => 'required',
|
||||
'role' => 'required',
|
||||
'assign_group' => 'required',
|
||||
'primary_dpt' => 'required',
|
||||
'agent_tzone' => 'required',
|
||||
// 'phone_number' => 'phone:IN',
|
||||
// 'mobile' => 'phone:IN',
|
||||
'team_id' => 'required',
|
||||
'user_name' => 'required|max:30',
|
||||
'first_name' => 'required|max:30',
|
||||
'last_name' => 'required|max:30',
|
||||
'email' => 'required|email',
|
||||
'active' => 'required',
|
||||
'role' => 'required',
|
||||
'group' => 'required',
|
||||
'primary_department' => 'required',
|
||||
'agent_time_zone' => 'required',
|
||||
'team' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class CannedRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required',
|
||||
'title' => 'required|min:2|max:50',
|
||||
'message' => 'required',
|
||||
];
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class CannedUpdateRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required',
|
||||
'title' => 'required|min:2|max:50',
|
||||
'message' => 'required',
|
||||
];
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ class ClientRequest extends Request
|
||||
{
|
||||
return [
|
||||
'Name' => 'required',
|
||||
'Email' => 'required',
|
||||
'Email' => 'required|email',
|
||||
'Subject' => 'required',
|
||||
'Details' => 'required',
|
||||
];
|
||||
|
@@ -29,8 +29,8 @@ class CompanyRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'company_name' => 'required',
|
||||
'website' => 'active_url',
|
||||
'company_name' => 'required|max:50',
|
||||
'website' => 'url',
|
||||
'phone' => 'numeric',
|
||||
'logo' => 'image',
|
||||
];
|
||||
|
@@ -30,13 +30,13 @@ class CreateTicketRequest extends Request
|
||||
{
|
||||
return [
|
||||
|
||||
'email' => 'required|email',
|
||||
'fullname' => 'required|min:3',
|
||||
'email' => 'required|email|max:60',
|
||||
'fullname' => 'required|min:3|max:40',
|
||||
'helptopic' => 'required',
|
||||
// 'dept' => 'required',
|
||||
'sla' => 'required',
|
||||
'subject' => 'required|min:5',
|
||||
'body' => 'required|min:20',
|
||||
'body' => 'required|min:10',
|
||||
'priority' => 'required',
|
||||
];
|
||||
}
|
||||
|
@@ -29,10 +29,7 @@ class DepartmentRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:department',
|
||||
// 'outgoing_email' => 'required',
|
||||
// 'auto_response_email' => 'required',
|
||||
// 'group_id' => 'required',
|
||||
'name' => 'required|unique:department|max:30',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -29,10 +29,7 @@ class DepartmentUpdate extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
// 'outgoing_email' => 'required',
|
||||
// 'auto_response_email' => 'required',
|
||||
// 'group_id' => 'required',
|
||||
'name' => 'required|max:30',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
38
app/Http/Requests/helpdesk/DiagnosRequest.php
Normal file
38
app/Http/Requests/helpdesk/DiagnosRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* EmailsEditRequest.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class DiagnosRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'from' => 'required',
|
||||
'to' => 'required|email',
|
||||
'subject' => 'required',
|
||||
'message' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@ class GroupRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:groups',
|
||||
'name' => 'required|unique:groups|max:30',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
35
app/Http/Requests/helpdesk/GroupUpdateRequest.php
Normal file
35
app/Http/Requests/helpdesk/GroupUpdateRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* GroupRequest.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class GroupUpdateRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|max:30',
|
||||
];
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@ class HelptopicRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'topic' => 'required|unique:help_topic',
|
||||
'topic' => 'required|unique:help_topic|max:50',
|
||||
// 'parent_topic' => 'required',
|
||||
// 'custom_form' => 'required',
|
||||
'department' => 'required',
|
||||
|
@@ -29,12 +29,10 @@ class HelptopicUpdate extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'parent_topic' => 'required',
|
||||
// 'custom_form' => 'required',
|
||||
'topic' => 'required|max:50',
|
||||
'department' => 'required',
|
||||
'priority' => 'required',
|
||||
'sla_plan' => 'required',
|
||||
// 'auto_assign' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ class OrganizationRequest extends Request
|
||||
return [
|
||||
|
||||
'name' => 'required|unique:organization',
|
||||
'website' => 'active_url',
|
||||
'website' => 'url',
|
||||
// 'phone' => 'size:10',
|
||||
];
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ class OrganizationUpdate extends Request
|
||||
{
|
||||
return [
|
||||
|
||||
'website' => 'active_url',
|
||||
'website' => 'url',
|
||||
// 'phone' => 'size:10',
|
||||
];
|
||||
}
|
||||
|
35
app/Http/Requests/helpdesk/RatingRequest.php
Normal file
35
app/Http/Requests/helpdesk/RatingRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class RatingRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:ratings|max:20',
|
||||
'display_order' => 'required|integer',
|
||||
'allow_modification' => 'required',
|
||||
'rating_scale' => 'required',
|
||||
'rating_area' => 'required',
|
||||
'restrict' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
34
app/Http/Requests/helpdesk/RatingUpdateRequest.php
Normal file
34
app/Http/Requests/helpdesk/RatingUpdateRequest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class RatingUpdateRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|max:20',
|
||||
'display_order' => 'required|integer',
|
||||
'allow_modification' => 'required',
|
||||
'rating_scale' => 'required',
|
||||
'restrict' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
37
app/Http/Requests/helpdesk/SecurityRequest.php
Normal file
37
app/Http/Requests/helpdesk/SecurityRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* AgentRequest.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class SecurityRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'lockout_message' => 'required',
|
||||
'backlist_threshold' => 'required|numeric',
|
||||
'lockout_period' => 'required|numeric',
|
||||
];
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@ class SlaRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:sla_plan',
|
||||
'name' => 'required|unique:sla_plan|max:50',
|
||||
'grace_period' => 'required',
|
||||
];
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ class SlaUpdate extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|max:50',
|
||||
'grace_period' => 'required',
|
||||
];
|
||||
}
|
||||
|
33
app/Http/Requests/helpdesk/StatusRequest.php
Normal file
33
app/Http/Requests/helpdesk/StatusRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class StatusRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'sort' => 'required|numeric',
|
||||
'icon_class' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
}
|
@@ -29,8 +29,7 @@ class SystemRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'name' => '',
|
||||
'name' => 'max:50',
|
||||
'url' => 'url',
|
||||
];
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class TeamRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:teams',
|
||||
'name' => 'required|unique:teams|max:30',
|
||||
'status' => 'required',
|
||||
];
|
||||
}
|
||||
|
@@ -29,6 +29,8 @@ class TeamUpdate extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|max:30',
|
||||
'status' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -30,9 +30,9 @@ class TemplateRequest extends Request
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:template',
|
||||
'ban_status' => 'required',
|
||||
'template_set_to_clone' => 'required',
|
||||
'language' => 'required',
|
||||
// 'subject' => 'required',
|
||||
'type' => 'required',
|
||||
'message' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
38
app/Http/Requests/helpdesk/TemplateRequest2.php
Normal file
38
app/Http/Requests/helpdesk/TemplateRequest2.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* TemplateRequest.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class TemplateRequest2 extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:template',
|
||||
'ban_status' => 'required',
|
||||
'template_set_to_clone' => 'required',
|
||||
'language' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
30
app/Http/Requests/helpdesk/TemplateSetRequest.php
Normal file
30
app/Http/Requests/helpdesk/TemplateSetRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class TemplateSetRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:template_sets',
|
||||
];
|
||||
}
|
||||
}
|
@@ -29,10 +29,10 @@ class TemplateUdate extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'ban_status' => 'required',
|
||||
'template_set_to_clone' => 'required',
|
||||
'language' => 'required',
|
||||
'name' => 'required|max:60',
|
||||
// 'subject' => 'required',
|
||||
'type' => 'required',
|
||||
'message' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
38
app/Http/Requests/helpdesk/TemplateUdate2.php
Normal file
38
app/Http/Requests/helpdesk/TemplateUdate2.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
/**
|
||||
* TemplateUdate.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class TemplateUdate2 extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'ban_status' => 'required',
|
||||
'template_set_to_clone' => 'required',
|
||||
'language' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
33
app/Http/Requests/helpdesk/WorkflowCloseRequest.php
Normal file
33
app/Http/Requests/helpdesk/WorkflowCloseRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\helpdesk;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class WorkflowCloseRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'days' => 'required|integer|min:1',
|
||||
'condition' => 'required|integer',
|
||||
'send_email' => 'required|integer',
|
||||
'status' => 'required|integer',
|
||||
];
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@ class WorkflowCreateRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:workflow_name,name',
|
||||
'name' => 'required|unique:workflow_name,name|max:50',
|
||||
'execution_order' => 'required',
|
||||
'target_channel' => 'required',
|
||||
'rule' => 'required',
|
||||
|
@@ -29,7 +29,7 @@ class WorkflowUpdateRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'name' => 'required|max:50',
|
||||
'execution_order' => 'required',
|
||||
'target_channel' => 'required',
|
||||
'rule' => 'required',
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user