Apply fixes from StyleCI

This commit is contained in:
Manish Verma
2016-12-13 13:14:54 +00:00
committed by StyleCI Bot
parent 857d3004eb
commit 88f3df2180
161 changed files with 4729 additions and 3879 deletions

View File

@@ -2,11 +2,11 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Http\Controllers\Client\helpdesk\UnAuthController; use App\Http\Controllers\Client\helpdesk\UnAuthController;
use Illuminate\Console\Command;
class CloseWork extends Command { class CloseWork extends Command
{
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *
@@ -26,7 +26,8 @@ class CloseWork extends Command {
* *
* @return void * @return void
*/ */
public function __construct() { public function __construct()
{
parent::__construct(); parent::__construct();
} }
@@ -35,15 +36,15 @@ class CloseWork extends Command {
* *
* @return mixed * @return mixed
*/ */
public function handle() { public function handle()
{
if (env('DB_INSTALL') == 1) { if (env('DB_INSTALL') == 1) {
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController(); $PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$controller = new UnAuthController($PhpMailController); $controller = new UnAuthController($PhpMailController);
$controller->autoCloseTickets(); $controller->autoCloseTickets();
loging('ticket-close-workflow', 'Close ticket workflow executed','info'); loging('ticket-close-workflow', 'Close ticket workflow executed', 'info');
//\Log::info('Close ticket workflow executed'); //\Log::info('Close ticket workflow executed');
$this->info('Close ticket workflow executed'); $this->info('Close ticket workflow executed');
} }
} }
} }

View File

@@ -2,13 +2,13 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Http\Controllers\Agent\helpdesk\NotificationController; use App\Http\Controllers\Agent\helpdesk\NotificationController;
use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Common\PhpMailController;
use Exception; use Exception;
use Illuminate\Console\Command;
class SendReport extends Command { class SendReport extends Command
{
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *
@@ -28,8 +28,8 @@ class SendReport extends Command {
* *
* @return void * @return void
*/ */
public function __construct() { public function __construct()
{
parent::__construct(); parent::__construct();
} }
@@ -38,21 +38,22 @@ class SendReport extends Command {
* *
* @return mixed * @return mixed
*/ */
public function handle() { public function handle()
{
try { try {
if (env('DB_INSTALL') == 1) { if (env('DB_INSTALL') == 1) {
$mail = new PhpMailController(); $mail = new PhpMailController();
$mail->setQueue(); $mail->setQueue();
$this_report = new NotificationController($mail); $this_report = new NotificationController($mail);
$report = $this_report->send_notification(); $report = $this_report->send_notification();
if ($report !== 0) { if ($report !== 0) {
loging('sending-mail-report', 'Report has send','info'); loging('sending-mail-report', 'Report has send', 'info');
//\Log::info("Report has send"); //\Log::info("Report has send");
$this->info("Report has send"); $this->info('Report has send');
} else { } else {
loging('sending-mail-report', 'Nothing to send','info'); loging('sending-mail-report', 'Nothing to send', 'info');
$this->info("Nothing to send"); $this->info('Nothing to send');
} }
} }
} catch (Exception $ex) { } catch (Exception $ex) {
@@ -60,5 +61,4 @@ class SendReport extends Command {
$this->error($ex->getMessage()); $this->error($ex->getMessage());
} }
} }
} }

View File

@@ -2,13 +2,13 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Http\Controllers\Agent\helpdesk\MailController; use App\Http\Controllers\Agent\helpdesk\MailController;
use Event;
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController; use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
use Event;
use Illuminate\Console\Command;
class TicketFetch extends Command { class TicketFetch extends Command
{
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *
@@ -28,7 +28,8 @@ class TicketFetch extends Command {
* *
* @return void * @return void
*/ */
public function __construct() { public function __construct()
{
parent::__construct(); parent::__construct();
} }
@@ -37,9 +38,9 @@ class TicketFetch extends Command {
* *
* @return mixed * @return mixed
*/ */
public function handle() { public function handle()
{
if (env('DB_INSTALL') == 1) { if (env('DB_INSTALL') == 1) {
$controller = $this->mailController(); $controller = $this->mailController();
$emails = new \App\Model\helpdesk\Email\Emails(); $emails = new \App\Model\helpdesk\Email\Emails();
$settings_email = new \App\Model\helpdesk\Settings\Email(); $settings_email = new \App\Model\helpdesk\Settings\Email();
@@ -47,19 +48,20 @@ class TicketFetch extends Command {
$ticket = new \App\Model\helpdesk\Settings\Ticket(); $ticket = new \App\Model\helpdesk\Settings\Ticket();
$controller->readmails($emails, $settings_email, $system, $ticket); $controller->readmails($emails, $settings_email, $system, $ticket);
Event::fire('ticket.fetch', ['event' => '']); Event::fire('ticket.fetch', ['event' => '']);
loging('fetching-ticket', 'Ticket has read','info'); loging('fetching-ticket', 'Ticket has read', 'info');
//\Log::info('Ticket has read'); //\Log::info('Ticket has read');
$this->info('Ticket has read'); $this->info('Ticket has read');
} }
} }
public function mailController() { public function mailController()
{
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController(); $PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController(); $NotificationController = new \App\Http\Controllers\Common\NotificationController();
$ticket = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController); $ticket = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
$work = new TicketWorkflowController($ticket); $work = new TicketWorkflowController($ticket);
$controller = new MailController($work); $controller = new MailController($work);
return $controller; return $controller;
} }
} }

View File

@@ -2,12 +2,12 @@
namespace App\Console; namespace App\Console;
use App\Model\MailJob\Condition;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Model\MailJob\Condition;
class Kernel extends ConsoleKernel {
class Kernel extends ConsoleKernel
{
/** /**
* The Artisan commands provided by your application. * The Artisan commands provided by your application.
* *
@@ -27,7 +27,8 @@ class Kernel extends ConsoleKernel {
* *
* @return void * @return void
*/ */
protected function schedule(Schedule $schedule) { protected function schedule(Schedule $schedule)
{
if (env('DB_INSTALL') == 1) { if (env('DB_INSTALL') == 1) {
$queue = $this->getCurrentQueue(); $queue = $this->getCurrentQueue();
$schedule->command('queue:listen '.$queue, ['--tries' => 1])->everyMinute(); $schedule->command('queue:listen '.$queue, ['--tries' => 1])->everyMinute();
@@ -37,75 +38,79 @@ class Kernel extends ConsoleKernel {
} }
} }
public function execute($schedule, $task) { public function execute($schedule, $task)
{
$condition = new Condition(); $condition = new Condition();
$command = $condition->getConditionValue($task); $command = $condition->getConditionValue($task);
switch ($task) { switch ($task) {
case "fetching": case 'fetching':
$this->getCondition($schedule->command('ticket:fetch'), $command); $this->getCondition($schedule->command('ticket:fetch'), $command);
break; break;
case "notification": case 'notification':
$this->getCondition($schedule->command('report:send'), $command); $this->getCondition($schedule->command('report:send'), $command);
break; break;
case "work": case 'work':
$this->getCondition($schedule->command('ticket:close'), $command); $this->getCondition($schedule->command('ticket:close'), $command);
break; break;
} }
} }
public function getCondition($schedule, $command) { public function getCondition($schedule, $command)
{
$condition = $command['condition']; $condition = $command['condition'];
$at = $command['at']; $at = $command['at'];
switch ($condition) { switch ($condition) {
case "everyMinute": case 'everyMinute':
$schedule->everyMinute()->withoutOverlapping(); $schedule->everyMinute()->withoutOverlapping();
break; break;
case "everyFiveMinutes": case 'everyFiveMinutes':
$schedule->everyFiveMinutes()->withoutOverlapping(); $schedule->everyFiveMinutes()->withoutOverlapping();
break; break;
case "everyTenMinutes": case 'everyTenMinutes':
$schedule->everyTenMinutes()->withoutOverlapping(); $schedule->everyTenMinutes()->withoutOverlapping();
break; break;
case "everyThirtyMinutes": case 'everyThirtyMinutes':
$schedule->everyThirtyMinutes()->withoutOverlapping(); $schedule->everyThirtyMinutes()->withoutOverlapping();
break; break;
case "hourly": case 'hourly':
$schedule->hourly()->withoutOverlapping(); $schedule->hourly()->withoutOverlapping();
break; break;
case "daily": case 'daily':
$schedule->daily()->withoutOverlapping(); $schedule->daily()->withoutOverlapping();
break; break;
case "dailyAt": case 'dailyAt':
$this->getConditionWithOption($schedule, $condition, $at); $this->getConditionWithOption($schedule, $condition, $at);
break; break;
case "weekly": case 'weekly':
$schedule->weekly()->withoutOverlapping(); $schedule->weekly()->withoutOverlapping();
break; break;
case "monthly": case 'monthly':
$schedule->monthly()->withoutOverlapping(); $schedule->monthly()->withoutOverlapping();
break; break;
case "yearly": case 'yearly':
$schedule->yearly()->withoutOverlapping(); $schedule->yearly()->withoutOverlapping();
break; break;
} }
} }
public function getConditionWithOption($schedule, $command, $at) { public function getConditionWithOption($schedule, $command, $at)
{
switch ($command) { switch ($command) {
case "dailyAt": case 'dailyAt':
$schedule->dailyAt($at)->withoutOverlapping(); $schedule->dailyAt($at)->withoutOverlapping();
break; break;
} }
} }
public function getCurrentQueue() { public function getCurrentQueue()
{
$queue = 'database'; $queue = 'database';
$services = new \App\Model\MailJob\QueueService(); $services = new \App\Model\MailJob\QueueService();
$current = $services->where('status', 1)->first(); $current = $services->where('status', 1)->first();
if ($current) { if ($current) {
$queue = $current->short_name; $queue = $current->short_name;
} }
return $queue; return $queue;
} }
} }

View File

@@ -19,7 +19,7 @@ class FaveoAfterReply extends Event
* *
* @return void * @return void
*/ */
public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '',$para6='') public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '', $para6 = '')
{ {
$this->para1 = $para1; $this->para1 = $para1;
$this->para2 = $para2; $this->para2 = $para2;

View File

@@ -1,5 +1,7 @@
<?php <?php
namespace App\Exceptions; namespace App\Exceptions;
// controller // controller
use Bugsnag; use Bugsnag;
//use Illuminate\Validation\ValidationException; //use Illuminate\Validation\ValidationException;
@@ -11,6 +13,7 @@ use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Validation\ValidationException; use Illuminate\Foundation\Validation\ValidationException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
/** /**
@@ -27,6 +30,7 @@ class Handler extends ExceptionHandler
ModelNotFoundException::class, ModelNotFoundException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class, \Symfony\Component\HttpKernel\Exception\HttpException::class,
]; ];
/** /**
* Report or log an exception. * Report or log an exception.
* *
@@ -48,8 +52,10 @@ class Handler extends ExceptionHandler
$version = \Config::get('app.version'); $version = \Config::get('app.version');
Bugsnag::setAppVersion($version); Bugsnag::setAppVersion($version);
} }
return parent::report($e); return parent::report($e);
} }
/** /**
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
@@ -71,6 +77,7 @@ class Handler extends ExceptionHandler
return $this->common($request, $e); return $this->common($request, $e);
} }
} }
/** /**
* Function to render 500 error page. * Function to render 500 error page.
* *
@@ -83,12 +90,14 @@ class Handler extends ExceptionHandler
{ {
if (config('app.debug') == true) { if (config('app.debug') == true) {
return parent::render($request, $e); return parent::render($request, $e);
}elseif($e instanceof ValidationException){ } elseif ($e instanceof ValidationException) {
return parent::render($request, $e); return parent::render($request, $e);
} }
return response()->view('errors.500'); return response()->view('errors.500');
//return redirect()->route('error500', []); //return redirect()->route('error500', []);
} }
/** /**
* Function to render 404 error page. * Function to render 404 error page.
* *
@@ -99,21 +108,23 @@ class Handler extends ExceptionHandler
*/ */
public function render404($request, $e) public function render404($request, $e)
{ {
$seg = $request->segments(); $seg = $request->segments();
if (in_array('api', $seg)) { if (in_array('api', $seg)) {
return response()->json(['status' => '404']); return response()->json(['status' => '404']);
} }
if (config('app.debug') == true) { if (config('app.debug') == true) {
if($e->getStatusCode() == '404') { if ($e->getStatusCode() == '404') {
return redirect()->route('error404', []); return redirect()->route('error404', []);
} }
return parent::render($request, $e); return parent::render($request, $e);
} }
return redirect()->route('error404', []); return redirect()->route('error404', []);
} }
/** /**
* Function to render database connection failed * Function to render database connection failed.
* *
* @param type $request * @param type $request
* @param type $e * @param type $e
@@ -129,8 +140,10 @@ class Handler extends ExceptionHandler
if (config('app.debug') == true) { if (config('app.debug') == true) {
return parent::render($request, $e); return parent::render($request, $e);
} }
return redirect()->route('error404', []); return redirect()->route('error404', []);
} }
/** /**
* Common finction to render both types of codes. * Common finction to render both types of codes.
* *
@@ -147,7 +160,7 @@ class Handler extends ExceptionHandler
case $e instanceof NotFoundHttpException: case $e instanceof NotFoundHttpException:
return $this->render404($request, $e); return $this->render404($request, $e);
case $e instanceof PDOException: case $e instanceof PDOException:
if(strpos('1045', $e->getMessage()) == true) { if (strpos('1045', $e->getMessage()) == true) {
return $this->renderDB($request, $e); return $this->renderDB($request, $e);
} else { } else {
return $this->render500($request, $e); return $this->render500($request, $e);
@@ -161,6 +174,7 @@ class Handler extends ExceptionHandler
default: default:
return $this->render500($request, $e); return $this->render500($request, $e);
} }
return parent::render($request, $e); return parent::render($request, $e);
} }
} }

View File

@@ -8,33 +8,32 @@ use ReflectionClass;
use UTC; use UTC;
/** /**
* Class LaravelLogViewer * Class LaravelLogViewer.
* @package Rap2hpoutre\LaravelLogViewer
*/ */
class LaravelLogViewer { class LaravelLogViewer
{
/** /**
* @var string file * @var string file
*/ */
private static $file; private static $file;
private static $levels_classes = [ private static $levels_classes = [
'debug' => 'info', 'debug' => 'info',
'info' => 'info', 'info' => 'info',
'notice' => 'info', 'notice' => 'info',
'warning' => 'warning', 'warning' => 'warning',
'error' => 'danger', 'error' => 'danger',
'critical' => 'danger', 'critical' => 'danger',
'alert' => 'danger', 'alert' => 'danger',
'emergency' => 'danger', 'emergency' => 'danger',
]; ];
private static $levels_imgs = [ private static $levels_imgs = [
'debug' => 'info', 'debug' => 'info',
'info' => 'info', 'info' => 'info',
'notice' => 'info', 'notice' => 'info',
'warning' => 'warning', 'warning' => 'warning',
'error' => 'warning', 'error' => 'warning',
'critical' => 'warning', 'critical' => 'warning',
'alert' => 'warning', 'alert' => 'warning',
'emergency' => 'warning', 'emergency' => 'warning',
]; ];
@@ -43,7 +42,8 @@ class LaravelLogViewer {
/** /**
* @param string $file * @param string $file
*/ */
public static function setFile($file) { public static function setFile($file)
{
$file = self::pathToLogFile($file); $file = self::pathToLogFile($file);
if (File::exists($file)) { if (File::exists($file)) {
@@ -51,14 +51,15 @@ class LaravelLogViewer {
} }
} }
public static function pathToLogFile($file) { public static function pathToLogFile($file)
{
$logsPath = storage_path('logs'); $logsPath = storage_path('logs');
if (File::exists($file)) { // try the absolute path if (File::exists($file)) { // try the absolute path
return $file; return $file;
} }
$file = $logsPath . '/' . $file; $file = $logsPath.'/'.$file;
// check if requested file is really in the logs directory // check if requested file is really in the logs directory
if (dirname($file) !== $logsPath) { if (dirname($file) !== $logsPath) {
@@ -71,15 +72,17 @@ class LaravelLogViewer {
/** /**
* @return string * @return string
*/ */
public static function getFileName() { public static function getFileName()
{
return basename(self::$file); return basename(self::$file);
} }
/** /**
* @return array * @return array
*/ */
public static function all() { public static function all()
$log = array(); {
$log = [];
$log_levels = self::getLogLevels(); $log_levels = self::getLogLevels();
@@ -93,15 +96,17 @@ class LaravelLogViewer {
self::$file = $log_file[0]; self::$file = $log_file[0];
} }
if (File::size(self::$file) > self::MAX_FILE_SIZE) if (File::size(self::$file) > self::MAX_FILE_SIZE) {
return null; return;
}
$file = File::get(self::$file); $file = File::get(self::$file);
preg_match_all($pattern, $file, $headings); preg_match_all($pattern, $file, $headings);
if (!is_array($headings)) if (!is_array($headings)) {
return $log; return $log;
}
$log_data = preg_split($pattern, $file); $log_data = preg_split($pattern, $file);
@@ -112,38 +117,38 @@ class LaravelLogViewer {
foreach ($headings as $h) { foreach ($headings as $h) {
for ($i = 0, $j = count($h); $i < $j; $i++) { for ($i = 0, $j = count($h); $i < $j; $i++) {
foreach ($log_levels as $level_key => $level_value) { foreach ($log_levels as $level_key => $level_value) {
if (strpos(strtolower($h[$i]), '.' . $level_value)) { if (strpos(strtolower($h[$i]), '.'.$level_value)) {
preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?(\w+)\.'.$level_key.': (.*?)( in .*?:[0-9]+)?$/', $h[$i], $current);
preg_match('/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\].*?(\w+)\.' . $level_key . ': (.*?)( in .*?:[0-9]+)?$/', $h[$i], $current); if (!isset($current[3])) {
if (!isset($current[3]))
continue; continue;
}
$array = explode(':-:-:-', $current[3]); $array = explode(':-:-:-', $current[3]);
$message = $current[3]; $message = $current[3];
$context = $current[2]; $context = $current[2];
if (is_array($array)) { if (is_array($array)) {
if (array_key_exists(0, $array)) { if (array_key_exists(0, $array)) {
$message = $array[0]; $message = $array[0];
} }
if (array_key_exists(1, $array)) { if (array_key_exists(1, $array)) {
$context = $array[1]; $context = $array[1];
}else{ } else {
$context = $current[2]; $context = $current[2];
} }
} }
//dd($current); //dd($current);
$log[] = array( $log[] = [
'context' => $context, 'context' => $context,
'level' => $level_value, 'level' => $level_value,
'level_class' => self::$levels_classes[$level_value], 'level_class' => self::$levels_classes[$level_value],
'level_img' => self::$levels_imgs[$level_value], 'level_img' => self::$levels_imgs[$level_value],
'date' => self::date($current[1]), 'date' => self::date($current[1]),
'text' => $message, 'text' => $message,
'in_file' => isset($current[4]) ? $current[4] : null, 'in_file' => isset($current[4]) ? $current[4] : null,
'stack' => preg_replace("/^\n*/", '', $log_data[$i]) 'stack' => preg_replace("/^\n*/", '', $log_data[$i]),
); ];
} }
} }
} }
@@ -154,10 +159,12 @@ class LaravelLogViewer {
/** /**
* @param bool $basename * @param bool $basename
*
* @return array * @return array
*/ */
public static function getFiles($basename = false) { public static function getFiles($basename = false)
$files = glob(storage_path() . '/logs/*'); {
$files = glob(storage_path().'/logs/*');
$files = array_reverse($files); $files = array_reverse($files);
$files = array_filter($files, 'is_file'); $files = array_filter($files, 'is_file');
if ($basename && is_array($files)) { if ($basename && is_array($files)) {
@@ -165,20 +172,24 @@ class LaravelLogViewer {
$files[$k] = basename($file); $files[$k] = basename($file);
} }
} }
return array_values($files); return array_values($files);
} }
/** /**
* @return array * @return array
*/ */
private static function getLogLevels() { private static function getLogLevels()
$class = new ReflectionClass(new LogLevel); {
$class = new ReflectionClass(new LogLevel());
return $class->getConstants(); return $class->getConstants();
} }
public static function date($utc) { public static function date($utc)
{
$system_date = UTC::usertimezone($utc); $system_date = UTC::usertimezone($utc);
return $system_date; return $system_date;
} }
} }

View File

@@ -4,8 +4,8 @@ namespace App\FaveoLog;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class LaravelLogViewerServiceProvider extends ServiceProvider { class LaravelLogViewerServiceProvider extends ServiceProvider
{
/** /**
* Indicates if loading of the provider is deferred. * Indicates if loading of the provider is deferred.
* *
@@ -18,17 +18,17 @@ class LaravelLogViewerServiceProvider extends ServiceProvider {
* *
* @return void * @return void
*/ */
public function boot() { public function boot()
{
if (method_exists($this, 'package')) { if (method_exists($this, 'package')) {
$this->package('rap2hpoutre/laravel-log-viewer', 'laravel-log-viewer', __DIR__ . '/../../'); $this->package('rap2hpoutre/laravel-log-viewer', 'laravel-log-viewer', __DIR__.'/../../');
} }
$view_path = app_path().DIRECTORY_SEPARATOR.'FaveoLog'.DIRECTORY_SEPARATOR.'views';
$view_path = app_path() . DIRECTORY_SEPARATOR . 'FaveoLog' . DIRECTORY_SEPARATOR . 'views';
$this->loadViewsFrom($view_path, 'log'); $this->loadViewsFrom($view_path, 'log');
$lang_path = app_path() . DIRECTORY_SEPARATOR . 'FaveoLog' . DIRECTORY_SEPARATOR . 'lang'; $lang_path = app_path().DIRECTORY_SEPARATOR.'FaveoLog'.DIRECTORY_SEPARATOR.'lang';
$this->loadTranslationsFrom($lang_path, "log"); $this->loadTranslationsFrom($lang_path, 'log');
} }
/** /**
@@ -36,7 +36,8 @@ class LaravelLogViewerServiceProvider extends ServiceProvider {
* *
* @return void * @return void
*/ */
public function register() { public function register()
{
// Add routes // Add routes
$routes = app_path('/FaveoLog/routes.php'); $routes = app_path('/FaveoLog/routes.php');
if (file_exists($routes)) { if (file_exists($routes)) {
@@ -49,8 +50,8 @@ class LaravelLogViewerServiceProvider extends ServiceProvider {
* *
* @return array * @return array
*/ */
public function provides() { public function provides()
return array(); {
return [];
} }
} }

View File

@@ -1,40 +1,38 @@
<?php <?php
namespace App\FaveoLog\controllers; namespace App\FaveoLog\controllers;
use App\FaveoLog\LaravelLogViewer;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Response; use Illuminate\Support\Facades\Response;
use App\FaveoLog\LaravelLogViewer; use Illuminate\Support\Facades\View;
class LogViewerController extends Controller class LogViewerController extends Controller
{ {
public function index() public function index()
{ {
if (Request::input('l')) { if (Request::input('l')) {
//dd(base64_decode(Request::input('l'))); //dd(base64_decode(Request::input('l')));
LaravelLogViewer::setFile(base64_decode(Request::input('l'))); LaravelLogViewer::setFile(base64_decode(Request::input('l')));
} }
if (Request::input('dl')) { if (Request::input('dl')) {
return Response::download(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('dl')))); return Response::download(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('dl'))));
} elseif (Request::has('del')) { } elseif (Request::has('del')) {
File::delete(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('del')))); File::delete(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('del'))));
return Redirect::to(Request::url()); return Redirect::to(Request::url());
} }
$logs = LaravelLogViewer::all(); $logs = LaravelLogViewer::all();
return View::make('log::log', [ return View::make('log::log', [
'logs' => $logs, 'logs' => $logs,
'files' => LaravelLogViewer::getFiles(true), 'files' => LaravelLogViewer::getFiles(true),
'current_file' => LaravelLogViewer::getFileName() 'current_file' => LaravelLogViewer::getFileName(),
]); ]);
} }
} }

View File

@@ -1,5 +1,5 @@
<?php <?php
return [ return [
'logs'=>'Logs', 'logs'=> 'Logs',
]; ];

View File

@@ -4,7 +4,6 @@ Breadcrumbs::register('logs', function ($breadcrumbs) {
$breadcrumbs->parent('setting'); $breadcrumbs->parent('setting');
$breadcrumbs->push('System Logs', route('logs')); $breadcrumbs->push('System Logs', route('logs'));
}); });
Route::group(['middleware' => ['web', 'auth', 'roles']], function() { Route::group(['middleware' => ['web', 'auth', 'roles']], function () {
Route::get('logs', ['as' => 'logs', 'uses' => 'App\FaveoLog\controllers\LogViewerController@index']); Route::get('logs', ['as' => 'logs', 'uses' => 'App\FaveoLog\controllers\LogViewerController@index']);
}); });

View File

@@ -3,32 +3,34 @@
namespace App\FaveoStorage\Controllers; namespace App\FaveoStorage\Controllers;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Model\helpdesk\Settings\CommonSettings; use App\Model\helpdesk\Settings\CommonSettings;
use Exception;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
use Artisan; use Artisan;
use Exception;
use Illuminate\Http\Request;
use Lang; use Lang;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
class SettingsController extends Controller { class SettingsController extends Controller
{
public function settingsIcon() { public function settingsIcon()
{
return ' <div class="col-md-2 col-sm-6"> return ' <div class="col-md-2 col-sm-6">
<div class="settingiconblue"> <div class="settingiconblue">
<div class="settingdivblue"> <div class="settingdivblue">
<a href="' . url('storage') . '"> <a href="'.url('storage').'">
<span class="fa-stack fa-2x"> <span class="fa-stack fa-2x">
<i class="fa fa-save fa-stack-1x"></i> <i class="fa fa-save fa-stack-1x"></i>
</span> </span>
</a> </a>
</div> </div>
<p class="box-title" >'.Lang::get("storage::lang.storage").'</p> <p class="box-title" >'.Lang::get('storage::lang.storage').'</p>
</div> </div>
</div>'; </div>';
} }
public function settings() { public function settings()
{
try { try {
$settings = new CommonSettings(); $settings = new CommonSettings();
$directories = $this->directories(); $directories = $this->directories();
@@ -42,13 +44,15 @@ class SettingsController extends Controller {
if ($ro) { if ($ro) {
$root = $ro->option_value; $root = $ro->option_value;
} }
return view('storage::settings', compact('default', 'root', 'directories')); return view('storage::settings', compact('default', 'root', 'directories'));
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function postSettings(Request $request) { public function postSettings(Request $request)
{
try { try {
$requests = $request->except('_token'); $requests = $request->except('_token');
$this->delete(); $this->delete();
@@ -59,13 +63,15 @@ class SettingsController extends Controller {
} }
} }
} }
return redirect()->back()->with('success', 'Updated'); return redirect()->back()->with('success', 'Updated');
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function delete() { public function delete()
{
$settings = CommonSettings::where('option_name', 'storage')->get(); $settings = CommonSettings::where('option_name', 'storage')->get();
if ($settings->count() > 0) { if ($settings->count() > 0) {
foreach ($settings as $setting) { foreach ($settings as $setting) {
@@ -74,16 +80,18 @@ class SettingsController extends Controller {
} }
} }
public function save($key, $value) { public function save($key, $value)
{
CommonSettings::create([ CommonSettings::create([
'option_name' => 'storage', 'option_name' => 'storage',
'optional_field' => $key, 'optional_field' => $key,
'option_value' => $value, 'option_value' => $value,
]); ]);
} }
public function directories($root = "") { public function directories($root = '')
if ($root == "") { {
if ($root == '') {
$root = base_path(); $root = base_path();
} }
@@ -91,7 +99,7 @@ class SettingsController extends Controller {
new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied" new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
); );
$paths = array($root); $paths = [$root];
foreach ($iter as $path => $dir) { foreach ($iter as $path => $dir) {
if ($dir->isDir()) { if ($dir->isDir()) {
$paths[$path] = $path; $paths[$path] = $path;
@@ -101,17 +109,18 @@ class SettingsController extends Controller {
return $paths; return $paths;
} }
public function attachment() { public function attachment()
{
$storage = new StorageController(); $storage = new StorageController();
$storage->upload(); $storage->upload();
} }
public function activate(){ public function activate()
$path = "app".DIRECTORY_SEPARATOR."FaveoStorage".DIRECTORY_SEPARATOR."database".DIRECTORY_SEPARATOR."migrations"; {
Artisan::call('migrate', [ $path = 'app'.DIRECTORY_SEPARATOR.'FaveoStorage'.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'migrations';
Artisan::call('migrate', [
'--path' => $path, '--path' => $path,
'--force'=>true, '--force'=> true,
]); ]);
} }
} }

View File

@@ -2,15 +2,15 @@
namespace App\FaveoStorage\Controllers; namespace App\FaveoStorage\Controllers;
use Storage;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Config; use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Ticket\Ticket_attachments; use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_Thread; use App\Model\helpdesk\Ticket\Ticket_Thread;
use Config;
use Storage;
class StorageController extends Controller { class StorageController extends Controller
{
protected $default; protected $default;
protected $driver; protected $driver;
protected $root; protected $root;
@@ -25,7 +25,8 @@ class StorageController extends Controller {
protected $rackspace_endpoint; protected $rackspace_endpoint;
protected $rackspace_url_type; protected $rackspace_url_type;
public function __construct() { public function __construct()
{
$this->default = $this->defaults(); $this->default = $this->defaults();
$this->driver = $this->driver(); $this->driver = $this->driver();
$this->root = $this->root(); $this->root = $this->root();
@@ -40,77 +41,95 @@ class StorageController extends Controller {
$this->rackspace_username = $this->rackspaceUsername(); $this->rackspace_username = $this->rackspaceUsername();
} }
protected function settings($option) { protected function settings($option)
{
$settings = new CommonSettings(); $settings = new CommonSettings();
$setting = $settings->getOptionValue('storage', $option); $setting = $settings->getOptionValue('storage', $option);
$value = ""; $value = '';
if ($setting) { if ($setting) {
$value = $setting->option_value; $value = $setting->option_value;
} }
return $value; return $value;
} }
public function defaults() { public function defaults()
$default = "local"; {
$default = 'local';
if ($this->settings('default')) { if ($this->settings('default')) {
$default = $this->settings('default'); $default = $this->settings('default');
} }
return $default; return $default;
} }
public function driver() { public function driver()
{
return $this->settings('default'); return $this->settings('default');
} }
public function root() { public function root()
{
$root = storage_path('app'); $root = storage_path('app');
if ($this->settings('root')) { if ($this->settings('root')) {
$root = $this->settings('root'); $root = $this->settings('root');
} }
return $root; return $root;
} }
public function s3Key() { public function s3Key()
{
return $this->settings('s3_key'); return $this->settings('s3_key');
} }
public function s3Region() { public function s3Region()
{
return $this->settings('s3_region'); return $this->settings('s3_region');
} }
public function s3Secret() { public function s3Secret()
{
return $this->settings('s3_secret'); return $this->settings('s3_secret');
} }
public function s3Bucket() { public function s3Bucket()
{
return $this->settings('s3_bucket'); return $this->settings('s3_bucket');
} }
public function rackspaceKey() { public function rackspaceKey()
{
return $this->settings('root'); return $this->settings('root');
} }
public function rackspaceRegion() { public function rackspaceRegion()
{
return $this->settings('rackspace_region'); return $this->settings('rackspace_region');
} }
public function rackspaceUsername() { public function rackspaceUsername()
{
return $this->settings('rackspace_username'); return $this->settings('rackspace_username');
} }
public function rackspaceContainer() { public function rackspaceContainer()
{
return $this->settings('rackspace_container'); return $this->settings('rackspace_container');
} }
public function rackspaceEndpoint() { public function rackspaceEndpoint()
{
return $this->settings('rackspace_endpoint'); return $this->settings('rackspace_endpoint');
} }
public function rackspaceUrlType() { public function rackspaceUrlType()
{
return $this->settings('rackspace_url_type'); return $this->settings('rackspace_url_type');
} }
protected function setFileSystem() { protected function setFileSystem()
{
$config = $this->config(); $config = $this->config();
//dd($config); //dd($config);
foreach ($config as $key => $con) { foreach ($config as $key => $con) {
@@ -121,43 +140,47 @@ class StorageController extends Controller {
} }
Config::set("filesystem.$key", $con); Config::set("filesystem.$key", $con);
} }
return Config::get('filesystem'); return Config::get('filesystem');
} }
protected function config() { protected function config()
{
return [ return [
'default' => $this->default, 'default' => $this->default,
'cloud' => 's3', 'cloud' => 's3',
'disks' => $this->disks(), 'disks' => $this->disks(),
]; ];
} }
protected function disks() { protected function disks()
{
return [ return [
"local" => [ 'local' => [
'driver' => "local", 'driver' => 'local',
'root' => $this->root . '/attachments', 'root' => $this->root.'/attachments',
], ],
"s3" => [ 's3' => [
'driver' => "s3", 'driver' => 's3',
'key' => $this->s3_key, 'key' => $this->s3_key,
'secret' => $this->s3_secret, 'secret' => $this->s3_secret,
'region' => $this->s3_region, 'region' => $this->s3_region,
'bucket' => $this->s3_bucket, 'bucket' => $this->s3_bucket,
], ],
"rackspace" => [ 'rackspace' => [
'driver' => "rackspace", 'driver' => 'rackspace',
'username' => $this->rackspace_username, 'username' => $this->rackspace_username,
'key' => $this->rackspace_key, 'key' => $this->rackspace_key,
'container' => $this->rackspace_container, 'container' => $this->rackspace_container,
'endpoint' => $this->rackspace_endpoint, 'endpoint' => $this->rackspace_endpoint,
'region' => $this->rackspace_region, 'region' => $this->rackspace_region,
'url_type' => $this->rackspace_url_type, 'url_type' => $this->rackspace_url_type,
], ],
]; ];
} }
public function upload($data, $filename, $type, $size, $disposition, $thread_id) { public function upload($data, $filename, $type, $size, $disposition, $thread_id)
{
$upload = new Ticket_attachments(); $upload = new Ticket_attachments();
$upload->thread_id = $thread_id; $upload->thread_id = $thread_id;
$upload->name = $filename; $upload->name = $filename;
@@ -166,7 +189,7 @@ class StorageController extends Controller {
$upload->poster = $disposition; $upload->poster = $disposition;
$upload->driver = $this->default; $upload->driver = $this->default;
$upload->path = $this->root; $upload->path = $this->root;
if ($this->default !== "database") { if ($this->default !== 'database') {
$this->setFileSystem(); $this->setFileSystem();
Storage::disk($this->default)->put($filename, $data); Storage::disk($this->default)->put($filename, $data);
} else { } else {
@@ -177,7 +200,8 @@ class StorageController extends Controller {
} }
} }
public function saveAttachments($thread_id, $attachments = []) { public function saveAttachments($thread_id, $attachments = [])
{
if (is_array($attachments) && count($attachments) > 0) { if (is_array($attachments) && count($attachments) > 0) {
foreach ($attachments as $attachment) { foreach ($attachments as $attachment) {
$structure = $attachment->getStructure(); $structure = $attachment->getStructure();
@@ -185,7 +209,7 @@ class StorageController extends Controller {
if (isset($structure->disposition)) { if (isset($structure->disposition)) {
$disposition = $structure->disposition; $disposition = $structure->disposition;
} }
$filename = str_random(16) . '-' . $attachment->getFileName(); $filename = str_random(16).'-'.$attachment->getFileName();
$type = $attachment->getMimeType(); $type = $attachment->getMimeType();
$size = $attachment->getSize(); $size = $attachment->getSize();
$data = $attachment->getData(); $data = $attachment->getData();
@@ -195,31 +219,32 @@ class StorageController extends Controller {
} }
} }
public function updateBody($attachment, $thread_id, $filename) { public function updateBody($attachment, $thread_id, $filename)
{
$structure = $attachment->getStructure(); $structure = $attachment->getStructure();
$disposition = 'ATTACHMENT'; $disposition = 'ATTACHMENT';
if (isset($structure->disposition)) { if (isset($structure->disposition)) {
$disposition = $structure->disposition; $disposition = $structure->disposition;
} }
if ($disposition == 'INLINE' || $disposition == 'inline') { if ($disposition == 'INLINE' || $disposition == 'inline') {
$id = str_replace(">", "", str_replace("<", "", $structure->id)); $id = str_replace('>', '', str_replace('<', '', $structure->id));
$threads = new Ticket_Thread(); $threads = new Ticket_Thread();
$thread = $threads->find($thread_id); $thread = $threads->find($thread_id);
$body = $thread->body; $body = $thread->body;
$body = str_replace('cid:' . $id, $filename, $body); $body = str_replace('cid:'.$id, $filename, $body);
$thread->body = $body; $thread->body = $body;
$thread->save(); $thread->save();
} }
} }
public function getFile($drive, $name) { public function getFile($drive, $name)
{
//dd($drive,$name); //dd($drive,$name);
if ($drive != "database") { if ($drive != 'database') {
$this->setFileSystem(); $this->setFileSystem();
if(Storage::disk($this->default)->exists($name)){ if (Storage::disk($this->default)->exists($name)) {
return Storage::disk($this->default)->get($name); return Storage::disk($this->default)->get($name);
} }
} }
} }
} }

View File

@@ -4,20 +4,20 @@ namespace App\FaveoStorage;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class StorageServiceProvider extends ServiceProvider { class StorageServiceProvider extends ServiceProvider
{
/** /**
* Bootstrap the application events. * Bootstrap the application events.
* *
* @return void * @return void
*/ */
public function boot() { public function boot()
{
$view_path = app_path() . DIRECTORY_SEPARATOR . 'FaveoStorage' . DIRECTORY_SEPARATOR . 'views'; $view_path = app_path().DIRECTORY_SEPARATOR.'FaveoStorage'.DIRECTORY_SEPARATOR.'views';
$this->loadViewsFrom($view_path, 'storage'); $this->loadViewsFrom($view_path, 'storage');
$lang_path = app_path() . DIRECTORY_SEPARATOR . 'FaveoStorage' . DIRECTORY_SEPARATOR . 'lang'; $lang_path = app_path().DIRECTORY_SEPARATOR.'FaveoStorage'.DIRECTORY_SEPARATOR.'lang';
$this->loadTranslationsFrom($lang_path, "storage"); $this->loadTranslationsFrom($lang_path, 'storage');
if (isInstall()) { if (isInstall()) {
$controller = new Controllers\SettingsController(); $controller = new Controllers\SettingsController();
@@ -25,7 +25,7 @@ class StorageServiceProvider extends ServiceProvider {
} }
if (class_exists('Breadcrumbs')) { if (class_exists('Breadcrumbs')) {
require __DIR__ . '/breadcrumbs.php'; require __DIR__.'/breadcrumbs.php';
} }
} }
@@ -44,5 +44,4 @@ class StorageServiceProvider extends ServiceProvider {
} }
} }
} }
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
Breadcrumbs::register('storage', function($breadcrumbs)
{ Breadcrumbs::register('storage', function ($breadcrumbs) {
$breadcrumbs->parent('setting'); $breadcrumbs->parent('setting');
$breadcrumbs->push('Storage', route('storage')); $breadcrumbs->push('Storage', route('storage'));
}); });

View File

@@ -1,7 +1,7 @@
<?php <?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterAttachmentTable extends Migration class AlterAttachmentTable extends Migration
{ {

View File

@@ -1,17 +1,16 @@
<?php <?php
return [ return [
'settings'=>'Settings', 'settings' => 'Settings',
'storage'=>'Storage', 'storage' => 'Storage',
'default'=>'Default', 'default' => 'Default',
'root'=>'Root', 'root' => 'Root',
'region'=>'Region', 'region' => 'Region',
'key'=>'Key', 'key' => 'Key',
'secret'=>'Secret', 'secret' => 'Secret',
'bucket'=>'Bucket', 'bucket' => 'Bucket',
'username'=>'Username', 'username' => 'Username',
'container'=>'Container', 'container'=> 'Container',
'endpoint'=>'End Point', 'endpoint' => 'End Point',
'url_type'=>'Url Type', 'url_type' => 'Url Type',
]; ];

View File

@@ -1,16 +1,12 @@
<?php <?php
\Event::listen('settings.system',function(){ \Event::listen('settings.system', function () {
$controller = new \App\FaveoStorage\Controllers\SettingsController(); $controller = new \App\FaveoStorage\Controllers\SettingsController();
echo $controller->settingsIcon(); echo $controller->settingsIcon();
}); });
Route::group(['middleware'=>['web']], function () {
Route::group(['middleware'=>['web']],function(){ Route::get('storage', ['as'=>'storage', 'uses'=>'App\FaveoStorage\Controllers\SettingsController@settings']);
Route::get('storage',['as'=>'storage','uses'=>'App\FaveoStorage\Controllers\SettingsController@settings']); Route::post('storage', ['as'=>'post.storage', 'uses'=>'App\FaveoStorage\Controllers\SettingsController@postSettings']);
Route::post('storage',['as'=>'post.storage','uses'=>'App\FaveoStorage\Controllers\SettingsController@postSettings']); Route::get('attachment', ['as'=>'attach', 'uses'=>'App\FaveoStorage\Controllers\SettingsController@attachment']);
Route::get('attachment',['as'=>'attach','uses'=>'App\FaveoStorage\Controllers\SettingsController@attachment']);
}); });

View File

@@ -4,156 +4,181 @@ namespace App\Helper;
use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Agent\Groups; use App\Model\helpdesk\Agent\Groups;
use App\Model\helpdesk\Ticket\TicketStatusType;
use App\Model\helpdesk\Ticket\Ticket_Status; use App\Model\helpdesk\Ticket\Ticket_Status;
use App\Model\helpdesk\Ticket\TicketStatusType;
/** /**
*------------------------------------------------------------------ *------------------------------------------------------------------
* Class Finder * Class Finder
*------------------------------------------------------------------ *------------------------------------------------------------------
* Description: This class is used for defining some common functions * Description: This class is used for defining some common functions
* used in the project. * used in the project.
* *
* @author <Ladybird Web Solution> * @author <Ladybird Web Solution>
*/ */
class Finder class Finder
{ {
/**
/** * DEPARTMENT
* DEPARTMENT * This function is used for returning department name with respect to id.
* This function is used for returning department name with respect to id *
* @param $id type int * @param $id type int
* @param $custom type array/null * @param $custom type array/null
* @return type string *
*/ * @return type string
public static function department($id, $custom = null) { */
if($custom == null) { public static function department($id, $custom = null)
$department = Department::whereId($id)->select(['name']); {
} elseif(isset($custom)) { if ($custom == null) {
$department = Department::whereId($id)->select($custom); $department = Department::whereId($id)->select(['name']);
} } elseif (isset($custom)) {
return $department->first()->name; $department = Department::whereId($id)->select($custom);
} }
return $department->first()->name;
}
/**
* GROUP
* This function is used for returning group name with respect to id.
*
* @param $id type int
* @param $custom type array/null
*
* @return type string
*/
public static function group($id, $custom = null)
{
if ($custom == null) {
$group = Groups::whereId($id)->select(['name']);
} elseif (isset($custom)) {
$group = Groups::whereId($id)->select($custom);
}
return $group->first()->name;
}
/**
* GROUP
* This function is used for returning group name with respect to id
* @param $id type int
* @param $custom type array/null
* @return type string
*/
public static function group($id, $custom = null) {
if($custom == null) {
$group = Groups::whereId($id)->select(['name']);
} elseif(isset($custom)) {
$group = Groups::whereId($id)->select($custom);
}
return $group->first()->name;
}
/** /**
* STATUS TYPE * STATUS TYPE
* This function is used for returning status type name with respect to id * This function is used for returning status type name with respect to id.
* @param $id type int *
* @param $custom type array/null * @param $id type int
* @return type string * @param $custom type array/null
*/ *
public static function statusType($id, $custom = null) { * @return type string
if($custom == null) { */
$status_type = TicketStatusType::whereId($id)->select(['name']); public static function statusType($id, $custom = null)
} elseif(isset($custom)) { {
$status_type = TicketStatusType::whereId($id)->select($custom); if ($custom == null) {
} $status_type = TicketStatusType::whereId($id)->select(['name']);
return $status_type->first()->name; } elseif (isset($custom)) {
} $status_type = TicketStatusType::whereId($id)->select($custom);
}
/**
* STATUS
* This function is used for returning status name with respect to id
* @param $id type int
* @param $custom type array/null
* @return type string
*/
public static function status($id, $custom = null) {
if($custom == null) {
$status = Ticket_Status::whereId($id)->first();
} elseif(isset($custom)) {
$status = Ticket_Status::whereId($id)->select($custom);
}
return $status;
}
/** return $status_type->first()->name;
* USER ROLES IN A GROUP FOR STATUS LIST }
* This function is used to return roles of users from a given value.
* If the value is 1 the response is client /**
* If the value is 2 the response is agent * STATUS
* If the value is 4 the response is admin * This function is used for returning status name with respect to id.
* If the value is 1+2 = 3 the response is client, agent *
* If the value is 1+4 = 5 the response is client, admin * @param $id type int
* If the value is 2+4 = 6 the response is agent, admin * @param $custom type array/null
* If the value is 1+2+4 = 7 the response is client, agent, admin *
* @param $id type int * @return type string
* @return type string */
*/ public static function status($id, $custom = null)
public static function rolesGroup($id) { {
if ($custom == null) {
switch ($id) { $status = Ticket_Status::whereId($id)->first();
} elseif (isset($custom)) {
$status = Ticket_Status::whereId($id)->select($custom);
}
return $status;
}
/**
* USER ROLES IN A GROUP FOR STATUS LIST
* This function is used to return roles of users from a given value.
* If the value is 1 the response is client
* If the value is 2 the response is agent
* If the value is 4 the response is admin
* If the value is 1+2 = 3 the response is client, agent
* If the value is 1+4 = 5 the response is client, admin
* If the value is 2+4 = 6 the response is agent, admin
* If the value is 1+2+4 = 7 the response is client, agent, admin.
*
* @param $id type int
*
* @return type string
*/
public static function rolesGroup($id)
{
switch ($id) {
case null: case null:
return \Lang::get('lang.none'); return \Lang::get('lang.none');
case 1: case 1:
return "Client"; return 'Client';
case 2: case 2:
return "Agent"; return 'Agent';
case 4: case 4:
return "Admin"; return 'Admin';
case 3: case 3:
return "Client,Agent"; return 'Client,Agent';
case 5: case 5:
return "Client,Admin"; return 'Client,Admin';
case 6: case 6:
return "Agent,Admin"; return 'Agent,Admin';
case 7: case 7:
return "Client,Agent,Admin"; return 'Client,Agent,Admin';
default: default:
return "Undefined!"; return 'Undefined!';
} }
} }
/** /**
* ANY TYPE STATUS * ANY TYPE STATUS
* This function is used to return the set of status which are of any type passed in the param * This function is used to return the set of status which are of any type passed in the param.
*
* @param type $id * @param type $id
*
* @return type array * @return type array
*/ */
public static function anyTypeStatus($id) { public static function anyTypeStatus($id)
$status_group = Ticket_Status::where('purpose_of_status', '=', $id)->select(['id'])->get(); {
foreach($status_group as $status) { $status_group = Ticket_Status::where('purpose_of_status', '=', $id)->select(['id'])->get();
$status_group2[] = $status->id; foreach ($status_group as $status) {
} $status_group2[] = $status->id;
return $status_group2; }
return $status_group2;
} }
/** /**
* RETURNS ALL STATUS * RETURNS ALL STATUS
* This function is used to return all the status given in the system * This function is used to return all the status given in the system.
*
* @return type array * @return type array
*/ */
public static function getAllStatus() { public static function getAllStatus()
$status = Ticket_Status::where('purpose_of_status', '!=', 3)->orwhere('purpose_of_status', '!=', 4)->get(); {
return $status; $status = Ticket_Status::where('purpose_of_status', '!=', 3)->orwhere('purpose_of_status', '!=', 4)->get();
return $status;
} }
/** /**
* VARIABLE REPLACEMENT * VARIABLE REPLACEMENT
* This function is used to replace the replaceable variables form a given content for templates * This function is used to replace the replaceable variables form a given content for templates.
*
*/ */
public static function replaceTemplateVariables($variables, $data, $contents) { public static function replaceTemplateVariables($variables, $data, $contents)
{
foreach ($variables as $key => $variable) { foreach ($variables as $key => $variable) {
$messagebody = str_replace($variables[$key], $data[$key], $contents); $messagebody = str_replace($variables[$key], $data[$key], $contents);
$contents = $messagebody; $contents = $messagebody;
} }
return $contents; return $contents;
} }
} }

View File

@@ -1,10 +1,13 @@
<?php <?php
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use Fetch\Server as Server; use Fetch\Server as Server;
class MailFetch extends Server{
class MailFetch extends Server
public function __construct($serverPath, $port = 143, $service = 'imap') { {
public function __construct($serverPath, $port = 143, $service = 'imap')
{
$this->serverPath = $serverPath; $this->serverPath = $serverPath;
$this->port = $port; $this->port = $port;

View File

@@ -3,8 +3,8 @@
namespace App\Http\Controllers\Admin\helpdesk; namespace App\Http\Controllers\Admin\helpdesk;
// controller // controller
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Controller;
// request // request
use App\Http\Requests\helpdesk\AgentRequest; use App\Http\Requests\helpdesk\AgentRequest;
use App\Http\Requests\helpdesk\AgentUpdate; use App\Http\Requests\helpdesk\AgentUpdate;
@@ -92,6 +92,7 @@ class AgentController extends Controller
$phonecode = $code->where('iso', '=', $location->iso_code)->first(); $phonecode = $code->where('iso', '=', $location->iso_code)->first();
// returns to the page with all the variables and their datas // returns to the page with all the variables and their datas
$send_otp = DB::table('common_settings')->select('status')->where('option_name', '=', 'send_otp')->first(); $send_otp = DB::table('common_settings')->select('status')->where('option_name', '=', 'send_otp')->first();
return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team', 'send_otp'))->with('phonecode', $phonecode->phonecode); return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team', 'send_otp'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) { } catch (Exception $e) {
// returns if try fails with exception meaagse // returns if try fails with exception meaagse
@@ -120,10 +121,9 @@ class AgentController extends Controller
} }
// fixing the user role to agent // fixing the user role to agent
$user->fill($request->except(['group', 'primary_department', 'agent_time_zone', 'mobile']))->save(); $user->fill($request->except(['group', 'primary_department', 'agent_time_zone', 'mobile']))->save();
if ($request->get('mobile')) if ($request->get('mobile')) {
{
$user->mobile = $request->get('mobile'); $user->mobile = $request->get('mobile');
} else{ } else {
$user->mobile = null; $user->mobile = null;
} }
$user->assign_group = $request->group; $user->assign_group = $request->group;
@@ -146,7 +146,7 @@ class AgentController extends Controller
// fetch user credentails to send mail // fetch user credentails to send mail
$name = $user->first_name; $name = $user->first_name;
$email = $user->email; $email = $user->email;
if($request->input('send_email')) { if ($request->input('send_email')) {
try { try {
// send mail on registration // send mail on registration
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $email], $message = ['subject' => null, 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $email, 'user_password' => $password]); $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $email], $message = ['subject' => null, 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $email, 'user_password' => $password]);
@@ -159,6 +159,7 @@ class AgentController extends Controller
if ($request->input('active') == '0' || $request->input('active') == 0) { if ($request->input('active') == '0' || $request->input('active') == 0) {
\Event::fire(new \App\Events\LoginEvent($request)); \Event::fire(new \App\Events\LoginEvent($request));
} }
return redirect('agents')->with('success', Lang::get('lang.agent_creation_success')); return redirect('agents')->with('success', Lang::get('lang.agent_creation_success'));
} else { } else {
// returns if fails // returns if fails
@@ -275,7 +276,6 @@ class AgentController extends Controller
$user->id; $user->id;
$user->delete(); $user->delete();
throw new \Exception($error); throw new \Exception($error);
return redirect('agents')->with('success', Lang::get('lang.agent_deleted_sucessfully')); return redirect('agents')->with('success', Lang::get('lang.agent_deleted_sucessfully'));
} catch (\Exception $e) { } catch (\Exception $e) {
return redirect('agents')->with('fails', $error); return redirect('agents')->with('fails', $error);

View File

@@ -29,14 +29,15 @@ use Lang;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class DepartmentController extends Controller { class DepartmentController extends Controller
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* *
* @return void * @return void
*/ */
public function __construct() { public function __construct()
{
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
@@ -48,9 +49,11 @@ class DepartmentController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function index(Department $department) { public function index(Department $department)
{
try { try {
$departments = $department->get(); $departments = $department->get();
return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments')); return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments'));
} catch (Exception $e) { } catch (Exception $e) {
return view('404'); return view('404');
@@ -70,14 +73,15 @@ class DepartmentController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group) { public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group)
{
try { try {
$slas = $sla->where('status', '=', 1) $slas = $sla->where('status', '=', 1)
->select('grace_period','id')->get(); ->select('grace_period', 'id')->get();
$user = $user->where('role', '<>', 'user') $user = $user->where('role', '<>', 'user')
->where('active', '=', 1) ->where('active', '=', 1)
->get(); ->get();
$emails = $email->select('email_name','id')->get(); $emails = $email->select('email_name', 'id')->get();
$templates = $template->get(); $templates = $template->get();
$department = $department->get(); $department = $department->get();
$groups = $group->lists('id', 'name'); $groups = $group->lists('id', 'name');
@@ -96,7 +100,8 @@ class DepartmentController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function store(Department $department, DepartmentRequest $request) { public function store(Department $department, DepartmentRequest $request)
{
try { try {
$department->fill($request->except('group_id', 'manager', 'sla'))->save(); $department->fill($request->except('group_id', 'manager', 'sla'))->save();
if ($request->sla) { if ($request->sla) {
@@ -119,6 +124,7 @@ class DepartmentController extends Controller {
->where('id', 1) ->where('id', 1)
->update(['department' => $department->id]); ->update(['department' => $department->id]);
} }
return redirect('departments')->with('success', Lang::get('lang.department_created_sucessfully')); return redirect('departments')->with('success', Lang::get('lang.department_created_sucessfully'));
} else { } else {
return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department')); return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department'));
@@ -143,18 +149,19 @@ class DepartmentController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group) { public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group)
{
try { try {
$sys_department = \DB::table('settings_system') $sys_department = \DB::table('settings_system')
->select('department') ->select('department')
->where('id', '=', 1) ->where('id', '=', 1)
->first(); ->first();
$slas = $sla->where('status', '=', 1) $slas = $sla->where('status', '=', 1)
->select('grace_period','id')->get(); ->select('grace_period', 'id')->get();
$user = $user->where('primary_dpt', $id) $user = $user->where('primary_dpt', $id)
->where('active', '=', 1) ->where('active', '=', 1)
->get(); ->get();
$emails = $email->select('email_name','id')->get(); $emails = $email->select('email_name', 'id')->get();
$templates = $template->get(); $templates = $template->get();
$departments = $department->whereId($id)->first(); $departments = $department->whereId($id)->first();
//$groups = $group->lists('id', 'name'); //$groups = $group->lists('id', 'name');
@@ -176,7 +183,8 @@ class DepartmentController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) { public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request)
{
// dd($id); // dd($id);
try { try {
$table = $group_assign_department->where('department_id', $id); $table = $group_assign_department->where('department_id', $id);
@@ -224,9 +232,10 @@ class DepartmentController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets) { public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets)
{
// try { // try {
$system = $system->where('id', '=', '1')->first(); $system = $system->where('id', '=', '1')->first();
if ($system->department == $id) { if ($system->department == $id) {
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department')); return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
@@ -238,7 +247,7 @@ class DepartmentController extends Controller {
} else { } else {
$text_tickets = 'Ticket'; $text_tickets = 'Ticket';
} }
$ticket = '<li>' . $tickets . ' ' . $text_tickets . Lang::get('lang.have_been_moved_to_default_department') . '</li>'; $ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_department').'</li>';
} else { } else {
$ticket = ''; $ticket = '';
} }
@@ -249,7 +258,7 @@ class DepartmentController extends Controller {
} else { } else {
$text_user = 'User'; $text_user = 'User';
} }
$user = '<li>' . $users . ' ' . $text_user . Lang::get('lang.have_been_moved_to_default_department') . '</li>'; $user = '<li>'.$users.' '.$text_user.Lang::get('lang.have_been_moved_to_default_department').'</li>';
} else { } else {
$user = ''; $user = '';
} }
@@ -260,28 +269,27 @@ class DepartmentController extends Controller {
} else { } else {
$text_emails = 'Email'; $text_emails = 'Email';
} }
$email = '<li>' . $emails . ' System ' . $text_emails . Lang::get('lang.have_been_moved_to_default_department') . ' </li>'; $email = '<li>'.$emails.' System '.$text_emails.Lang::get('lang.have_been_moved_to_default_department').' </li>';
} else { } else {
$email = ''; $email = '';
} }
$helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']); $helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']);
if ($helptopic > 0) { if ($helptopic > 0) {
$helptopic = '<li>' . Lang::get('lang.the_associated_helptopic_has_been_deactivated') . '</li>'; $helptopic = '<li>'.Lang::get('lang.the_associated_helptopic_has_been_deactivated').'</li>';
} else { } else {
$helptopic = ''; $helptopic = '';
} }
$message = $ticket . $user . $email . $helptopic; $message = $ticket.$user.$email.$helptopic;
/* Becouse of foreign key we delete group_assign_department first */ /* Becouse of foreign key we delete group_assign_department first */
$group_assign_department = $group_assign_department->where('department_id', $id); $group_assign_department = $group_assign_department->where('department_id', $id);
$group_assign_department->delete(); $group_assign_department->delete();
$departments = $department->whereId($id)->first(); $departments = $department->whereId($id)->first();
/* Check the function is Success or Fail */ /* Check the function is Success or Fail */
if ($departments->delete() == true) { if ($departments->delete() == true) {
return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully') . $message); return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully').$message);
} else { } else {
return redirect('departments')->with('fails', Lang::get('lang.department_can_not_delete')); return redirect('departments')->with('fails', Lang::get('lang.department_can_not_delete'));
} }
} }
} }
} }

View File

@@ -3,21 +3,21 @@
namespace App\Http\Controllers\Admin\helpdesk; namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Admin\MailFetch as Fetch;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\helpdesk\EmailsRequest; use App\Http\Requests\helpdesk\EmailsRequest;
use App\Model\helpdesk\Agent\Department;
// model // model
use App\Http\Requests\helpdesk\Mail\MailRequest;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Settings\Email; use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Ticket_Priority; use App\Model\helpdesk\Ticket\Ticket_Priority;
// classes
use App\Model\helpdesk\Utility\MailboxProtocol; use App\Model\helpdesk\Utility\MailboxProtocol;
use Crypt; use Crypt;
// classes
use Exception; use Exception;
use Lang; use Lang;
use App\Http\Requests\helpdesk\Mail\MailRequest;
use App\Http\Controllers\Admin\MailFetch as Fetch;
/** /**
* ====================================== * ======================================
@@ -27,14 +27,15 @@ use App\Http\Controllers\Admin\MailFetch as Fetch;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class EmailsController extends Controller { class EmailsController extends Controller
{
/** /**
* Defining constructor variables. * Defining constructor variables.
* *
* @return type * @return type
*/ */
public function __construct() { public function __construct()
{
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
@@ -46,7 +47,8 @@ class EmailsController extends Controller {
* *
* @return type view * @return type view
*/ */
public function index(Emails $email) { public function index(Emails $email)
{
try { try {
// fetch all the emails from emails table // fetch all the emails from emails table
$emails = $email->get(); $emails = $email->get();
@@ -67,7 +69,8 @@ class EmailsController extends Controller {
* *
* @return type Response * @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 { try {
// fetch all the departments from the department table // fetch all the departments from the department table
$departments = $department->get(); $departments = $department->get();
@@ -96,7 +99,8 @@ class EmailsController extends Controller {
* *
* @return int * @return int
*/ */
public function validatingEmailSettings(MailRequest $request, $id = "") { public function validatingEmailSettings(MailRequest $request, $id = '')
{
//dd($request->all()); //dd($request->all());
try { try {
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code'); $service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code');
@@ -114,8 +118,10 @@ class EmailsController extends Controller {
} }
if ($send == 1 && $fetch == 1) { if ($send == 1 && $fetch == 1) {
$this->store($request, $service_request, $id); $this->store($request, $service_request, $id);
return $this->jsonResponse('success', Lang::get('lang.success')); return $this->jsonResponse('success', Lang::get('lang.success'));
} }
return $this->validateEmailError($send, $fetch); return $this->validateEmailError($send, $fetch);
} catch (Exception $ex) { } catch (Exception $ex) {
$message = $ex->getMessage(); $message = $ex->getMessage();
@@ -123,11 +129,13 @@ class EmailsController extends Controller {
$message = imap_last_error(); $message = imap_last_error();
} }
loging('mail-config', $message); loging('mail-config', $message);
return $this->jsonResponse('fails', $message); return $this->jsonResponse('fails', $message);
} }
} }
public function validateEmailError($out, $in) { public function validateEmailError($out, $in)
{
if ($out !== 1) { if ($out !== 1) {
return $this->jsonResponse('fails', Lang::get('lang.outgoing_email_connection_failed')); return $this->jsonResponse('fails', Lang::get('lang.outgoing_email_connection_failed'));
} }
@@ -136,13 +144,15 @@ class EmailsController extends Controller {
} }
} }
public function jsonResponse($type, $message) { public function jsonResponse($type, $message)
{
if ($type == 'fails') { if ($type == 'fails') {
$result = ['fails' => $message]; $result = ['fails' => $message];
} }
if ($type == 'success') { if ($type == 'success') {
$result = ['success' => $message]; $result = ['success' => $message];
} }
return response()->json(compact('result')); return response()->json(compact('result'));
} }
@@ -154,9 +164,10 @@ class EmailsController extends Controller {
* *
* @return type Redirect * @return type Redirect
*/ */
public function store($request, $service_request = [], $id = "") { public function store($request, $service_request = [], $id = '')
{
$email = new Emails(); $email = new Emails();
if ($id !== "") { if ($id !== '') {
$email = $email->find($id); $email = $email->find($id);
} }
@@ -208,7 +219,7 @@ class EmailsController extends Controller {
if ($request->input('fetching_status')) { if ($request->input('fetching_status')) {
$this->fetch($email); $this->fetch($email);
} }
if ($id === "") { if ($id === '') {
// Creating a default system email as the first email is inserted to the system // Creating a default system email as the first email is inserted to the system
$email_settings = Email::where('id', '=', '1')->first(); $email_settings = Email::where('id', '=', '1')->first();
$email_settings->sys_email = $email->id; $email_settings->sys_email = $email->id;
@@ -222,10 +233,12 @@ class EmailsController extends Controller {
if ($request->input('fetching_status')) { if ($request->input('fetching_status')) {
$this->fetch($email); $this->fetch($email);
} }
return 1; return 1;
} }
public function checkMail($request) { public function checkMail($request)
{
$mailservice_id = $request->input('sending_protocol'); $mailservice_id = $request->input('sending_protocol');
$driver = $this->getDriver($mailservice_id); $driver = $this->getDriver($mailservice_id);
$username = $request->input('email_address'); $username = $request->input('email_address');
@@ -243,10 +256,12 @@ class EmailsController extends Controller {
$transport->setPassword($password); $transport->setPassword($password);
$mailer = \Swift_Mailer::newInstance($transport); $mailer = \Swift_Mailer::newInstance($transport);
$mailer->getTransport()->start(); $mailer->getTransport()->start();
return 1; return 1;
} }
public function sendDiagnoEmail($request) { public function sendDiagnoEmail($request)
{
$mailservice_id = $request->input('sending_protocol'); $mailservice_id = $request->input('sending_protocol');
$driver = $this->getDriver($mailservice_id); $driver = $this->getDriver($mailservice_id);
$username = $request->input('email_address'); $username = $request->input('email_address');
@@ -260,41 +275,45 @@ class EmailsController extends Controller {
$this->emailService($driver, $service_request); $this->emailService($driver, $service_request);
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port); $this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
$controller = new \App\Http\Controllers\Common\PhpMailController(); $controller = new \App\Http\Controllers\Common\PhpMailController();
$subject = "test"; $subject = 'test';
$data = "test"; $data = 'test';
//dd(\Config::get('mail'),\Config::get('services')); //dd(\Config::get('mail'),\Config::get('services'));
$send = $controller->laravelMail($username, $name, $subject, $data, [], []); $send = $controller->laravelMail($username, $name, $subject, $data, [], []);
return $send; return $send;
} }
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port) { public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port)
{
$configs = [ $configs = [
'username' => $username, 'username' => $username,
'from' => ['address' => $username, 'name' => $name,], 'from' => ['address' => $username, 'name' => $name],
'password' => $password, 'password' => $password,
'encryption' => $enc, 'encryption' => $enc,
'host' => $host, 'host' => $host,
'port' => $port, 'port' => $port,
'driver' => $driver, 'driver' => $driver,
]; ];
foreach ($configs as $key => $config) { foreach ($configs as $key => $config) {
if (is_array($config)) { if (is_array($config)) {
foreach ($config as $from) { foreach ($config as $from) {
\Config::set('mail.' . $key, $config); \Config::set('mail.'.$key, $config);
} }
} else { } else {
\Config::set('mail.' . $key, $config); \Config::set('mail.'.$key, $config);
} }
} }
} }
public function getDriver($driver_id) { public function getDriver($driver_id)
$short = ""; {
$short = '';
$email_drivers = new \App\Model\MailJob\MailService(); $email_drivers = new \App\Model\MailJob\MailService();
$email_driver = $email_drivers->find($driver_id); $email_driver = $email_drivers->find($driver_id);
if ($email_driver) { if ($email_driver) {
$short = $email_driver->short_name; $short = $email_driver->short_name;
} }
return $short; return $short;
} }
@@ -310,7 +329,8 @@ class EmailsController extends Controller {
* *
* @return type Response * @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 { try {
$sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first(); $sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first();
// dd($sys_email); // dd($sys_email);
@@ -345,7 +365,8 @@ class EmailsController extends Controller {
* *
* @return int * @return int
*/ */
public function validatingEmailSettingsUpdate($id, MailRequest $request) { public function validatingEmailSettingsUpdate($id, MailRequest $request)
{
try { try {
return $this->validatingEmailSettings($request, $id); return $this->validatingEmailSettings($request, $id);
} catch (Exception $ex) { } catch (Exception $ex) {
@@ -369,9 +390,9 @@ class EmailsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function update($id, $request) { public function update($id, $request)
{
try { try {
if ($request->sys_email == 'on') { if ($request->sys_email == 'on') {
$system = \DB::table('settings_email') $system = \DB::table('settings_email')
->where('id', '=', 1) ->where('id', '=', 1)
@@ -397,7 +418,8 @@ class EmailsController extends Controller {
* *
* @return type Redirect * @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 // fetching the details on the basis of the $id passed to the function
$default_system_email = Email::where('id', '=', '1')->first(); $default_system_email = Email::where('id', '=', '1')->first();
if ($default_system_email->sys_email) { if ($default_system_email->sys_email) {
@@ -411,6 +433,7 @@ class EmailsController extends Controller {
$emails = $email->whereId($id)->first(); $emails = $email->whereId($id)->first();
// checking if deleting the email is success or if it's carrying any dependencies // checking if deleting the email is success or if it's carrying any dependencies
$emails->delete(); $emails->delete();
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully')); return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
} catch (Exception $e) { } catch (Exception $e) {
// returns if the try fails // returns if the try fails
@@ -425,7 +448,8 @@ class EmailsController extends Controller {
* *
* @return type int * @return type int
*/ */
public function getImapStream($request) { public function getImapStream($request)
{
$host = $request->input('fetching_host'); $host = $request->input('fetching_host');
$port = $request->input('fetching_port'); $port = $request->input('fetching_port');
$service = $request->input('fetching_protocol'); $service = $request->input('fetching_protocol');
@@ -435,7 +459,7 @@ class EmailsController extends Controller {
$password = $request->input('password'); $password = $request->input('password');
$server = new Fetch($host, $port, $service); $server = new Fetch($host, $port, $service);
//$server->setFlag('novalidate-cert'); //$server->setFlag('novalidate-cert');
if ($encryption != "") { if ($encryption != '') {
$server->setFlag($encryption); $server->setFlag($encryption);
} }
if (!$validate) { if (!$validate) {
@@ -446,6 +470,7 @@ class EmailsController extends Controller {
$server->setAuthentication($username, $password); $server->setAuthentication($username, $password);
$server->getImapStream(); $server->getImapStream();
return 1; return 1;
} }
@@ -456,7 +481,8 @@ class EmailsController extends Controller {
* *
* @return type int * @return type int
*/ */
public function checkImapStream($imap_stream) { public function checkImapStream($imap_stream)
{
$check_imap_stream = imap_check($imap_stream); $check_imap_stream = imap_check($imap_stream);
if ($check_imap_stream) { if ($check_imap_stream) {
$imap_stream = 1; $imap_stream = 1;
@@ -474,7 +500,8 @@ class EmailsController extends Controller {
* *
* @return int * @return int
*/ */
public function getSmtp($request) { public function getSmtp($request)
{
$sending_status = $request->input('sending_status'); $sending_status = $request->input('sending_status');
// cheking for the sending protocol // cheking for the sending protocol
if ($request->input('sending_protocol') == 'smtp') { if ($request->input('sending_protocol') == 'smtp') {
@@ -490,8 +517,8 @@ class EmailsController extends Controller {
$mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPAuth = true; // Enable SMTP authentication
$mail->SMTPOptions = [ $mail->SMTPOptions = [
'ssl' => [ 'ssl' => [
'verify_peer' => false, 'verify_peer' => false,
'verify_peer_name' => false, 'verify_peer_name' => false,
'allow_self_signed' => true, 'allow_self_signed' => true,
], ],
]; ];
@@ -523,7 +550,8 @@ class EmailsController extends Controller {
* *
* @return type string or null * @return type string or null
*/ */
public function departmentValue($dept) { public function departmentValue($dept)
{
if ($dept) { if ($dept) {
$email_department = $dept; $email_department = $dept;
} else { } else {
@@ -540,7 +568,8 @@ class EmailsController extends Controller {
* *
* @return type string or null * @return type string or null
*/ */
public function priorityValue($priority) { public function priorityValue($priority)
{
if ($priority) { if ($priority) {
$email_priority = $priority; $email_priority = $priority;
} else { } else {
@@ -557,7 +586,8 @@ class EmailsController extends Controller {
* *
* @return type string or null * @return type string or null
*/ */
public function helpTopicValue($help_topic) { public function helpTopicValue($help_topic)
{
if ($help_topic) { if ($help_topic) {
$email_help_topic = $help_topic; $email_help_topic = $help_topic;
} else { } else {
@@ -567,18 +597,20 @@ class EmailsController extends Controller {
return $email_help_topic; return $email_help_topic;
} }
public function emailService($service, $value = []) { public function emailService($service, $value = [])
{
switch ($service) { switch ($service) {
case "mailgun": case 'mailgun':
$this->setServiceConfig($service, $value); $this->setServiceConfig($service, $value);
case "mandrill": case 'mandrill':
$this->setServiceConfig($service, $value); $this->setServiceConfig($service, $value);
case "ses": case 'ses':
$this->setServiceConfig($service, $value); $this->setServiceConfig($service, $value);
} }
} }
public function setServiceConfig($service, $value) { public function setServiceConfig($service, $value)
{
//dd($service); //dd($service);
if (count($value) > 0) { if (count($value) > 0) {
foreach ($value as $k => $v) { foreach ($value as $k => $v) {
@@ -587,7 +619,8 @@ class EmailsController extends Controller {
} }
} }
public function saveMailService($emailid, $request, $driver) { public function saveMailService($emailid, $request, $driver)
{
$mail_service = new \App\Model\MailJob\FaveoMail(); $mail_service = new \App\Model\MailJob\FaveoMail();
$mails = $mail_service->where('email_id', $emailid)->get(); $mails = $mail_service->where('email_id', $emailid)->get();
if (count($request) > 0) { if (count($request) > 0) {
@@ -596,16 +629,17 @@ class EmailsController extends Controller {
} }
foreach ($request as $key => $value) { foreach ($request as $key => $value) {
$mail_service->create([ $mail_service->create([
'drive' => $driver, 'drive' => $driver,
'key' => $key, 'key' => $key,
'value' => $value, 'value' => $value,
'email_id' => $emailid, 'email_id' => $emailid,
]); ]);
} }
} }
} }
public function readMails() { public function readMails()
{
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController(); $PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController(); $NotificationController = new \App\Http\Controllers\Common\NotificationController();
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController); $TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
@@ -618,7 +652,8 @@ class EmailsController extends Controller {
$controller->readmails($emails, $settings_email, $system, $ticket); $controller->readmails($emails, $settings_email, $system, $ticket);
} }
public function fetch($email) { public function fetch($email)
{
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController(); $PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController(); $NotificationController = new \App\Http\Controllers\Common\NotificationController();
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController); $TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
@@ -626,5 +661,4 @@ class EmailsController extends Controller {
$controller = new \App\Http\Controllers\Agent\helpdesk\MailController($TicketWorkflowController); $controller = new \App\Http\Controllers\Agent\helpdesk\MailController($TicketWorkflowController);
$controller->fetch($email); $controller->fetch($email);
} }
} }

View File

@@ -9,13 +9,13 @@ use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Form\Forms; use App\Model\helpdesk\Form\Forms;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
// Request // Request
use Illuminate\Http\Request; use Exception;
// Class // Class
use Form;
use Illuminate\Http\Request;
use Input; use Input;
use Lang; use Lang;
use Redirect; use Redirect;
use Exception;
use Form;
/** /**
* FormController * FormController
@@ -23,12 +23,13 @@ use Form;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class FormController extends Controller { class FormController extends Controller
{
private $fields; private $fields;
private $forms; private $forms;
public function __construct(Fields $fields, Forms $forms) { public function __construct(Fields $fields, Forms $forms)
{
$this->fields = $fields; $this->fields = $fields;
$this->forms = $forms; $this->forms = $forms;
$this->middleware('auth', [ $this->middleware('auth', [
@@ -43,7 +44,7 @@ class FormController extends Controller {
'jqueryScript', 'jqueryScript',
'jqueryCheckboxScript', 'jqueryCheckboxScript',
'jquerySelectScript', 'jquerySelectScript',
] ],
]); ]);
} }
@@ -52,7 +53,8 @@ class FormController extends Controller {
* *
* @return type * @return type
*/ */
public function home() { public function home()
{
return view('forms.home'); return view('forms.home');
} }
@@ -63,7 +65,8 @@ class FormController extends Controller {
* *
* @return Response * @return Response
*/ */
public function index(Forms $forms) { public function index(Forms $forms)
{
try { try {
return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms')); return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms'));
} catch (Exception $e) { } catch (Exception $e) {
@@ -76,7 +79,8 @@ class FormController extends Controller {
* *
* @return Response * @return Response
*/ */
public function create() { public function create()
{
try { try {
return view('themes.default1.admin.helpdesk.manage.form.form'); return view('themes.default1.admin.helpdesk.manage.form.form');
} catch (Exception $e) { } catch (Exception $e) {
@@ -91,13 +95,15 @@ class FormController extends Controller {
* *
* @return Response * @return Response
*/ */
public function show($id) { public function show($id)
{
try { try {
$forms = new Forms(); $forms = new Forms();
$form = $forms->find($id); $form = $forms->find($id);
//dd($form); //dd($form);
if ($form) { if ($form) {
$fields = $form->fields(); $fields = $form->fields();
return view('themes.default1.admin.helpdesk.manage.form.preview', compact('form', 'fields')); return view('themes.default1.admin.helpdesk.manage.form.preview', compact('form', 'fields'));
} }
throw new Exception("Sorry we can't find your request"); throw new Exception("Sorry we can't find your request");
@@ -111,12 +117,13 @@ class FormController extends Controller {
* *
* @return Response * @return Response
*/ */
public function store(Request $request) { public function store(Request $request)
{
$this->validate($request, [ $this->validate($request, [
'formname' => 'required|unique:custom_forms,formname', 'formname' => 'required|unique:custom_forms,formname',
'label.*' => 'required', 'label.*' => 'required',
'name.*' => 'required', 'name.*' => 'required',
'type.*' => 'required', 'type.*' => 'required',
]); ]);
try { try {
$forms = new Forms(); $forms = new Forms();
@@ -131,19 +138,20 @@ class FormController extends Controller {
$name = str_slug(Input::get('name')[$i], '_'); $name = str_slug(Input::get('name')[$i], '_');
$field = Fields::create([ $field = Fields::create([
'forms_id' => $forms->id, 'forms_id' => $forms->id,
'label' => Input::get('label')[$i], 'label' => Input::get('label')[$i],
'name' => $name, 'name' => $name,
'type' => Input::get('type')[$i], 'type' => Input::get('type')[$i],
'required' => $require[$i], 'required' => $require[$i],
]); ]);
$field_id = $field->id; $field_id = $field->id;
$this->createValues($field_id, Input::get('value')[$i],null,$name); $this->createValues($field_id, Input::get('value')[$i], null, $name);
} }
} }
return Redirect::back()->with('success', Lang::get('lang.successfully_created_form')); return Redirect::back()->with('success', Lang::get('lang.successfully_created_form'));
} catch (Exception $ex) { } catch (Exception $ex) {
dd($ex); dd($ex);
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
@@ -158,7 +166,8 @@ class FormController extends Controller {
* *
* @return type redirect * @return type redirect
*/ */
public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic) { public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic)
{
$fields = $field->where('forms_id', $id)->get(); $fields = $field->where('forms_id', $id)->get();
$help_topics = $help_topic->where('custom_form', '=', $id)->get(); $help_topics = $help_topic->where('custom_form', '=', $id)->get();
foreach ($help_topics as $help_topic) { foreach ($help_topics as $help_topic) {
@@ -174,7 +183,8 @@ class FormController extends Controller {
return redirect()->back()->with('success', Lang::get('lang.form_deleted_successfully')); return redirect()->back()->with('success', Lang::get('lang.form_deleted_successfully'));
} }
public function edit($id) { public function edit($id)
{
try { try {
$forms = new Forms(); $forms = new Forms();
$form = $forms->find($id); $form = $forms->find($id);
@@ -187,12 +197,12 @@ class FormController extends Controller {
} }
throw new Exception("Sorry we can't find your request"); throw new Exception("Sorry we can't find your request");
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function addChildForm($id) { public function addChildForm($id)
{
try { try {
$forms = new Forms(); $forms = new Forms();
$form = $forms->find($id); $form = $forms->find($id);
@@ -205,17 +215,17 @@ class FormController extends Controller {
} }
throw new Exception("Sorry we can't find your request"); throw new Exception("Sorry we can't find your request");
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function update($id, Request $request) { public function update($id, Request $request)
{
$this->validate($request, [ $this->validate($request, [
'formname' => 'required|unique:custom_forms,formname,' . $id, 'formname' => 'required|unique:custom_forms,formname,'.$id,
'label.*' => 'required', 'label.*' => 'required',
'name.*' => 'required', 'name.*' => 'required',
'type.*' => 'required', 'type.*' => 'required',
]); ]);
try { try {
if (!$request->input('formname')) { if (!$request->input('formname')) {
@@ -224,7 +234,7 @@ class FormController extends Controller {
$form = new Forms(); $form = new Forms();
$forms = $form->find($id); $forms = $form->find($id);
if (!$forms) { if (!$forms) {
throw new Exception("Sorry we can not find your request"); throw new Exception('Sorry we can not find your request');
} }
$forms->formname = Input::get('formname'); $forms->formname = Input::get('formname');
$forms->save(); $forms->save();
@@ -241,23 +251,26 @@ class FormController extends Controller {
$name = str_slug(Input::get('name')[$i], '_'); $name = str_slug(Input::get('name')[$i], '_');
$field = $field->create([ $field = $field->create([
'forms_id' => $forms->id, 'forms_id' => $forms->id,
'label' => Input::get('label')[$i], 'label' => Input::get('label')[$i],
'name' => $name, 'name' => $name,
'type' => Input::get('type')[$i], 'type' => Input::get('type')[$i],
'required' => Input::get('required')[$i], 'required' => Input::get('required')[$i],
]); ]);
$field_id = $field->id; $field_id = $field->id;
$this->createValues($field_id, Input::get('value')[$i],null,$name); $this->createValues($field_id, Input::get('value')[$i], null, $name);
} }
return redirect()->back()->with('success', 'updated'); return redirect()->back()->with('success', 'updated');
} catch (Exception $ex) { } catch (Exception $ex) {
dd($ex); dd($ex);
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function renderForm($formid) { public function renderForm($formid)
$html = ""; {
$html = '';
$forms = new Forms(); $forms = new Forms();
$form = $forms->find($formid); $form = $forms->find($formid);
if ($form) { if ($form) {
@@ -266,54 +279,58 @@ class FormController extends Controller {
$html .= self::getForm($field); $html .= self::getForm($field);
} }
} }
return self::requiredStyle() . $html;
return self::requiredStyle().$html;
} }
public static function getType($type) { public static function getType($type)
{
switch ($type) { switch ($type) {
case "select": case 'select':
return "select"; return 'select';
case "text": case 'text':
return "text"; return 'text';
case "email": case 'email':
return "email"; return 'email';
case "textarea": case 'textarea':
return "textarea"; return 'textarea';
case "select": case 'select':
return "select"; return 'select';
case "radio": case 'radio':
return "radio"; return 'radio';
case "checkbox": case 'checkbox':
return "checkbox"; return 'checkbox';
case "hidden": case 'hidden':
return "hidden"; return 'hidden';
case "password": case 'password':
return "password"; return 'password';
} }
} }
public static function getAttribute($type) { public static function getAttribute($type)
{
switch ($type) { switch ($type) {
case "select": case 'select':
return "null,['class'=>'form-control']"; return "null,['class'=>'form-control']";
case "text": case 'text':
return "['class'=>'form-control']"; return "['class'=>'form-control']";
case "email": case 'email':
return "['class'=>'form-control']"; return "['class'=>'form-control']";
case "textarea": case 'textarea':
return "['class'=>'form-control']"; return "['class'=>'form-control']";
case "radio": case 'radio':
return ""; return '';
case "checkbox": case 'checkbox':
return ""; return '';
case "hidden": case 'hidden':
return ""; return '';
case "password": case 'password':
return "['class'=>'form-control']"; return "['class'=>'form-control']";
} }
} }
public static function getForm($field) { public static function getForm($field)
{
$required = false; $required = false;
$required_class = self::requiredClass($field->required); $required_class = self::requiredClass($field->required);
if ($field->required === '1') { if ($field->required === '1') {
@@ -322,32 +339,33 @@ class FormController extends Controller {
$type = $field->type; $type = $field->type;
$field_type = self::getType($type); $field_type = self::getType($type);
switch ($field_type) { switch ($field_type) {
case "select": case 'select':
return self::selectForm($field_type, $field, $required, $required_class); return self::selectForm($field_type, $field, $required, $required_class);
case "text": case 'text':
return Form::label($field->label, $field->label, ['class' => $required_class]) . return Form::label($field->label, $field->label, ['class' => $required_class]).
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]); Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case "email": case 'email':
return Form::label($field->label, $field->label, ['class' => $required_class]) . return Form::label($field->label, $field->label, ['class' => $required_class]).
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]); Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case "password": case 'password':
return Form::label($field->label, $field->label, ['class' => $required_class]) . return Form::label($field->label, $field->label, ['class' => $required_class]).
Form::$field_type($field->name, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]); Form::$field_type($field->name, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case "textarea": case 'textarea':
return Form::label($field->label, $field->label, ['class' => $required_class]) . return Form::label($field->label, $field->label, ['class' => $required_class]).
Form::$field_type($field->name, NULL, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]); Form::$field_type($field->name, null, ['class' => "form-control $field->id", 'id' => $field->id, 'required' => $required]);
case "radio": case 'radio':
return self::radioForm($field_type, $field, $required, $required_class); return self::radioForm($field_type, $field, $required, $required_class);
case "checkbox": case 'checkbox':
return self::checkboxForm($field_type, $field, $required, $required_class); return self::checkboxForm($field_type, $field, $required, $required_class);
case "hidden": case 'hidden':
return Form::$field_type($field->name, NULL, ['id' => $field->id]); return Form::$field_type($field->name, null, ['id' => $field->id]);
} }
} }
public function createValues($fieldid, $values, $childid = NULL, $key = "") { public function createValues($fieldid, $values, $childid = null, $key = '')
{
if ($values) { if ($values) {
$values_array = explode(',', $values); $values_array = explode(',', $values);
$field_values = new \App\Model\helpdesk\Form\FieldValue(); $field_values = new \App\Model\helpdesk\Form\FieldValue();
@@ -360,9 +378,9 @@ class FormController extends Controller {
if (count($values_array) > 0) { if (count($values_array) > 0) {
foreach ($values_array as $value) { foreach ($values_array as $value) {
$field_values->create([ $field_values->create([
'field_id' => $fieldid, 'field_id' => $fieldid,
'child_id' => $childid, 'child_id' => $childid,
'field_key' => $key, 'field_key' => $key,
'field_value' => str_slug($value, '_'), 'field_value' => str_slug($value, '_'),
]); ]);
} }
@@ -370,7 +388,8 @@ class FormController extends Controller {
} }
} }
public function addChild($fieldid, Request $request) { public function addChild($fieldid, Request $request)
{
$ids = $request->except('_token'); $ids = $request->except('_token');
try { try {
foreach ($ids as $valueid => $formid) { foreach ($ids as $valueid => $formid) {
@@ -384,86 +403,91 @@ class FormController extends Controller {
//} //}
} }
} }
return redirect()->back()->with('success', 'Updated'); return redirect()->back()->with('success', 'Updated');
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function renderChild(Request $request) { public function renderChild(Request $request)
{
self::setSession(); self::setSession();
$render = ""; $render = '';
$value = $request->input('valueid'); $value = $request->input('valueid');
$fieldid = $request->input('fieldid'); $fieldid = $request->input('fieldid');
$field_values = new \App\Model\helpdesk\Form\FieldValue(); $field_values = new \App\Model\helpdesk\Form\FieldValue();
$field_value = $field_values->where('field_id', $fieldid)->where('field_value', $value)->first(); $field_value = $field_values->where('field_id', $fieldid)->where('field_value', $value)->first();
$child = ""; $child = '';
if ($field_value) { if ($field_value) {
$child = $field_value->child_id; $child = $field_value->child_id;
} }
if ($child !== "") { if ($child !== '') {
$render = $this->renderForm($child); $render = $this->renderForm($child);
} }
return $render; return $render;
} }
public static function jqueryScript($value, $fieldid, $fieldname, $type = "", $index = "") { public static function jqueryScript($value, $fieldid, $fieldname, $type = '', $index = '')
if ($type == "select") { {
if ($type == 'select') {
return self::jquerySelectScript($fieldid); return self::jquerySelectScript($fieldid);
} }
if ($type == "checkbox") { if ($type == 'checkbox') {
return self::jqueryCheckboxScript($fieldid, $index); return self::jqueryCheckboxScript($fieldid, $index);
} }
return '<script> return '<script>
$("#' . str_slug($value) . '").on("change", function () { $("#'.str_slug($value).'").on("change", function () {
var valueid = $("#' . str_slug($value) . '").val(); var valueid = $("#'.str_slug($value).'").val();
var fieldid = $("#' . $fieldid . str_slug($value) . '").val(); var fieldid = $("#'.$fieldid.str_slug($value).'").val();
send' . $fieldid . str_slug($value) . '(valueid,fieldid); send'.$fieldid.str_slug($value).'(valueid,fieldid);
}); });
function send' . $fieldid . str_slug($value) . '(valueid,fieldid) { function send'.$fieldid.str_slug($value).'(valueid,fieldid) {
$.ajax({ $.ajax({
url: "' . url('forms/render/child/') . '", url: "'.url('forms/render/child/').'",
dataType: "html", dataType: "html",
data: {"valueid": valueid,"fieldid": fieldid}, data: {"valueid": valueid,"fieldid": fieldid},
success: function (response) { success: function (response) {
$("#' . $fieldname . '").html(response); $("#'.$fieldname.'").html(response);
}, },
error: function (response) { error: function (response) {
$("#' . $fieldname . '").html(response); $("#'.$fieldname.'").html(response);
} }
}); });
} }
</script>'; </script>';
} }
public static function jqueryCheckboxScript($fieldid, $index) { public static function jqueryCheckboxScript($fieldid, $index)
{
$session = self::getSession(); $session = self::getSession();
$fields = new Fields(); $fields = new Fields();
$field = $fields->find($fieldid); $field = $fields->find($fieldid);
if ($field) { if ($field) {
return '<script> return '<script>
$("#' . $session . $index . '").on("change", function () { $("#'.$session.$index.'").on("change", function () {
var valueid = $("#' . $session . $index . '").val(); var valueid = $("#'.$session.$index.'").val();
var fieldid = $("#f' . $session . $index . '").val(); var fieldid = $("#f'.$session.$index.'").val();
if($(this).is(":checked")) { if($(this).is(":checked")) {
send' . $session . $index . '(valueid,fieldid); send'.$session.$index.'(valueid,fieldid);
}else{ }else{
$("#div' . $session . '"+valueid).empty(); $("#div'.$session.'"+valueid).empty();
} }
}); });
function send' . $session . $index . '(valueid,fieldid) { function send'.$session.$index.'(valueid,fieldid) {
$.ajax({ $.ajax({
url: "' . url('forms/render/child/') . '", url: "'.url('forms/render/child/').'",
dataType: "html", dataType: "html",
data: {"valueid": valueid,"fieldid": fieldid}, data: {"valueid": valueid,"fieldid": fieldid},
success: function (response) { success: function (response) {
$("#div' . $session . '"+valueid).html(response); $("#div'.$session.'"+valueid).html(response);
}, },
error: function (response) { error: function (response) {
$("#div' . $session . '"+valueid).html(response); $("#div'.$session.'"+valueid).html(response);
} }
}); });
} }
@@ -471,31 +495,32 @@ class FormController extends Controller {
} }
} }
public static function jquerySelectScript($fieldid) { public static function jquerySelectScript($fieldid)
{
$fields = new Fields(); $fields = new Fields();
$field = $fields->find($fieldid); $field = $fields->find($fieldid);
$session = self::getSession(); $session = self::getSession();
if ($field) { if ($field) {
return '<script> return '<script>
$(document).ready(function () { $(document).ready(function () {
var valueid = $(".' . $session . $fieldid . '").val(); var valueid = $(".'.$session.$fieldid.'").val();
var fieldid = $("#hidden' . $session . $fieldid . '").val(); var fieldid = $("#hidden'.$session.$fieldid.'").val();
send' . $session . $fieldid . '(valueid,fieldid); send'.$session.$fieldid.'(valueid,fieldid);
$(".' . $session . $fieldid . '").on("change", function () { $(".'.$session.$fieldid.'").on("change", function () {
valueid = $(".' . $session . $fieldid . '").val(); valueid = $(".'.$session.$fieldid.'").val();
var fieldid = $("#hidden' . $session . $fieldid . '").val(); var fieldid = $("#hidden'.$session.$fieldid.'").val();
send' . $session . $fieldid . '(valueid,fieldid); send'.$session.$fieldid.'(valueid,fieldid);
}); });
function send' . $session . $fieldid . '(valueid,fieldid) { function send'.$session.$fieldid.'(valueid,fieldid) {
$.ajax({ $.ajax({
url: "' . url('forms/render/child/') . '", url: "'.url('forms/render/child/').'",
dataType: "html", dataType: "html",
data: {"valueid": valueid,"fieldid": fieldid}, data: {"valueid": valueid,"fieldid": fieldid},
success: function (response) { success: function (response) {
$("#' . $session . $field->name . '").html(response); $("#'.$session.$field->name.'").html(response);
}, },
error: function (response) { error: function (response) {
$("#' . $session . $field->name . '").html(response); $("#'.$session.$field->name.'").html(response);
} }
}); });
} }
@@ -505,55 +530,60 @@ class FormController extends Controller {
} }
} }
public static function selectForm($field_type, $field, $required, $required_class) { public static function selectForm($field_type, $field, $required, $required_class)
{
$session = self::getSession(); $session = self::getSession();
$script = self::jqueryScript($field_value = "", $field->id, $field->name, $field_type); $script = self::jqueryScript($field_value = '', $field->id, $field->name, $field_type);
$form_hidden = Form::hidden('fieldid[]', $field->id, ['id' => "hidden" . $session . $field->id]) . Form::label($field->label, $field->label, ['class' => $required_class]); $form_hidden = Form::hidden('fieldid[]', $field->id, ['id' => 'hidden'.$session.$field->id]).Form::label($field->label, $field->label, ['class' => $required_class]);
$select = Form::$field_type($field->name, ['' => 'Select', 'Selects' => self::removeUnderscoreFromDB($field->values()->lists('field_value', 'field_value')->toArray())], null, ['class' => "form-control $session$field->id", 'id' => $session . $field->id, 'required' => $required]) . "</br>"; $select = Form::$field_type($field->name, ['' => 'Select', 'Selects' => self::removeUnderscoreFromDB($field->values()->lists('field_value', 'field_value')->toArray())], null, ['class' => "form-control $session$field->id", 'id' => $session.$field->id, 'required' => $required]).'</br>';
$html = $script . $form_hidden . $select; $html = $script.$form_hidden.$select;
$response_div = "<div id=" . $session . $field->name . "></div>"; $response_div = '<div id='.$session.$field->name.'></div>';
return $html . $response_div;
return $html.$response_div;
} }
public static function radioForm($field_type, $field, $required, $required_class) { public static function radioForm($field_type, $field, $required, $required_class)
$radio = ""; {
$html = ""; $radio = '';
$html = '';
$values = $field->values()->lists('field_value')->toArray(); $values = $field->values()->lists('field_value')->toArray();
if (count($values) > 0) { if (count($values) > 0) {
foreach ($values as $field_value) { foreach ($values as $field_value) {
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type); $script = self::jqueryScript($field_value, $field->id, $field->name, $field_type);
$radio .= "<div>" . Form::hidden('fieldid[]', $field->id, ['id' => $field->id . str_slug($field_value)]); $radio .= '<div>'.Form::hidden('fieldid[]', $field->id, ['id' => $field->id.str_slug($field_value)]);
$radio .= Form::$field_type($field->name, $field_value, NULL, ['class' => "$field->id", 'id' => str_slug($field_value), 'required' => $required]) . $script . "<span> " . removeUnderscore($field_value) . "</span></div>"; $radio .= Form::$field_type($field->name, $field_value, null, ['class' => "$field->id", 'id' => str_slug($field_value), 'required' => $required]).$script.'<span> '.removeUnderscore($field_value).'</span></div>';
} }
$html = Form::label($field->label, $field->label, ['class' => $required_class]) . "</br>" . $radio . "<div id=" . $field->name . "></br></div>"; $html = Form::label($field->label, $field->label, ['class' => $required_class]).'</br>'.$radio.'<div id='.$field->name.'></br></div>';
} }
return $html; return $html;
} }
public static function checkboxForm($field_type, $field, $required, $required_class) { public static function checkboxForm($field_type, $field, $required, $required_class)
{
$session = self::getSession(); $session = self::getSession();
$checkbox = ""; $checkbox = '';
$html = ""; $html = '';
$values = $field->values()->lists('field_value')->toArray(); $values = $field->values()->lists('field_value')->toArray();
if (count($values) > 0) { if (count($values) > 0) {
$i = 1; $i = 1;
foreach ($values as $field_value) { foreach ($values as $field_value) {
$script = self::jqueryScript($field_value, $field->id, $field->name, $field_type, $i); $script = self::jqueryScript($field_value, $field->id, $field->name, $field_type, $i);
$checkbox .= Form::hidden('fieldid[]', $field->id, ['id' => 'f' . $session . $i]); $checkbox .= Form::hidden('fieldid[]', $field->id, ['id' => 'f'.$session.$i]);
$checkbox .= Form::$field_type($field->name, $field_value, NULL, ['class' => "$field->id", 'id' => $session . $i, 'required' => $required]); $checkbox .= Form::$field_type($field->name, $field_value, null, ['class' => "$field->id", 'id' => $session.$i, 'required' => $required]);
$checkbox .= "<span> " . removeUnderscore($field_value) . "</span>"; $checkbox .= '<span> '.removeUnderscore($field_value).'</span>';
//$checkbox .="</br>"; //$checkbox .="</br>";
$checkbox .="<div>" . $script . "<div id=div" . $session . $field_value . "></div></div>"; $checkbox .= '<div>'.$script.'<div id=div'.$session.$field_value.'></div></div>';
$i++; $i++;
} }
$html = Form::label($field->label, $field->label, ['class' => $required_class]) . "</br>" . $checkbox; $html = Form::label($field->label, $field->label, ['class' => $required_class]).'</br>'.$checkbox;
} }
return $html; return $html;
} }
public static function requiredStyle() { public static function requiredStyle()
{
$style = "<style> $style = "<style>
.required:after { .required:after {
color: #e32 !important; color: #e32 !important;
@@ -561,39 +591,46 @@ class FormController extends Controller {
display:inline !important; display:inline !important;
} }
</style>"; </style>";
return $style; return $style;
} }
public static function requiredClass($required) { public static function requiredClass($required)
$class = ""; {
$class = '';
if ($required === '1') { if ($required === '1') {
$class = "required"; $class = 'required';
} }
return $class; return $class;
} }
public static function setSession() { public static function setSession()
{
$form = self::getSession(); $form = self::getSession();
$form++; $form++;
\Session::set('fromid', $form); \Session::set('fromid', $form);
} }
public static function getSession() { public static function getSession()
{
$form = 0; $form = 0;
if (\Session::has('fromid')) { if (\Session::has('fromid')) {
$form = \Session::get('fromid'); $form = \Session::get('fromid');
} }
return $form; return $form;
} }
public static function removeUnderscoreFromDB($array) { public static function removeUnderscoreFromDB($array)
{
$result = []; $result = [];
if (is_array($array) && count($array) > 0) { if (is_array($array) && count($array) > 0) {
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
$result[$key] = removeUnderscore($value); $result[$key] = removeUnderscore($value);
} }
} }
return $result; return $result;
} }
} }

View File

@@ -87,7 +87,8 @@ class HelptopicController extends Controller
$forms = $form->get(); $forms = $form->get();
$agents = $agent->where('role', '=', 'agent')->get(); $agents = $agent->where('role', '=', 'agent')->get();
$slas = $sla->get(); $slas = $sla->get();
$priority = Ticket_Priority::where('status','=',1)->get(); $priority = Ticket_Priority::where('status', '=', 1)->get();
return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas')); return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
@@ -147,7 +148,7 @@ class HelptopicController extends Controller
$topics = $topic->whereId($id)->first(); $topics = $topic->whereId($id)->first();
$forms = $form->get(); $forms = $form->get();
$slas = $sla->get(); $slas = $sla->get();
$priority = Ticket_Priority::where('status','=',1)->get(); $priority = Ticket_Priority::where('status', '=', 1)->get();
$sys_help_topic = \DB::table('settings_ticket') $sys_help_topic = \DB::table('settings_ticket')
->select('help_topic') ->select('help_topic')
->where('id', '=', 1)->first(); ->where('id', '=', 1)->first();

View File

@@ -8,7 +8,6 @@ use App;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
//supports //supports
use App\Http\Requests; use App\Http\Requests;
use Cache;
use Config; use Config;
//classes //classes
use File; use File;
@@ -17,8 +16,8 @@ use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
use Input; use Input;
use Lang; use Lang;
use Validator;
use UnAuth; use UnAuth;
use Validator;
/** /**
* SlaController. * SlaController.
@@ -53,7 +52,6 @@ class LanguageController extends Controller
} else { } else {
return \Redirect::back(); return \Redirect::back();
} }
} }
/** /**
@@ -89,11 +87,10 @@ class LanguageController extends Controller
return \Datatable::collection(new Collection($values)) return \Datatable::collection(new Collection($values))
->addColumn('language', function ($model) { ->addColumn('language', function ($model) {
if ($model == Config::get('app.fallback_locale')) { if ($model == Config::get('app.fallback_locale')) {
return Config::get('languages.'.$model).' ('.Lang::get('lang.default').')'; return Config::get('languages.'.$model).' ('.Lang::get('lang.default').')';
} else { } else {
return Config::get('languages.'.$model); return Config::get('languages.'.$model);
} }
}) })
->addColumn('id', function ($model) { ->addColumn('id', function ($model) {
return $model; return $model;
@@ -229,16 +226,17 @@ class LanguageController extends Controller
if ($success) { if ($success) {
//sending back with success message //sending back with success message
Session::flash('success', Lang::get('lang.delete-success')); Session::flash('success', Lang::get('lang.delete-success'));
return Redirect::back(); return Redirect::back();
} else { } else {
//sending back with error message //sending back with error message
Session::flash('fails', Lang::get('lang.lang-doesnot-exist')); Session::flash('fails', Lang::get('lang.lang-doesnot-exist'));
return Redirect::back(); return Redirect::back();
} }
} else { } else {
Session::flash('fails', Lang::get('lang.lang-fallback-lang')); Session::flash('fails', Lang::get('lang.lang-fallback-lang'));
return redirect('languages'); return redirect('languages');
} }
} else { } else {
@@ -247,5 +245,4 @@ class LanguageController extends Controller
return redirect('languages'); return redirect('languages');
} }
} }
} }

View File

@@ -5,61 +5,33 @@ namespace App\Http\Controllers\Admin\helpdesk;
// controllers // controllers
use App\Http\Controllers\Common\NotificationController; use App\Http\Controllers\Common\NotificationController;
use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Common\FileuploadController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
use App\Http\Requests\helpdesk\CreateTicketRequest;
use App\Http\Requests\helpdesk\TicketRequest;
use App\Http\Requests\helpdesk\PriorityRequest; use App\Http\Requests\helpdesk\PriorityRequest;
// models // models
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Settings\CommonSettings; use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Settings\Alert;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email; use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Ticket\Ticket_Form_Data;
use App\Model\helpdesk\Ticket\Ticket_Priority; use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Status;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Utility\CountryCode;
use App\Model\helpdesk\Utility\Date_time_format;
use App\Model\helpdesk\Utility\Timezones;
use App\User;
use Auth; use Auth;
use DB; use DB;
use Exception; use Exception;
use ForceUTF8\Encoding;
use GeoIP;
// classes // classes
use Hash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\support\Collection; use Illuminate\support\Collection;
use Input; use Input;
use Lang; use Lang;
use Mail;
use PDF;
use UTC;
/** /**
* TicketController. * TicketController.
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class PriorityController extends Controller { class PriorityController extends Controller
{
public function __construct(PhpMailController $PhpMailController, NotificationController $NotificationController) { public function __construct(PhpMailController $PhpMailController, NotificationController $NotificationController)
{
$this->PhpMailController = $PhpMailController; $this->PhpMailController = $PhpMailController;
$this->NotificationController = $NotificationController; $this->NotificationController = $NotificationController;
$this->middleware('auth'); $this->middleware('auth');
@@ -70,57 +42,61 @@ class PriorityController extends Controller {
* *
* @return type response * @return type response
*/ */
public function priorityIndex() { public function priorityIndex()
$user_status=CommonSettings::where('option_name','=', 'user_priority')->first(); {
$user_status = CommonSettings::where('option_name', '=', 'user_priority')->first();
// dd( $user_status); // dd( $user_status);
return view('themes.default1.admin.helpdesk.manage.ticket_priority.index', compact('user_status')); return view('themes.default1.admin.helpdesk.manage.ticket_priority.index', compact('user_status'));
} }
/**
/**
* Show the Inbox ticket list page. * Show the Inbox ticket list page.
* *
* @return type response * @return type response
*/ */
public function userPriorityIndex(Request $request) { public function userPriorityIndex(Request $request)
try { {
$user_status= $request->user_settings_priority; try {
$user_status = $request->user_settings_priority;
CommonSettings::where('option_name','=', 'user_priority')->update(['status' => $user_status]);
return 'Your Status Updated'; CommonSettings::where('option_name', '=', 'user_priority')->update(['status' => $user_status]);
} catch (Exception $e) {
return 'Your Status Updated';
} catch (Exception $e) {
return Redirect()->back()->with('fails', $e->getMessage()); return Redirect()->back()->with('fails', $e->getMessage());
} }
} }
/** /**
*
* @return type * @return type
*/ */
public function priorityIndex1() { public function priorityIndex1()
{
try { try {
$ticket = new Ticket_Priority(); $ticket = new Ticket_Priority();
$tickets = $ticket->select('priority_id', 'priority', 'priority_desc', 'priority_color', 'status', 'is_default', 'ispublic')->get(); $tickets = $ticket->select('priority_id', 'priority', 'priority_desc', 'priority_color', 'status', 'is_default', 'ispublic')->get();
return \Datatable::Collection($tickets) return \Datatable::Collection($tickets)
->showColumns('priority', 'priority_desc') ->showColumns('priority', 'priority_desc')
->addColumn('priority_color', function($model) { ->addColumn('priority_color', function ($model) {
return "<button class='btn' style = 'background-color:$model->priority_color'></button>"; return "<button class='btn' style = 'background-color:$model->priority_color'></button>";
}) })
->addColumn('status', function($model) { ->addColumn('status', function ($model) {
if ($model->status == 1) { if ($model->status == 1) {
return "<a style='color:green'>active</a>"; return "<a style='color:green'>active</a>";
} elseif ($model->status == 0) { } elseif ($model->status == 0) {
Ticket_Priority::where('priority_id', '=', '$priority_id') Ticket_Priority::where('priority_id', '=', '$priority_id')
->update(['priority_id' => '']); ->update(['priority_id' => '']);
return "<a style='color:red'>inactive</a>"; return "<a style='color:red'>inactive</a>";
} }
}) })
->addColumn('action', function($model) { ->addColumn('action', function ($model) {
if ($model->is_default > 0) { if ($model->is_default > 0) {
return "<a href=" . url('ticket/priority/' . $model->priority_id . '/edit') . " class='btn btn-info btn-xs' disabled='disabled'>Edit</a>&nbsp;<a href=" . url('ticket/priority/' . $model->priority_id . '/destroy') . " class='btn btn-warning btn-info btn-xs' disabled='disabled' > delete </a>"; return '<a href='.url('ticket/priority/'.$model->priority_id.'/edit')." class='btn btn-info btn-xs' disabled='disabled'>Edit</a>&nbsp;<a href=".url('ticket/priority/'.$model->priority_id.'/destroy')." class='btn btn-warning btn-info btn-xs' disabled='disabled' > delete </a>";
} else { } else {
return "<a href=" . url('ticket/priority/' . $model->priority_id . '/edit') . " class='btn btn-info btn-xs'>Edit</a>&nbsp;<a class='btn btn-danger btn-xs' onclick='confirmDelete(" . $model->priority_id . ")'>Delete </a>"; return '<a href='.url('ticket/priority/'.$model->priority_id.'/edit')." class='btn btn-info btn-xs'>Edit</a>&nbsp;<a class='btn btn-danger btn-xs' onclick='confirmDelete(".$model->priority_id.")'>Delete </a>";
} }
}) })
->searchColumns('priority') ->searchColumns('priority')
@@ -132,42 +108,45 @@ class PriorityController extends Controller {
} }
/** /**
*
* @return type * @return type
*/ */
public function priorityCreate() { public function priorityCreate()
{
return view('themes.default1.admin.helpdesk.manage.ticket_priority.create'); return view('themes.default1.admin.helpdesk.manage.ticket_priority.create');
} }
public function priorityCreate1(PriorityRequest $request) { public function priorityCreate1(PriorityRequest $request)
$tk_priority = new Ticket_Priority; {
$tk_priority = new Ticket_Priority();
$tk_priority->priority = $request->priority; $tk_priority->priority = $request->priority;
$tk_priority->status = $request->status; $tk_priority->status = $request->status;
$tk_priority->priority_desc = $request->priority_desc; $tk_priority->priority_desc = $request->priority_desc;
$tk_priority->priority_color = $request->priority_color; $tk_priority->priority_color = $request->priority_color;
$tk_priority->ispublic = $request->ispublic; $tk_priority->ispublic = $request->ispublic;
$tk_priority->save(); $tk_priority->save();
return \Redirect::route('priority.index')->with('success', Lang::get('lang.priority_successfully_created')); return \Redirect::route('priority.index')->with('success', Lang::get('lang.priority_successfully_created'));
} }
/** /**
*
* @param type $priority_id * @param type $priority_id
*
* @return type * @return type
*/ */
public function priorityEdit($priority_id) { public function priorityEdit($priority_id)
{
$tk_priority = Ticket_Priority::wherepriority_id($priority_id)->first(); $tk_priority = Ticket_Priority::wherepriority_id($priority_id)->first();
return view('themes.default1.admin.helpdesk.manage.ticket_priority.edit', compact('tk_priority')); return view('themes.default1.admin.helpdesk.manage.ticket_priority.edit', compact('tk_priority'));
} }
/** /**
*
* @param PriorityRequest $request * @param PriorityRequest $request
*
* @return type * @return type
*/ */
public function priorityEdit1(PriorityRequest $request) { public function priorityEdit1(PriorityRequest $request)
{
$priority_id = $request->priority_id; $priority_id = $request->priority_id;
$tk_priority = Ticket_Priority::findOrFail($priority_id); $tk_priority = Ticket_Priority::findOrFail($priority_id);
$tk_priority->priority = $request->priority; $tk_priority->priority = $request->priority;
@@ -182,16 +161,17 @@ class PriorityController extends Controller {
Ticket_Priority::where('priority_id', '=', $priority_id) Ticket_Priority::where('priority_id', '=', $priority_id)
->update(['is_default' => 1]); ->update(['is_default' => 1]);
} }
return \Redirect::route('priority.index')->with('success', (Lang::get('lang.priority_successfully_updated'))); return \Redirect::route('priority.index')->with('success', (Lang::get('lang.priority_successfully_updated')));
} }
/** /**
*
* @param type $priority_id * @param type $priority_id
*
* @return type * @return type
*/ */
public function destroy($priority_id) { public function destroy($priority_id)
{
$default_priority = Ticket_Priority::where('is_default', '>', '0')->first(); $default_priority = Ticket_Priority::where('is_default', '>', '0')->first();
// dd($default_priority->is_default); // dd($default_priority->is_default);
$topic = DB::table('help_topic')->where('priority', '=', $priority_id)->update(['priority' => $default_priority->is_default]); $topic = DB::table('help_topic')->where('priority', '=', $priority_id)->update(['priority' => $default_priority->is_default]);
@@ -212,5 +192,4 @@ class PriorityController extends Controller {
return \Redirect::route('priority.index')->with('success', (Lang::get('lang.delete_successfully'))); return \Redirect::route('priority.index')->with('success', (Lang::get('lang.delete_successfully')));
} }
} }

View File

@@ -7,10 +7,11 @@ use App\Http\Controllers\Controller;
// requests // requests
use App\Http\Requests\helpdesk\CompanyRequest; use App\Http\Requests\helpdesk\CompanyRequest;
use App\Http\Requests\helpdesk\EmailRequest; use App\Http\Requests\helpdesk\EmailRequest;
use App\Http\Requests\helpdesk\Job\TaskRequest;
use App\Http\Requests\helpdesk\RatingUpdateRequest; use App\Http\Requests\helpdesk\RatingUpdateRequest;
use App\Http\Requests\helpdesk\StatusRequest; use App\Http\Requests\helpdesk\StatusRequest;
use App\Http\Requests\helpdesk\SystemRequest;
// models // models
use App\Http\Requests\helpdesk\SystemRequest;
use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Email\Template; use App\Model\helpdesk\Email\Template;
@@ -19,9 +20,10 @@ use App\Model\helpdesk\Manage\Sla_plan;
use App\Model\helpdesk\Notification\UserNotification; use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Ratings\Rating; use App\Model\helpdesk\Ratings\Rating;
use App\Model\helpdesk\Settings\Alert; use App\Model\helpdesk\Settings\Alert;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Settings\Company; use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Followup;
use App\Model\helpdesk\Settings\Email; use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Settings\Followup;
use App\Model\helpdesk\Settings\Responder; use App\Model\helpdesk\Settings\Responder;
use App\Model\helpdesk\Settings\System; use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Ticket; use App\Model\helpdesk\Settings\Ticket;
@@ -31,30 +33,29 @@ use App\Model\helpdesk\Utility\Date_time_format;
use App\Model\helpdesk\Utility\Time_format; use App\Model\helpdesk\Utility\Time_format;
use App\Model\helpdesk\Utility\Timezones; use App\Model\helpdesk\Utility\Timezones;
use App\Model\helpdesk\Workflow\WorkflowClose; use App\Model\helpdesk\Workflow\WorkflowClose;
use App\Model\helpdesk\Settings\CommonSettings;
use DateTime;
// classes // classes
use DateTime;
use DB; use DB;
use Exception; use Exception;
use File; use File;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Input; use Input;
use Lang; use Lang;
use App\Http\Requests\helpdesk\Job\TaskRequest;
/** /**
* SettingsController. * SettingsController.
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class SettingsController extends Controller { class SettingsController extends Controller
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* *
* @return void * @return void
*/ */
public function __construct() { public function __construct()
{
// $this->smtp(); // $this->smtp();
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
@@ -68,7 +69,8 @@ class SettingsController extends Controller {
* *
* @return Response * @return Response
*/ */
public function getcompany(Company $company) { public function getcompany(Company $company)
{
try { try {
/* fetch the values of company from company table */ /* fetch the values of company from company table */
$companys = $company->whereId('1')->first(); $companys = $company->whereId('1')->first();
@@ -88,13 +90,14 @@ class SettingsController extends Controller {
* *
* @return Response * @return Response
*/ */
public function postcompany($id, Company $company, CompanyRequest $request) { public function postcompany($id, Company $company, CompanyRequest $request)
{
/* fetch the values of company request */ /* fetch the values of company request */
$companys = $company->whereId('1')->first(); $companys = $company->whereId('1')->first();
if (Input::file('logo')) { if (Input::file('logo')) {
$name = Input::file('logo')->getClientOriginalName(); $name = Input::file('logo')->getClientOriginalName();
$destinationPath = 'uploads/company/'; $destinationPath = 'uploads/company/';
$fileName = rand(0000, 9999) . '.' . $name; $fileName = rand(0000, 9999).'.'.$name;
Input::file('logo')->move($destinationPath, $fileName); Input::file('logo')->move($destinationPath, $fileName);
$companys->logo = $fileName; $companys->logo = $fileName;
} }
@@ -108,7 +111,7 @@ class SettingsController extends Controller {
return redirect('getcompany')->with('success', Lang::get('lang.company_updated_successfully')); return redirect('getcompany')->with('success', Lang::get('lang.company_updated_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated') . '<li>' . $e->getMessage() . '</li>'); return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated').'<li>'.$e->getMessage().'</li>');
} }
} }
@@ -117,7 +120,8 @@ class SettingsController extends Controller {
* *
* @return type string * @return type string
*/ */
public function deleteLogo() { public function deleteLogo()
{
$path = $_GET['data1']; //get file path of logo image $path = $_GET['data1']; //get file path of logo image
if (!unlink($path)) { if (!unlink($path)) {
return 'false'; return 'false';
@@ -144,7 +148,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time, CommonSettings $common_settings) { public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time, CommonSettings $common_settings)
{
try { try {
/* fetch the values of system from system table */ /* fetch the values of system from system table */
$systems = $system->whereId('1')->first(); $systems = $system->whereId('1')->first();
@@ -178,7 +183,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function postsystem($id, System $system, SystemRequest $request) { public function postsystem($id, System $system, SystemRequest $request)
{
try { try {
/* fetch the values of system request */ /* fetch the values of system request */
$systems = $system->whereId('1')->first(); $systems = $system->whereId('1')->first();
@@ -202,8 +208,8 @@ class SettingsController extends Controller {
->update(['status' => $request->send_otp]); ->update(['status' => $request->send_otp]);
$email_mandatory = CommonSettings::where('option_name', '=', 'email_mandatory') $email_mandatory = CommonSettings::where('option_name', '=', 'email_mandatory')
->update(['status' => $request->email_mandatory]); ->update(['status' => $request->email_mandatory]);
if($request->has('itil')){ if ($request->has('itil')) {
$itil = $request->input('itil'); $itil = $request->input('itil');
$sett = CommonSettings::firstOrCreate(['option_name'=>'itil']); $sett = CommonSettings::firstOrCreate(['option_name'=>'itil']);
$sett->status = $itil; $sett->status = $itil;
@@ -213,7 +219,7 @@ class SettingsController extends Controller {
return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully')); return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated') . '<br>' . $e->getMessage()); return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated').'<br>'.$e->getMessage());
} }
} }
@@ -227,7 +233,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) { public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority)
{
try { try {
/* fetch the values of ticket from ticket table */ /* fetch the values of ticket from ticket table */
$tickets = $ticket->whereId('1')->first(); $tickets = $ticket->whereId('1')->first();
@@ -251,7 +258,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function postticket($id, Ticket $ticket, Request $request) { public function postticket($id, Ticket $ticket, Request $request)
{
try { try {
/* fetch the values of ticket request */ /* fetch the values of ticket request */
$tickets = $ticket->whereId('1')->first(); $tickets = $ticket->whereId('1')->first();
@@ -272,7 +280,7 @@ class SettingsController extends Controller {
return redirect('getticket')->with('success', Lang::get('lang.ticket_updated_successfully')); return redirect('getticket')->with('success', Lang::get('lang.ticket_updated_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated') . '<li>' . $e->getMessage() . '</li>'); return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated').'<li>'.$e->getMessage().'</li>');
} }
} }
@@ -285,7 +293,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getemail(Email $email, Template $template, Emails $email1) { public function getemail(Email $email, Template $template, Emails $email1)
{
try { try {
/* fetch the values of email from Email table */ /* fetch the values of email from Email table */
$emails = $email->whereId('1')->first(); $emails = $email->whereId('1')->first();
@@ -309,7 +318,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function postemail($id, Email $email, EmailRequest $request) { public function postemail($id, Email $email, EmailRequest $request)
{
try { try {
/* fetch the values of email request */ /* fetch the values of email request */
$emails = $email->whereId('1')->first(); $emails = $email->whereId('1')->first();
@@ -328,7 +338,7 @@ class SettingsController extends Controller {
return redirect('getemail')->with('success', Lang::get('lang.email_updated_successfully')); return redirect('getemail')->with('success', Lang::get('lang.email_updated_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated') . '<li>' . $e->getMessage() . '</li>'); return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated').'<li>'.$e->getMessage().'</li>');
} }
} }
@@ -341,7 +351,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getSchedular(Email $email, Template $template, Emails $email1, WorkflowClose $workflow) { public function getSchedular(Email $email, Template $template, Emails $email1, WorkflowClose $workflow)
{
// try { // try {
/* fetch the values of email from Email table */ /* fetch the values of email from Email table */
$emails = $email->whereId('1')->first(); $emails = $email->whereId('1')->first();
@@ -354,41 +365,43 @@ class SettingsController extends Controller {
$cron_path = base_path('artisan'); $cron_path = base_path('artisan');
$command = ":- <pre>***** php $cron_path schedule:run >> /dev/null 2>&1</pre>"; $command = ":- <pre>***** php $cron_path schedule:run >> /dev/null 2>&1</pre>";
$shared = ":- <pre>/usr/bin/php-cli -q $cron_path schedule:run >> /dev/null 2>&1</pre>"; $shared = ":- <pre>/usr/bin/php-cli -q $cron_path schedule:run >> /dev/null 2>&1</pre>";
$warn = ""; $warn = '';
$condition = new \App\Model\MailJob\Condition(); $condition = new \App\Model\MailJob\Condition();
$job = $condition->checkActiveJob(); $job = $condition->checkActiveJob();
$commands = [ $commands = [
'' => 'Select', '' => 'Select',
'everyMinute' => 'Every Minute', 'everyMinute' => 'Every Minute',
'everyFiveMinutes' => 'Every Five Minute', 'everyFiveMinutes' => 'Every Five Minute',
'everyTenMinutes' => 'Every Ten Minute', 'everyTenMinutes' => 'Every Ten Minute',
'everyThirtyMinutes' => 'Every Thirty Minute', 'everyThirtyMinutes' => 'Every Thirty Minute',
'hourly' => 'Every Hour', 'hourly' => 'Every Hour',
'daily' => 'Every Day', 'daily' => 'Every Day',
'dailyAt' => 'Daily at', 'dailyAt' => 'Daily at',
'weekly' => 'Every Week', 'weekly' => 'Every Week',
'monthly' => 'Monthly', 'monthly' => 'Monthly',
'yearly' => 'Yearly', 'yearly' => 'Yearly',
]; ];
$followupcommands = [ $followupcommands = [
'' => 'Select', '' => 'Select',
'everyMinute' => 'Every Minute', 'everyMinute' => 'Every Minute',
'everyFiveMinutes' => 'Every Five Minute', 'everyFiveMinutes' => 'Every Five Minute',
'everyTenMinutes' => 'Every Ten Minute', 'everyTenMinutes' => 'Every Ten Minute',
'everyThirtyMinutes' => 'Every Thirty Minute', 'everyThirtyMinutes' => 'Every Thirty Minute',
'hourly' => 'Every Hour', 'hourly' => 'Every Hour',
'daily' => 'Every Day', 'daily' => 'Every Day',
'weekly' => 'Every Week', 'weekly' => 'Every Week',
'monthly' => 'Monthly', 'monthly' => 'Monthly',
'yearly' => 'Yearly', 'yearly' => 'Yearly',
]; ];
if (ini_get('register_argc_argv') == "") { if (ini_get('register_argc_argv') == '') {
//$warn = "Please make 'register_argc_argv' flag as on. Or you can set all your job url in cron"; //$warn = "Please make 'register_argc_argv' flag as on. Or you can set all your job url in cron";
} }
return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands','followupcommands','condition','shared'));
return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands', 'followupcommands', 'condition', 'shared'));
// } catch { // } catch {
// } // }
} }
/** /**
* Update the specified schedular in storage for cron job. * Update the specified schedular in storage for cron job.
* *
@@ -397,18 +410,16 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function postSchedular(Email $email, Template $template, Followup $followup, Emails $email1, TaskRequest $request, WorkflowClose $workflow) { public function postSchedular(Email $email, Template $template, Followup $followup, Emails $email1, TaskRequest $request, WorkflowClose $workflow)
{
try { try {
$followup = $followup->whereId('1')->first();
$status = $request->followup_notification_cron;
$followup=$followup->whereId('1')->first(); if ($status = 'null') {
$status=$request->followup_notification_cron;
if ($status='null') {
$followup->status = $request->followup_notification_cron; $followup->status = $request->followup_notification_cron;
} }
if($status= 1) { if ($status = 1) {
$followup->status = $request->followup_notification_cron; $followup->status = $request->followup_notification_cron;
$followup->condition = $request->followup_notification_commands; $followup->condition = $request->followup_notification_commands;
$followup->save(); $followup->save();
@@ -444,7 +455,7 @@ class SettingsController extends Controller {
return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success')); return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error') . '<li>' . $e->getMessage() . '</li>'); return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error').'<li>'.$e->getMessage().'</li>');
} }
} }
@@ -455,7 +466,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getresponder(Responder $responder) { public function getresponder(Responder $responder)
{
try { try {
/* fetch the values of responder from responder table */ /* fetch the values of responder from responder table */
$responders = $responder->whereId('1')->first(); $responders = $responder->whereId('1')->first();
@@ -474,7 +486,8 @@ class SettingsController extends Controller {
* *
* @return type * @return type
*/ */
public function postresponder(Responder $responder, Request $request) { public function postresponder(Responder $responder, Request $request)
{
try { try {
/* fetch the values of responder request */ /* fetch the values of responder request */
$responders = $responder->whereId('1')->first(); $responders = $responder->whereId('1')->first();
@@ -491,7 +504,7 @@ class SettingsController extends Controller {
return redirect('getresponder')->with('success', Lang::get('lang.auto_response_updated_successfully')); return redirect('getresponder')->with('success', Lang::get('lang.auto_response_updated_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated') . '<li>' . $e->getMessage() . '</li>'); return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated').'<li>'.$e->getMessage().'</li>');
} }
} }
@@ -502,7 +515,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getalert(Alert $alert) { public function getalert(Alert $alert)
{
try { try {
/* fetch the values of alert from alert table */ /* fetch the values of alert from alert table */
$alerts = $alert->whereId('1')->first(); $alerts = $alert->whereId('1')->first();
@@ -522,7 +536,8 @@ class SettingsController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function postalert($id, Alert $alert, Request $request) { public function postalert($id, Alert $alert, Request $request)
{
try { try {
/* fetch the values of alert request */ /* fetch the values of alert request */
$alerts = $alert->whereId('1')->first(); $alerts = $alert->whereId('1')->first();
@@ -577,7 +592,7 @@ class SettingsController extends Controller {
return redirect('getalert')->with('success', Lang::get('lang.alert_&_notices_updated_successfully')); return redirect('getalert')->with('success', Lang::get('lang.alert_&_notices_updated_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated') . '<li>' . $e->getMessage() . '</li>'); return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated').'<li>'.$e->getMessage().'</li>');
} }
} }
@@ -586,7 +601,8 @@ class SettingsController extends Controller {
* *
* @return type json * @return type json
*/ */
public function generateApiKey() { public function generateApiKey()
{
$key = str_random(32); $key = str_random(32);
return $key; return $key;
@@ -597,7 +613,8 @@ class SettingsController extends Controller {
* *
* @return type view * @return type view
*/ */
public function settings() { public function settings()
{
return view('themes.default1.admin.helpdesk.setting'); return view('themes.default1.admin.helpdesk.setting');
} }
@@ -609,7 +626,8 @@ class SettingsController extends Controller {
* *
* @return Response * @return Response
*/ */
public function getStatuses() { public function getStatuses()
{
try { try {
/* fetch the values of company from company table */ /* fetch the values of company from company table */
$statuss = \DB::table('ticket_status')->get(); $statuss = \DB::table('ticket_status')->get();
@@ -628,7 +646,8 @@ class SettingsController extends Controller {
* *
* @return Response * @return Response
*/ */
public function getEditStatuses($id) { public function getEditStatuses($id)
{
try { try {
/* fetch the values of company from company table */ /* fetch the values of company from company table */
$status = \DB::table('ticket_status')->where('id', '=', $id)->first(); $status = \DB::table('ticket_status')->where('id', '=', $id)->first();
@@ -647,7 +666,8 @@ class SettingsController extends Controller {
* *
* @return Response * @return Response
*/ */
public function editStatuses($id, StatusRequest $request) { public function editStatuses($id, StatusRequest $request)
{
try { try {
/* fetch the values of company from company table */ /* fetch the values of company from company table */
$statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first(); $statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first();
@@ -678,7 +698,8 @@ class SettingsController extends Controller {
* *
* @return type redirect * @return type redirect
*/ */
public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request) { public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request)
{
try { try {
/* fetch the values of company from company table */ /* fetch the values of company from company table */
$statuss->name = $request->input('name'); $statuss->name = $request->input('name');
@@ -707,7 +728,8 @@ class SettingsController extends Controller {
* *
* @return type redirect * @return type redirect
*/ */
public function deleteStatuses($id) { public function deleteStatuses($id)
{
try { try {
if ($id > 5) { if ($id > 5) {
/* fetch the values of company from company table */ /* fetch the values of company from company table */
@@ -727,7 +749,8 @@ class SettingsController extends Controller {
* *
* @return type view * @return type view
*/ */
public function notificationSettings() { public function notificationSettings()
{
return view('themes.default1.admin.helpdesk.settings.notification'); return view('themes.default1.admin.helpdesk.settings.notification');
} }
@@ -736,7 +759,8 @@ class SettingsController extends Controller {
* *
* @return type redirect * @return type redirect
*/ */
public function deleteReadNoti() { public function deleteReadNoti()
{
$markasread = UserNotification::where('is_read', '=', 1)->get(); $markasread = UserNotification::where('is_read', '=', 1)->get();
foreach ($markasread as $mark) { foreach ($markasread as $mark) {
$mark->delete(); $mark->delete();
@@ -751,13 +775,14 @@ class SettingsController extends Controller {
* *
* @return type redirect * @return type redirect
*/ */
public function deleteNotificationLog() { public function deleteNotificationLog()
{
$days = Input::get('no_of_days'); $days = Input::get('no_of_days');
if ($days == null) { if ($days == null) {
return redirect()->back()->with('fails', 'Please enter valid no of days'); return redirect()->back()->with('fails', 'Please enter valid no of days');
} }
$date = new DateTime(); $date = new DateTime();
$date->modify($days . ' day'); $date->modify($days.' day');
$formatted_date = $date->format('Y-m-d H:i:s'); $formatted_date = $date->format('Y-m-d H:i:s');
$markasread = UserNotification::where('created_at', '<=', $formatted_date)->get(); $markasread = UserNotification::where('created_at', '<=', $formatted_date)->get();
foreach ($markasread as $mark) { foreach ($markasread as $mark) {
@@ -765,7 +790,7 @@ class SettingsController extends Controller {
\App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->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.'); return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_notification_records_since').$days.' days.');
} }
/** /**
@@ -773,7 +798,8 @@ class SettingsController extends Controller {
* *
* @return type View * @return type View
*/ */
public function RatingSettings() { public function RatingSettings()
{
try { try {
$ratings = Rating::orderBy('display_order', 'asc')->get(); $ratings = Rating::orderBy('display_order', 'asc')->get();
@@ -790,7 +816,8 @@ class SettingsController extends Controller {
* *
* @return type view * @return type view
*/ */
public function editRatingSettings($id) { public function editRatingSettings($id)
{
try { try {
$rating = Rating::whereId($id)->first(); $rating = Rating::whereId($id)->first();
@@ -805,7 +832,8 @@ class SettingsController extends Controller {
* *
* @return type Redirect * @return type Redirect
*/ */
public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request) { public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request)
{
try { try {
$rating = $ratings->whereId($id)->first(); $rating = $ratings->whereId($id)->first();
$rating->name = $request->input('name'); $rating->name = $request->input('name');
@@ -827,11 +855,12 @@ class SettingsController extends Controller {
* *
* @return type redirect * @return type redirect
*/ */
public function createRating() { public function createRating()
{
try { try {
return view('themes.default1.admin.helpdesk.settings.create-ratings'); return view('themes.default1.admin.helpdesk.settings.create-ratings');
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created') . '<li>' . $ex->getMessage() . '</li>'); return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created').'<li>'.$ex->getMessage().'</li>');
} }
} }
@@ -844,7 +873,8 @@ class SettingsController extends Controller {
* *
* @return type redirect * @return type redirect
*/ */
public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request) { public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request)
{
$rating->name = $request->input('name'); $rating->name = $request->input('name');
$rating->display_order = $request->input('display_order'); $rating->display_order = $request->input('display_order');
$rating->allow_modification = $request->input('allow_modification'); $rating->allow_modification = $request->input('allow_modification');
@@ -863,13 +893,16 @@ class SettingsController extends Controller {
* *
* @return type Redirect * @return type Redirect
*/ */
public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs) { public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs)
{
$ratingrefs->where('rating_id', '=', $slug)->delete(); $ratingrefs->where('rating_id', '=', $slug)->delete();
Rating::whereId($slug)->delete(); Rating::whereId($slug)->delete();
return redirect()->back()->with('success', Lang::get('lang.rating_deleted_successfully')); return redirect()->back()->with('success', Lang::get('lang.rating_deleted_successfully'));
} }
public function saveConditions() {
public function saveConditions()
{
if (\Input::get('fetching-commands') && \Input::get('notification-commands')) { if (\Input::get('fetching-commands') && \Input::get('notification-commands')) {
$fetching_commands = \Input::get('fetching-commands'); $fetching_commands = \Input::get('fetching-commands');
$fetching_dailyAt = \Input::get('fetching-dailyAt'); $fetching_dailyAt = \Input::get('fetching-dailyAt');
@@ -880,62 +913,66 @@ class SettingsController extends Controller {
$fetching_command = $this->getCommand($fetching_commands, $fetching_dailyAt); $fetching_command = $this->getCommand($fetching_commands, $fetching_dailyAt);
$notification_command = $this->getCommand($notification_commands, $notification_dailyAt); $notification_command = $this->getCommand($notification_commands, $notification_dailyAt);
$work_command = $this->getCommand($work_commands, $workflow_dailyAt); $work_command = $this->getCommand($work_commands, $workflow_dailyAt);
$jobs = ['fetching'=>$fetching_command,'notification'=>$notification_command,'work'=>$work_command]; $jobs = ['fetching'=>$fetching_command, 'notification'=>$notification_command, 'work'=>$work_command];
$this->storeCommand($jobs); $this->storeCommand($jobs);
} }
} }
public function getCommand($command, $daily_at) { public function getCommand($command, $daily_at)
{
if ($command == 'dailyAt') { if ($command == 'dailyAt') {
$command = "dailyAt,$daily_at"; $command = "dailyAt,$daily_at";
} }
return $command; return $command;
} }
public function storeCommand($array=[]){ public function storeCommand($array = [])
{
$command = new \App\Model\MailJob\Condition(); $command = new \App\Model\MailJob\Condition();
$commands = $command->get(); $commands = $command->get();
if($commands->count()>0){ if ($commands->count() > 0) {
foreach($commands as $condition){ foreach ($commands as $condition) {
$condition->delete(); $condition->delete();
} }
} }
if(count($array)>0){ if (count($array) > 0) {
foreach($array as $key=>$save){ foreach ($array as $key=>$save) {
$command->create([ $command->create([
'job'=>$key, 'job' => $key,
'value'=>$save, 'value'=> $save,
]); ]);
} }
} }
} }
public function getTicketNumber(Request $request) { public function getTicketNumber(Request $request)
{
$this->validate($request, [ $this->validate($request, [
'format' => ['required', 'regex:/^(?=.*[$|-|#]).+$/'], 'format' => ['required', 'regex:/^(?=.*[$|-|#]).+$/'],
'type' => 'required', 'type' => 'required',
]); ]);
$format = $request->input('format'); $format = $request->input('format');
$type = $request->input('type'); $type = $request->input('type');
$number = $this->switchNumber($format, $type); $number = $this->switchNumber($format, $type);
return $number; return $number;
} }
public function switchNumber($format, $type) { public function switchNumber($format, $type)
{
switch ($type) { switch ($type) {
case "random": case 'random':
return $this->createRandomNumber($format); return $this->createRandomNumber($format);
case "sequence": case 'sequence':
return $this->createSequencialNumber($format); return $this->createSequencialNumber($format);
} }
} }
public function createRandomNumber($format) { public function createRandomNumber($format)
$number = ""; {
$number = '';
$array = str_split($format); $array = str_split($format);
for ($i = 0; $i < count($array); $i++) { for ($i = 0; $i < count($array); $i++) {
if ($array[$i] === '$') { if ($array[$i] === '$') {
@@ -948,11 +985,13 @@ class SettingsController extends Controller {
$number .= $array[$i]; $number .= $array[$i];
} }
} }
return $number; return $number;
} }
public function createSequencialNumber($format) { public function createSequencialNumber($format)
$number = ""; {
$number = '';
$array_format = str_split($format); $array_format = str_split($format);
$count = count($array_format); $count = count($array_format);
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
@@ -965,16 +1004,17 @@ class SettingsController extends Controller {
$number .= '0'; $number .= '0';
} }
if ($array_format[$i] !== '$' && $array_format[$i] !== '#') { if ($array_format[$i] !== '$' && $array_format[$i] !== '#') {
$number .= $array_format[$i]; $number .= $array_format[$i];
} }
} }
return $number; return $number;
//return $this->nthTicketNumber($number); //return $this->nthTicketNumber($number);
} }
public function checkCurrentFormat($current, $format) { public function checkCurrentFormat($current, $format)
{
$check = true; $check = true;
$array_current = str_split($current); $array_current = str_split($current);
$array_format = str_split($format); $array_format = str_split($format);
@@ -988,11 +1028,12 @@ class SettingsController extends Controller {
return false; return false;
} }
} }
return $check; return $check;
} }
public function nthTicketNumber($current, $type, $format, $force = false) { public function nthTicketNumber($current, $type, $format, $force = false)
{
$check = $this->checkCurrentFormat($current, $format); $check = $this->checkCurrentFormat($current, $format);
if ($check === false && $force === false) { if ($check === false && $force === false) {
$current = $this->createSequencialNumber($format); $current = $this->createSequencialNumber($format);
@@ -1012,16 +1053,17 @@ class SettingsController extends Controller {
if ($type === 'random') { if ($type === 'random') {
$number = $this->createRandomNumber($format); $number = $this->createRandomNumber($format);
} }
return $number; return $number;
} }
public function getRandomAlphebet() { public function getRandomAlphebet()
$alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; {
$alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$shuffled = str_shuffle($alpha); $shuffled = str_shuffle($alpha);
$shuffled_array = str_split($shuffled); $shuffled_array = str_split($shuffled);
$char = $shuffled_array[0]; $char = $shuffled_array[0];
return $char; return $char;
} }
} }

View File

@@ -2,76 +2,87 @@
namespace App\Http\Controllers\Admin\helpdesk\SocialMedia; namespace App\Http\Controllers\Admin\helpdesk\SocialMedia;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Exception;
use App\Model\helpdesk\Settings\SocialMedia; use App\Model\helpdesk\Settings\SocialMedia;
use Exception;
use Illuminate\Http\Request;
class SocialMediaController extends Controller { class SocialMediaController extends Controller
{
public function __construct() { public function __construct()
{
$this->middleware(['auth', 'roles'], ['except' => ['configService']]); $this->middleware(['auth', 'roles'], ['except' => ['configService']]);
} }
public function settings($provider) { public function settings($provider)
{
try { try {
$social = new SocialMedia(); $social = new SocialMedia();
return view('themes.default1.admin.helpdesk.settings.social-media.settings', compact('social', 'provider')); return view('themes.default1.admin.helpdesk.settings.social-media.settings', compact('social', 'provider'));
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function postSettings($provider, Request $request) { public function postSettings($provider, Request $request)
{
$this->validate($request, [ $this->validate($request, [
'client_id' => 'required', 'client_id' => 'required',
'client_secret' => 'required', 'client_secret' => 'required',
'redirect' => 'required|url', 'redirect' => 'required|url',
]); ]);
try { try {
$requests = $request->except('_token'); $requests = $request->except('_token');
$this->insertProvider($provider, $requests); $this->insertProvider($provider, $requests);
return redirect()->back()->with('success', 'Updated'); return redirect()->back()->with('success', 'Updated');
} catch (Exception $ex) { } catch (Exception $ex) {
dd($ex); dd($ex);
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function deleteProvider($provider, $requests) { public function deleteProvider($provider, $requests)
{
$social = new SocialMedia(); $social = new SocialMedia();
$socials = $social->where('provider', $provider)->get(); $socials = $social->where('provider', $provider)->get();
if ($socials->count() > 0) { if ($socials->count() > 0) {
foreach ($socials as $media) { foreach ($socials as $media) {
if (array_key_exists($media->key,$requests)) { if (array_key_exists($media->key, $requests)) {
$media->delete(); $media->delete();
} }
} }
} }
} }
public function insertProvider($provider, $requests = []) { public function insertProvider($provider, $requests = [])
{
$this->deleteProvider($provider, $requests); $this->deleteProvider($provider, $requests);
$social = new SocialMedia(); $social = new SocialMedia();
foreach ($requests as $key => $value) { foreach ($requests as $key => $value) {
$social->create([ $social->create([
'provider' => $provider, 'provider' => $provider,
'key' => $key, 'key' => $key,
'value' => $value, 'value' => $value,
]); ]);
} }
} }
public function index() { public function index()
{
try { try {
$social = new SocialMedia(); $social = new SocialMedia();
return view('themes.default1.admin.helpdesk.settings.social-media.index', compact('social')); return view('themes.default1.admin.helpdesk.settings.social-media.index', compact('social'));
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function configService() { public function configService()
{
$social = new SocialMedia(); $social = new SocialMedia();
$services = $this->services(); $services = $this->services();
foreach ($services as $service) { foreach ($services as $service) {
@@ -82,7 +93,8 @@ class SocialMediaController extends Controller {
// dd(\Config::get('services')); // dd(\Config::get('services'));
} }
public function services() { public function services()
{
return [ return [
'facebook', 'facebook',
'google', 'google',
@@ -92,5 +104,4 @@ class SocialMediaController extends Controller {
'bitbucket', 'bitbucket',
]; ];
} }
} }

View File

@@ -9,9 +9,9 @@ use App\Http\Requests\helpdesk\TeamRequest;
use App\Http\Requests\helpdesk\TeamUpdate; use App\Http\Requests\helpdesk\TeamUpdate;
// models // models
use App\Model\helpdesk\Agent\Assign_team_agent; use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Agent\Groups; use App\Model\helpdesk\Agent\Groups;
use App\Model\helpdesk\Agent\Teams;
use App\User; use App\User;
// classes // classes
use DB; use DB;
@@ -102,7 +102,8 @@ class TeamController extends Controller
return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_create').'<li>'.$e->getMessage().'</li>'); return redirect('teams')->with('fails', Lang::get('lang.teams_can_not_create').'<li>'.$e->getMessage().'</li>');
} }
} }
/**
/**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param type $id * @param type $id
@@ -117,79 +118,76 @@ class TeamController extends Controller
try { try {
$user = $user->whereId($id)->first(); $user = $user->whereId($id)->first();
$teams = $team->whereId($id)->first(); $teams = $team->whereId($id)->first();
// $team_lead_name=User::whereId($teams->team_lead)->first(); // $team_lead_name=User::whereId($teams->team_lead)->first();
// $team_lead = $team_lead_name->first_name . " " . $team_lead_name->last_name; // $team_lead = $team_lead_name->first_name . " " . $team_lead_name->last_name;
// $total_members = $assign_team_agent->where('team_id',$id)->count(); // $total_members = $assign_team_agent->where('team_id',$id)->count();
return view('themes.default1.admin.helpdesk.agent.teams.show', compact('user', 'teams','id')); return view('themes.default1.admin.helpdesk.agent.teams.show', compact('user', 'teams', 'id'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
} }
public function getshow($id) { public function getshow($id)
// dd($request); {
// dd($request);
// $id = $request->input('show_id'); // $id = $request->input('show_id');
// dd($id); // dd($id);
$users = DB::table('team_assign_agent')->select('team_assign_agent.id','team_assign_agent.team_id','users.user_name','users.first_name' ,'users.last_name','users.active','users.assign_group','users.primary_dpt','users.role') $users = DB::table('team_assign_agent')->select('team_assign_agent.id', 'team_assign_agent.team_id', 'users.user_name', 'users.first_name', 'users.last_name', 'users.active', 'users.assign_group', 'users.primary_dpt', 'users.role')
->join('users','users.id','=','team_assign_agent.agent_id') ->join('users', 'users.id', '=', 'team_assign_agent.agent_id')
->where('team_assign_agent.team_id', '=',$id); ->where('team_assign_agent.team_id', '=', $id);
// ->get(); // ->get();
// dd($users); // dd($users);
return \Datatable::query($users) return \Datatable::query($users)
->showColumns('user_name') ->showColumns('user_name')
->addColumn('first_name', function($model) { ->addColumn('first_name', function ($model) {
$full_name = ucfirst($model->first_name).' '.ucfirst($model->last_name); $full_name = ucfirst($model->first_name).' '.ucfirst($model->last_name);
return $full_name;
})
return $full_name;
})
->addColumn('active', function($model) { ->addColumn('active', function ($model) {
if ($model->active == '1') { if ($model->active == '1') {
$role = "<a class='btn btn-success btn-xs'>".'Active'."</a>"; $role = "<a class='btn btn-success btn-xs'>".'Active'.'</a>';
} elseif ($model->active == 'agent') { } elseif ($model->active == 'agent') {
$role = "<a class='btn btn-primary btn-xs'>".'Inactive'."</a>"; $role = "<a class='btn btn-primary btn-xs'>".'Inactive'.'</a>';
} }
return $role;
})
return $role;
})
->addColumn('assign_group', function($model) { ->addColumn('assign_group', function ($model) {
$group=Groups::whereId($model->assign_group)->first(); $group = Groups::whereId($model->assign_group)->first();
return ($group->name);
}) return $group->name;
->addColumn('primary_dpt', function($model) { })
$dept=Department::whereId($model->primary_dpt)->first(); ->addColumn('primary_dpt', function ($model) {
return $dept->name; $dept = Department::whereId($model->primary_dpt)->first();
})
->addColumn('role', function($model) { return $dept->name;
})
->addColumn('role', function ($model) {
if ($model->role == 'admin') { if ($model->role == 'admin') {
$role = "<a class='btn btn-success btn-xs'>".$model->role."</a>"; $role = "<a class='btn btn-success btn-xs'>".$model->role.'</a>';
} elseif ($model->role == 'agent') { } elseif ($model->role == 'agent') {
$role = "<a class='btn btn-primary btn-xs'>".$model->role."</a>"; $role = "<a class='btn btn-primary btn-xs'>".$model->role.'</a>';
} }
return $role;
}) return $role;
})
// ->showColumns('role') // ->showColumns('role')
->searchColumns('first_name','last_name') ->searchColumns('first_name', 'last_name')
->orderColumns('first_name','last_name') ->orderColumns('first_name', 'last_name')
->make(); ->make();
}
}
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.

View File

@@ -13,26 +13,25 @@ use App\Http\Requests\helpdesk\TemplateUdate;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Email\Template; use App\Model\helpdesk\Email\Template;
use App\Model\helpdesk\Utility\Languages; use App\Model\helpdesk\Utility\Languages;
use App\Model\helpdesk\Settings\CommonSettings;
// classes // classes
use Exception; use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Input; use Input;
use Lang;
/** /**
* TemplateController. * TemplateController.
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class TemplateController extends Controller { class TemplateController extends Controller
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* *
* @return type void * @return type void
*/ */
public function __construct(PhpMailController $PhpMailController) { public function __construct(PhpMailController $PhpMailController)
{
$this->PhpMailController = $PhpMailController; $this->PhpMailController = $PhpMailController;
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
@@ -45,7 +44,8 @@ class TemplateController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function index(Template $template) { public function index(Template $template)
{
try { try {
$templates = $template->get(); $templates = $template->get();
@@ -63,7 +63,8 @@ class TemplateController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function create(Languages $language, Template $template) { public function create(Languages $language, Template $template)
{
try { try {
$templates = $template->get(); $templates = $template->get();
$languages = $language->get(); $languages = $language->get();
@@ -82,7 +83,8 @@ class TemplateController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function store(Template $template, TemplateRequest $request) { public function store(Template $template, TemplateRequest $request)
{
try { try {
/* Check whether function success or not */ /* Check whether function success or not */
if ($template->fill($request->input())->save() == true) { if ($template->fill($request->input())->save() == true) {
@@ -105,7 +107,8 @@ class TemplateController extends Controller {
* *
* @return Response * @return Response
*/ */
public function show($id) { public function show($id)
{
// //
} }
@@ -118,37 +121,41 @@ class TemplateController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function listdirectories() { public function listdirectories()
$path = \Config::get('view.paths')[0] . '/emails/'; {
$path = \Config::get('view.paths')[0].'/emails/';
$directories = scandir($path); $directories = scandir($path);
$directory = str_replace('/', '-', $path); $directory = str_replace('/', '-', $path);
return view('themes.default1.admin.helpdesk.emails.template.listdirectories', compact('directories', 'directory')); 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); $paths = str_replace('-', '/', $path);
$directory2 = $paths . $template; $directory2 = $paths.$template;
$templates = scandir($directory2); $templates = scandir($directory2);
$directory = str_replace('/', '-', $directory2 . '/'); $directory = str_replace('/', '-', $directory2.'/');
return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates', 'directory')); 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); $directory = str_replace('-', '/', $path);
$handle = fopen($directory . $template, 'r'); $handle = fopen($directory.$template, 'r');
$contents = fread($handle, filesize($directory . $template)); $contents = fread($handle, filesize($directory.$template));
fclose($handle); fclose($handle);
return view('themes.default1.admin.helpdesk.emails.template.readtemplates', compact('contents', 'template', 'path')); return view('themes.default1.admin.helpdesk.emails.template.readtemplates', compact('contents', 'template', 'path'));
} }
public function createtemplate() { public function createtemplate()
{
$directory = '../resources/views/emails/'; $directory = '../resources/views/emails/';
$fname = Input::get('folder_name'); $fname = Input::get('folder_name');
$filename = $directory . $fname; $filename = $directory.$fname;
// images folder creation using php // images folder creation using php
// $mydir = dirname( __FILE__ )."/html/images"; // $mydir = dirname( __FILE__ )."/html/images";
@@ -160,7 +167,7 @@ class TemplateController extends Controller {
if (!file_exists($filename)) { if (!file_exists($filename)) {
mkdir($filename, 0777); mkdir($filename, 0777);
} }
$files = array_filter(scandir($directory . 'default')); $files = array_filter(scandir($directory.'default'));
foreach ($files as $file) { foreach ($files as $file) {
if ($file === '.' or $file === '..') { if ($file === '.' or $file === '..') {
@@ -168,27 +175,29 @@ class TemplateController extends Controller {
} }
if (!is_dir($file)) { if (!is_dir($file)) {
// $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$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'); return \Redirect::back()->with('success', 'Successfully copied');
} }
public function writetemplate($template, $path) { public function writetemplate($template, $path)
{
$directory = str_replace('-', '/', $path); $directory = str_replace('-', '/', $path);
$b = Input::get('templatedata'); $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'); return \Redirect::back()->with('success', 'Successfully updated');
} }
public function deletetemplate($template, $path) { public function deletetemplate($template, $path)
{
$directory = str_replace('-', '/', $path); $directory = str_replace('-', '/', $path);
$dir = $directory . $template; $dir = $directory.$template;
$status = \DB::table('settings_email')->first(); $status = \DB::table('settings_email')->first();
if ($template == 'default' or $template == $status->template) { if ($template == 'default' or $template == $status->template) {
return \Redirect::back()->with('fails', 'You cannot delete a default or active directory!'); return \Redirect::back()->with('fails', 'You cannot delete a default or active directory!');
@@ -197,7 +206,7 @@ class TemplateController extends Controller {
$objects = scandir($dir); $objects = scandir($dir);
foreach ($objects as $object) { foreach ($objects as $object) {
if ($object != '.' && $object != '..') { if ($object != '.' && $object != '..') {
unlink($dir . '/' . $object); unlink($dir.'/'.$object);
} }
} }
rmdir($dir); rmdir($dir);
@@ -208,13 +217,15 @@ class TemplateController extends Controller {
return \Redirect::back()->with('success', 'Successfully Deleted'); return \Redirect::back()->with('success', 'Successfully Deleted');
} }
public function activateset($setname) { public function activateset($setname)
{
\DB::table('settings_email')->update(['template' => $setname]); \DB::table('settings_email')->update(['template' => $setname]);
return \Redirect::back()->with('success', 'You have Successfully Activated this Set'); 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 { try {
$templates = $template->whereId($id)->first(); $templates = $template->whereId($id)->first();
$languages = $language->get(); $languages = $language->get();
@@ -234,7 +245,8 @@ class TemplateController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function update($id, Template $template, TemplateUdate $request) { public function update($id, Template $template, TemplateUdate $request)
{
try { try {
//TODO validation //TODO validation
$templates = $template->whereId($id)->first(); $templates = $template->whereId($id)->first();
@@ -260,7 +272,8 @@ class TemplateController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function destroy($id, Template $template) { public function destroy($id, Template $template)
{
try { try {
$templates = $template->whereId($id)->first(); $templates = $template->whereId($id)->first();
/* Check whether function success or not */ /* Check whether function success or not */
@@ -284,7 +297,8 @@ class TemplateController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function formDiagno(Emails $email) { public function formDiagno(Emails $email)
{
try { try {
$emails = $email->get(); $emails = $email->get();
@@ -301,7 +315,8 @@ class TemplateController extends Controller {
* *
* @return type * @return type
*/ */
public function postDiagno(DiagnosRequest $request) { public function postDiagno(DiagnosRequest $request)
{
try { try {
$to = $request->input('to'); $to = $request->input('to');
$subject = $request->input('subject'); $subject = $request->input('subject');
@@ -313,12 +328,13 @@ class TemplateController extends Controller {
} }
$controller = new PhpMailController(); $controller = new PhpMailController();
$controller->setMailConfig($from_address); $controller->setMailConfig($from_address);
$controller->laravelMail($to, '', $subject, $msg,[],null); $controller->laravelMail($to, '', $subject, $msg, [], null);
return redirect()->back()->with('success', 'Mail has send successfully'); return redirect()->back()->with('success', 'Mail has send successfully');
} catch (Exception $e) { } catch (Exception $e) {
dd($e); dd($e);
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
} }
} }

View File

@@ -2,102 +2,118 @@
namespace App\Http\Controllers\Admin\helpdesk; namespace App\Http\Controllers\Admin\helpdesk;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Exception; use Exception;
use Illuminate\Http\Request;
class UrlSettingController extends Controller { class UrlSettingController extends Controller
{
public function __construct() { public function __construct()
{
$this->middleware('auth'); $this->middleware('auth');
} }
public function settings(Request $request) { public function settings(Request $request)
{
$url = $request->url(); $url = $request->url();
$www = $this->checkWWW($url); $www = $this->checkWWW($url);
$https = $this->checkHTTP($url); $https = $this->checkHTTP($url);
//dd($www, $https); //dd($www, $https);
try { try {
return view('themes.default1.admin.helpdesk.settings.url.settings',compact('www','https')); return view('themes.default1.admin.helpdesk.settings.url.settings', compact('www', 'https'));
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function postSettings(Request $request) { public function postSettings(Request $request)
{
try { try {
$www = $request->input('www'); $www = $request->input('www');
$ssl = $request->input('ssl'); $ssl = $request->input('ssl');
$string_www = $this->www($www); $string_www = $this->www($www);
$sting_ssl = $this->ssl($ssl); $sting_ssl = $this->ssl($ssl);
$string = $string_www . $sting_ssl; $string = $string_www.$sting_ssl;
$this->writeHtaccess($string); $this->writeHtaccess($string);
return redirect()->back()->with('success', 'updated'); return redirect()->back()->with('success', 'updated');
} catch (Exception $ex) { } catch (Exception $ex) {
dd($ex); dd($ex);
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function www($www) { public function www($www)
{
switch ($www) { switch ($www) {
case "yes": case 'yes':
return $this->changeWww(); return $this->changeWww();
case "no": case 'no':
return $this->changeNonwww(); return $this->changeNonwww();
} }
} }
public function changeWww() { public function changeWww()
{
$string = "RewriteCond %{HTTP_HOST} !^www\. $string = "RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"; RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
return $string; return $string;
} }
public function changeNonwww() { public function changeNonwww()
{
$string = "RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] $string = "RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]\n"; RewriteRule ^(.*)$ http://%1/$1 [R=301,L]\n";
return $string; return $string;
} }
public function ssl($ssl) { public function ssl($ssl)
{
switch ($ssl) { switch ($ssl) {
case "yes": case 'yes':
return $this->changeHttps(); return $this->changeHttps();
case "no": case 'no':
return $this->changeHttp(); return $this->changeHttp();
} }
} }
public function changeHttps() { public function changeHttps()
{
$string = "RewriteCond %{HTTPS} off $string = "RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"; RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
return $string; return $string;
} }
public function changeHttp() { public function changeHttp()
{
//$string = "RewriteCond %{HTTPS} off //$string = "RewriteCond %{HTTPS} off
//RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"; //RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
$string = ""; $string = '';
return $string; return $string;
} }
public function writeHtaccess($string) { public function writeHtaccess($string)
{
//dd(public_path('.htaccess'),base_path('.htaccess')); //dd(public_path('.htaccess'),base_path('.htaccess'));
$file = public_path('.htaccess'); $file = public_path('.htaccess');
if(!\File::exists($file)){ if (!\File::exists($file)) {
$file = base_path('/../.htaccess'); $file = base_path('/../.htaccess');
} }
$this->deleteCustom(); $this->deleteCustom();
$content = file_get_contents($file); $content = file_get_contents($file);
file_put_contents($file, $content . "#custom\n" . $string); file_put_contents($file, $content."#custom\n".$string);
$new_content = file_get_contents($file); $new_content = file_get_contents($file);
} }
public function deleteCustom() { public function deleteCustom()
{
$file = public_path('.htaccess'); $file = public_path('.htaccess');
if(!\File::exists($file)){ if (!\File::exists($file)) {
$file = base_path('/../.htaccess'); $file = base_path('/../.htaccess');
} }
$content = file_get_contents($file); $content = file_get_contents($file);
@@ -108,23 +124,28 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
file_put_contents($file, $content); file_put_contents($file, $content);
} }
public function checkWwwInUrl($url) { public function checkWwwInUrl($url)
{
$check = false; $check = false;
if (strpos($url, 'www') !== false) { if (strpos($url, 'www') !== false) {
$check = true; $check = true;
} }
return $check; return $check;
} }
public function checkHttpsInUrl($url) { public function checkHttpsInUrl($url)
{
$check = false; $check = false;
if (strpos($url, 'https') !== false) { if (strpos($url, 'https') !== false) {
$check = true; $check = true;
} }
return $check; return $check;
} }
public function checkWWW($url) { public function checkWWW($url)
{
$check = $this->checkWwwInUrl($url); $check = $this->checkWwwInUrl($url);
$array['www'] = true; $array['www'] = true;
$array['nonwww'] = false; $array['nonwww'] = false;
@@ -132,9 +153,12 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
$array['www'] = false; $array['www'] = false;
$array['nonwww'] = true; $array['nonwww'] = true;
} }
return $array; return $array;
} }
public function checkHTTP($url) {
public function checkHTTP($url)
{
$check = $this->checkHttpsInUrl($url); $check = $this->checkHttpsInUrl($url);
$array['https'] = true; $array['https'] = true;
$array['http'] = false; $array['http'] = false;
@@ -142,7 +166,7 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n";
$array['https'] = false; $array['https'] = false;
$array['http'] = true; $array['http'] = true;
} }
return $array; return $array;
} }
} }

View File

@@ -2,30 +2,30 @@
namespace App\Http\Controllers\Agent\helpdesk\Filter; namespace App\Http\Controllers\Agent\helpdesk\Filter;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Filters\Label;
use App\Model\helpdesk\Filters\Filter;
use App\Model\helpdesk\Ticket\Tickets;
use DB;
use Auth;
use App\Http\Controllers\Agent\helpdesk\TicketController; use App\Http\Controllers\Agent\helpdesk\TicketController;
use Datatables; use App\Http\Controllers\Controller;
use App\Model\helpdesk\Filters\Filter;
use App\Model\helpdesk\Filters\Label;
use App\Model\helpdesk\Ticket\Tickets;
use Auth;
use DB;
use Illuminate\Http\Request;
class FilterController extends Controller { class FilterController extends Controller
{
protected $request; protected $request;
public function __construct(Request $req) { public function __construct(Request $req)
{
$this->middleware(['auth', 'role.agent']); $this->middleware(['auth', 'role.agent']);
$this->request = $req; $this->request = $req;
} }
public function getFilter(Request $request) { public function getFilter(Request $request)
{
$labels = $this->request->input('labels'); $labels = $this->request->input('labels');
$tags = $this->request->input('tags'); $tags = $this->request->input('tags');
if($request->has('department')) { if ($request->has('department')) {
$table = $this->departmentTickets($request->input('department'), $request->input('status')); $table = $this->departmentTickets($request->input('department'), $request->input('status'));
} else { } else {
$segment = $this->request->input('segment'); $segment = $this->request->input('segment');
@@ -35,212 +35,216 @@ class FilterController extends Controller {
$render = false; $render = false;
if (is_array($labels) && count($labels) > 0) { if (is_array($labels) && count($labels) > 0) {
$table = $table $table = $table
->leftJoin('filters as label',function($join){ ->leftJoin('filters as label', function ($join) {
$join->on('tickets.id', '=', 'label.ticket_id') $join->on('tickets.id', '=', 'label.ticket_id')
->where('label.key','=','label'); ->where('label.key', '=', 'label');
}) })
->whereIn('label.value',$labels); ->whereIn('label.value', $labels);
} }
if (is_array($tags) && count($tags) > 0) { if (is_array($tags) && count($tags) > 0) {
$table = $table $table = $table
->leftJoin('filters as tag',function($join){ ->leftJoin('filters as tag', function ($join) {
$join->on('tickets.id', '=', 'tag.ticket_id') $join->on('tickets.id', '=', 'tag.ticket_id')
->where('tag.key','=','tag'); ->where('tag.key', '=', 'tag');
}) })
->whereIn('tag.value',$tags); ->whereIn('tag.value', $tags);
} }
if((is_array($tags) && count($tags) > 0) || (is_array($labels) && count($labels) > 0)){ if ((is_array($tags) && count($tags) > 0) || (is_array($labels) && count($labels) > 0)) {
$render = true; $render = true;
} }
// return \Datatables::of($table)->make(); // return \Datatables::of($table)->make();
return \Ttable::getTable($table); return \Ttable::getTable($table);
} }
public function filterByKey($key,$labels = []) { public function filterByKey($key, $labels = [])
{
$filter = new Filter(); $filter = new Filter();
$query = $filter->where('key', $key) $query = $filter->where('key', $key)
->where(function($query) use($labels) { ->where(function ($query) use ($labels) {
if (is_array($labels) && count($labels) > 0) { if (is_array($labels) && count($labels) > 0) {
for ($i = 0; $i < count($labels); $i++) { for ($i = 0; $i < count($labels); $i++) {
$query->orWhere('value', 'LIKE', '%' . $labels[$i] . '%'); $query->orWhere('value', 'LIKE', '%'.$labels[$i].'%');
} }
} }
}) })
->lists('ticket_id') ->lists('ticket_id')
->toArray(); ->toArray();
return $query; return $query;
} }
public function segments($segment){ public function segments($segment)
if (strpos($segment, "user") !== false) { {
if (strpos($segment, 'user') !== false) {
return $this->formatUserTickets($segment); return $this->formatUserTickets($segment);
} }
$table = $this->table(); $table = $this->table();
switch($segment){ switch ($segment) {
case "/ticket/inbox": case '/ticket/inbox':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id)->orWhere('assigned_to', '=', Auth::user()->id); $table = $table->where('tickets.dept_id', '=', $id)->orWhere('assigned_to', '=', Auth::user()->id);
} }
return $table return $table
->Join('ticket_status', function ($join) { ->Join('ticket_status', function ($join) {
$join->on('ticket_status.id', '=', 'tickets.status') $join->on('ticket_status.id', '=', 'tickets.status')
->whereIn('ticket_status.id', [1, 7]); ->whereIn('ticket_status.id', [1, 7]);
}); });
case "/ticket/closed": case '/ticket/closed':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->Join('ticket_status', function ($join) { ->Join('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status') $join->on('ticket_status.id', '=', 'tickets.status')
->whereIn('ticket_status.state',['closed']); ->whereIn('ticket_status.state', ['closed']);
}); });
case "/ticket/myticket": case '/ticket/myticket':
return $table return $table
->leftJoin('ticket_status', function ($join) { ->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status'); $join->on('ticket_status.id', '=', 'tickets.status');
})
})
->orWhere('tickets.assigned_to', '=', Auth::user()->id) ->orWhere('tickets.assigned_to', '=', Auth::user()->id)
->where('tickets.status','=',1 ); ->where('tickets.status', '=', 1);
case "/unassigned": case '/unassigned':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->leftJoin('ticket_status', function ($join) { ->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status'); $join->on('ticket_status.id', '=', 'tickets.status');
})
})
->where('tickets.assigned_to', '=', null) ->where('tickets.assigned_to', '=', null)
->where('tickets.status','=',1 ); ->where('tickets.status', '=', 1);
case "/ticket/overdue": case '/ticket/overdue':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->leftJoin('ticket_status', function ($join) { ->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status'); $join->on('ticket_status.id', '=', 'tickets.status');
}) })
->where('tickets.status', '=', 1) ->where('tickets.status', '=', 1)
// ->where('tickets.isanswered', '=', 0) // ->where('tickets.isanswered', '=', 0)
->whereNotNull('tickets.duedate') ->whereNotNull('tickets.duedate')
->where('tickets.duedate','!=', '00-00-00 00:00:00') ->where('tickets.duedate', '!=', '00-00-00 00:00:00')
// ->where('duedate','>',\Carbon\Carbon::now()); // ->where('duedate','>',\Carbon\Carbon::now());
->where('tickets.duedate','<', \Carbon\Carbon::now()); ->where('tickets.duedate', '<', \Carbon\Carbon::now());
case "/ticket/approval/closed": case '/ticket/approval/closed':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->Join('ticket_status', function ($join) { ->Join('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status') $join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status','=',7 ); ->where('tickets.status', '=', 7);
}); });
case "/trash": case '/trash':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->Join('ticket_status', function ($join) { ->Join('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status') $join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status','=',5 ); ->where('tickets.status', '=', 5);
}); });
case "/ticket/answered": case '/ticket/answered':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->Join('ticket_status', function ($join) { ->Join('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status') $join->on('ticket_status.id', '=', 'tickets.status')
->where('tickets.status','=',1 ) ->where('tickets.status', '=', 1)
->where('tickets.isanswered', '=', 1); ->where('tickets.isanswered', '=', 1);
}); });
case "/ticket/assigned": case '/ticket/assigned':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->leftJoin('ticket_status', function ($join) { ->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status'); $join->on('ticket_status.id', '=', 'tickets.status');
})
})
->where('tickets.assigned_to', '>', 0) ->where('tickets.assigned_to', '>', 0)
->where('tickets.status','=',1 ); ->where('tickets.status', '=', 1);
case "/ticket/open": case '/ticket/open':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->leftJoin('ticket_status', function ($join) { ->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status'); $join->on('ticket_status.id', '=', 'tickets.status');
})
}) ->where('tickets.status', '=', 1);
->where('tickets.status','=',1 ); case '/duetoday':
case "/duetoday":
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->leftJoin('ticket_status', function ($join) { ->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status'); $join->on('ticket_status.id', '=', 'tickets.status');
}) })
->where('tickets.status','=',1 ) ->where('tickets.status', '=', 1)
->whereNotNull('tickets.duedate') ->whereNotNull('tickets.duedate')
->whereDate('tickets.duedate','=', \Carbon\Carbon::now()->format('Y-m-d')); ->whereDate('tickets.duedate', '=', \Carbon\Carbon::now()->format('Y-m-d'));
case "/ticket/followup": case '/ticket/followup':
if (Auth::user()->role == 'agent') { if (Auth::user()->role == 'agent') {
$id=Auth::user()->primary_dpt; $id = Auth::user()->primary_dpt;
$table = $table->where('tickets.dept_id', '=', $id); $table = $table->where('tickets.dept_id', '=', $id);
} }
return $table return $table
->leftJoin('ticket_status', function ($join) { ->leftJoin('ticket_status', function ($join) {
$join->on('ticket_status.id','=','tickets.status'); $join->on('ticket_status.id', '=', 'tickets.status');
}) })
->where('tickets.status', '=', 1) ->where('tickets.status', '=', 1)
// ->where('tickets.isanswered', '=', 0) // ->where('tickets.isanswered', '=', 0)
->where('tickets.follow_up', '=', 1); ->where('tickets.follow_up', '=', 1);
} }
} }
public function table(){ public function table()
{
// if (Auth::user()->role == 'admin') { // if (Auth::user()->role == 'admin') {
$ticket = new Tickets(); $ticket = new Tickets();
$tickets = $ticket $tickets = $ticket
->leftJoin('ticket_thread', function ($join) { ->leftJoin('ticket_thread', function ($join) {
$join->on('tickets.id', '=', 'ticket_thread.ticket_id') $join->on('tickets.id', '=', 'ticket_thread.ticket_id')
->whereNotNull('title') ->whereNotNull('title')
->where('ticket_thread.is_internal', '<>', 1); ->where('ticket_thread.is_internal', '<>', 1);
}) })
->Join('ticket_source', 'ticket_source.id', '=', 'tickets.source') ->Join('ticket_source', 'ticket_source.id', '=', 'tickets.source')
->leftJoin('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') ->leftJoin('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->leftJoin('users as u', 'u.id', '=', 'tickets.user_id') ->leftJoin('users as u', 'u.id', '=', 'tickets.user_id')
->leftJoin('users as u1', 'u1.id', '=', 'tickets.assigned_to') ->leftJoin('users as u1', 'u1.id', '=', 'tickets.assigned_to')
->leftJoin('ticket_attachment', 'ticket_attachment.thread_id', '=', 'ticket_thread.id') ->leftJoin('ticket_attachment', 'ticket_attachment.thread_id', '=', 'ticket_thread.id')
->leftJoin('ticket_collaborator', 'ticket_collaborator.ticket_id', '=', 'tickets.id') ->leftJoin('ticket_collaborator', 'ticket_collaborator.ticket_id', '=', 'tickets.id')
->select( ->select(
'tickets.id', 'tickets.id',
@@ -254,7 +258,7 @@ class FilterController extends Controller {
'tickets.priority_id', 'tickets.assigned_to', 'tickets.priority_id', 'tickets.assigned_to',
DB::raw('COUNT(ticket_thread.updated_at) as countthread'), DB::raw('COUNT(ticket_thread.updated_at) as countthread'),
'ticket_priority.priority_color', 'ticket_priority.priority_color',
'u.first_name as first_name', 'u.first_name as first_name',
'u.last_name as last_name', 'u.last_name as last_name',
'u1.first_name as assign_first_name', 'u1.first_name as assign_first_name',
'u1.last_name as assign_last_name', 'u1.last_name as assign_last_name',
@@ -268,58 +272,67 @@ class FilterController extends Controller {
DB::raw('substring_index(group_concat(ticket_thread.title order by ticket_thread.id asc) , ",", 1) as ticket_title'), DB::raw('substring_index(group_concat(ticket_thread.title order by ticket_thread.id asc) , ",", 1) as ticket_title'),
'u.active as verified') 'u.active as verified')
->groupby('tickets.id'); ->groupby('tickets.id');
return $tickets; return $tickets;
} }
public function filter($render,$ticket_id=[]){ public function filter($render, $ticket_id = [])
{
if (Auth::user()->role == 'admin') { if (Auth::user()->role == 'admin') {
$tickets = Tickets::whereIn('status', array(1, 7)); $tickets = Tickets::whereIn('status', [1, 7]);
} else { } else {
$dept = DB::table('department')->where('id', '=', Auth::user()->primary_dpt)->first(); $dept = DB::table('department')->where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::whereIn('status', array(1, 7))->where('dept_id', '=', $dept->id); $tickets = Tickets::whereIn('status', [1, 7])->where('dept_id', '=', $dept->id);
} }
if($render==true){ if ($render == true) {
$tickets = $tickets->whereIn('id',$ticket_id); $tickets = $tickets->whereIn('id', $ticket_id);
} }
return $tickets; return $tickets;
} }
public function ticketController(){ public function ticketController()
{
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController(); $PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController(); $NotificationController = new \App\Http\Controllers\Common\NotificationController();
$ticket_controller = new TicketController($PhpMailController, $NotificationController); $ticket_controller = new TicketController($PhpMailController, $NotificationController);
return $ticket_controller; return $ticket_controller;
} }
public function departmentTickets($dept, $status) public function departmentTickets($dept, $status)
{ {
$table = $this->table(); $table = $this->table();
return $table->leftJoin('department as dep', 'tickets.dept_id', '=', 'dep.id') return $table->leftJoin('department as dep', 'tickets.dept_id', '=', 'dep.id')
->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id') ->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('dep.name',$dept) ->where('dep.name', $dept)
->where('ticket_status.name',$status); ->where('ticket_status.name', $status);
} }
/** /**
*@category function to format and return user tickets *@category function to format and return user tickets
*
*@param string $segment *@param string $segment
*
*@return builder *@return builder
*/ */
public function formatUserTickets($segment) public function formatUserTickets($segment)
{ {
$convert_to_array = explode("/",$segment); $convert_to_array = explode('/', $segment);
$user_id = $convert_to_array[2]; $user_id = $convert_to_array[2];
$user = \DB::table('users')->select('role', 'id')->where('id', '=', $user_id)->first(); $user = \DB::table('users')->select('role', 'id')->where('id', '=', $user_id)->first();
$table = $this->table(); $table = $this->table();
if ($user->role == 'user') { if ($user->role == 'user') {
$table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id') $table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('tickets.user_id', '=', $user->id) ->where('tickets.user_id', '=', $user->id)
->where('ticket_status.name',$convert_to_array[3]); ->where('ticket_status.name', $convert_to_array[3]);
} else { } else {
$table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id') $table = $table->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->where('tickets.assigned_to', '=', $user->id) ->where('tickets.assigned_to', '=', $user->id)
->where('ticket_status.name',$convert_to_array[3]); ->where('ticket_status.name', $convert_to_array[3]);
} }
return $table; return $table;
} }
} }

View File

@@ -4,10 +4,12 @@ namespace App\Http\Controllers\Agent\helpdesk;
use PhpImap\Mailbox; use PhpImap\Mailbox;
class ImapMail extends Mailbox { class ImapMail extends Mailbox
{
public function get_overview($mailId) { public function get_overview($mailId)
{
$overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID); $overview = imap_fetch_overview($this->getImapStream(), $mailId, FT_UID);
return $overview; return $overview;
} }
@@ -16,13 +18,14 @@ class ImapMail extends Mailbox {
* For example, to match all unanswered mails sent by Mom, you'd use: "UNANSWERED FROM mom". * For example, to match all unanswered mails sent by Mom, you'd use: "UNANSWERED FROM mom".
* *
* @param string $criteria See http://php.net/imap_search for a complete list of available criteria * @param string $criteria See http://php.net/imap_search for a complete list of available criteria
*
* @return array mailsIds (or empty array) * @return array mailsIds (or empty array)
*/ */
public function searchMailbox($criteria = 'ALL') { public function searchMailbox($criteria = 'ALL')
{
//dd($this->getImapStream()); //dd($this->getImapStream());
$mailsIds = imap_search($this->getImapStream(), $criteria, SE_UID); $mailsIds = imap_search($this->getImapStream(), $criteria, SE_UID);
//dd($mailsIds); //dd($mailsIds);
return $mailsIds ? $mailsIds : array(); return $mailsIds ? $mailsIds : [];
} }
} }

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Agent\helpdesk; namespace App\Http\Controllers\Agent\helpdesk;
// models // models
use App\Http\Controllers\Admin\MailFetch as Fetch;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
@@ -12,24 +13,24 @@ use App\Model\helpdesk\Settings\Ticket;
use App\Model\helpdesk\Ticket\Ticket_attachments; use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_source; use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Thread; use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
// classes // classes
use App\Http\Controllers\Admin\MailFetch as Fetch; use App\Model\helpdesk\Ticket\Tickets;
/** /**
* MailController. * MailController.
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class MailController extends Controller { class MailController extends Controller
{
/** /**
* constructor * constructor
* Create a new controller instance. * Create a new controller instance.
* *
* @param type TicketController $TicketController * @param type TicketController $TicketController
*/ */
public function __construct(TicketWorkflowController $TicketWorkflowController) { public function __construct(TicketWorkflowController $TicketWorkflowController)
{
$this->middleware('board'); $this->middleware('board');
$this->TicketWorkflowController = $TicketWorkflowController; $this->TicketWorkflowController = $TicketWorkflowController;
} }
@@ -39,7 +40,8 @@ class MailController extends Controller {
* *
* @return type * @return type
*/ */
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) { public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket)
{
//dd($emails); //dd($emails);
if ($settings_email->first()->email_fetching == 1) { if ($settings_email->first()->email_fetching == 1) {
if ($settings_email->first()->all_emails == 1) { if ($settings_email->first()->all_emails == 1) {
@@ -60,7 +62,8 @@ class MailController extends Controller {
* *
* @return type string * @return type string
*/ */
public function separate_reply($body) { public function separate_reply($body)
{
$body2 = explode('---Reply above this line---', $body); $body2 = explode('---Reply above this line---', $body);
$body3 = $body2[0]; $body3 = $body2[0];
@@ -68,51 +71,64 @@ class MailController extends Controller {
} }
/** /**
*
* @param object $email * @param object $email
* @return integer *
* @return int
*/ */
public function priority($email) { public function priority($email)
{
$priority = $email->priority; $priority = $email->priority;
if (!$priority) { if (!$priority) {
$priority = $this->ticketController()->getSystemDefaultPriority(); $priority = $this->ticketController()->getSystemDefaultPriority();
} }
return $priority; return $priority;
} }
/** /**
* get department * get department.
*
* @param object $email * @param object $email
* @return integer *
* @return int
*/ */
public function department($email) { public function department($email)
{
$department = $email->department; $department = $email->department;
if (!$department) { if (!$department) {
$department = $this->ticketController()->getSystemDefaultDepartment(); $department = $this->ticketController()->getSystemDefaultDepartment();
} }
return $department; return $department;
} }
/** /**
* get help topic * get help topic.
*
* @param object $email * @param object $email
* @return integer *
* @return int
*/ */
public function helptopic($email) { public function helptopic($email)
{
//dd($email); //dd($email);
$helptopic = $email->help_topic; $helptopic = $email->help_topic;
if (!$helptopic) { if (!$helptopic) {
$helptopic = $this->ticketController()->getSystemDefaultHelpTopic(); $helptopic = $this->ticketController()->getSystemDefaultHelpTopic();
} }
return $helptopic; return $helptopic;
} }
/** /**
* get sla * get sla.
*
* @param object $email * @param object $email
* @return integer *
* @return int
*/ */
public function sla($email) { public function sla($email)
{
$helptopic = $this->helptopic($email); $helptopic = $this->helptopic($email);
$help = Help_topic::where('id', '=', $helptopic)->first(); $help = Help_topic::where('id', '=', $helptopic)->first();
if ($help) { if ($help) {
@@ -121,21 +137,26 @@ class MailController extends Controller {
if (!$sla) { if (!$sla) {
$sla = $this->ticketController()->getSystemDefaultSla(); $sla = $this->ticketController()->getSystemDefaultSla();
} }
return $sla; return $sla;
} }
/** /**
* get ticket controller * get ticket controller.
*
* @return \App\Http\Controllers\Agent\helpdesk\TicketController * @return \App\Http\Controllers\Agent\helpdesk\TicketController
*/ */
public function ticketController() { public function ticketController()
{
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController(); $PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController(); $NotificationController = new \App\Http\Controllers\Common\NotificationController();
$controller = new TicketController($PhpMailController, $NotificationController); $controller = new TicketController($PhpMailController, $NotificationController);
return $controller; return $controller;
} }
public function fetch($email) { public function fetch($email)
{
// dd($email); // dd($email);
if ($email) { if ($email) {
$username = $email->email_address; $username = $email->email_address;
@@ -146,18 +167,19 @@ class MailController extends Controller {
$encryption = $email->fetching_encryption; $encryption = $email->fetching_encryption;
$cert = $email->mailbox_protocol; $cert = $email->mailbox_protocol;
$server = new Fetch($host, $port, $service); $server = new Fetch($host, $port, $service);
if ($encryption != null || $encryption != "") { if ($encryption != null || $encryption != '') {
$server->setFlag($encryption); $server->setFlag($encryption);
} }
$server->setFlag($cert); $server->setFlag($cert);
$server->setAuthentication($username, $password); $server->setAuthentication($username, $password);
$date = date("d M Y", strToTime("-1 days")); $date = date('d M Y', strtotime('-1 days'));
$messages = $server->search("SINCE \"$date\" UNSEEN"); $messages = $server->search("SINCE \"$date\" UNSEEN");
$this->message($messages, $email); $this->message($messages, $email);
} }
} }
public function message($messages, $email) { public function message($messages, $email)
{
if (count($messages) > 0) { if (count($messages) > 0) {
foreach ($messages as $message) { foreach ($messages as $message) {
$this->getMessageContent($message, $email); $this->getMessageContent($message, $email);
@@ -165,7 +187,8 @@ class MailController extends Controller {
} }
} }
public function getMessageContent($message, $email) { public function getMessageContent($message, $email)
{
$body = $message->getMessageBody(true); $body = $message->getMessageBody(true);
if (!$body) { if (!$body) {
$body = $message->getMessageBody(); $body = $message->getMessageBody();
@@ -182,7 +205,8 @@ class MailController extends Controller {
$this->workflow($address, $subject, $body, $collaborators, $attachments, $email); $this->workflow($address, $subject, $body, $collaborators, $attachments, $email);
} }
public function workflow($address, $subject, $body, $collaborator, $attachments, $email) { public function workflow($address, $subject, $body, $collaborator, $attachments, $email)
{
$fromaddress = checkArray('address', $address[0]); $fromaddress = checkArray('address', $address[0]);
$fromname = checkArray('name', $address[0]); $fromname = checkArray('name', $address[0]);
$helptopic = $this->helptopic($email); $helptopic = $this->helptopic($email);
@@ -203,7 +227,8 @@ class MailController extends Controller {
} }
} }
public function updateThread($ticket_number, $body, $attachments) { public function updateThread($ticket_number, $body, $attachments)
{
$ticket_table = Tickets::where('ticket_number', '=', $ticket_number)->first(); $ticket_table = Tickets::where('ticket_number', '=', $ticket_number)->first();
$thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id'); $thread_id = Ticket_Thread::where('ticket_id', '=', $ticket_table->id)->max('id');
$thread = Ticket_Thread::where('id', '=', $thread_id)->first(); $thread = Ticket_Thread::where('id', '=', $thread_id)->first();
@@ -220,20 +245,20 @@ class MailController extends Controller {
loging('attachment', 'FaveoStorage not installed'); loging('attachment', 'FaveoStorage not installed');
} }
\Log::info("Ticket has created : ", ['id' => $thread->ticket_id]); \Log::info('Ticket has created : ', ['id' => $thread->ticket_id]);
} }
public function saveAttachments($thread_id, $attachments = []) { public function saveAttachments($thread_id, $attachments = [])
{
if (is_array($attachments) && count($attachments) > 0) { if (is_array($attachments) && count($attachments) > 0) {
foreach ($attachments as $attachment) { foreach ($attachments as $attachment) {
$structure = $attachment->getStructure(); $structure = $attachment->getStructure();
$disposition = 'ATTACHMENT'; $disposition = 'ATTACHMENT';
if (isset($structure->disposition)) { if (isset($structure->disposition)) {
$disposition = $structure->disposition; $disposition = $structure->disposition;
} }
$filename = str_random(16) . '-' . $attachment->getFileName(); $filename = str_random(16).'-'.$attachment->getFileName();
$type = $attachment->getMimeType(); $type = $attachment->getMimeType();
$size = $attachment->getSize(); $size = $attachment->getSize();
$data = $attachment->getData(); $data = $attachment->getData();
@@ -245,7 +270,8 @@ class MailController extends Controller {
} }
} }
public function manageAttachment($data, $filename, $type, $size, $disposition, $thread_id) { public function manageAttachment($data, $filename, $type, $size, $disposition, $thread_id)
{
$upload = new Ticket_attachments(); $upload = new Ticket_attachments();
$upload->file = $data; $upload->file = $data;
$upload->thread_id = $thread_id; $upload->thread_id = $thread_id;
@@ -258,25 +284,27 @@ class MailController extends Controller {
} }
} }
public function updateBody($attachment, $thread_id, $filename) { public function updateBody($attachment, $thread_id, $filename)
{
$structure = $attachment->getStructure(); $structure = $attachment->getStructure();
$disposition = 'ATTACHMENT'; $disposition = 'ATTACHMENT';
if (isset($structure->disposition)) { if (isset($structure->disposition)) {
$disposition = $structure->disposition; $disposition = $structure->disposition;
} }
if ($disposition == 'INLINE' || $disposition == 'inline') { if ($disposition == 'INLINE' || $disposition == 'inline') {
$id = str_replace(">", "", str_replace("<", "", $structure->id)); $id = str_replace('>', '', str_replace('<', '', $structure->id));
//$filename = $attachment->getFileName(); //$filename = $attachment->getFileName();
$threads = new Ticket_Thread(); $threads = new Ticket_Thread();
$thread = $threads->find($thread_id); $thread = $threads->find($thread_id);
$body = $thread->body; $body = $thread->body;
$body = str_replace('cid:' . $id, $filename, $body); $body = str_replace('cid:'.$id, $filename, $body);
$thread->body = $body; $thread->body = $body;
$thread->save(); $thread->save();
} }
} }
public function collaburators($message, $email) { public function collaburators($message, $email)
{
$this_address = $email->email_address; $this_address = $email->email_address;
$collaborator_cc = $message->getAddresses('cc'); $collaborator_cc = $message->getAddresses('cc');
//dd($collaborator_cc); //dd($collaborator_cc);
@@ -311,6 +339,7 @@ class MailController extends Controller {
if (array_key_exists($this_address, $array)) { if (array_key_exists($this_address, $array)) {
unset($array[$this_address]); unset($array[$this_address]);
} }
return $array; return $array;
} }
@@ -321,18 +350,20 @@ class MailController extends Controller {
* *
* @return type file * @return type file
*/ */
public function get_data($id) { public function get_data($id)
{
$attachment = \App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->first(); $attachment = \App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->first();
if (mime($attachment->type) == true) { if (mime($attachment->type) == true) {
echo "<img src=data:$attachment->type;base64," . $attachment->file . ">"; echo "<img src=data:$attachment->type;base64,".$attachment->file.'>';
} else { } else {
$file = base64_decode($attachment->file); $file = base64_decode($attachment->file);
return response($file) return response($file)
->header('Cache-Control', 'no-cache private') ->header('Cache-Control', 'no-cache private')
->header('Content-Description', 'File Transfer') ->header('Content-Description', 'File Transfer')
->header('Content-Type', $attachment->type) ->header('Content-Type', $attachment->type)
->header('Content-length', strlen($file)) ->header('Content-length', strlen($file))
->header('Content-Disposition', 'attachment; filename=' . $attachment->name) ->header('Content-Disposition', 'attachment; filename='.$attachment->name)
->header('Content-Transfer-Encoding', 'binary'); ->header('Content-Transfer-Encoding', 'binary');
} }
} }
@@ -344,12 +375,13 @@ class MailController extends Controller {
* *
* @return type string * @return type string
*/ */
public function separateReply($body) { public function separateReply($body)
{
$body2 = explode('---Reply above this line---', $body); $body2 = explode('---Reply above this line---', $body);
if (is_array($body2) && array_key_exists(0, $body2)) { if (is_array($body2) && array_key_exists(0, $body2)) {
$body = $body2[0]; $body = $body2[0];
} }
return $body; return $body;
} }
} }

View File

@@ -22,17 +22,19 @@ use View;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class NotificationController extends Controller { class NotificationController extends Controller
{
public function __construct(PhpMailController $PhpMailController) { public function __construct(PhpMailController $PhpMailController)
{
$this->PhpMailController = $PhpMailController; $this->PhpMailController = $PhpMailController;
} }
/** /**
* This function is for sending daily report/notification about the system. * This function is for sending daily report/notification about the system.
* */ * */
public function send_notification() { public function send_notification()
// dd('sdckjdsc'); {
// dd('sdckjdsc');
//fetching email settings //fetching email settings
$email = Email::where('id', '=', '1')->first(); $email = Email::where('id', '=', '1')->first();
//dd('yes'); //dd('yes');
@@ -61,6 +63,7 @@ class NotificationController extends Controller {
//} //}
Log_notification::create(['log' => 'NOT-1']); Log_notification::create(['log' => 'NOT-1']);
} }
return $send; return $send;
} }
@@ -71,24 +74,25 @@ class NotificationController extends Controller {
* *
* @return mail * @return mail
* */ * */
public function send_notification_to_admin($company) { public function send_notification_to_admin($company)
{
// get all admin users // get all admin users
$users = User::where('role', '=', 'admin')->get(); $users = User::where('role', '=', 'admin')->get();
foreach ($users as $user) { foreach ($users as $user) {
// Send notification details to admin // Send notification details to admin
$email = $user->email; $email = $user->email;
$user_name = $user->first_name . ' ' . $user->last_name; $user_name = $user->first_name.' '.$user->last_name;
$view = View::make('emails.notifications.admin', ['company' => $company, 'name' => $user_name]); $view = View::make('emails.notifications.admin', ['company' => $company, 'name' => $user_name]);
$contents = $view->render(); $contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0'); $from = $this->PhpMailController->mailfrom('1', '0');
$to = [ $to = [
'name' => $user_name, 'name' => $user_name,
'email' => $email 'email' => $email,
]; ];
$message = [ $message = [
'subject' => 'Daily Report', 'subject' => 'Daily Report',
'scenario' => null, 'scenario' => null,
'body' => $contents 'body' => $contents,
]; ];
return $this->PhpMailController->sendEmail($from, $to, $message); return $this->PhpMailController->sendEmail($from, $to, $message);
@@ -100,7 +104,8 @@ class NotificationController extends Controller {
* *
* @return mail * @return mail
* */ * */
public function send_notification_to_manager($company) { public function send_notification_to_manager($company)
{
// get all department managers // get all department managers
$depts = Department::all(); $depts = Department::all();
foreach ($depts as $dept) { foreach ($depts as $dept) {
@@ -110,19 +115,20 @@ class NotificationController extends Controller {
foreach ($users as $user) { foreach ($users as $user) {
// Send notification details to manager of a department // Send notification details to manager of a department
$email = $user->email; $email = $user->email;
$user_name = $user->first_name . ' ' . $user->last_name; $user_name = $user->first_name.' '.$user->last_name;
$view = View::make('emails.notifications.manager', ['company' => $company, 'name' => $user_name]); $view = View::make('emails.notifications.manager', ['company' => $company, 'name' => $user_name]);
$contents = $view->render(); $contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0'); $from = $this->PhpMailController->mailfrom('1', '0');
$to = [ $to = [
'name' => $user_name, 'name' => $user_name,
'email' => $email 'email' => $email,
]; ];
$message = [ $message = [
'subject' => 'Daily Report', 'subject' => 'Daily Report',
'scenario' => null, 'scenario' => null,
'body' => $contents 'body' => $contents,
]; ];
return $this->PhpMailController->sendEmail($from, $to, $message); return $this->PhpMailController->sendEmail($from, $to, $message);
} }
} }
@@ -134,7 +140,8 @@ class NotificationController extends Controller {
* *
* @return mail * @return mail
* */ * */
public function send_notification_to_team_lead($company) { public function send_notification_to_team_lead($company)
{
// get all Team leads // get all Team leads
$teams = Teams::all(); $teams = Teams::all();
foreach ($teams as $team) { foreach ($teams as $team) {
@@ -144,19 +151,20 @@ class NotificationController extends Controller {
foreach ($users as $user) { foreach ($users as $user) {
// Send notification details to team lead // Send notification details to team lead
$email = $user->email; $email = $user->email;
$user_name = $user->first_name . ' ' . $user->last_name; $user_name = $user->first_name.' '.$user->last_name;
$view = View::make('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id]); $view = View::make('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id]);
$contents = $view->render(); $contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0'); $from = $this->PhpMailController->mailfrom('1', '0');
$to = [ $to = [
'name' => $user_name, 'name' => $user_name,
'email' => $email 'email' => $email,
]; ];
$message = [ $message = [
'subject' => 'Daily Report', 'subject' => 'Daily Report',
'scenario' => null, 'scenario' => null,
'body' => $contents 'body' => $contents,
]; ];
return $this->PhpMailController->sendEmail($from, $to, $message); return $this->PhpMailController->sendEmail($from, $to, $message);
} }
} }
@@ -168,26 +176,28 @@ class NotificationController extends Controller {
* *
* @return mail * @return mail
* */ * */
public function send_notification_to_agent($company) { public function send_notification_to_agent($company)
{
// get all agents users // get all agents users
$users = User::where('role', '=', 'agent')->get(); $users = User::where('role', '=', 'agent')->get();
foreach ($users as $user) { foreach ($users as $user) {
// Send notification details to all the agents // Send notification details to all the agents
$email = $user->email; $email = $user->email;
$user_name = $user->first_name . ' ' . $user->last_name; $user_name = $user->first_name.' '.$user->last_name;
$view = View::make('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => $user->id]); $view = View::make('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => $user->id]);
$contents = $view->render(); $contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0'); $from = $this->PhpMailController->mailfrom('1', '0');
$to = [ $to = [
'name' => $user_name, 'name' => $user_name,
'email' => $email 'email' => $email,
]; ];
$message = [ $message = [
'subject' => 'Daily Report', 'subject' => 'Daily Report',
'scenario' => null, 'scenario' => null,
'body' => $contents 'body' => $contents,
]; ];
return $this->PhpMailController->sendEmail($from,$to,$message);
return $this->PhpMailController->sendEmail($from, $to, $message);
} }
} }
@@ -196,7 +206,8 @@ class NotificationController extends Controller {
* *
* @return type variable * @return type variable
*/ */
public function company() { public function company()
{
// fetching comapny model // fetching comapny model
$company = Company::Where('id', '=', '1')->first(); $company = Company::Where('id', '=', '1')->first();
// fetching company name // fetching company name
@@ -208,5 +219,4 @@ class NotificationController extends Controller {
return $company; return $company;
} }
} }

View File

@@ -16,8 +16,8 @@ use App\Model\helpdesk\Agent_panel\User_org;
use App\User; use App\User;
// classes // classes
use Exception; use Exception;
use Lang;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Lang;
/** /**
* OrganizationController * OrganizationController
@@ -329,24 +329,26 @@ class OrganizationController extends Controller
return '['.$last.']'; return '['.$last.']';
} }
public function getOrgAjax(Request $request){ public function getOrgAjax(Request $request)
{
$org = new Organization(); $org = new Organization();
$q = $request->input('term'); $q = $request->input('term');
$orgs = $org->where('name','LIKE','%'.$q.'%') $orgs = $org->where('name', 'LIKE', '%'.$q.'%')
->select('name as label','id as value') ->select('name as label', 'id as value')
->get() ->get()
->toJson(); ->toJson();
return $orgs; return $orgs;
} }
/** /**
* This function is used autofill organizations name . * This function is used autofill organizations name .
* *
* @return datatable * @return datatable
*/ */
public function organizationAutofill() public function organizationAutofill()
{ {
return view('themes.default1.agent.helpdesk.organization.getautocomplete'); return view('themes.default1.agent.helpdesk.organization.getautocomplete');
} }
} }

View File

@@ -6,9 +6,9 @@ namespace App\Http\Controllers\Agent\helpdesk;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
// request // request
use Illuminate\Http\Request;
// Model
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
// Model
use Illuminate\Http\Request;
// classes // classes
use PDF; use PDF;
@@ -18,8 +18,8 @@ use PDF;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class ReportController extends Controller { class ReportController extends Controller
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
@@ -29,7 +29,8 @@ class ReportController extends Controller {
* *
* @return void * @return void
*/ */
public function __construct() { public function __construct()
{
// checking for authentication // checking for authentication
$this->middleware('auth'); $this->middleware('auth');
// checking if the role is agent // checking if the role is agent
@@ -38,23 +39,26 @@ class ReportController extends Controller {
/** /**
* Get the Report page. * Get the Report page.
*
* @return type view * @return type view
*/ */
public function index() { public function index()
{
try { try {
return view('themes.default1.agent.helpdesk.report.index'); return view('themes.default1.agent.helpdesk.report.index');
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
/** /**
* function to get help_topic graph * function to get help_topic graph.
*
* @param type $date111 * @param type $date111
* @param type $date122 * @param type $date122
* @param type $helptopic * @param type $helptopic
*/ */
public function chartdataHelptopic(Request $request, $date111 = '', $date122 = '', $helptopic = '') { public function chartdataHelptopic(Request $request, $date111 = '', $date122 = '', $helptopic = '')
{
$date11 = strtotime($date122); $date11 = strtotime($date122);
$date12 = strtotime($date111); $date12 = strtotime($date111);
$help_topic = $helptopic; $help_topic = $helptopic;
@@ -73,25 +77,24 @@ class ReportController extends Controller {
$format = 'Y-m-d'; $format = 'Y-m-d';
// generating a date range of 1 month // generating a date range of 1 month
if ($request->input('duration') == 'day') { if ($request->input('duration') == 'day') {
$date1 = strtotime(date($format, strtotime('-15 day' . $date3))); $date1 = strtotime(date($format, strtotime('-15 day'.$date3)));
} elseif ($request->input('duration') == 'week') { } elseif ($request->input('duration') == 'week') {
$date1 = strtotime(date($format, strtotime('-69 days' . $date3))); $date1 = strtotime(date($format, strtotime('-69 days'.$date3)));
} elseif ($request->input('duration') == 'month') { } elseif ($request->input('duration') == 'month') {
$date1 = strtotime(date($format, strtotime('-179 days' . $date3))); $date1 = strtotime(date($format, strtotime('-179 days'.$date3)));
} else { } else {
$date1 = strtotime(date($format, strtotime('-30 days' . $date3))); $date1 = strtotime(date($format, strtotime('-30 days'.$date3)));
} }
// $help_topic = Help_topic::where('status', '=', '1')->min('id'); // $help_topic = Help_topic::where('status', '=', '1')->min('id');
} }
$return = ''; $return = '';
$last = ''; $last = '';
$j = 0; $j = 0;
$created1 = ''; $created1 = '';
$closed1 = ''; $closed1 = '';
$reopened1 = ''; $reopened1 = '';
$in_progress = \DB::table('tickets')->where('help_topic_id', '=', $help_topic)->where('status','=',1)->count(); $in_progress = \DB::table('tickets')->where('help_topic_id', '=', $help_topic)->where('status', '=', 1)->count();
for ($i = $date1; $i <= $date2; $i = $i + 86400) { for ($i = $date1; $i <= $date2; $i = $i + 86400) {
$j++; $j++;
@@ -103,15 +106,15 @@ class ReportController extends Controller {
if ($request->input('open') || $request->input('closed') || $request->input('reopened')) { if ($request->input('open') || $request->input('closed') || $request->input('reopened')) {
if ($request->input('open') && $request->input('open') == 'on') { if ($request->input('open') && $request->input('open') == 'on') {
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count(); $created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
$open_array = ['open' => $created]; $open_array = ['open' => $created];
} }
if ($request->input('closed') && $request->input('closed') == 'on') { if ($request->input('closed') && $request->input('closed') == 'on') {
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count(); $closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
$closed_array = ['closed' => $closed]; $closed_array = ['closed' => $closed];
} }
if ($request->input('reopened') && $request->input('reopened') == 'on') { if ($request->input('reopened') && $request->input('reopened') == 'on') {
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count(); $reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
$reopened_array = ['reopened' => $reopened]; $reopened_array = ['reopened' => $reopened];
} }
// if ($request->input('overdue') && $request->input('overdue') == 'on') { // if ($request->input('overdue') && $request->input('overdue') == 'on') {
@@ -131,14 +134,14 @@ class ReportController extends Controller {
// } // }
$array = array_map('htmlentities', $value); $array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array)); $json = html_entity_decode(json_encode($array));
$return .= $json . ','; $return .= $json.',';
} else { } else {
if ($duration == 'week') { if ($duration == 'week') {
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count(); $created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
$created1 += $created; $created1 += $created;
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count(); $closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
$closed1 += $closed; $closed1 += $closed;
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count(); $reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
$reopened1 += $reopened; $reopened1 += $reopened;
if ($j % 7 == 0) { if ($j % 7 == 0) {
$open_array = ['open' => $created1]; $open_array = ['open' => $created1];
@@ -158,14 +161,14 @@ class ReportController extends Controller {
// } // }
$array = array_map('htmlentities', $value); $array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array)); $json = html_entity_decode(json_encode($array));
$return .= $json . ','; $return .= $json.',';
} }
} elseif ($duration == 'month') { } elseif ($duration == 'month') {
$created_month = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count(); $created_month = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
$created1 += $created_month; $created1 += $created_month;
$closed_month = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count(); $closed_month = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
$closed1 += $closed_month; $closed1 += $closed_month;
$reopened_month = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count(); $reopened_month = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
$reopened1 += $reopened_month; $reopened1 += $reopened_month;
if ($j % 30 == 0) { if ($j % 30 == 0) {
$open_array = ['open' => $created1]; $open_array = ['open' => $created1];
@@ -183,17 +186,17 @@ class ReportController extends Controller {
$array = array_map('htmlentities', $value); $array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array)); $json = html_entity_decode(json_encode($array));
$return .= $json . ','; $return .= $json.',';
} }
} else { } else {
if ($request->input('default') == null) { if ($request->input('default') == null) {
$help_topic = Help_topic::where('status', '=', '1')->min('id'); $help_topic = Help_topic::where('status', '=', '1')->min('id');
} }
$created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%' . $thisDate . '%')->count(); $created = \DB::table('tickets')->select('created_at')->where('help_topic_id', '=', $help_topic)->where('created_at', 'LIKE', '%'.$thisDate.'%')->count();
$open_array = ['open' => $created]; $open_array = ['open' => $created];
$closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count(); $closed = \DB::table('tickets')->select('closed_at')->where('help_topic_id', '=', $help_topic)->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count();
$closed_array = ['closed' => $closed]; $closed_array = ['closed' => $closed];
$reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count(); $reopened = \DB::table('tickets')->select('reopened_at')->where('help_topic_id', '=', $help_topic)->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count();
$reopened_array = ['reopened' => $reopened]; $reopened_array = ['reopened' => $reopened];
if ($j % 1 == 0) { if ($j % 1 == 0) {
$open_array = ['open' => $created]; $open_array = ['open' => $created];
@@ -232,7 +235,7 @@ class ReportController extends Controller {
// } // }
$array = array_map('htmlentities', $value); $array = array_map('htmlentities', $value);
$json = html_entity_decode(json_encode($array)); $json = html_entity_decode(json_encode($array));
$return .= $json . ','; $return .= $json.',';
} }
} }
} }
@@ -247,20 +250,19 @@ class ReportController extends Controller {
// if($reopened_array) { // if($reopened_array) {
// $value = array_merge($value,$reopened_array); // $value = array_merge($value,$reopened_array);
// } // }
} }
$last = rtrim($return, ','); $last = rtrim($return, ',');
return '[' . $last . ']'; return '['.$last.']';
} }
public function helptopicPdf(Request $request){ public function helptopicPdf(Request $request)
{
$table_datas = json_decode($request->input('pdf_form')); $table_datas = json_decode($request->input('pdf_form'));
$table_help_topic = json_decode($request->input('pdf_form_help_topic')); $table_help_topic = json_decode($request->input('pdf_form_help_topic'));
$html = view('themes.default1.agent.helpdesk.report.pdf', compact('table_datas', 'table_help_topic'))->render(); $html = view('themes.default1.agent.helpdesk.report.pdf', compact('table_datas', 'table_help_topic'))->render();
$html1 = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); $html1 = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
return PDF::load($html1)->show(); return PDF::load($html1)->show();
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -166,7 +166,7 @@ class TicketWorkflowController extends Controller
} }
} }
} }
//dd($form_data); //dd($form_data);
if ($ticket_settings_details['reject'] == true) { if ($ticket_settings_details['reject'] == true) {
return ['0' => false, '1' => false]; return ['0' => false, '1' => false];
@@ -287,7 +287,7 @@ class TicketWorkflowController extends Controller
*/ */
public function checkStarts($statement, $to_check) public function checkStarts($statement, $to_check)
{ {
if (substr($to_check, 0, strlen($statement)) == $statement) { if (substr($to_check, 0, strlen($statement)) == $statement) {
return true; return true;
} else { } else {
return false; return false;
@@ -305,7 +305,7 @@ class TicketWorkflowController extends Controller
public function checkEnds($statement, $to_check) public function checkEnds($statement, $to_check)
{ {
$to_check = strip_tags($to_check); $to_check = strip_tags($to_check);
if (substr($to_check, -strlen($statement)) == $statement) { if (substr($to_check, -strlen($statement)) == $statement) {
return true; return true;
} else { } else {
return false; return false;
@@ -352,6 +352,7 @@ class TicketWorkflowController extends Controller
$ticket_settings_details = $this->changeStatus($workflow_action, $ticket_settings_details); $ticket_settings_details = $this->changeStatus($workflow_action, $ticket_settings_details);
} }
} }
return $ticket_settings_details; return $ticket_settings_details;
} }

View File

@@ -3,49 +3,44 @@
namespace App\Http\Controllers\Agent\helpdesk; namespace App\Http\Controllers\Agent\helpdesk;
// controllers // controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Controller;
// requests // requests
/* Include Sys_user Model */ /* 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;
use App\Http\Requests\helpdesk\OtpVerifyRequest;
// change password request
use App\Http\Requests\helpdesk\ChangepasswordRequest; use App\Http\Requests\helpdesk\ChangepasswordRequest;
/* For validation include Sys_userRequest in create */
use App\Http\Requests\helpdesk\OtpVerifyRequest;
/* For validation include Sys_userUpdate in update */
use App\Http\Requests\helpdesk\ProfilePassword;
/* include guest_note model */
use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\Sys_userRequest;
// change password request
use App\Http\Requests\helpdesk\Sys_userUpdate;
// models // models
use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Agent_panel\Organization; use App\Model\helpdesk\Agent_panel\Organization;
use App\Model\helpdesk\Agent_panel\User_org; use App\Model\helpdesk\Agent_panel\User_org;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Settings\CommonSettings; use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Utility\CountryCode; use App\Model\helpdesk\Utility\CountryCode;
use App\Model\helpdesk\Utility\Otp; use App\Model\helpdesk\Utility\Otp;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Settings\Email;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Agent\Assign_team_agent;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\User; use App\User;
// classes // classes
use Auth; use Auth;
use DateTime;
use DB;
use Exception; use Exception;
use GeoIP; use GeoIP;
use Hash; use Hash;
use Illuminate\Http\Request;
use Input; use Input;
use Lang; use Lang;
use Redirect; use Redirect;
use Illuminate\Http\Request;
use DateTime;
use DB;
/** /**
* UserController * UserController
@@ -53,8 +48,8 @@ use DB;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class UserController extends Controller { class UserController extends Controller
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* constructor to check * constructor to check
@@ -64,7 +59,8 @@ class UserController extends Controller {
* *
* @return void * @return void
*/ */
public function __construct(PhpMailController $PhpMailController) { public function __construct(PhpMailController $PhpMailController)
{
$this->PhpMailController = $PhpMailController; $this->PhpMailController = $PhpMailController;
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
@@ -79,7 +75,8 @@ class UserController extends Controller {
* *
* @return type view * @return type view
*/ */
public function index() { public function index()
{
try { try {
/* get all values in Sys_user */ /* get all values in Sys_user */
@@ -93,13 +90,15 @@ class UserController extends Controller {
Lang::get('lang.role'), Lang::get('lang.role'),
Lang::get('lang.action')) // these are the column headings to be shown Lang::get('lang.action')) // these are the column headings to be shown
->noScript(); ->noScript();
return view('themes.default1.agent.helpdesk.user.index',compact('table'));
return view('themes.default1.agent.helpdesk.user.index', compact('table'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
} }
public function deletedUser() { public function deletedUser()
{
try { try {
// dd('here'); // dd('here');
/* get all values in Sys_user */ /* get all values in Sys_user */
@@ -109,30 +108,20 @@ class UserController extends Controller {
} }
} }
/** /**
* This function is used to display the list of users using chumper datatables. * This function is used to display the list of users using chumper datatables.
* *
* @return datatable * @return datatable
*/ */
public function user_list(Request $request) { public function user_list(Request $request)
{
$type = $request->input('profiletype'); $type = $request->input('profiletype');
if($type=="active"){
$users=User::where('role', "!=", "admin")->where('is_delete','=',0)->get();
}
else{
$users=User::where('role', "!=", "admin")->where('is_delete','=',1)->get();
}
if ($type == 'active') {
$users = User::where('role', '!=', 'admin')->where('is_delete', '=', 0)->get();
} else {
$users = User::where('role', '!=', 'admin')->where('is_delete', '=', 1)->get();
}
// displaying list of users with chumper datatables // displaying list of users with chumper datatables
// return \Datatable::collection(User::where('role', "!=", "admin")->get()) // return \Datatable::collection(User::where('role', "!=", "admin")->get())
@@ -144,7 +133,7 @@ else{
/* column username */ /* column username */
->addColumn('user_name', function ($model) { ->addColumn('user_name', function ($model) {
if ($model->first_name) { if ($model->first_name) {
$string = strip_tags($model->first_name . ' ' . $model->last_name); $string = strip_tags($model->first_name.' '.$model->last_name);
} else { } else {
$string = strip_tags($model->user_name); $string = strip_tags($model->user_name);
} }
@@ -154,11 +143,12 @@ else{
} else { } else {
$stringCut = $string; $stringCut = $string;
} }
return "<a href='" . route('user.show', $model->id) . "' title='".$string."''>".$stringCut."</a>";
return "<a href='".route('user.show', $model->id)."' title='".$string."''>".$stringCut.'</a>';
}) })
/* column email */ /* column email */
->addColumn('email', function ($model) { ->addColumn('email', function ($model) {
$email = "<a href='" . route('user.show', $model->id) . "'>" . $model->email . '</a>'; $email = "<a href='".route('user.show', $model->id)."'>".$model->email.'</a>';
return $email; return $email;
}) })
@@ -166,13 +156,13 @@ else{
->addColumn('phone', function ($model) { ->addColumn('phone', function ($model) {
$phone = ''; $phone = '';
if ($model->phone_number) { if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number; $phone = $model->ext.' '.$model->phone_number;
} }
$mobile = ''; $mobile = '';
if ($model->mobile) { if ($model->mobile) {
$mobile = $model->mobile; $mobile = $model->mobile;
} }
$phone = $phone . '&nbsp;&nbsp;&nbsp;' . $mobile; $phone = $phone.'&nbsp;&nbsp;&nbsp;'.$mobile;
return $phone; return $phone;
}) })
@@ -207,46 +197,42 @@ else{
/* column Role */ /* column Role */
->addColumn('role', function ($model) { ->addColumn('role', function ($model) {
$role = $model->role; $role = $model->role;
return $role; return $role;
}) })
/* column actions */ /* column actions */
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
if($model->is_delete==0){ if ($model->is_delete == 0) {
return '<a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a>&nbsp; <a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>'; return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a>&nbsp; <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
} else {
if (Auth::user()->role == 'admin') {
// @if(Auth::user()->role == 'admin')
return '<a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
}
if (Auth::user()->role == 'agent') {
// @if(Auth::user()->role == 'admin')
if ($model->role == 'user') {
return '<a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
}
}
} }
else{
if(Auth::user()->role == 'admin'){
// @if(Auth::user()->role == 'admin')
return '<a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
}
if(Auth::user()->role == 'agent'){
// @if(Auth::user()->role == 'admin')
if($model->role=="user"){
return '<a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
}
}
}
}) })
->make(); ->make();
} }
public function restoreUser($id) public function restoreUser($id)
{ {
// dd($id); // dd($id);
// $delete_all = Input::get('delete_all'); // $delete_all = Input::get('delete_all');
$users = User::where('id', '=', $id)->first(); $users = User::where('id', '=', $id)->first();
$users->is_delete=0; $users->is_delete = 0;
$users->active=1; $users->active = 1;
$users->ban=0; $users->ban = 0;
$users->save(); $users->save();
return redirect('user')->with('success', Lang::get('lang.user_restore_successfully'));
return redirect('user')->with('success', Lang::get('lang.user_restore_successfully'));
} }
/** /**
@@ -254,13 +240,15 @@ else{
* *
* @return type view * @return type view
*/ */
public function create(CountryCode $code) { public function create(CountryCode $code)
{
try { try {
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first(); $email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
$location = GeoIP::getLocation(); $location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first(); $phonecode = $code->where('iso', '=', $location->iso_code)->first();
$org = Organization::lists('name', 'id')->toArray(); $org = Organization::lists('name', 'id')->toArray();
return view('themes.default1.agent.helpdesk.user.create', compact('org', 'settings', 'email_mandatory'))->with('phonecode', $phonecode->phonecode); return view('themes.default1.agent.helpdesk.user.create', compact('org', 'settings', 'email_mandatory'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
@@ -275,7 +263,8 @@ else{
* *
* @return type redirect * @return type redirect
*/ */
public function store(User $user, Sys_userRequest $request) { public function store(User $user, Sys_userRequest $request)
{
/* insert the input request to sys_user table */ /* insert the input request to sys_user table */
/* Check whether function success or not */ /* Check whether function success or not */
if ($request->input('email') != '') { if ($request->input('email') != '') {
@@ -310,9 +299,9 @@ else{
} }
// save user credentails // save user credentails
if ($user->save() == true) { if ($user->save() == true) {
if ($request->input('org_id') != "") { if ($request->input('org_id') != '') {
$orgid = $request->input('org_id'); $orgid = $request->input('org_id');
$this->storeUserOrgRelation($user->id, $orgid); $this->storeUserOrgRelation($user->id, $orgid);
} }
// fetch user credentails to send mail // fetch user credentails to send mail
$name = $user->first_name; $name = $user->first_name;
@@ -332,6 +321,7 @@ else{
if (($request->input('active') == '0' || $request->input('active') == 0) || ($email_mandatory->status == '0') || $email_mandatory->status == 0) { if (($request->input('active') == '0' || $request->input('active') == 0) || ($email_mandatory->status == '0') || $email_mandatory->status == 0) {
\Event::fire(new \App\Events\LoginEvent($request)); \Event::fire(new \App\Events\LoginEvent($request));
} }
return redirect('user')->with('success', Lang::get('lang.User-Created-Successfully')); return redirect('user')->with('success', Lang::get('lang.User-Created-Successfully'));
} }
// $user->save(); // $user->save();
@@ -344,17 +334,18 @@ else{
} }
/** /**
* Random Password Genetor for users * Random Password Genetor for users.
* *
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* *
* @return type view * @return type view
*/ */
public function randomPassword() { public function randomPassword()
{
try { try {
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*(){}[]'; $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*(){}[]';
$pass = array(); //remember to declare $pass as an array $pass = []; //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 10; $i++) { for ($i = 0; $i < 10; $i++) {
$n = rand(0, $alphaLength); $n = rand(0, $alphaLength);
@@ -369,14 +360,15 @@ else{
} }
/** /**
* Random Password Genetor for users * Random Password Genetor for users.
* *
* @param type int $id * @param type int $id
* @param type User $user * @param type User $user
* *
* @return type view * @return type view
*/ */
public function randomPostPassword($id, ChangepasswordRequest $request) { public function randomPostPassword($id, ChangepasswordRequest $request)
{
try { try {
$changepassword = $request->change_password; $changepassword = $request->change_password;
$user = User::whereId($id)->first(); $user = User::whereId($id)->first();
@@ -391,24 +383,25 @@ else{
return redirect('user')->with('success', Lang::get('lang.password_change_successfully')); return redirect('user')->with('success', Lang::get('lang.password_change_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect('user')->with('fails', $e->getMessage()); return redirect('user')->with('fails', $e->getMessage());
} }
} }
/** /**
* * @param type $id
* @param type $id
* @param Request $request * @param Request $request
*
* @return type * @return type
*/ */
public function changeRoleAdmin($id, Request $request) { public function changeRoleAdmin($id, Request $request)
{
try { try {
$user = User::whereId($id)->first(); $user = User::whereId($id)->first();
$user->role = 'admin'; $user->role = 'admin';
$user->assign_group = $request->group; $user->assign_group = $request->group;
$user->primary_dpt = $request->primary_department; $user->primary_dpt = $request->primary_department;
$user->save(); $user->save();
return redirect('user')->with('success', Lang::get('lang.role_change_successfully')); return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
/* redirect to Index page with Fails Message */ /* redirect to Index page with Fails Message */
@@ -417,14 +410,14 @@ else{
} }
/** /**
* * @param type $id
* @param type $id
* @param Request $request * @param Request $request
*
* @return type * @return type
*/ */
public function changeRoleAgent($id, Request $request) { public function changeRoleAgent($id, Request $request)
{
try { try {
$user = User::whereId($id)->first(); $user = User::whereId($id)->first();
$user->role = 'agent'; $user->role = 'agent';
$user->assign_group = $request->group; $user->assign_group = $request->group;
@@ -439,22 +432,22 @@ else{
} }
/** /**
*
* @param type $id * @param type $id
*
* @return type * @return type
*/ */
public function changeRoleUser($id) { public function changeRoleUser($id)
{
try { try {
$ticket = Tickets::where('assigned_to', '=', $id)->where('status', '=', '1')->get(); $ticket = Tickets::where('assigned_to', '=', $id)->where('status', '=', '1')->get();
if ($ticket) { if ($ticket) {
$ticket = Tickets::where('assigned_to', '=', $id)->update(['assigned_to' => null]);
$ticket = Tickets::where('assigned_to', '=', $id)->update(array("assigned_to" => NULL));
} }
$user = User::whereId($id)->first(); $user = User::whereId($id)->first();
$user->role = 'user'; $user->role = 'user';
$user->assign_group = NULL; $user->assign_group = null;
$user->primary_dpt = NULL; $user->primary_dpt = null;
$user->remember_token = NULL; $user->remember_token = null;
$user->save(); $user->save();
return redirect('user')->with('success', Lang::get('lang.role_change_successfully')); return redirect('user')->with('success', Lang::get('lang.role_change_successfully'));
@@ -466,32 +459,28 @@ else{
} }
/** /**
*
* @param type $id * @param type $id
*
* @return type * @return type
*/ */
public function deleteAgent($id) public function deleteAgent($id)
{ {
// try { // try {
$delete_all = Input::get('delete_all'); $delete_all = Input::get('delete_all');
$delete_all = Input::get('delete_all'); $delete_all = Input::get('delete_all');
$users = User::where('id', '=', $id)->first(); $users = User::where('id', '=', $id)->first();
if ($users->role == 'user') { if ($users->role == 'user') {
$users = User::where('id', '=', $id)->first();
$users->is_delete = 1;
$users->active = 0;
$users->ban = 1;
$users->save();
$users = User::where('id', '=', $id)->first(); return redirect('user')->with('success', Lang::get('lang.user_delete_successfully'));
$users->is_delete=1; }
$users->active=0;
$users->ban=1;
$users->save();
return redirect('user')->with('success', Lang::get('lang.user_delete_successfully'));
}
// } // }
if ($users->role == 'agent') { if ($users->role == 'agent') {
if ($delete_all == null) { if ($delete_all == null) {
$UserEmail = Input::get('assign_to'); $UserEmail = Input::get('assign_to');
@@ -524,68 +513,62 @@ else{
// Assign_team_agent::where('agent_id', '=', $id)->update(['agent_id' => $assign_to[1]]); // Assign_team_agent::where('agent_id', '=', $id)->update(['agent_id' => $assign_to[1]]);
$tickets = Tickets::where('assigned_to', '=', $id)->get(); $tickets = Tickets::where('assigned_to', '=', $id)->get();
foreach ($tickets as $ticket) {
foreach ($tickets as $ticket ) { // code...
# code...
$ticket->assigned_to = $assign_to[1]; $ticket->assigned_to = $assign_to[1];
$user_detail = User::where('id', '=', $assign_to[1])->first(); $user_detail = User::where('id', '=', $assign_to[1])->first();
$assignee = $user_detail->first_name . ' ' . $user_detail->last_name; $assignee = $user_detail->first_name.' '.$user_detail->last_name;
$ticket_number = $ticket->ticket_number; $ticket_number = $ticket->ticket_number;
$ticket->save(); $ticket->save();
$thread = new Ticket_Thread(); $thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id; $thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id; $thread->user_id = Auth::user()->id;
$thread->is_internal = 1; $thread->is_internal = 1;
$thread->body = 'This Ticket has been assigned to ' . $assignee; $thread->body = 'This Ticket has been assigned to '.$assignee;
$thread->save(); $thread->save();
} }
$user = User::find($id); $user = User::find($id);
$users->is_delete=1; $users->is_delete = 1;
$users->active=0; $users->active = 0;
$users->ban=1; $users->ban = 1;
$users->save(); $users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully_and_ticket_assign_to_another_agent')); return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully_and_ticket_assign_to_another_agent'));
} }
// if (User_org::where('user_id', '=', $id)) { // if (User_org::where('user_id', '=', $id)) {
// DB::table('user_assign_organization')->where('user_id', '=', $id)->delete(); // DB::table('user_assign_organization')->where('user_id', '=', $id)->delete();
// } // }
$user = User::find($id); $user = User::find($id);
$users->is_delete=1; $users->is_delete = 1;
$users->active=0; $users->active = 0;
$users->ban=1; $users->ban = 1;
$users->save(); $users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully')); return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
} elseif ($delete_all == 1) { } elseif ($delete_all == 1) {
if ($delete_all) {
if ($delete_all) { // dd('here');
// dd('here');
$tickets = Tickets::where('assigned_to', '=', $id)->get(); $tickets = Tickets::where('assigned_to', '=', $id)->get();
// dd($tickets); // dd($tickets);
foreach ($tickets as $ticket ) { foreach ($tickets as $ticket) {
$ticket->assigned_to = NULL; $ticket->assigned_to = null;
$ticket_number = $ticket->ticket_number; $ticket_number = $ticket->ticket_number;
$ticket->save(); $ticket->save();
$thread = new Ticket_Thread(); $thread = new Ticket_Thread();
$thread->ticket_id = $ticket->id; $thread->ticket_id = $ticket->id;
$thread->user_id = Auth::user()->id; $thread->user_id = Auth::user()->id;
$thread->is_internal = 1; $thread->is_internal = 1;
$thread->body = 'This Ticket has been unassigned '; $thread->body = 'This Ticket has been unassigned ';
$thread->save(); $thread->save();
} }
// $users = User::where('id', '=', $id)->get(); // $users = User::where('id', '=', $id)->get();
$user = User::find($id); $user = User::find($id);
$users->is_delete=1; $users->is_delete = 1;
$users->active=0; $users->active = 0;
$users->save(); $users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully')); return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
@@ -593,8 +576,8 @@ foreach ($tickets as $ticket ) {
// Assign_team_agent::where('agent_id', '=', $id)->delete(); // Assign_team_agent::where('agent_id', '=', $id)->delete();
// User_org::where('user_id', '=', $id)->delete(); // User_org::where('user_id', '=', $id)->delete();
$user = User::find($id); $user = User::find($id);
$users->is_delete=1; $users->is_delete = 1;
$users->active=0; $users->active = 0;
$users->save(); $users->save();
return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully')); return redirect('user')->with('success', Lang::get('lang.agent_delete_successfully'));
@@ -616,10 +599,11 @@ foreach ($tickets as $ticket ) {
* *
* @return type view * @return type view
*/ */
public function show($id) { public function show($id)
{
try { try {
$users = User::where('id','=', $id)->first(); $users = User::where('id', '=', $id)->first();
if (count($users)>0) { if (count($users) > 0) {
return view('themes.default1.agent.helpdesk.user.show', compact('users')); return view('themes.default1.agent.helpdesk.user.show', compact('users'));
} else { } else {
return redirect()->back()->with('fails', Lang::get('lang.user-not-found')); return redirect()->back()->with('fails', Lang::get('lang.user-not-found'));
@@ -637,10 +621,10 @@ foreach ($tickets as $ticket ) {
* *
* @return type Response * @return type Response
*/ */
public function edit($id, CountryCode $code) { public function edit($id, CountryCode $code)
{
try { try {
// dd('here'); // dd('here');
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first(); $email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
@@ -652,12 +636,12 @@ foreach ($tickets as $ticket ) {
$phonecode = $code->where('iso', '=', $location->iso_code)->first(); $phonecode = $code->where('iso', '=', $location->iso_code)->first();
$orgs = Organization::all(); $orgs = Organization::all();
// dd($org); // dd($org);
$organization_id=User_org::where('user_id','=',$id)->lists('org_id')->first(); $organization_id = User_org::where('user_id', '=', $id)->lists('org_id')->first();
// $org_name=Organization::where('id','=',$org_id)->lists('name')->first(); // $org_name=Organization::where('id','=',$org_id)->lists('name')->first();
// dd($org_name); // dd($org_name);
return view('themes.default1.agent.helpdesk.user.edit', compact('users', 'orgs', '$settings', '$email_mandatory','organization_id'))->with('phonecode', $phonecode->phonecode); return view('themes.default1.agent.helpdesk.user.edit', compact('users', 'orgs', '$settings', '$email_mandatory', 'organization_id'))->with('phonecode', $phonecode->phonecode);
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
@@ -672,8 +656,8 @@ foreach ($tickets as $ticket ) {
* *
* @return type Response * @return type Response
*/ */
public function update($id, Sys_userUpdate $request) { public function update($id, Sys_userUpdate $request)
{
$user = new User(); $user = new User();
/* select the field where id = $id(request Id) */ /* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first(); $users = $user->whereId($id)->first();
@@ -693,10 +677,10 @@ foreach ($tickets as $ticket ) {
$users->mobile = ($request->input('mobile') == '') ? null : $request->input('mobile'); $users->mobile = ($request->input('mobile') == '') ? null : $request->input('mobile');
$users->fill($request->except('mobile')); $users->fill($request->except('mobile'));
$users->save(); $users->save();
if ($request->input('org_id') != "") { if ($request->input('org_id') != '') {
$orgid = $request->input('org_id'); $orgid = $request->input('org_id');
$this->storeUserOrgRelation($id, $orgid); $this->storeUserOrgRelation($id, $orgid);
} }
/* redirect to Index page with Success Message */ /* redirect to Index page with Success Message */
return redirect('user')->with('success', Lang::get('lang.User-profile-Updated-Successfully')); return redirect('user')->with('success', Lang::get('lang.User-profile-Updated-Successfully'));
@@ -711,7 +695,8 @@ foreach ($tickets as $ticket ) {
* *
* @return type view * @return type view
*/ */
public function getProfile() { public function getProfile()
{
$user = Auth::user(); $user = Auth::user();
try { try {
return view('themes.default1.agent.helpdesk.user.profile', compact('user')); return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
@@ -725,7 +710,8 @@ foreach ($tickets as $ticket ) {
* *
* @return type view * @return type view
*/ */
public function getProfileedit(CountryCode $code) { public function getProfileedit(CountryCode $code)
{
$user = Auth::user(); $user = Auth::user();
$location = GeoIP::getLocation(); $location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first(); $phonecode = $code->where('iso', '=', $location->iso_code)->first();
@@ -734,7 +720,7 @@ foreach ($tickets as $ticket ) {
try { 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, ->with(['phonecode' => $phonecode->phonecode,
'verify' => $status]); 'verify' => $status, ]);
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
@@ -748,7 +734,8 @@ foreach ($tickets as $ticket ) {
* *
* @return type Redirect * @return type Redirect
*/ */
public function postProfileedit(ProfileRequest $request) { public function postProfileedit(ProfileRequest $request)
{
try { try {
// geet authenticated user details // geet authenticated user details
$user = Auth::user(); $user = Auth::user();
@@ -758,14 +745,14 @@ foreach ($tickets as $ticket ) {
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get(); $code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
if (!count($code)) { if (!count($code)) {
return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput(); return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput();
} }
$user->country_code = $request->country_code; $user->country_code = $request->country_code;
} }
$user->fill($request->except('profile_pic', 'mobile')); $user->fill($request->except('profile_pic', 'mobile'));
$user->gender = $request->input('gender'); $user->gender = $request->input('gender');
$user->save(); $user->save();
if (Input::file('profile_pic')) { if (Input::file('profile_pic')) {
// fetching picture name // fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName(); $name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path // fetching upload destination path
$destinationPath = 'uploads/profilepic'; $destinationPath = 'uploads/profilepic';
@@ -782,11 +769,10 @@ foreach ($tickets as $ticket ) {
$user->mobile = null; $user->mobile = null;
} }
if ($user->save()) { if ($user->save()) {
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully')); return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
} else { } else {
return Redirect::route('profile')->with('fails', Lang::get('lang.Profile-Updated-sucessfully')); return Redirect::route('profile')->with('fails', Lang::get('lang.Profile-Updated-sucessfully'));
} }
} catch (Exception $e) { } catch (Exception $e) {
return Redirect::route('profile')->with('fails', $e->getMessage()); return Redirect::route('profile')->with('fails', $e->getMessage());
} }
@@ -826,49 +812,50 @@ foreach ($tickets as $ticket ) {
* *
* @return type boolean * @return type boolean
*/ */
public function UserAssignOrg($id) { public function UserAssignOrg($id)
{
$org_name = Input::get('org'); $org_name = Input::get('org');
if ($org_name) { if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first(); $org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) { if ($org) {
$user_org = new User_org(); $user_org = new User_org();
$user_org->org_id = $org; $user_org->org_id = $org;
$user_org->user_id = $id; $user_org->user_id = $id;
$user_org->save(); $user_org->save();
return 1; return 1;
} else { } else {
return 0; return 0;
} }
} else { } else {
return 2; return 2;
} }
} }
public function UsereditAssignOrg($id) public function UsereditAssignOrg($id)
{ {
$org_name = Input::get('org'); $org_name = Input::get('org');
if ($org_name) {
$org = Organization::where('name', '=', $org_name)->lists('id')->first();
if ($org) {
$user_org = User_org::where('user_id', '=', $id)->first();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1; if ($org_name) {
} else { $org = Organization::where('name', '=', $org_name)->lists('id')->first();
return 0; if ($org) {
$user_org = User_org::where('user_id', '=', $id)->first();
$user_org->org_id = $org;
$user_org->user_id = $id;
$user_org->save();
return 1;
} else {
return 0;
} }
} else { } else {
return 2; return 2;
} }
} }
public function orgAssignUser($id) { public function orgAssignUser($id)
{
$org = Input::get('org'); $org = Input::get('org');
$user_org = new User_org(); $user_org = new User_org();
$user_org->org_id = $id; $user_org->org_id = $id;
@@ -878,7 +865,8 @@ if ($org_name) {
return 1; return 1;
} }
public function removeUserOrg($id) { public function removeUserOrg($id)
{
$user_org = User_org::where('org_id', '=', $id)->first(); $user_org = User_org::where('org_id', '=', $id)->first();
$user_org->delete(); $user_org->delete();
@@ -892,7 +880,8 @@ if ($org_name) {
* *
* @return type * @return type
*/ */
public function User_Create_Org($id) { public function User_Create_Org($id)
{
// checking if the entered value for website is available in database // checking if the entered value for website is available in database
if (Input::get('website') != null) { if (Input::get('website') != null) {
// checking website // checking website
@@ -935,7 +924,8 @@ if ($org_name) {
* *
* @return string * @return string
*/ */
public function generateRandomString($length = 10) { public function generateRandomString($length = 10)
{
// list of supported characters // list of supported characters
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// character length checked // character length checked
@@ -950,7 +940,8 @@ if ($org_name) {
return $randomString; return $randomString;
} }
public function storeUserOrgRelation($userid, $orgid) { public function storeUserOrgRelation($userid, $orgid)
{
$org_relations = new User_org(); $org_relations = new User_org();
$org_relation = $org_relations->where('user_id', $userid)->first(); $org_relation = $org_relations->where('user_id', $userid)->first();
if ($org_relation) { if ($org_relation) {
@@ -958,11 +949,12 @@ if ($org_name) {
} }
$org_relations->create([ $org_relations->create([
'user_id' => $userid, 'user_id' => $userid,
'org_id' => $orgid, 'org_id' => $orgid,
]); ]);
} }
public function getExportUser() { public function getExportUser()
{
try { try {
return view('themes.default1.agent.helpdesk.user.export'); return view('themes.default1.agent.helpdesk.user.export');
} catch (Exception $ex) { } catch (Exception $ex) {
@@ -970,30 +962,34 @@ if ($org_name) {
} }
} }
public function exportUser(Request $request) { public function exportUser(Request $request)
{
try { try {
$date = $request->input('date'); $date = $request->input('date');
$date = str_replace(' ', '', $date); $date = str_replace(' ', '', $date);
$date_array = explode(':', $date); $date_array = explode(':', $date);
$first = $date_array[0] . " 00:00:00"; $first = $date_array[0].' 00:00:00';
$second = $date_array[1] . " 23:59:59"; $second = $date_array[1].' 23:59:59';
$first_date = $this->convertDate($first); $first_date = $this->convertDate($first);
$second_date = $this->convertDate($second); $second_date = $this->convertDate($second);
$users = $this->getUsers($first_date, $second_date); $users = $this->getUsers($first_date, $second_date);
$excel_controller = new \App\Http\Controllers\Common\ExcelController(); $excel_controller = new \App\Http\Controllers\Common\ExcelController();
$filename = "users" . $date; $filename = 'users'.$date;
$excel_controller->export($filename, $users); $excel_controller->export($filename, $users);
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function convertDate($date) { public function convertDate($date)
{
$converted_date = date('Y-m-d H:i:s', strtotime($date)); $converted_date = date('Y-m-d H:i:s', strtotime($date));
return $converted_date; return $converted_date;
} }
public function getUsers($first, $last) { public function getUsers($first, $last)
{
$user = new User(); $user = new User();
$users = $user->leftJoin('user_assign_organization', 'users.id', '=', 'user_assign_organization.user_id') $users = $user->leftJoin('user_assign_organization', 'users.id', '=', 'user_assign_organization.user_id')
->leftJoin('organization', 'user_assign_organization.org_id', '=', 'organization.id') ->leftJoin('organization', 'user_assign_organization.org_id', '=', 'organization.id')
@@ -1003,37 +999,42 @@ if ($org_name) {
->select('users.user_name as Username', 'users.email as Email', 'users.first_name as Fisrtname', 'users.last_name as Lastname', 'organization.name as Organization') ->select('users.user_name as Username', 'users.email as Email', 'users.first_name as Fisrtname', 'users.last_name as Lastname', 'organization.name as Organization')
->get() ->get()
->toArray(); ->toArray();
return $users; return $users;
} }
public function resendOTP(OtpVerifyRequest $request) { public function resendOTP(OtpVerifyRequest $request)
{
if (\Schema::hasTable('sms')) { if (\Schema::hasTable('sms')) {
$sms = DB::table('sms')->get(); $sms = DB::table('sms')->get();
if (count($sms) > 0) { if (count($sms) > 0) {
\Event::fire(new \App\Events\LoginEvent($request)); \Event::fire(new \App\Events\LoginEvent($request));
return 1; return 1;
} }
} else { } else {
return "Plugin has not been setup successfully."; return 'Plugin has not been setup successfully.';
} }
} }
public function verifyOTP() { public function verifyOTP()
{
// dd(Input::all()); // dd(Input::all());
// $user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))->first(); // $user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))->first();
$otp = Otp::select('otp', 'updated_at')->where('user_id', '=', Input::get('u_id')) $otp = Otp::select('otp', 'updated_at')->where('user_id', '=', Input::get('u_id'))
->first(); ->first();
if ($otp != null) { if ($otp != null) {
$otp_length = strlen(Input::get('otp')); $otp_length = strlen(Input::get('otp'));
if (($otp_length == 6 && !preg_match("/[a-z]/i", Input::get('otp')))) { if (($otp_length == 6 && !preg_match('/[a-z]/i', Input::get('otp')))) {
$otp2 = Hash::make(Input::get('otp')); $otp2 = Hash::make(Input::get('otp'));
$date1 = date_format($otp->updated_at, "Y-m-d h:i:sa"); $date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
$date2 = date("Y-m-d h:i:sa"); $date2 = date('Y-m-d h:i:sa');
$time1 = new DateTime($date2); $time1 = new DateTime($date2);
$time2 = new DateTime($date1); $time2 = new DateTime($date1);
$interval = $time1->diff($time2); $interval = $time1->diff($time2);
if ($interval->i > 10 || $interval->h > 0) { if ($interval->i > 10 || $interval->h > 0) {
$message = Lang::get('lang.otp-expired'); $message = Lang::get('lang.otp-expired');
return $message; return $message;
} else { } else {
if (Hash::check(Input::get('otp'), $otp->otp)) { if (Hash::check(Input::get('otp'), $otp->otp)) {
@@ -1045,26 +1046,27 @@ if ($org_name) {
return 1; return 1;
} else { } else {
$message = Lang::get('lang.otp-not-matched'); $message = Lang::get('lang.otp-not-matched');
return $message; return $message;
} }
} }
} else { } else {
$message = Lang::get('lang.otp-invalid'); $message = Lang::get('lang.otp-invalid');
return $message; return $message;
} }
} else { } else {
$message = Lang::get('lang.otp-not-matched'); $message = Lang::get('lang.otp-not-matched');
return $message; return $message;
} }
} }
/**
*/
public function getAgentDetails() public function getAgentDetails()
{ {
$users = User::where('role', '<>', 'user')->where('active', '=', 1)->get(); $users = User::where('role', '<>', 'user')->where('active', '=', 1)->get();
foreach ($users as $user) { foreach ($users as $user) {
echo "<option value='user_$user->id'>".$user->name().'</option>'; echo "<option value='user_$user->id'>".$user->name().'</option>';
} }
} }
} }

View File

@@ -65,7 +65,7 @@ class ArticleController extends Controller
$article = new Article(); $article = new Article();
$articles = $article $articles = $article
->select('id', 'name', 'description', 'publish_time', 'slug') ->select('id', 'name', 'description', 'publish_time', 'slug')
->orderBy('publish_time','desc') ->orderBy('publish_time', 'desc')
->get(); ->get();
// returns chumper datatable // returns chumper datatable
return Datatable::Collection($articles) return Datatable::Collection($articles)

View File

@@ -77,6 +77,7 @@ class CategoryController extends Controller
/* add column name */ /* add column name */
->addColumn('name', function ($model) { ->addColumn('name', function ($model) {
$string = strip_tags($model->name); $string = strip_tags($model->name);
return str_limit($string, 20); return str_limit($string, 20);
}) })
/* add column Created */ /* add column Created */
@@ -120,7 +121,7 @@ class CategoryController extends Controller
public function create(Category $category) public function create(Category $category)
{ {
/* Get the all attributes in the category model */ /* Get the all attributes in the category model */
$category = $category->lists('name','id')->toArray(); $category = $category->lists('name', 'id')->toArray();
/* get the view page to create new category with all attributes /* get the view page to create new category with all attributes
of category model */ of category model */
try { try {
@@ -147,6 +148,7 @@ class CategoryController extends Controller
// send success message to index page // send success message to index page
try { try {
$category->fill($request->input())->save(); $category->fill($request->input())->save();
return Redirect::back()->with('success', Lang::get('lang.category_inserted_successfully')); return Redirect::back()->with('success', Lang::get('lang.category_inserted_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
return Redirect::back()->with('fails', Lang::get('lang.category_not_inserted').'<li>'.$e->getMessage().'</li>'); return Redirect::back()->with('fails', Lang::get('lang.category_not_inserted').'<li>'.$e->getMessage().'</li>');
@@ -165,9 +167,9 @@ class CategoryController extends Controller
{ {
/* get the atributes of the category model whose id == $id */ /* get the atributes of the category model whose id == $id */
$category = Category::whereId($id)->first(); $category = Category::whereId($id)->first();
$categories = Category::lists('name','id')->toArray(); $categories = Category::lists('name', 'id')->toArray();
/* get the Edit page the selected category via id */ /* get the Edit page the selected category via id */
return view('themes.default1.agent.kb.category.edit', compact('category','categories')); return view('themes.default1.agent.kb.category.edit', compact('category', 'categories'));
} }
/** /**
@@ -191,6 +193,7 @@ class CategoryController extends Controller
try { try {
$category->slug = $slug; $category->slug = $slug;
$category->fill($request->input())->save(); $category->fill($request->input())->save();
return redirect('category')->with('success', Lang::get('lang.category_updated_successfully')); return redirect('category')->with('success', Lang::get('lang.category_updated_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
//redirect to index with fails message //redirect to index with fails message

View File

@@ -144,11 +144,13 @@ class SettingsController extends Controller
$name = "<p>$model->name</p><br>"; $name = "<p>$model->name</p><br>";
$email = "<p>$model->email</p><br>"; $email = "<p>$model->email</p><br>";
$website = "<p>$model->website</p><br>"; $website = "<p>$model->website</p><br>";
return $name.$email.$website; return $name.$email.$website;
}) })
->addColumn('comment', function ($model) { ->addColumn('comment', function ($model) {
$created = TicketController::usertimezone(date($model->created_at)); $created = TicketController::usertimezone(date($model->created_at));
return $model->comment."<p>$created</p>"; return $model->comment."<p>$created</p>";
}) })
->addColumn('status', function ($model) { ->addColumn('status', function ($model) {
@@ -159,7 +161,7 @@ class SettingsController extends Controller
return '<p style="color:red"">'.\Lang::get('lang.not_published'); return '<p style="color:red"">'.\Lang::get('lang.not_published');
} }
}) })
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
return '<div class="row"><div class="col-md-12"><a href=comment/delete/'.$model->id.' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a></div><div class="col-md-12"><a href=published/'.$model->id.' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a></div></div>'; return '<div class="row"><div class="col-md-12"><a href=comment/delete/'.$model->id.' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a></div><div class="col-md-12"><a href=published/'.$model->id.' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a></div></div>';
}) })

View File

@@ -2,9 +2,10 @@
namespace App\Http\Controllers\Api\v1; namespace App\Http\Controllers\Api\v1;
use App\Http\Controllers\Agent\helpdesk\TicketController as CoreTicketController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\helpdesk\TicketRequest;
//use Illuminate\Support\Facades\Request as Value; //use Illuminate\Support\Facades\Request as Value;
use App\Http\Requests\helpdesk\TicketRequest;
use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Agent\Teams; use App\Model\helpdesk\Agent\Teams;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
@@ -20,7 +21,6 @@ use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use App\Http\Controllers\Agent\helpdesk\TicketController as CoreTicketController;
/** /**
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
@@ -34,8 +34,8 @@ use App\Http\Controllers\Agent\helpdesk\TicketController as CoreTicketController
* *
* @version v1 * @version v1
*/ */
class ApiController extends Controller { class ApiController extends Controller
{
public $user; public $user;
public $request; public $request;
public $ticket; public $ticket;
@@ -55,7 +55,8 @@ class ApiController extends Controller {
/** /**
* @param Request $request * @param Request $request
*/ */
public function __construct(Request $request) { public function __construct(Request $request)
{
$this->request = $request; $this->request = $request;
$this->middleware('jwt.auth'); $this->middleware('jwt.auth');
@@ -64,9 +65,7 @@ class ApiController extends Controller {
$user = \JWTAuth::parseToken()->authenticate(); $user = \JWTAuth::parseToken()->authenticate();
$this->user = $user; $this->user = $user;
} catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) { } catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
} catch (\Tymon\JWTAuth\Exceptions\JWTException $e) { } catch (\Tymon\JWTAuth\Exceptions\JWTException $e) {
} }
$ticket = new TicketController(); $ticket = new TicketController();
@@ -121,7 +120,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function createTicket(\App\Http\Requests\helpdesk\CreateTicketRequest $request, \App\Model\helpdesk\Utility\CountryCode $code) { public function createTicket(\App\Http\Requests\helpdesk\CreateTicketRequest $request, \App\Model\helpdesk\Utility\CountryCode $code)
{
try { try {
$user_id = $this->request->input('user_id'); $user_id = $this->request->input('user_id');
@@ -148,7 +148,7 @@ class ApiController extends Controller {
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController(); $PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController(); $NotificationController = new \App\Http\Controllers\Common\NotificationController();
$core = new CoreTicketController($PhpMailController, $NotificationController); $core = new CoreTicketController($PhpMailController, $NotificationController);
$response = $core->post_newticket($request, $code,true); $response = $core->post_newticket($request, $code, true);
//$response = $this->ticket->createTicket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach); //$response = $this->ticket->createTicket($user_id, $subject, $body, $helptopic, $sla, $priority, $source, $headers, $dept, $assignto, $form_data, $attach);
//return $response; //return $response;
/* /*
@@ -179,11 +179,12 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function ticketReply() { public function ticketReply()
{
//dd($this->request->all()); //dd($this->request->all());
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'ticket_ID' => 'required|exists:tickets,id', 'ticket_ID' => 'required|exists:tickets,id',
'reply_content' => 'required', 'reply_content' => 'required',
]); ]);
if ($v->fails()) { if ($v->fails()) {
@@ -193,9 +194,10 @@ class ApiController extends Controller {
} }
$attach = $this->request->input('attachments'); $attach = $this->request->input('attachments');
$result = $this->ticket->reply($this->thread, $this->request, $this->attach, $attach); $result = $this->ticket->reply($this->thread, $this->request, $this->attach, $attach);
$result = $result->join('users','ticket_thread.user_id','=','users.id') $result = $result->join('users', 'ticket_thread.user_id', '=', 'users.id')
->select('ticket_thread.*','users.first_name as first_name') ->select('ticket_thread.*', 'users.first_name as first_name')
->first(); ->first();
return response()->json(compact('result')); return response()->json(compact('result'));
} catch (\Exception $e) { } catch (\Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
@@ -215,14 +217,15 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function editTicket() { public function editTicket()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'ticket_id' => 'required|exists:tickets,id', 'ticket_id' => 'required|exists:tickets,id',
'subject' => 'required', 'subject' => 'required',
'sla_plan' => 'required|exists:sla_plan,id', 'sla_plan' => 'required|exists:sla_plan,id',
'help_topic' => 'required|exists:help_topic,id', 'help_topic' => 'required|exists:help_topic,id',
'ticket_source' => 'required|exists:ticket_source,id', 'ticket_source' => 'required|exists:ticket_source,id',
'ticket_priority' => 'required|exists:ticket_priority,priority_id', 'ticket_priority' => 'required|exists:ticket_priority,priority_id',
]); ]);
if ($v->fails()) { if ($v->fails()) {
@@ -252,7 +255,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function deleteTicket() { public function deleteTicket()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'ticket_id' => 'required|exists:tickets,id', 'ticket_id' => 'required|exists:tickets,id',
@@ -285,15 +289,16 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function openedTickets() { public function openedTickets()
{
try { try {
// $result = $this->model->where('status', '=', 1)->where('isanswered', '=', 0)->where('assigned_to', '=', null)->orderBy('id', 'DESC')->get(); // $result = $this->model->where('status', '=', 1)->where('isanswered', '=', 0)->where('assigned_to', '=', null)->orderBy('id', 'DESC')->get();
// return response()->json(compact('result')); // return response()->json(compact('result'));
$result = $this->user->join('tickets', function ($join) { $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'); ->where('isanswered', '=', 0)->where('status', '=', 1)->whereNull('assigned_to');
}) })
->join('department', 'department.id', '=', 'tickets.dept_id') ->join('department', 'department.id', '=', 'tickets.dept_id')
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') ->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla') ->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
@@ -329,16 +334,17 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function unassignedTickets() { public function unassignedTickets()
{
try { try {
//dd('sdhjbc'); //dd('sdhjbc');
// $result = $this->model->where('assigned_to', '=', null)->where('status', '1')->orderBy('id', 'DESC')->get(); // $result = $this->model->where('assigned_to', '=', null)->where('status', '1')->orderBy('id', 'DESC')->get();
// return response()->json(compact('result')); // return response()->json(compact('result'));
$user = \JWTAuth::parseToken()->authenticate(); $user = \JWTAuth::parseToken()->authenticate();
$unassigned = $this->user->join('tickets', function ($join) { $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); ->whereNull('assigned_to')->where('status', '=', 1);
}) })
->join('department', 'department.id', '=', 'tickets.dept_id') ->join('department', 'department.id', '=', 'tickets.dept_id')
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') ->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla') ->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
@@ -349,7 +355,7 @@ class ApiController extends Controller {
->whereNotNull('title'); ->whereNotNull('title');
}) })
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name') ->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
->where(function($query) use($user) { ->where(function ($query) use ($user) {
if ($user->role != 'admin') { if ($user->role != 'admin') {
$query->where('tickets.dept_id', '=', $user->primary_dpt); $query->where('tickets.dept_id', '=', $user->primary_dpt);
} }
@@ -379,15 +385,16 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function closeTickets() { public function closeTickets()
{
try { try {
// $result = $this->model->where('status', '>', 1)->where('status', '<', 4)->orderBy('id', 'DESC')->get(); // $result = $this->model->where('status', '>', 1)->where('status', '<', 4)->orderBy('id', 'DESC')->get();
// return response()->json(compact('result')); // return response()->json(compact('result'));
$user = \JWTAuth::parseToken()->authenticate(); $user = \JWTAuth::parseToken()->authenticate();
$result = $this->user->join('tickets', function ($join) { $result = $this->user->join('tickets', function ($join) {
$join->on('users.id', '=', 'tickets.user_id') $join->on('users.id', '=', 'tickets.user_id')
->where('status', '=', 3)->orWhere('status', '=', 2); ->where('status', '=', 3)->orWhere('status', '=', 2);
}) })
->join('department', 'department.id', '=', 'tickets.dept_id') ->join('department', 'department.id', '=', 'tickets.dept_id')
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') ->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla') ->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
@@ -398,7 +405,7 @@ class ApiController extends Controller {
->whereNotNull('title'); ->whereNotNull('title');
}) })
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name') ->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
->where(function($query) use($user) { ->where(function ($query) use ($user) {
if ($user->role != 'admin') { if ($user->role != 'admin') {
$query->where('tickets.dept_id', '=', $user->primary_dpt); $query->where('tickets.dept_id', '=', $user->primary_dpt);
} }
@@ -428,7 +435,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getAgents() { public function getAgents()
{
try { try {
$result = $this->faveoUser->where('role', 'agent')->orWhere('role', 'admin')->where('active', 1)->get(); $result = $this->faveoUser->where('role', 'agent')->orWhere('role', 'admin')->where('active', 1)->get();
@@ -451,7 +459,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getTeams() { public function getTeams()
{
try { try {
$result = $this->team->get(); $result = $this->team->get();
@@ -474,11 +483,12 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function assignTicket() { public function assignTicket()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'ticket_id' => 'required', 'ticket_id' => 'required',
'user' => 'required', 'user' => 'required',
]); ]);
if ($v->fails()) { if ($v->fails()) {
$error = $v->errors(); $error = $v->errors();
@@ -512,7 +522,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getCustomers() { public function getCustomers()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'search' => 'required', 'search' => 'required',
@@ -523,7 +534,7 @@ class ApiController extends Controller {
return response()->json(compact('error')); return response()->json(compact('error'));
} }
$search = $this->request->input('search'); $search = $this->request->input('search');
$result = $this->faveoUser->where('first_name', 'like', '%' . $search . '%')->orWhere('last_name', 'like', '%' . $search . '%')->orWhere('user_name', 'like', '%' . $search . '%')->orWhere('email', 'like', '%' . $search . '%')->get(); $result = $this->faveoUser->where('first_name', 'like', '%'.$search.'%')->orWhere('last_name', 'like', '%'.$search.'%')->orWhere('user_name', 'like', '%'.$search.'%')->orWhere('email', 'like', '%'.$search.'%')->get();
return response()->json(compact('result')) return response()->json(compact('result'))
->header('X-Header-One', 'Header Value'); ->header('X-Header-One', 'Header Value');
@@ -546,7 +557,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getCustomersWith() { public function getCustomersWith()
{
try { try {
$users = $this->user $users = $this->user
->leftJoin('user_assign_organization', 'user_assign_organization.user_id', '=', 'users.id') ->leftJoin('user_assign_organization', 'user_assign_organization.user_id', '=', 'users.id')
@@ -577,7 +589,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getCustomer() { public function getCustomer()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'user_id' => 'required', 'user_id' => 'required',
@@ -609,7 +622,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function searchTicket() { public function searchTicket()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'search' => 'required', 'search' => 'required',
@@ -620,7 +634,7 @@ class ApiController extends Controller {
return response()->json(compact('error')); return response()->json(compact('error'));
} }
$search = $this->request->input('search'); $search = $this->request->input('search');
$result = $this->thread->select('ticket_id')->where('title', 'like', '%' . $search . '%')->orWhere('body', 'like', '%' . $search . '%')->get(); $result = $this->thread->select('ticket_id')->where('title', 'like', '%'.$search.'%')->orWhere('body', 'like', '%'.$search.'%')->get();
return response()->json(compact('result')); return response()->json(compact('result'));
} catch (Exception $e) { } catch (Exception $e) {
@@ -641,7 +655,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function ticketThreads() { public function ticketThreads()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'id' => 'required', 'id' => 'required',
@@ -678,7 +693,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function checkUrl() { public function checkUrl()
{
//dd($this->request); //dd($this->request);
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
@@ -695,7 +711,7 @@ class ApiController extends Controller {
$url = str_finish($url, '/'); $url = str_finish($url, '/');
} }
$url = $url . '/api/v1/helpdesk/check-url?api_key=' . $this->request->input('api_key') . '&token=' . \Config::get('app.token'); $url = $url.'/api/v1/helpdesk/check-url?api_key='.$this->request->input('api_key').'&token='.\Config::get('app.token');
$result = $this->CallGetApi($url); $result = $this->CallGetApi($url);
//dd($result); //dd($result);
return response()->json(compact('result')); return response()->json(compact('result'));
@@ -715,7 +731,8 @@ class ApiController extends Controller {
* *
* @return string * @return string
*/ */
public function urlResult() { public function urlResult()
{
return 'success'; return 'success';
} }
@@ -726,7 +743,8 @@ class ApiController extends Controller {
* *
* @return type int|string|json * @return type int|string|json
*/ */
public function callGetApi($url) { public function callGetApi($url)
{
$curl = curl_init($url); $curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_URL, $url);
@@ -735,7 +753,7 @@ class ApiController extends Controller {
$response = curl_exec($curl); $response = curl_exec($curl);
if (curl_errno($curl)) { if (curl_errno($curl)) {
echo 'error:' . curl_error($curl); echo 'error:'.curl_error($curl);
} }
return $response; return $response;
@@ -750,7 +768,8 @@ class ApiController extends Controller {
* *
* @return type int|string|json * @return type int|string|json
*/ */
public function callPostApi($url, $data) { public function callPostApi($url, $data)
{
$curl = curl_init($url); $curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_URL, $url);
@@ -760,7 +779,7 @@ class ApiController extends Controller {
$response = curl_exec($curl); $response = curl_exec($curl);
if (curl_errno($curl)) { if (curl_errno($curl)) {
echo 'error:' . curl_error($curl); echo 'error:'.curl_error($curl);
} }
return $response; return $response;
@@ -772,7 +791,8 @@ class ApiController extends Controller {
* *
* @return type | json * @return type | json
*/ */
public function generateApiKey() { public function generateApiKey()
{
try { try {
$set = $this->setting->where('id', '1')->first(); $set = $this->setting->where('id', '1')->first();
//dd($set); //dd($set);
@@ -806,7 +826,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getHelpTopic() { public function getHelpTopic()
{
try { try {
$result = $this->helptopic->get(); $result = $this->helptopic->get();
@@ -829,7 +850,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getSlaPlan() { public function getSlaPlan()
{
try { try {
$result = $this->slaPlan->get(); $result = $this->slaPlan->get();
@@ -852,7 +874,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getPriority() { public function getPriority()
{
try { try {
$result = $this->priority->get(); $result = $this->priority->get();
@@ -875,7 +898,8 @@ class ApiController extends Controller {
* *
* @return json * @return json
*/ */
public function getDepartment() { public function getDepartment()
{
try { try {
$result = $this->department->get(); $result = $this->department->get();
@@ -898,7 +922,8 @@ class ApiController extends Controller {
* *
* @return type json * @return type json
*/ */
public function getTickets() { public function getTickets()
{
try { try {
$tickets = $this->model->orderBy('created_at', 'desc')->paginate(10); $tickets = $this->model->orderBy('created_at', 'desc')->paginate(10);
$tickets->toJson(); $tickets->toJson();
@@ -922,13 +947,14 @@ class ApiController extends Controller {
* *
* @return type json * @return type json
*/ */
public function inbox() { public function inbox()
{
try { try {
$user = \JWTAuth::parseToken()->authenticate(); $user = \JWTAuth::parseToken()->authenticate();
$inbox = $this->user->join('tickets', function ($join) { $inbox = $this->user->join('tickets', function ($join) {
$join->on('users.id', '=', 'tickets.user_id') $join->on('users.id', '=', 'tickets.user_id')
->where('status', '=', 1); ->where('status', '=', 1);
}) })
->join('department', 'department.id', '=', 'tickets.dept_id') ->join('department', 'department.id', '=', 'tickets.dept_id')
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') ->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla') ->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
@@ -939,7 +965,7 @@ class ApiController extends Controller {
->whereNotNull('ticket_thread.title'); ->whereNotNull('ticket_thread.title');
}) })
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'ticket_thread.title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name', 'department.id as department_id', 'users.primary_dpt as user_dpt') ->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'ticket_thread.title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name', 'department.id as department_id', 'users.primary_dpt as user_dpt')
->where(function($query) use($user) { ->where(function ($query) use ($user) {
if ($user->role != 'admin') { if ($user->role != 'admin') {
$query->where('tickets.dept_id', '=', $user->primary_dpt); $query->where('tickets.dept_id', '=', $user->primary_dpt);
} }
@@ -949,6 +975,7 @@ class ApiController extends Controller {
->distinct() ->distinct()
->paginate(10) ->paginate(10)
->toJson(); ->toJson();
return $inbox; return $inbox;
} catch (\Exception $ex) { } catch (\Exception $ex) {
$error = $ex->getMessage(); $error = $ex->getMessage();
@@ -968,12 +995,13 @@ class ApiController extends Controller {
* *
* @return type json * @return type json
*/ */
public function internalNote() { public function internalNote()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'userid' => 'required|exists:users,id', 'userid' => 'required|exists:users,id',
'ticketid' => 'required|exists:tickets,id', 'ticketid' => 'required|exists:tickets,id',
'body' => 'required', 'body' => 'required',
]); ]);
if ($v->fails()) { if ($v->fails()) {
$error = $v->errors(); $error = $v->errors();
@@ -1000,13 +1028,14 @@ class ApiController extends Controller {
} }
} }
public function getTrash() { public function getTrash()
{
try { try {
$user = \JWTAuth::parseToken()->authenticate(); $user = \JWTAuth::parseToken()->authenticate();
$trash = $this->user->join('tickets', function ($join) { $trash = $this->user->join('tickets', function ($join) {
$join->on('users.id', '=', 'tickets.user_id') $join->on('users.id', '=', 'tickets.user_id')
->where('status', '=', 5); ->where('status', '=', 5);
}) })
->join('department', 'department.id', '=', 'tickets.dept_id') ->join('department', 'department.id', '=', 'tickets.dept_id')
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') ->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla') ->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
@@ -1017,7 +1046,7 @@ class ApiController extends Controller {
->whereNotNull('title'); ->whereNotNull('title');
}) })
->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name') ->select(\DB::raw('max(ticket_thread.updated_at) as updated_at'), 'user_name', 'first_name', 'last_name', 'email', 'profile_pic', 'ticket_number', 'tickets.id', 'title', 'tickets.created_at', 'department.name as department_name', 'ticket_priority.priority as priotity_name', 'sla_plan.name as sla_plan_name', 'help_topic.topic as help_topic_name', 'ticket_status.name as ticket_status_name')
->where(function($query) use($user) { ->where(function ($query) use ($user) {
if ($user->role != 'admin') { if ($user->role != 'admin') {
$query->where('tickets.dept_id', '=', $user->primary_dpt); $query->where('tickets.dept_id', '=', $user->primary_dpt);
} }
@@ -1042,7 +1071,8 @@ class ApiController extends Controller {
} }
} }
public function getMyTicketsAgent() { public function getMyTicketsAgent()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'user_id' => 'required|exists:users,id', 'user_id' => 'required|exists:users,id',
@@ -1060,10 +1090,10 @@ class ApiController extends Controller {
} }
//$user = \JWTAuth::parseToken()->authenticate(); //$user = \JWTAuth::parseToken()->authenticate();
$result = $this->user->join('tickets', function ($join) use ($id) { $result = $this->user->join('tickets', function ($join) use ($id) {
$join->on('users.id', '=', 'tickets.assigned_to') $join->on('users.id', '=', 'tickets.assigned_to')
->where('status', '=', 1); ->where('status', '=', 1);
//->where('user_id', '=', $id); //->where('user_id', '=', $id);
}) })
->join('department', 'department.id', '=', 'tickets.dept_id') ->join('department', 'department.id', '=', 'tickets.dept_id')
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') ->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla') ->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
@@ -1100,7 +1130,8 @@ class ApiController extends Controller {
} }
} }
public function getMyTicketsUser() { public function getMyTicketsUser()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'user_id' => 'required|exists:users,id', 'user_id' => 'required|exists:users,id',
@@ -1117,9 +1148,9 @@ class ApiController extends Controller {
return response()->json(compact('error')); return response()->json(compact('error'));
} }
$result = $this->user->join('tickets', function ($join) use ($id) { $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); ->where('user_id', '=', $id);
}) })
->join('department', 'department.id', '=', 'tickets.dept_id') ->join('department', 'department.id', '=', 'tickets.dept_id')
->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id') ->join('ticket_priority', 'ticket_priority.priority_id', '=', 'tickets.priority_id')
->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla') ->join('sla_plan', 'sla_plan.id', '=', 'tickets.sla')
@@ -1151,7 +1182,8 @@ class ApiController extends Controller {
} }
} }
public function getTicketById() { public function getTicketById()
{
try { try {
$v = \Validator::make($this->request->all(), [ $v = \Validator::make($this->request->all(), [
'id' => 'required|exists:tickets,id', 'id' => 'required|exists:tickets,id',
@@ -1163,7 +1195,7 @@ class ApiController extends Controller {
} }
$id = $this->request->input('id'); $id = $this->request->input('id');
if (!$this->model->where('id', $id)->first()) { if (!$this->model->where('id', $id)->first()) {
$error = 'There is no Ticket as ticket id: ' . $id; $error = 'There is no Ticket as ticket id: '.$id;
return response()->json(compact('error')); return response()->json(compact('error'));
} }
@@ -1171,44 +1203,43 @@ class ApiController extends Controller {
$join->on('users.id', '=', 'tickets.user_id') $join->on('users.id', '=', 'tickets.user_id')
->where('tickets.id', '=', $id); ->where('tickets.id', '=', $id);
}); });
$response = $this->differenciateHelpTopic($query) $response = $this->differenciateHelpTopic($query)
->leftJoin('department','tickets.dept_id','=',"department.id") ->leftJoin('department', 'tickets.dept_id', '=', 'department.id')
->leftJoin('ticket_priority','tickets.priority_id','=','ticket_priority.priority_id') ->leftJoin('ticket_priority', 'tickets.priority_id', '=', 'ticket_priority.priority_id')
->leftJoin('ticket_status','tickets.status','=','ticket_status.id') ->leftJoin('ticket_status', 'tickets.status', '=', 'ticket_status.id')
->leftJoin('sla_plan','tickets.sla','=','sla_plan.id') ->leftJoin('sla_plan', 'tickets.sla', '=', 'sla_plan.id')
->leftJoin('ticket_source','tickets.source','=','ticket_source.id'); ->leftJoin('ticket_source', 'tickets.source', '=', 'ticket_source.id');
//$select = 'users.email','users.user_name','users.first_name','users.last_name','tickets.id','ticket_number','num_sequence','user_id','priority_id','sla','max_open_ticket','captcha','status','lock_by','lock_at','source','isoverdue','reopened','isanswered','is_deleted', 'closed','is_transfer','transfer_at','reopened_at','duedate','closed_at','last_message_at'; //$select = 'users.email','users.user_name','users.first_name','users.last_name','tickets.id','ticket_number','num_sequence','user_id','priority_id','sla','max_open_ticket','captcha','status','lock_by','lock_at','source','isoverdue','reopened','isanswered','is_deleted', 'closed','is_transfer','transfer_at','reopened_at','duedate','closed_at','last_message_at';
$result = $response->addSelect( $result = $response->addSelect(
'users.email', 'users.email',
'users.user_name', 'users.user_name',
'users.first_name', 'users.first_name',
'users.last_name', 'users.last_name',
'tickets.id', 'tickets.id',
'ticket_number', 'ticket_number',
'user_id', 'user_id',
'ticket_priority.priority_id', 'ticket_priority.priority_id',
'ticket_priority.priority as priority_name', 'ticket_priority.priority as priority_name',
'department.name as dept_name', 'department.name as dept_name',
'ticket_status.name as status_name', 'ticket_status.name as status_name',
'sla_plan.name as sla_name', 'sla_plan.name as sla_name',
'ticket_source.name as source_name', 'ticket_source.name as source_name',
'sla_plan.id as sla', 'sla_plan.id as sla',
'ticket_status.id as status', 'ticket_status.id as status',
'lock_by', 'lock_by',
'lock_at', 'lock_at',
'ticket_source.id as source', 'ticket_source.id as source',
'isoverdue', 'isoverdue',
'reopened', 'reopened',
'isanswered', 'isanswered',
'is_deleted', 'is_deleted',
'closed', 'closed',
'reopened_at', 'reopened_at',
'duedate', 'duedate',
'closed_at', 'closed_at',
'tickets.created_at', 'tickets.created_at',
'tickets.updated_at')->first(); 'tickets.updated_at')->first();
return response()->json(compact('result')); return response()->json(compact('result'));
@@ -1225,7 +1256,8 @@ class ApiController extends Controller {
} }
} }
public function createPagination($array, $perPage) { public function createPagination($array, $perPage)
{
try { try {
//Get current page form url e.g. &page=6 //Get current page form url e.g. &page=6
$currentPage = LengthAwarePaginator::resolveCurrentPage(); $currentPage = LengthAwarePaginator::resolveCurrentPage();
@@ -1253,7 +1285,8 @@ class ApiController extends Controller {
} }
} }
public function collaboratorSearch() { public function collaboratorSearch()
{
$this->validate($this->request, ['term' => 'required']); $this->validate($this->request, ['term' => 'required']);
try { try {
$emails = $this->ticket->autosearch(); $emails = $this->ticket->autosearch();
@@ -1263,7 +1296,7 @@ class ApiController extends Controller {
foreach ($emails as $key => $email) { foreach ($emails as $key => $email) {
$user_model = $user->where('email', $email)->first(); $user_model = $user->where('email', $email)->first();
//return $user_model; //return $user_model;
$users[$key]['name'] = $user_model->first_name . ' ' . $user_model->last_name; $users[$key]['name'] = $user_model->first_name.' '.$user_model->last_name;
$users[$key]['email'] = $email; $users[$key]['email'] = $email;
$users[$key]['avatar'] = $this->avatarUrl($email); $users[$key]['avatar'] = $this->avatarUrl($email);
} }
@@ -1280,12 +1313,13 @@ class ApiController extends Controller {
} }
} }
public function avatarUrl($email) { public function avatarUrl($email)
{
try { try {
$user = new User(); $user = new User();
$user = $user->where('email', $email)->first(); $user = $user->where('email', $email)->first();
if ($user->profile_pic) { if ($user->profile_pic) {
$url = url('uploads/profilepic/' . $user->profile_pic); $url = url('uploads/profilepic/'.$user->profile_pic);
} else { } else {
$url = \Gravatar::src($email); $url = \Gravatar::src($email);
} }
@@ -1297,10 +1331,11 @@ class ApiController extends Controller {
} }
} }
public function addCollaboratorForTicket() { public function addCollaboratorForTicket()
{
try { try {
$v = \Validator::make(\Input::get(), [ $v = \Validator::make(\Input::get(), [
'email' => 'required|email|unique:users', 'email' => 'required|email|unique:users',
'ticket_id' => 'required', 'ticket_id' => 'required',
] ]
); );
@@ -1327,7 +1362,8 @@ class ApiController extends Controller {
} }
} }
public function getCollaboratorForTicket() { public function getCollaboratorForTicket()
{
try { try {
$v = \Validator::make(\Input::get(), [ $v = \Validator::make(\Input::get(), [
'ticket_id' => 'required', 'ticket_id' => 'required',
@@ -1356,11 +1392,12 @@ class ApiController extends Controller {
} }
} }
public function deleteCollaborator() { public function deleteCollaborator()
{
try { try {
$v = \Validator::make(\Input::get(), [ $v = \Validator::make(\Input::get(), [
'ticketid' => 'required', 'ticketid' => 'required',
'email' => 'required', 'email' => 'required',
] ]
); );
if ($v->fails()) { if ($v->fails()) {
@@ -1380,7 +1417,8 @@ class ApiController extends Controller {
} }
} }
public function dependency() { public function dependency()
{
try { try {
$department = $this->department->select('name', 'id')->get()->toArray(); $department = $this->department->select('name', 'id')->get()->toArray();
$sla = $this->slaPlan->select('name', 'id')->get()->toArray(); $sla = $this->slaPlan->select('name', 'id')->get()->toArray();
@@ -1391,7 +1429,7 @@ class ApiController extends Controller {
$status = \DB::table('ticket_status')->select('name', 'id')->get(); $status = \DB::table('ticket_status')->select('name', 'id')->get();
$source = \DB::table('ticket_source')->select('name', 'id')->get(); $source = \DB::table('ticket_source')->select('name', 'id')->get();
$result = ['departments' => $department, 'sla' => $sla, 'staffs' => $staff, 'teams' => $team, $result = ['departments' => $department, 'sla' => $sla, 'staffs' => $staff, 'teams' => $team,
'priorities' => $priority, 'helptopics' => $helptopic, 'status' => $status, 'sources' => $source,]; 'priorities' => $priority, 'helptopics' => $helptopic, 'status' => $status, 'sources' => $source, ];
return response()->json(compact('result')); return response()->json(compact('result'));
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -1403,7 +1441,8 @@ class ApiController extends Controller {
} }
} }
public function differenciateHelpTopic($query) { public function differenciateHelpTopic($query)
{
$ticket = $query->first(); $ticket = $query->first();
$check = 'department'; $check = 'department';
if ($ticket) { if ($ticket) {
@@ -1417,16 +1456,18 @@ class ApiController extends Controller {
return $query->select('tickets.dept_id'); return $query->select('tickets.dept_id');
} }
} }
return $query; return $query;
} }
public function getSystem($check, $query) { public function getSystem($check, $query)
{
switch ($check) { switch ($check) {
case 'department': case 'department':
return $query->select('tickets.dept_id'); return $query->select('tickets.dept_id');
case 'helpTopic': case 'helpTopic':
return $query->select('tickets.help_topic_id'); return $query->select('tickets.help_topic_id');
default : default:
return $query->select('tickets.dept_id'); return $query->select('tickets.dept_id');
} }
} }
@@ -1438,10 +1479,11 @@ class ApiController extends Controller {
* *
* @return type json * @return type json
*/ */
public function register(Request $request) { public function register(Request $request)
{
try { try {
$v = \Validator::make($request->all(), [ $v = \Validator::make($request->all(), [
'email' => 'required|email|unique:users', 'email' => 'required|email|unique:users',
'password' => 'required|min:6', 'password' => 'required|min:6',
]); ]);
if ($v->fails()) { if ($v->fails()) {
@@ -1455,7 +1497,7 @@ class ApiController extends Controller {
$password = \Hash::make($request->input('password')); $password = \Hash::make($request->input('password'));
$role = $request->input('role'); $role = $request->input('role');
if ($auth->role == 'agent') { if ($auth->role == 'agent') {
$role = "user"; $role = 'user';
} }
$user = new User(); $user = new User();
$user->password = $password; $user->password = $password;
@@ -1463,6 +1505,7 @@ class ApiController extends Controller {
$user->email = $email; $user->email = $email;
$user->role = $role; $user->role = $role;
$user->save(); $user->save();
return response()->json(compact('user')); return response()->json(compact('user'));
} catch (\Exception $e) { } catch (\Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
@@ -1470,5 +1513,4 @@ class ApiController extends Controller {
return response()->json(compact('error')); return response()->json(compact('error'));
} }
} }
} }

View File

@@ -98,7 +98,7 @@ class InstallerApiController extends Controller
$ENV['QUEUE_DRIVER'] = 'sync'; $ENV['QUEUE_DRIVER'] = 'sync';
$config = ''; $config = '';
foreach ($ENV as $key => $val) { foreach ($ENV as $key => $val) {
$config .= "{$key}={$val}\n"; $config .= "{$key}={$val}\n";
} }

View File

@@ -50,7 +50,7 @@ class TokenAuthController extends Controller
//$credentials = $request->only('email', 'password'); //$credentials = $request->only('email', 'password');
try { try {
if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password,'active'=>1])) { if (!$token = JWTAuth::attempt([$field => $usernameinput, 'password' => $password, 'active'=>1])) {
return response()->json(['error' => 'invalid_credentials', 'status_code' => 401]); return response()->json(['error' => 'invalid_credentials', 'status_code' => 401]);
} }
} catch (JWTException $e) { } catch (JWTException $e) {

View File

@@ -3,31 +3,29 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
// controllers // controllers
use App\Http\Controllers\Admin\helpdesk\SocialMedia\SocialMediaController;
use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Controller;
// requests // requests
use App\Http\Controllers\Controller;
use App\Http\Requests\helpdesk\LoginRequest; use App\Http\Requests\helpdesk\LoginRequest;
use App\Http\Requests\helpdesk\RegisterRequest;
use App\Http\Requests\helpdesk\OtpVerifyRequest; use App\Http\Requests\helpdesk\OtpVerifyRequest;
use App\Model\helpdesk\Settings\Security; use App\Http\Requests\helpdesk\RegisterRequest;
use App\Model\helpdesk\Settings\CommonSettings; use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Settings\Plugin; use App\Model\helpdesk\Settings\Plugin;
use App\Model\helpdesk\Settings\Security;
use App\Model\helpdesk\Ticket\Ticket_Thread;
// classes // classes
use App\User; use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Utility\Otp; use App\Model\helpdesk\Utility\Otp;
use App\User;
use Auth; use Auth;
use DateTime;
use DB; use DB;
use Hash; use Hash;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Lang;
use DateTime;
use Input; use Input;
use Lang;
use Socialite; use Socialite;
use App\Http\Controllers\Admin\helpdesk\SocialMedia\SocialMediaController;
/** /**
* --------------------------------------------------- * ---------------------------------------------------
@@ -39,8 +37,8 @@ use App\Http\Controllers\Admin\helpdesk\SocialMedia\SocialMediaController;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class AuthController extends Controller { class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers; use AuthenticatesAndRegistersUsers;
/* to redirect after login */ /* to redirect after login */
@@ -61,14 +59,15 @@ class AuthController extends Controller {
* *
* @return void * @return void
*/ */
public function __construct(PhpMailController $PhpMailController, SocialMediaController $social) { public function __construct(PhpMailController $PhpMailController, SocialMediaController $social)
{
$this->PhpMailController = $PhpMailController; $this->PhpMailController = $PhpMailController;
$social->configService(); $social->configService();
$this->middleware('guest', ['except' => ['getLogout', 'verifyOTP', 'redirectToProvider']]); $this->middleware('guest', ['except' => ['getLogout', 'verifyOTP', 'redirectToProvider']]);
} }
public function redirectToProvider($provider, $redirect = '') { public function redirectToProvider($provider, $redirect = '')
{
if ($redirect !== '') { if ($redirect !== '') {
$this->setSession($provider, $redirect); $this->setSession($provider, $redirect);
} }
@@ -78,7 +77,8 @@ class AuthController extends Controller {
return $s; return $s;
} }
public function handleProviderCallback($provider) { public function handleProviderCallback($provider)
{
try { try {
//notice we are not doing any validation, you should do it //notice we are not doing any validation, you should do it
$this->changeRedirect(); $this->changeRedirect();
@@ -91,25 +91,24 @@ class AuthController extends Controller {
if ($user->nickname) { if ($user->nickname) {
$username = $user->nickname; $username = $user->nickname;
} }
if(!$first_name){ if (!$first_name) {
$first_name = $username; $first_name = $username;
} }
$data = [ $data = [
'first_name' => $first_name, 'first_name' => $first_name,
'email' => $user->getEmail(), 'email' => $user->getEmail(),
'user_name' => $username, 'user_name' => $username,
'role' => 'user', 'role' => 'user',
'active' => 1, 'active' => 1,
]; ];
$user = User::where('email',$data['email'])->first(); $user = User::where('email', $data['email'])->first();
if(!$user){ if (!$user) {
$user = User::where('user_name',$data['user_name'])->first(); $user = User::where('user_name', $data['user_name'])->first();
} }
if(!$user){ if (!$user) {
$user = User::firstOrCreate($data); $user = User::firstOrCreate($data);
} }
Auth::login($user); Auth::login($user);
} }
//after login redirecting to home page //after login redirecting to home page
return redirect('/'); return redirect('/');
@@ -123,7 +122,8 @@ class AuthController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getRegister(CommonSettings $settings) { public function getRegister(CommonSettings $settings)
{
// Event for login // Event for login
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first(); $settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
$email_mandatory = $settings->select('status')->where('option_name', '=', 'email_mandatory')->first(); $email_mandatory = $settings->select('status')->where('option_name', '=', 'email_mandatory')->first();
@@ -148,46 +148,47 @@ class AuthController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function postRegister(User $user, RegisterRequest $request) { public function postRegister(User $user, RegisterRequest $request)
{
try { try {
$request_array = $request->input(); $request_array = $request->input();
$password = Hash::make($request->input('password')); $password = Hash::make($request->input('password'));
$user->password = $password; $user->password = $password;
$name = $request->input('full_name'); $name = $request->input('full_name');
$user->first_name = $name; $user->first_name = $name;
if ($request_array['email'] == '') { if ($request_array['email'] == '') {
$user->email = null; $user->email = null;
} else { } else {
$user->email = $request->input('email'); $user->email = $request->input('email');
} }
if ($request_array['mobile'] == '') { if ($request_array['mobile'] == '') {
$user->mobile = null; $user->mobile = null;
} else { } else {
$user->mobile = $request->input('mobile'); $user->mobile = $request->input('mobile');
} }
if ($request_array['code'] == '') { if ($request_array['code'] == '') {
$user->country_code = 0; $user->country_code = 0;
} else { } else {
$user->country_code = $request->input('code'); $user->country_code = $request->input('code');
} }
if ($request_array['email'] != '') { if ($request_array['email'] != '') {
$user->user_name = $request->input('email'); $user->user_name = $request->input('email');
} else { } else {
$user->user_name = $request->input('mobile'); $user->user_name = $request->input('mobile');
} }
$user->role = 'user'; $user->role = 'user';
$code = str_random(60); $code = str_random(60);
$user->remember_token = $code; $user->remember_token = $code;
$user->save(); $user->save();
$message12 = ''; $message12 = '';
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$sms = Plugin::select('status')->where('name', '=', 'SMS')->first(); $sms = Plugin::select('status')->where('name', '=', 'SMS')->first();
// Event for login // Event for login
\Event::fire(new \App\Events\LoginEvent($request)); \Event::fire(new \App\Events\LoginEvent($request));
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/' . $code)]); $var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/'.$code)]);
if ($settings->status == 1 || $settings->status == '1') { if ($settings->status == 1 || $settings->status == '1') {
if(count($sms) > 0) { if (count($sms) > 0) {
if($sms->status == 1 || $sms->status == '1') { if ($sms->status == 1 || $sms->status == '1') {
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_and_moble'); $message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_and_moble');
} else { } else {
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_sms_plugin_inactive_or_not_setup'); $message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail_sms_plugin_inactive_or_not_setup');
@@ -198,9 +199,10 @@ class AuthController extends Controller {
} else { } else {
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail'); $message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
} }
return redirect('home')->with('success', $message12);
return redirect('home')->with('success', $message12);
} catch (\Exception $e) { } catch (\Exception $e) {
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
} }
@@ -211,13 +213,15 @@ class AuthController extends Controller {
* *
* @return type redirect * @return type redirect
*/ */
public function accountActivate($token) { public function accountActivate($token)
{
$user = User::where('remember_token', '=', $token)->first(); $user = User::where('remember_token', '=', $token)->first();
if ($user) { if ($user) {
$user->active = 1; $user->active = 1;
$user->remember_token = null; $user->remember_token = null;
$user->save(); $user->save();
$this->openTicketAfterVerification($user->id); $this->openTicketAfterVerification($user->id);
return redirect('/auth/login')->with('status', 'Acount activated. Login to start'); return redirect('/auth/login')->with('status', 'Acount activated. Login to start');
} else { } else {
return redirect('/auth/login')->with('fails', 'Invalid Token'); return redirect('/auth/login')->with('fails', 'Invalid Token');
@@ -232,7 +236,8 @@ class AuthController extends Controller {
* *
* @return type Response * @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(); $user = $user->where('remember_token', $token)->where('active', 0)->first();
if ($user) { if ($user) {
$user->active = 1; $user->active = 1;
@@ -249,9 +254,10 @@ class AuthController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getLogin() { public function getLogin()
{
$directory = base_path(); $directory = base_path();
if (file_exists($directory . DIRECTORY_SEPARATOR . '.env')) { if (file_exists($directory.DIRECTORY_SEPARATOR.'.env')) {
if (Auth::user()) { if (Auth::user()) {
if (Auth::user()->role == 'admin' || Auth::user()->role == 'agent') { if (Auth::user()->role == 'admin' || Auth::user()->role == 'agent') {
return \Redirect::route('dashboard'); return \Redirect::route('dashboard');
@@ -288,7 +294,7 @@ class AuthController extends Controller {
} }
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name'; $field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
$result = $this->confirmIPAddress($value, $usernameinput); $result = $this->confirmIPAddress($value, $usernameinput);
// If attempts > 3 and time < 30 minutes // If attempts > 3 and time < 30 minutes
$security = Security::whereId('1')->first(); $security = Security::whereId('1')->first();
if ($result == 1) { if ($result == 1) {
@@ -301,15 +307,15 @@ class AuthController extends Controller {
return redirect()->back() return redirect()->back()
->withInput($request->only('email', 'remember')) ->withInput($request->only('email', 'remember'))
->withErrors([ ->withErrors([
'email' => $this->getFailedLoginMessage(), 'email' => $this->getFailedLoginMessage(),
'password' => $this->getFailedLoginMessage(), 'password' => $this->getFailedLoginMessage(),
])->with(['error' => Lang::get('lang.not-registered'), ])->with(['error' => Lang::get('lang.not-registered'),
'referer' => $referer, ]); 'referer' => $referer, ]);
} }
//if user exists //if user exists
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
if ($settings->status == '1' || $settings->status == 1) { // check for otp verification setting if ($settings->status == '1' || $settings->status == 1) { // check for otp verification setting
// setting is enabled // setting is enabled
$sms = Plugin::select('status')->where('name', '=', 'SMS')->first(); $sms = Plugin::select('status')->where('name', '=', 'SMS')->first();
@@ -320,7 +326,7 @@ class AuthController extends Controller {
if (!$check_active->active) { //check account is active or not if (!$check_active->active) { //check account is active or not
// account is not active show verify otp window // account is not active show verify otp window
if ($check_active->mobile) { //check user has mobile or not if ($check_active->mobile) { //check user has mobile or not
// user has mobile number return verify OTP screen // user has mobile number return verify OTP screen
return \Redirect::route('otp-verification') return \Redirect::route('otp-verification')
->withInput($request->input()) ->withInput($request->input())
->with(['values' => $request->input(), ->with(['values' => $request->input(),
@@ -329,7 +335,7 @@ class AuthController extends Controller {
'number' => $check_active->mobile, 'number' => $check_active->mobile,
'code' => $check_active->country_code, ]); 'code' => $check_active->country_code, ]);
} else { } else {
goto a; //attenmpt login (be careful while using goto statements) goto a; //attenmpt login (be careful while using goto statements)
} }
} else { } else {
goto a; //attenmpt login (be careful while using goto statements) goto a; //attenmpt login (be careful while using goto statements)
@@ -384,14 +390,15 @@ class AuthController extends Controller {
if ($request->input('referer')) { if ($request->input('referer')) {
return \Redirect::route($request->input('referer')); return \Redirect::route($request->input('referer'));
} }
return \Redirect::route('/'); return \Redirect::route('/');
} else { } else {
return redirect()->intended($this->redirectPath()); return redirect()->intended($this->redirectPath());
} }
} }
} }
} }
return redirect()->back() return redirect()->back()
->withInput($request->only('email', 'remember')) ->withInput($request->only('email', 'remember'))
->withErrors([ ->withErrors([
@@ -409,7 +416,8 @@ class AuthController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function addLoginAttempt($value, $field) { public function addLoginAttempt($value, $field)
{
$result = DB::table('login_attempts')->where('IP', '=', $value)->first(); $result = DB::table('login_attempts')->where('IP', '=', $value)->first();
$data = $result; $data = $result;
$security = Security::whereId('1')->first(); $security = Security::whereId('1')->first();
@@ -417,15 +425,15 @@ class AuthController extends Controller {
if ($data) { if ($data) {
$attempts = $data->Attempts + 1; $attempts = $data->Attempts + 1;
if ($attempts == $apt) { if ($attempts == $apt) {
// $result = DB::select('UPDATE login_attempts SET Attempts='.$attempts.", LastLogin=NOW() WHERE IP = '$value' OR User = '$field'"); // $result = DB::select('UPDATE login_attempts SET Attempts='.$attempts.", LastLogin=NOW() WHERE IP = '$value' OR User = '$field'");
$result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts, 'LastLogin' => Date('Y-m-d H:i:s')]); $result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts, 'LastLogin' => date('Y-m-d H:i:s')]);
} else { } else {
$result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts]); $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'"); // $result = DB::select("UPDATE login_attempts SET Attempts=".$attempts." WHERE IP = '$value' OR User = '$field'");
} }
} else { } else {
// $result = DB::select("INSERT INTO login_attempts (Attempts,User,IP,LastLogin) values (1,'$field','$value', NOW())"); // $result = DB::select("INSERT INTO login_attempts (Attempts,User,IP,LastLogin) values (1,'$field','$value', NOW())");
$result = DB::table('login_attempts')->update(['Attempts' => 1, 'User' => $field, 'IP' => $value, 'LastLogin' => Date('Y-m-d H:i:s')]); $result = DB::table('login_attempts')->update(['Attempts' => 1, 'User' => $field, 'IP' => $value, 'LastLogin' => date('Y-m-d H:i:s')]);
} }
} }
@@ -436,7 +444,8 @@ class AuthController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function clearLoginAttempts($value, $field) { public function clearLoginAttempts($value, $field)
{
$data = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['attempts' => '0']); $data = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['attempts' => '0']);
return $data; return $data;
@@ -449,13 +458,14 @@ class AuthController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function confirmIPAddress($value, $field) { public function confirmIPAddress($value, $field)
{
$security = Security::whereId('1')->first(); $security = Security::whereId('1')->first();
$time = $security->lockout_period; $time = $security->lockout_period;
$max_attempts = $security->backlist_threshold; $max_attempts = $security->backlist_threshold;
$table = 'login_attempts'; $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 ' . $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'"); ' FROM '.$table." WHERE IP = '$value' OR User = '$field'");
$data = $result; $data = $result;
//Verify that at least one login attempt is in database //Verify that at least one login attempt is in database
if (!$data) { if (!$data) {
@@ -466,6 +476,7 @@ class AuthController extends Controller {
return 1; return 1;
} else { } else {
$this->clearLoginAttempts($value, $field); $this->clearLoginAttempts($value, $field);
return 0; return 0;
} }
} }
@@ -478,16 +489,20 @@ class AuthController extends Controller {
* *
* @return type string * @return type string
*/ */
protected function getFailedLoginMessage() { protected function getFailedLoginMessage()
{
return Lang::get('lang.this_field_do_not_match_our_records'); return Lang::get('lang.this_field_do_not_match_our_records');
} }
/** /**
*@category function to show verify OTP page *@category function to show verify OTP page
*
*@param null *@param null
*
*@return response|view *@return response|view
*/ */
public function getVerifyOTP() { public function getVerifyOTP()
{
if (\Session::has('values')) { if (\Session::has('values')) {
return view('auth.otp-verify'); return view('auth.otp-verify');
} else { } else {
@@ -497,10 +512,13 @@ class AuthController extends Controller {
/** /**
*@category function to verify OTP *@category function to verify OTP
*
*@param $request *@param $request
*
*@return int|string *@return int|string
*/ */
public function verifyOTP(LoginRequest $request) { public function verifyOTP(LoginRequest $request)
{
$user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email')) $user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))
->orWhere('user_name', '=', $request->input('email'))->first(); ->orWhere('user_name', '=', $request->input('email'))->first();
$otp_length = strlen($request->input('otp')); $otp_length = strlen($request->input('otp'));
@@ -510,10 +528,10 @@ class AuthController extends Controller {
$otp = Otp::select('otp', 'updated_at')->where('user_id', '=', $user->id) $otp = Otp::select('otp', 'updated_at')->where('user_id', '=', $user->id)
->first(); ->first();
if ($otp != null) { if ($otp != null) {
if (($otp_length == 6 && !preg_match("/[a-z]/i", $request->input('otp')))) { if (($otp_length == 6 && !preg_match('/[a-z]/i', $request->input('otp')))) {
$otp2 = Hash::make($request->input('otp')); $otp2 = Hash::make($request->input('otp'));
$date1 = date_format($otp->updated_at, "Y-m-d h:i:sa"); $date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
$date2 = date("Y-m-d h:i:sa"); $date2 = date('Y-m-d h:i:sa');
$time1 = new DateTime($date2); $time1 = new DateTime($date2);
$time2 = new DateTime($date1); $time2 = new DateTime($date1);
$interval = $time1->diff($time2); $interval = $time1->diff($time2);
@@ -526,6 +544,7 @@ class AuthController extends Controller {
User::where('id', '=', $user->id) User::where('id', '=', $user->id)
->update(['active' => 1]); ->update(['active' => 1]);
$this->openTicketAfterVerification($user->id); $this->openTicketAfterVerification($user->id);
return $this->postLogin($request); return $this->postLogin($request);
} else { } else {
$message = Lang::get('lang.otp-not-matched'); $message = Lang::get('lang.otp-not-matched');
@@ -538,37 +557,46 @@ class AuthController extends Controller {
$message = Lang::get('lang.otp-not-matched'); $message = Lang::get('lang.otp-not-matched');
} }
} }
return \Redirect::route('otp-verification') return \Redirect::route('otp-verification')
->withInput($request->input()) ->withInput($request->input())
->with(['values' => $request->input(), ->with(['values' => $request->input(),
'number' => $user->mobile, 'number' => $user->mobile,
'name' => $user->user_name, 'name' => $user->user_name,
'fails' => $message]); 'fails' => $message, ]);
} }
public function resendOTP(OtpVerifyRequest $request) { public function resendOTP(OtpVerifyRequest $request)
{
if (!\Schema::hasTable('user_verification') || !\Schema::hasTable('sms')) { if (!\Schema::hasTable('user_verification') || !\Schema::hasTable('sms')) {
$message = Lang::get('lang.opt-can-not-be-verified'); $message = Lang::get('lang.opt-can-not-be-verified');
return $message; return $message;
} else { } else {
$sms =DB::table('sms')->get(); $sms = DB::table('sms')->get();
if (count($sms) > 0) { if (count($sms) > 0) {
\Event::fire(new \App\Events\LoginEvent($request)); \Event::fire(new \App\Events\LoginEvent($request));
return 1; return 1;
} else { } else {
$message = Lang::get('lang.opt-can-not-be-verified'); $message = Lang::get('lang.opt-can-not-be-verified');
return $message; return $message;
} }
} }
} }
/** /**
* @category function to change ticket status when user verifies his account * @category function to change ticket status when user verifies his account
*
* @param int $id => user_id * @param int $id => user_id
*
* @return null * @return null
*
* @author manish.verma@ladybirdweb.com * @author manish.verma@ladybirdweb.com
*/ */
public function openTicketAfterVerification($id) { public function openTicketAfterVerification($id)
{
// dd($id); // dd($id);
$ticket = Tickets::select('id') $ticket = Tickets::select('id')
->where(['user_id' => $id, 'status' => 6]) ->where(['user_id' => $id, 'status' => 6])
@@ -579,23 +607,23 @@ class AuthController extends Controller {
foreach ($ticket as $value) { foreach ($ticket as $value) {
$ticket_id = $value->id; $ticket_id = $value->id;
Ticket_Thread::where('ticket_id', '=', $ticket_id) Ticket_Thread::where('ticket_id', '=', $ticket_id)
->update(["updated_at" => date('Y-m-d H:i:s')]); ->update(['updated_at' => date('Y-m-d H:i:s')]);
} }
} }
} }
public function changeRedirect()
public function changeRedirect() { {
$provider = \Session::get('provider'); $provider = \Session::get('provider');
$url = \Session::get($provider . 'redirect'); $url = \Session::get($provider.'redirect');
\Config::set("services.$provider.redirect", $url); \Config::set("services.$provider.redirect", $url);
} }
public function setSession($provider, $redirect) { public function setSession($provider, $redirect)
{
$url = url($redirect); $url = url($redirect);
\Session::set('provider', $provider); \Session::set('provider', $provider);
\Session::set($provider . 'redirect', $url); \Session::set($provider.'redirect', $url);
$this->changeRedirect(); $this->changeRedirect();
} }
} }

View File

@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Auth;
// controllers // controllers
use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// request // request
use App\User; use App\User;
@@ -51,41 +50,42 @@ class PasswordController extends Controller
*/ */
public function postEmail(Request $request) public function postEmail(Request $request)
{ {
try{ try {
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
$this->validate($request, ['email' => 'required']); $this->validate($request, ['email' => 'required']);
\Event::fire('reset.password',array()); \Event::fire('reset.password', []);
$user = User::where('email', '=', $request->only('email'))->orWhere('mobile', '=', $request->only('email'))->first(); $user = User::where('email', '=', $request->only('email'))->orWhere('mobile', '=', $request->only('email'))->first();
if (isset($user)) { if (isset($user)) {
$user1 = $user->email; $user1 = $user->email;
//gen new code and pass //gen new code and pass
$code = str_random(60); $code = str_random(60);
$password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->first(); $password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->first();
if (isset($password_reset_table)) { if (isset($password_reset_table)) {
$password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->update(['token' => $code, 'created_at' => $date]); $password_reset_table = \DB::table('password_resets')->where('email', '=', $user->email)->update(['token' => $code, 'created_at' => $date]);
// $password_reset_table->token = $code; // $password_reset_table->token = $code;
// $password_reset_table->update(['token' => $code]); // $password_reset_table->update(['token' => $code]);
} else {
$create_password_reset = \DB::table('password_resets')->insert(['email' => $user->email, 'token' => $code, 'created_at' => $date]);
}
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user->user_name, 'email' => $user->email], $message = ['subject' => 'Your Password Reset Link', 'scenario' => 'reset-password'], $template_variables = ['user' => $user->first_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/'.$code)],true);
if ($user->mobile != '' && $user->mobile != null) {
if($user->first_name) {
$name = $user->first_name;
} else { } else {
$name = $user->user_name; $create_password_reset = \DB::table('password_resets')->insert(['email' => $user->email, 'token' => $code, 'created_at' => $date]);
} }
$value = [ $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user->user_name, 'email' => $user->email], $message = ['subject' => 'Your Password Reset Link', 'scenario' => 'reset-password'], $template_variables = ['user' => $user->first_name, 'email_address' => $user->email, 'password_reset_link' => url('password/reset/'.$code)], true);
if ($user->mobile != '' && $user->mobile != null) {
if ($user->first_name) {
$name = $user->first_name;
} else {
$name = $user->user_name;
}
$value = [
'url' => url('password/reset/'.$code), 'url' => url('password/reset/'.$code),
'name' => $name, 'name' => $name,
'mobile' => $user->mobile, 'mobile' => $user->mobile,
'code' => $user->country_code]; 'code' => $user->country_code, ];
\Event::fire('reset.password2',array($value)); \Event::fire('reset.password2', [$value]);
}
return redirect()->back()->with('status', Lang::get('lang.we_have_e-mailed_your_password_reset_link'));
} else {
return redirect()->back()->with('fails', Lang::get("lang.we_can't_find_a_user_with_that_e-mail_address"));
} }
return redirect()->back()->with('status', Lang::get('lang.we_have_e-mailed_your_password_reset_link'));
} else {
return redirect()->back()->with('fails', Lang::get("lang.we_can't_find_a_user_with_that_e-mail_address"));
}
} catch (\Exception $e) { } catch (\Exception $e) {
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
@@ -94,12 +94,12 @@ class PasswordController extends Controller
/** /**
* Reset the given user's password. * Reset the given user's password.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function reset(Request $request) public function reset(Request $request)
{ {
$this->validate( $this->validate(
$request, $request,
$this->getResetValidationRules(), $this->getResetValidationRules(),
@@ -111,26 +111,25 @@ class PasswordController extends Controller
$email = $credentials['email']; $email = $credentials['email'];
$password = $credentials['password']; $password = $credentials['password'];
$token = $credentials['token']; $token = $credentials['token'];
$response = "fails"; $response = 'fails';
$password_tokens = \DB::table('password_resets')->where('email','=',$email)->first(); $password_tokens = \DB::table('password_resets')->where('email', '=', $email)->first();
if($password_tokens){ if ($password_tokens) {
if($password_tokens->token == $token){ if ($password_tokens->token == $token) {
$users = new User(); $users = new User();
$user = $users->where('email',$email)->first(); $user = $users->where('email', $email)->first();
if($user){ if ($user) {
$user->password = \Hash::make($password); $user->password = \Hash::make($password);
$user->save(); $user->save();
$response = "success"; $response = 'success';
} else { } else {
$response = "fails"; $response = 'fails';
} }
} }
} }
if ($response == "success") { if ($response == 'success') {
return redirect('/auth/login')->with('status', Lang::get('lang.password-reset-successfully')); return redirect('/auth/login')->with('status', Lang::get('lang.password-reset-successfully'));
} else { } else {
return redirect('/home')->with('fails', Lang::get('lang.password-can-not-reset')); return redirect('/home')->with('fails', Lang::get('lang.password-can-not-reset'));
} }
} }
} }

View File

@@ -11,15 +11,14 @@ use App\Model\helpdesk\Agent\Department;
// models // models
use App\Model\helpdesk\Form\Fields; use App\Model\helpdesk\Form\Fields;
use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Settings\System; use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Settings\Ticket; use App\Model\helpdesk\Settings\Ticket;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Ticket\Ticket_attachments; use App\Model\helpdesk\Ticket\Ticket_attachments;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Ticket\Ticket_source; use App\Model\helpdesk\Ticket\Ticket_source;
use App\Model\helpdesk\Ticket\Ticket_Thread; use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Ticket\Ticket_Priority;
use App\Model\helpdesk\Utility\CountryCode; use App\Model\helpdesk\Utility\CountryCode;
use App\User; use App\User;
use Exception; use Exception;
@@ -36,15 +35,16 @@ use Redirect;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class FormController extends Controller { class FormController extends Controller
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* Constructor to check. * Constructor to check.
* *
* @return void * @return void
*/ */
public function __construct(TicketWorkflowController $TicketWorkflowController) { public function __construct(TicketWorkflowController $TicketWorkflowController)
{
$this->middleware('board'); $this->middleware('board');
// creating a TicketController instance // creating a TicketController instance
$this->TicketWorkflowController = $TicketWorkflowController; $this->TicketWorkflowController = $TicketWorkflowController;
@@ -57,29 +57,31 @@ class FormController extends Controller {
* *
* @return type * @return type
*/ */
public function getForm(Help_topic $topic, CountryCode $code) { public function getForm(Help_topic $topic, CountryCode $code)
{
if (\Config::get('database.install') == '%0%') { if (\Config::get('database.install') == '%0%') {
return \Redirect::route('licence'); return \Redirect::route('licence');
} }
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first(); $email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
if (!\Auth::check() && ($settings->status == 1 || $settings->status == '1')) { if (!\Auth::check() && ($settings->status == 1 || $settings->status == '1')) {
return redirect('auth/login')->with(['login_require'=> 'Please login to your account for submitting a ticket', 'referer' => 'form']); return redirect('auth/login')->with(['login_require'=> 'Please login to your account for submitting a ticket', 'referer' => 'form']);
} }
$location = GeoIP::getLocation(); $location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first(); $phonecode = $code->where('iso', '=', $location->iso_code)->first();
if (System::first()->status == 1) { if (System::first()->status == 1) {
$topics = $topic->get(); $topics = $topic->get();
$codes = $code->get(); $codes = $code->get();
if ($phonecode->phonecode) { if ($phonecode->phonecode) {
$phonecode = $phonecode->phonecode; $phonecode = $phonecode->phonecode;
} else {
$phonecode = "";
}
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory'))->with('phonecode', $phonecode);
} else { } else {
return \Redirect::route('home'); $phonecode = '';
} }
return view('themes.default1.client.helpdesk.form', compact('topics', 'codes', 'email_mandatory'))->with('phonecode', $phonecode);
} else {
return \Redirect::route('home');
}
} }
/** /**
@@ -90,43 +92,43 @@ class FormController extends Controller {
* *
* @return type string * @return type string
*/ */
public function postForm($id, Help_topic $topic) { public function postForm($id, Help_topic $topic)
{
if ($id != 0) { if ($id != 0) {
$helptopic = $topic->where('id', '=', $id)->first(); $helptopic = $topic->where('id', '=', $id)->first();
$custom_form = $helptopic->custom_form; $custom_form = $helptopic->custom_form;
$values = Fields::where('forms_id', '=', $custom_form)->get(); $values = Fields::where('forms_id', '=', $custom_form)->get();
if (!$values) { if (!$values) {
} }
if ($values) { if ($values) {
foreach ($values as $form_data) { foreach ($values as $form_data) {
if ($form_data->type == "select") { if ($form_data->type == 'select') {
$form_fields = explode(',', $form_data->value); $form_fields = explode(',', $form_data->value);
$var = ""; $var = '';
foreach ($form_fields as $form_field) { foreach ($form_fields as $form_field) {
$var .= '<option value="' . $form_field . '">' . $form_field . '</option>'; $var .= '<option value="'.$form_field.'">'.$form_field.'</option>';
} }
echo '<br/><label>' . ucfirst($form_data->label) . '</label><select class="form-control" name="' . $form_data->name . '">' . $var . '</select>'; echo '<br/><label>'.ucfirst($form_data->label).'</label><select class="form-control" name="'.$form_data->name.'">'.$var.'</select>';
} elseif ($form_data->type == "radio") { } elseif ($form_data->type == 'radio') {
$type2 = $form_data->value; $type2 = $form_data->value;
$vals = explode(',', $type2); $vals = explode(',', $type2);
echo '<br/><label>' . ucfirst($form_data->label) . '</label><br/>'; echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
foreach ($vals as $val) { foreach ($vals as $val) {
echo '<input type="' . $form_data->type . '" name="' . $form_data->name . '"> ' . $form_data->value . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'"> '.$form_data->value.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
} }
echo "<br/>"; echo '<br/>';
} elseif ($form_data->type == "textarea") { } elseif ($form_data->type == 'textarea') {
$type3 = $form_data->value; $type3 = $form_data->value;
echo '<br/><label>' . $form_data->label . '</label></br><textarea id="unique-textarea" name="' . $form_data->name . '" class="form-control" style="height:15%;"></textarea>'; echo '<br/><label>'.$form_data->label.'</label></br><textarea id="unique-textarea" name="'.$form_data->name.'" class="form-control" style="height:15%;"></textarea>';
} elseif ($form_data->type == "checkbox") { } elseif ($form_data->type == 'checkbox') {
$type4 = $form_data->value; $type4 = $form_data->value;
$checks = explode(',', $type4); $checks = explode(',', $type4);
echo '<br/><label>' . ucfirst($form_data->label) . '</label><br/>'; echo '<br/><label>'.ucfirst($form_data->label).'</label><br/>';
foreach ($checks as $check) { foreach ($checks as $check) {
echo '<input type="' . $form_data->type . '" name="' . $form_data->name . '">&nbsp&nbsp' . $check; echo '<input type="'.$form_data->type.'" name="'.$form_data->name.'">&nbsp&nbsp'.$check;
} }
} else { } else {
echo '<br/><label>' . ucfirst($form_data->label) . '</label><input type="' . $form_data->type . '" class="form-control" name="' . $form_data->name . '" />'; echo '<br/><label>'.ucfirst($form_data->label).'</label><input type="'.$form_data->type.'" class="form-control" name="'.$form_data->name.'" />';
} }
} }
echo '<br/><br/>'; echo '<br/><br/>';
@@ -142,15 +144,16 @@ class FormController extends Controller {
* @param type Request $request * @param type Request $request
* @param type User $user * @param type User $user
*/ */
public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta, CountryCode $code) { public function postedForm(User $user, ClientRequest $request, Ticket $ticket_settings, Ticket_source $ticket_source, Ticket_attachments $ta, CountryCode $code)
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token','mobile','Code', 'priority'); {
$form_extras = $request->except('Name', 'Phone', 'Email', 'Subject', 'Details', 'helptopic', '_wysihtml5_mode', '_token', 'mobile', 'Code', 'priority');
$name = $request->input('Name'); $name = $request->input('Name');
$phone = $request->input('Phone'); $phone = $request->input('Phone');
if ($request->input('Email')) { if ($request->input('Email')) {
if($request->input('Email')) { if ($request->input('Email')) {
$email = $request->input('Email'); $email = $request->input('Email');
} else { } else {
$email = null; $email = null;
} }
} else { } else {
$email = null; $email = null;
@@ -165,18 +168,18 @@ class FormController extends Controller {
} }
$status = $ticket_settings->first()->status; $status = $ticket_settings->first()->status;
$helptopic = $request->input('helptopic'); $helptopic = $request->input('helptopic');
$helpTopicObj = Help_topic::where('id','=', $helptopic); $helpTopicObj = Help_topic::where('id', '=', $helptopic);
if($helpTopicObj->exists() && ($helpTopicObj->value('status')==1)){ if ($helpTopicObj->exists() && ($helpTopicObj->value('status') == 1)) {
$department = $helpTopicObj->value('department'); $department = $helpTopicObj->value('department');
}else{ } else {
$defaultHelpTopicID = Ticket::where('id', '=', '1')->first()->help_topic; $defaultHelpTopicID = Ticket::where('id', '=', '1')->first()->help_topic;
$department = Help_topic::where('id','=', $defaultHelpTopicID)->value('department'); $department = Help_topic::where('id', '=', $defaultHelpTopicID)->value('department');
} }
$sla = $ticket_settings->first()->sla; $sla = $ticket_settings->first()->sla;
// $priority = $ticket_settings->first()->priority; // $priority = $ticket_settings->first()->priority;
$default_priority = Ticket_Priority::where('is_default','=',1)->first(); $default_priority = Ticket_Priority::where('is_default', '=', 1)->first();
$user_priority = CommonSettings::where('option_name','=','user_priority')->first(); $user_priority = CommonSettings::where('option_name', '=', 'user_priority')->first();
if (!($request->input('priority'))) { if (!($request->input('priority'))) {
$priority = $default_priority->priority_id; $priority = $default_priority->priority_id;
} else { } else {
@@ -193,8 +196,8 @@ class FormController extends Controller {
$geoipcode = $code->where('iso', '=', $location->iso_code)->first(); $geoipcode = $code->where('iso', '=', $location->iso_code)->first();
if ($phonecode == null) { if ($phonecode == null) {
$data = [ $data = [
'fails' => Lang::get('lang.country-code-required-error'), 'fails' => Lang::get('lang.country-code-required-error'),
'phonecode' => $geoipcode->phonecode, 'phonecode' => $geoipcode->phonecode,
'country_code_error' => 1, 'country_code_error' => 1,
]; ];
@@ -203,8 +206,8 @@ class FormController extends Controller {
$code = CountryCode::select('phonecode')->where('phonecode', '=', $phonecode)->get(); $code = CountryCode::select('phonecode')->where('phonecode', '=', $phonecode)->get();
if (!count($code)) { if (!count($code)) {
$data = [ $data = [
'fails' => Lang::get('lang.incorrect-country-code-error'), 'fails' => Lang::get('lang.incorrect-country-code-error'),
'phonecode' => $geoipcode->phonecode, 'phonecode' => $geoipcode->phonecode,
'country_code_error' => 1, 'country_code_error' => 1,
]; ];
@@ -230,7 +233,7 @@ class FormController extends Controller {
} }
} }
// dd($result); // dd($result);
return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is') . ' ' . $result[0] . '. ' . Lang::get('lang.Please-save-this-for-future-reference')); return Redirect::back()->with('success', Lang::get('lang.Ticket-has-been-created-successfully-your-ticket-number-is').' '.$result[0].'. '.Lang::get('lang.Please-save-this-for-future-reference'));
} else { } else {
return Redirect::back()->withInput($request->except('password'))->with('fails', Lang::get('lang.failed-to-create-user-tcket-as-mobile-has-been-taken')); return Redirect::back()->withInput($request->except('password'))->with('fails', Lang::get('lang.failed-to-create-user-tcket-as-mobile-has-been-taken'));
} }
@@ -244,14 +247,14 @@ class FormController extends Controller {
* *
* @return type view * @return type view
*/ */
public function post_ticket_reply($id, Request $request) { public function post_ticket_reply($id, Request $request)
{
try { try {
if ($comment != null) { if ($comment != null) {
$tickets = Tickets::where('id', '=', $id)->first(); $tickets = Tickets::where('id', '=', $id)->first();
$thread = Ticket_Thread::where('ticket_id', '=', $tickets->id)->first(); $thread = Ticket_Thread::where('ticket_id', '=', $tickets->id)->first();
$subject = $thread->title . '[#' . $tickets->ticket_number . ']'; $subject = $thread->title.'[#'.$tickets->ticket_number.']';
$body = $request->input('comment'); $body = $request->input('comment');
$user_cred = User::where('id', '=', $tickets->user_id)->first(); $user_cred = User::where('id', '=', $tickets->user_id)->first();
@@ -285,13 +288,14 @@ class FormController extends Controller {
} }
} }
public function getCustomForm(Request $request) { public function getCustomForm(Request $request)
$html = ""; {
$html = '';
$helptopic_id = $request->input('helptopic'); $helptopic_id = $request->input('helptopic');
$helptopics = new Help_topic(); $helptopics = new Help_topic();
$helptopic = $helptopics->find($helptopic_id); $helptopic = $helptopics->find($helptopic_id);
if (!$helptopic) { if (!$helptopic) {
throw new Exception("We can not find your request"); throw new Exception('We can not find your request');
} }
$custom_form = $helptopic->custom_form; $custom_form = $helptopic->custom_form;
if ($custom_form) { if ($custom_form) {
@@ -300,7 +304,7 @@ class FormController extends Controller {
$form_controller = new \App\Http\Controllers\Admin\helpdesk\FormController($fields, $forms); $form_controller = new \App\Http\Controllers\Admin\helpdesk\FormController($fields, $forms);
$html = $form_controller->renderForm($custom_form); $html = $form_controller->renderForm($custom_form);
} }
return $html; return $html;
} }
} }

View File

@@ -6,30 +6,30 @@ namespace App\Http\Controllers\Client\helpdesk;
use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
// requests // requests
use App\Http\Requests\helpdesk\OtpVerifyRequest;
use App\Http\Requests\helpdesk\ProfilePassword; use App\Http\Requests\helpdesk\ProfilePassword;
use App\Http\Requests\helpdesk\ProfileRequest; use App\Http\Requests\helpdesk\ProfileRequest;
use App\Http\Requests\helpdesk\TicketRequest; use App\Http\Requests\helpdesk\TicketRequest;
use App\Model\helpdesk\Manage\Help_topic;
// models // models
use App\Model\helpdesk\Manage\Help_topic;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Settings\Company; use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\System; use App\Model\helpdesk\Settings\System;
use App\Model\helpdesk\Ticket\Ticket_Thread; use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Utility\CountryCode; use App\Model\helpdesk\Utility\CountryCode;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Http\Requests\helpdesk\OtpVerifyRequest;
use App\Model\helpdesk\Utility\Otp; use App\Model\helpdesk\Utility\Otp;
use App\User; use App\User;
use Auth; use Auth;
// classes // classes
use DateTime;
use DB;
use Exception; use Exception;
use GeoIP; use GeoIP;
use Hash; use Hash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Input; use Input;
use Lang; use Lang;
use DateTime;
use DB;
use Socialite; use Socialite;
/** /**
@@ -37,14 +37,15 @@ use Socialite;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class GuestController extends Controller { class GuestController extends Controller
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* *
* @return type void * @return type void
*/ */
public function __construct(PhpMailController $PhpMailController) { public function __construct(PhpMailController $PhpMailController)
{
$this->middleware('board'); $this->middleware('board');
$this->PhpMailController = $PhpMailController; $this->PhpMailController = $PhpMailController;
// checking authentication // checking authentication
@@ -56,15 +57,17 @@ class GuestController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getProfile(CountryCode $code) { public function getProfile(CountryCode $code)
{
$user = Auth::user(); $user = Auth::user();
$location = GeoIP::getLocation(); $location = GeoIP::getLocation();
$phonecode = $code->where('iso', '=', $location->iso_code)->first(); $phonecode = $code->where('iso', '=', $location->iso_code)->first();
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
$status = $settings->status; $status = $settings->status;
return view('themes.default1.client.helpdesk.profile', compact('user')) return view('themes.default1.client.helpdesk.profile', compact('user'))
->with(['phonecode' => $phonecode->phonecode, ->with(['phonecode' => $phonecode->phonecode,
'verify' => $status]); 'verify' => $status, ]);
} }
/** /**
@@ -75,7 +78,8 @@ class GuestController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function postProfile(ProfileRequest $request) { public function postProfile(ProfileRequest $request)
{
try { try {
// geet authenticated user details // geet authenticated user details
$user = Auth::user(); $user = Auth::user();
@@ -85,14 +89,14 @@ class GuestController extends Controller {
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get(); $code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
if (!count($code)) { if (!count($code)) {
return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput(); return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput();
} }
$user->country_code = $request->country_code; $user->country_code = $request->country_code;
} }
$user->fill($request->except('profile_pic', 'mobile')); $user->fill($request->except('profile_pic', 'mobile'));
$user->gender = $request->input('gender'); $user->gender = $request->input('gender');
$user->save(); $user->save();
if (Input::file('profile_pic')) { if (Input::file('profile_pic')) {
// fetching picture name // fetching picture name
$name = Input::file('profile_pic')->getClientOriginalName(); $name = Input::file('profile_pic')->getClientOriginalName();
// fetching upload destination path // fetching upload destination path
$destinationPath = 'uploads/profilepic'; $destinationPath = 'uploads/profilepic';
@@ -109,11 +113,10 @@ class GuestController extends Controller {
$user->mobile = null; $user->mobile = null;
} }
if ($user->save()) { if ($user->save()) {
return redirect()->back()->with('success', Lang::get('lang.Profile-Updated-sucessfully')); return redirect()->back()->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
} else { } else {
return redirect()->back()->route('profile')->with('fails', Lang::get('lang.Profile-Updated-sucessfully')); return redirect()->back()->route('profile')->with('fails', Lang::get('lang.Profile-Updated-sucessfully'));
} }
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->route('profile')->with('fails', $e->getMessage()); return redirect()->back()->route('profile')->with('fails', $e->getMessage());
} }
@@ -121,8 +124,10 @@ class GuestController extends Controller {
/** /**
*@category fucntion to check if mobile number is unqique or not *@category fucntion to check if mobile number is unqique or not
*
*@param string $mobile *@param string $mobile
*@return boolean true(if mobile exists in users table)/false (if mobile does not exist in user table) *
*@return bool true(if mobile exists in users table)/false (if mobile does not exist in user table)
*/ */
public function checkMobile($mobile) public function checkMobile($mobile)
{ {
@@ -134,6 +139,7 @@ class GuestController extends Controller {
return true; return true;
} }
} }
return false; return false;
} }
@@ -144,7 +150,8 @@ class GuestController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getTicket(Help_topic $topic) { public function getTicket(Help_topic $topic)
{
$topics = $topic->get(); $topics = $topic->get();
return view('themes.default1.client.helpdesk.tickets.form', compact('topics')); return view('themes.default1.client.helpdesk.tickets.form', compact('topics'));
@@ -157,7 +164,8 @@ class GuestController extends Controller {
* *
* @return type * @return type
*/ */
public function getForm(Help_topic $topic) { public function getForm(Help_topic $topic)
{
if (\Config::get('database.install') == '%0%') { if (\Config::get('database.install') == '%0%') {
return \Redirect::route('licence'); return \Redirect::route('licence');
} }
@@ -179,7 +187,8 @@ class GuestController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function getMyticket() { public function getMyticket()
{
return view('themes.default1.client.helpdesk.mytickets'); return view('themes.default1.client.helpdesk.mytickets');
} }
@@ -192,7 +201,8 @@ class GuestController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function thread(Ticket_Thread $thread, Tickets $tickets, User $user) { public function thread(Ticket_Thread $thread, Tickets $tickets, User $user)
{
$user_id = Auth::user()->id; $user_id = Auth::user()->id;
//dd($user_id); //dd($user_id);
/* get the ticket's id == ticket_id of thread */ /* get the ticket's id == ticket_id of thread */
@@ -209,8 +219,8 @@ class GuestController extends Controller {
* *
* @return * @return
*/ */
public function ticketEdit() { public function ticketEdit()
{
} }
/** /**
@@ -221,7 +231,8 @@ class GuestController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function postProfilePassword(ProfilePassword $request) { public function postProfilePassword(ProfilePassword $request)
{
$user = Auth::user(); $user = Auth::user();
//echo $user->password; //echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
@@ -246,7 +257,8 @@ class GuestController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function reply(Ticket_Thread $thread, TicketRequest $request) { public function reply(Ticket_Thread $thread, TicketRequest $request)
{
$thread->ticket_id = $request->input('ticket_ID'); $thread->ticket_id = $request->input('ticket_ID');
$thread->title = $request->input('To'); $thread->title = $request->input('To');
$thread->user_id = Auth::user()->id; $thread->user_id = Auth::user()->id;
@@ -257,7 +269,7 @@ class GuestController extends Controller {
$tickets = Tickets::where('id', '=', $ticket_id)->first(); $tickets = Tickets::where('id', '=', $ticket_id)->first();
$thread = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first(); $thread = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first();
return Redirect('thread/' . $ticket_id); return Redirect('thread/'.$ticket_id);
} }
/** /**
@@ -268,7 +280,8 @@ class GuestController extends Controller {
* *
* @return type response * @return type response
*/ */
public function getCheckTicket(Tickets $ticket, User $user) { public function getCheckTicket(Tickets $ticket, User $user)
{
return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket')); return view('themes.default1.client.helpdesk.guest-user.newticket', compact('ticket'));
} }
@@ -282,9 +295,10 @@ class GuestController extends Controller {
* *
* @return type Response * @return type Response
*/ */
public function PostCheckTicket(Request $request) { public function PostCheckTicket(Request $request)
{
$validator = \Validator::make($request->all(), [ $validator = \Validator::make($request->all(), [
'email' => 'required|email', 'email' => 'required|email',
'ticket_number' => 'required', 'ticket_number' => 'required',
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
@@ -304,7 +318,7 @@ class GuestController extends Controller {
if ($user->role == 'user') { if ($user->role == 'user') {
$username = $user->first_name; $username = $user->first_name;
} else { } else {
$username = $user->first_name . ' ' . $user->last_name; $username = $user->first_name.' '.$user->last_name;
} }
if ($user->email != $Email) { if ($user->email != $Email) {
return \Redirect::route('form')->with('fails', Lang::get("lang.email_didn't_match_with_ticket_number")); return \Redirect::route('form')->with('fails', Lang::get("lang.email_didn't_match_with_ticket_number"));
@@ -315,7 +329,7 @@ class GuestController extends Controller {
$company = $this->company(); $company = $this->company();
$this->PhpMailController->sendmail( $this->PhpMailController->sendmail(
$from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $user->email], $message = ['subject' => 'Ticket link Request [' . $Ticket_number . ']', 'scenario' => 'check-ticket'], $template_variables = ['user' => $username, 'ticket_link_with_number' => \URL::route('check_ticket', $code)] $from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $username, 'email' => $user->email], $message = ['subject' => 'Ticket link Request ['.$Ticket_number.']', 'scenario' => 'check-ticket'], $template_variables = ['user' => $username, 'ticket_link_with_number' => \URL::route('check_ticket', $code)]
); );
return \Redirect::back() return \Redirect::back()
@@ -331,10 +345,12 @@ class GuestController extends Controller {
* *
* @return type * @return type
*/ */
public function get_ticket_email($id, CommonSettings $common_settings) { public function get_ticket_email($id, CommonSettings $common_settings)
{
$common_setting = $common_settings->select('status') $common_setting = $common_settings->select('status')
->where('option_name', '=', 'user_set_ticket_status') ->where('option_name', '=', 'user_set_ticket_status')
->first(); ->first();
return view('themes.default1.client.helpdesk.ckeckticket', compact('id', 'common_setting')); return view('themes.default1.client.helpdesk.ckeckticket', compact('id', 'common_setting'));
} }
@@ -345,7 +361,8 @@ class GuestController extends Controller {
* *
* @return type * @return type
*/ */
public function getTicketStat(Tickets $ticket) { public function getTicketStat(Tickets $ticket)
{
return view('themes.default1.client.helpdesk.ckeckticket', compact('ticket')); return view('themes.default1.client.helpdesk.ckeckticket', compact('ticket'));
} }
@@ -354,7 +371,8 @@ class GuestController extends Controller {
* *
* @return type * @return type
*/ */
public function company() { public function company()
{
$company = Company::Where('id', '=', '1')->first(); $company = Company::Where('id', '=', '1')->first();
if ($company->company_name == null) { if ($company->company_name == null) {
$company = 'Support Center'; $company = 'Support Center';
@@ -371,10 +389,11 @@ class GuestController extends Controller {
$sms = DB::table('sms')->get(); $sms = DB::table('sms')->get();
if (count($sms) > 0) { if (count($sms) > 0) {
\Event::fire(new \App\Events\LoginEvent($request)); \Event::fire(new \App\Events\LoginEvent($request));
return 1; return 1;
} }
} else { } else {
return "Plugin has not been setup successfully."; return 'Plugin has not been setup successfully.';
} }
} }
@@ -386,18 +405,19 @@ class GuestController extends Controller {
->first(); ->first();
if ($otp != null) { if ($otp != null) {
$otp_length = strlen(Input::get('otp')); $otp_length = strlen(Input::get('otp'));
if(($otp_length == 6 && !preg_match("/[a-z]/i", Input::get('otp'))) ) { if (($otp_length == 6 && !preg_match('/[a-z]/i', Input::get('otp')))) {
$otp2 = Hash::make(Input::get('otp')); $otp2 = Hash::make(Input::get('otp'));
$date1 = date_format($otp->updated_at, "Y-m-d h:i:sa"); $date1 = date_format($otp->updated_at, 'Y-m-d h:i:sa');
$date2 = date("Y-m-d h:i:sa"); $date2 = date('Y-m-d h:i:sa');
$time1 = new DateTime($date2); $time1 = new DateTime($date2);
$time2 = new DateTime($date1); $time2 = new DateTime($date1);
$interval = $time1->diff($time2); $interval = $time1->diff($time2);
if($interval->i >10 || $interval->h >0){ if ($interval->i > 10 || $interval->h > 0) {
$message = Lang::get('lang.otp-expired'); $message = Lang::get('lang.otp-expired');
return $message; return $message;
} else { } else {
if (Hash::check(Input::get('otp'), $otp->otp)){ if (Hash::check(Input::get('otp'), $otp->otp)) {
Otp::where('user_id', '=', Input::get('u_id')) Otp::where('user_id', '=', Input::get('u_id'))
->update(['otp' => '']); ->update(['otp' => '']);
// User::where('id', '=', $user->id) // User::where('id', '=', $user->id)
@@ -406,20 +426,24 @@ class GuestController extends Controller {
return 1; return 1;
} else { } else {
$message = Lang::get('lang.otp-not-matched'); $message = Lang::get('lang.otp-not-matched');
return $message; return $message;
} }
} }
} else { } else {
$message = Lang::get('lang.otp-invalid'); $message = Lang::get('lang.otp-invalid');
return $message; return $message;
} }
} else { } else {
$message = Lang::get('lang.otp-not-matched'); $message = Lang::get('lang.otp-not-matched');
return $message; return $message;
} }
} }
public function sync() { public function sync()
{
try { try {
$provider = $this->getProvider(); $provider = $this->getProvider();
$this->changeRedirect(); $this->changeRedirect();
@@ -431,56 +455,67 @@ class GuestController extends Controller {
$user['email'] = $users->email; $user['email'] = $users->email;
$user['username'] = $users->nickname; $user['username'] = $users->nickname;
$user['avatar'] = $users->avatar; $user['avatar'] = $users->avatar;
return redirect('client-profile')->with('success', 'Additional informations fetched'); return redirect('client-profile')->with('success', 'Additional informations fetched');
} catch (Exception $ex) { } catch (Exception $ex) {
dd($ex); dd($ex);
return redirect('client-profile')->with('fails', $ex->getMessage()); return redirect('client-profile')->with('fails', $ex->getMessage());
} }
} }
public function getProvider() { public function getProvider()
{
$provider = \Session::get('provider'); $provider = \Session::get('provider');
return $provider; return $provider;
} }
public function changeRedirect() { public function changeRedirect()
{
$provider = \Session::get('provider'); $provider = \Session::get('provider');
$url = \Session::get($provider . 'redirect'); $url = \Session::get($provider.'redirect');
\Config::set("services.$provider.redirect", $url); \Config::set("services.$provider.redirect", $url);
} }
public function forgetSession() { public function forgetSession()
{
$provider = $this->getProvider(); $provider = $this->getProvider();
\Session::forget('provider'); \Session::forget('provider');
\Session::forget($provider . 'redirect'); \Session::forget($provider.'redirect');
} }
public function checkArray($key, $array) { public function checkArray($key, $array)
$value = ""; {
$value = '';
if (array_key_exists($key, $array)) { if (array_key_exists($key, $array)) {
$value = $array[$key]; $value = $array[$key];
} }
return $value; return $value;
} }
public function updateUser($user = []) { public function updateUser($user = [])
{
$userid = \Auth::user()->id; $userid = \Auth::user()->id;
$useremail = \Auth::user()->email; $useremail = \Auth::user()->email;
$email = $this->checkArray('email', $user); //$user['email']; $email = $this->checkArray('email', $user); //$user['email'];
if ($email !== "" && $email !== $useremail) { if ($email !== '' && $email !== $useremail) {
throw new Exception("Sorry! your current email and " . ucfirst($user['provider']) . " email is different so system can not sync"); throw new Exception('Sorry! your current email and '.ucfirst($user['provider']).' email is different so system can not sync');
} }
$this->update($userid, $user); $this->update($userid, $user);
} }
public function update($userid, $user, $provider) { public function update($userid, $user, $provider)
{
$email = $this->checkArray('email', $user); $email = $this->checkArray('email', $user);
$this->deleteUser($userid, $user, $provider); $this->deleteUser($userid, $user, $provider);
$this->insertAdditional($userid, $provider, $user); $this->insertAdditional($userid, $provider, $user);
$this->changeEmail($email); $this->changeEmail($email);
} }
public function deleteUser($userid, $user, $provider) { public function deleteUser($userid, $user, $provider)
{
$info = new \App\UserAdditionalInfo(); $info = new \App\UserAdditionalInfo();
$infos = $info->where('owner', $userid)->where('service', $provider)->get(); $infos = $info->where('owner', $userid)->where('service', $provider)->get();
if ($infos->count() > 0 && count($user) > 0) { if ($infos->count() > 0 && count($user) > 0) {
@@ -492,27 +527,27 @@ class GuestController extends Controller {
} }
} }
public function insertAdditional($id, $provider, $user = []) { public function insertAdditional($id, $provider, $user = [])
{
$info = new \App\UserAdditionalInfo(); $info = new \App\UserAdditionalInfo();
if (count($user) > 0) { if (count($user) > 0) {
foreach ($user as $key => $value) { foreach ($user as $key => $value) {
$info->create([ $info->create([
'owner' => $id, 'owner' => $id,
'service' => $provider, 'service' => $provider,
'key' => $key, 'key' => $key,
'value' => $value, 'value' => $value,
]); ]);
} }
} }
} }
public function changeEmail($email) { public function changeEmail($email)
{
$user = \Auth::user(); $user = \Auth::user();
if ($user && $email && !$user->email) { if ($user && $email && !$user->email) {
$user->email = $email; $user->email = $email;
$user->save(); $user->save();
} }
} }
} }

View File

@@ -9,9 +9,9 @@ use App\Http\Controllers\Controller;
use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Emails;
// models // models
use App\Model\helpdesk\Settings\CommonSettings; use App\Model\helpdesk\Settings\CommonSettings;
use App\Model\helpdesk\Settings\Followup;
use App\Model\helpdesk\Ticket\Ticket_Status; use App\Model\helpdesk\Ticket\Ticket_Status;
use App\Model\helpdesk\Ticket\Ticket_Thread; use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Settings\Followup;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Ticket\TicketToken; use App\Model\helpdesk\Ticket\TicketToken;
use App\User; use App\User;
@@ -320,9 +320,10 @@ class UnAuthController extends Controller
/** /**
*@category function to change system's language *@category function to change system's language
*@param string $lang //desired language's iso code
*@return response
* *
*@param string $lang //desired language's iso code
*
*@return response
*/ */
public static function changeLanguage($lang) public static function changeLanguage($lang)
{ {
@@ -341,54 +342,55 @@ class UnAuthController extends Controller
// dd() // dd()
} else { } else {
return false; return false;
} }
return true; return true;
} }
// Follow up tickets // Follow up tickets
public function followup() public function followup()
{ {
$followup=Followup::whereId('1')->first(); $followup = Followup::whereId('1')->first();
$condition=$followup->condition; $condition = $followup->condition;
// dd($condition); // dd($condition);
switch ($condition) { switch ($condition) {
case "everyMinute": case 'everyMinute':
$followup_set= ' + 1 minute'; $followup_set = ' + 1 minute';
break; break;
case "everyFiveMinutes": case 'everyFiveMinutes':
$followup_set= ' + 5 minute'; $followup_set = ' + 5 minute';
break; break;
case "everyTenMinutes": case 'everyTenMinutes':
$followup_set= ' + 10 minute'; $followup_set = ' + 10 minute';
break; break;
case "everyThirtyMinutes": case 'everyThirtyMinutes':
$followup_set=' + 30 minute'; $followup_set = ' + 30 minute';
break; break;
case "hourly": case 'hourly':
$followup_set=' + 1 hours'; $followup_set = ' + 1 hours';
break; break;
case "daily": case 'daily':
$followup_set=' + 1 day'; $followup_set = ' + 1 day';
break; break;
case "weekly": case 'weekly':
$followup_set=' + 7 day'; $followup_set = ' + 7 day';
break; break;
case "monthly": case 'monthly':
$followup_set=' + 30 day'; $followup_set = ' + 30 day';
break; break;
case "yearly": case 'yearly':
$followup_set=' + 365 day'; $followup_set = ' + 365 day';
break; break;
} }
if($followup->status=1){ if ($followup->status = 1) {
$tickets=Tickets::where('id', '>=', 1)->where('status', '!=', 5)->get(); $tickets = Tickets::where('id', '>=', 1)->where('status', '!=', 5)->get();
// dd( $tickets); // dd( $tickets);
// $tickets=Tickets::where('id', '>=', 1)->where('status', '!=', 5)->pluck('id'); // $tickets=Tickets::where('id', '>=', 1)->where('status', '!=', 5)->pluck('id');
// dd( $tickets); // dd( $tickets);
// $id=1; // $id=1;
foreach($tickets as $ticket) { foreach ($tickets as $ticket) {
// $id=1; // $id=1;
// $id++; // $id++;
// $ticket=Tickets::where('status', '!=', 5)->get(); // $ticket=Tickets::where('status', '!=', 5)->get();
@@ -396,27 +398,20 @@ class UnAuthController extends Controller
// dd($ticket); // dd($ticket);
// if($ticket != null){ // if($ticket != null){
// dd('here'); // dd('here');
$ck=date('Y-m-d H:i:s', strtotime($ticket->updated_at . $followup_set)); $ck = date('Y-m-d H:i:s', strtotime($ticket->updated_at.$followup_set));
// dd($ck); // dd($ck);
$current_time=date('Y-m-d H:i:s'); $current_time = date('Y-m-d H:i:s');
if($current_time>$ck){ if ($current_time > $ck) {
$ticket->follow_up = 1;
$ticket->follow_up=1;
$ticket->save(); $ticket->save();
// Tickets::where('id', '=',$id) // Tickets::where('id', '=',$id)
// ->update(['follow_up' => 1]); // ->update(['follow_up' => 1]);
// } // }
}
}
// if($id=2) // if($id=2)
// {dd($ticket);} // {dd($ticket);}
}
} }
}
} }
} }

View File

@@ -24,9 +24,10 @@ use Lang;
use Mail; use Mail;
use Redirect; use Redirect;
class UserController extends Controller { class UserController extends Controller
{
public function __construct() { public function __construct()
{
$this->middleware('board'); $this->middleware('board');
} }
@@ -35,18 +36,20 @@ class UserController extends Controller {
* *
* @return response * @return response
*/ */
public function getArticle(Article $article, Category $category, Settings $settings) { public function getArticle(Article $article, Category $category, Settings $settings)
{
$setting = $settings->first(); $setting = $settings->first();
$pagination = $setting->pagination; $pagination = $setting->pagination;
if (!Auth::check() || \Auth::user()->role == 'user') { if (!Auth::check() || \Auth::user()->role == 'user') {
$article = $article->where('status', '1'); $article = $article->where('status', '1');
} }
$article = $article->where('type', '1'); $article = $article->where('type', '1');
$article = $article->orderBy('publish_time','desc'); $article = $article->orderBy('publish_time', 'desc');
$article = $article->paginate($pagination); $article = $article->paginate($pagination);
$article->setPath('article-list'); $article->setPath('article-list');
$categorys = $category->get(); $categorys = $category->get();
return view('themes.default1.client.kb.article-list.articles', compact('time', 'categorys', 'article')); return view('themes.default1.client.kb.article-list.articles', compact('time', 'categorys', 'article'));
} }
@@ -59,7 +62,8 @@ class UserController extends Controller {
* *
* @return string excerpt * @return string excerpt
*/ */
public static function getExcerpt($str, $startPos = 0, $maxLength = 50) { public static function getExcerpt($str, $startPos = 0, $maxLength = 50)
{
if (strlen($str) > $maxLength) { if (strlen($str) > $maxLength) {
$excerpt = substr($str, $startPos, $maxLength - 3); $excerpt = substr($str, $startPos, $maxLength - 3);
$lastSpace = strrpos($excerpt, ' '); $lastSpace = strrpos($excerpt, ' ');
@@ -82,13 +86,14 @@ class UserController extends Controller {
* *
* @return type view * @return type view
*/ */
public function search(SearchRequest $request, Category $category, Article $article, Settings $settings) { public function search(SearchRequest $request, Category $category, Article $article, Settings $settings)
{
$settings = $settings->first(); $settings = $settings->first();
$pagination = $settings->pagination; $pagination = $settings->pagination;
$search = $request->input('s'); $search = $request->input('s');
$result = $article->where('name', 'LIKE', '%' . $search . '%') $result = $article->where('name', 'LIKE', '%'.$search.'%')
->orWhere('slug', 'LIKE', '%' . $search . '%') ->orWhere('slug', 'LIKE', '%'.$search.'%')
->orWhere('description', 'LIKE', '%' . $search . '%') ->orWhere('description', 'LIKE', '%'.$search.'%')
->paginate($pagination); ->paginate($pagination);
$result->setPath('search?s='.$search); $result->setPath('search?s='.$search);
$categorys = $category->get(); $categorys = $category->get();
@@ -101,15 +106,16 @@ class UserController extends Controller {
* *
* @return response * @return response
*/ */
public function show($slug, Article $article, Category $category) { public function show($slug, Article $article, Category $category)
{
//ArticleController::timezone(); //ArticleController::timezone();
$tz = \App\Model\helpdesk\Settings\System::where('id', '1')->first()->time_zone; $tz = \App\Model\helpdesk\Settings\System::where('id', '1')->first()->time_zone;
$tz = \App\Model\helpdesk\Utility\Timezones::where('id', $tz)->first()->name; $tz = \App\Model\helpdesk\Utility\Timezones::where('id', $tz)->first()->name;
date_default_timezone_set($tz); date_default_timezone_set($tz);
$date = \Carbon\Carbon::now()->toDateTimeString(); $date = \Carbon\Carbon::now()->toDateTimeString();
$arti = $article->where('slug', $slug); $arti = $article->where('slug', $slug);
if (!Auth::check()|| \Auth::user()->role == 'user') { if (!Auth::check() || \Auth::user()->role == 'user') {
$arti = $arti->where('status', '1'); $arti = $arti->where('status', '1');
$arti = $arti->where('publish_time', '<', $date); $arti = $arti->where('publish_time', '<', $date);
} }
@@ -125,7 +131,8 @@ class UserController extends Controller {
} }
} }
public function getCategory($slug, Article $article, Category $category, Relationship $relation) { public function getCategory($slug, Article $article, Category $category, Relationship $relation)
{
/* get the article_id where category_id == current category */ /* get the article_id where category_id == current category */
$catid = $category->where('slug', $slug)->first(); $catid = $category->where('slug', $slug)->first();
if (!$catid) { if (!$catid) {
@@ -141,7 +148,8 @@ class UserController extends Controller {
return view('themes.default1.client.kb.article-list.category', compact('all', 'id', 'categorys', 'article_id')); return view('themes.default1.client.kb.article-list.category', compact('all', 'id', 'categorys', 'article_id'));
} }
public function home(Article $article, Category $category, Relationship $relation) { public function home(Article $article, Category $category, Relationship $relation)
{
if (Config::get('database.install') == '%0%') { if (Config::get('database.install') == '%0%') {
return redirect('step1'); return redirect('step1');
} else { } else {
@@ -153,7 +161,8 @@ class UserController extends Controller {
} }
} }
public function Faq(Faq $faq, Category $category) { public function Faq(Faq $faq, Category $category)
{
$faq = $faq->where('id', '1')->first(); $faq = $faq->where('id', '1')->first();
$categorys = $category->get(); $categorys = $category->get();
@@ -165,7 +174,8 @@ class UserController extends Controller {
* *
* @return response * @return response
*/ */
public function contact(Category $category, Settings $settings) { public function contact(Category $category, Settings $settings)
{
$settings = $settings->whereId('1')->first(); $settings = $settings->whereId('1')->first();
$categorys = $category->get(); $categorys = $category->get();
@@ -177,7 +187,8 @@ class UserController extends Controller {
* *
* @return response * @return response
*/ */
public function postContact(ContactRequest $request, Contact $contact) { public function postContact(ContactRequest $request, Contact $contact)
{
$this->port(); $this->port();
$this->host(); $this->host();
$this->encryption(); $this->encryption();
@@ -195,8 +206,8 @@ class UserController extends Controller {
//echo $message; //echo $message;
//echo $contact->email; //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) { $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) { if ($mail) {
return redirect('contact')->with('success', Lang::get('lang.your_details_send_to_system')); return redirect('contact')->with('success', Lang::get('lang.your_details_send_to_system'));
} else { } else {
@@ -204,7 +215,8 @@ class UserController extends Controller {
} }
} }
public function contactDetails() { public function contactDetails()
{
return view('themes.default1.client.kb.article-list.contact-details'); return view('themes.default1.client.kb.article-list.contact-details');
} }
@@ -218,10 +230,11 @@ class UserController extends Controller {
* *
* @return type response * @return type response
*/ */
public function postComment($slug, Article $article, CommentRequest $request, Comment $comment) { public function postComment($slug, Article $article, CommentRequest $request, Comment $comment)
{
$article = $article->where('slug', $slug)->first(); $article = $article->where('slug', $slug)->first();
if(!$article){ if (!$article) {
return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed')); return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed'));
} }
$id = $article->id; $id = $article->id;
$comment->article_id = $id; $comment->article_id = $id;
@@ -232,42 +245,49 @@ class UserController extends Controller {
} }
} }
public function getPage($name, Page $page) { public function getPage($name, Page $page)
{
$page = $page->where('slug', $name)->first(); $page = $page->where('slug', $name)->first();
if($page){ if ($page) {
return view('themes.default1.client.kb.article-list.pages', compact('page')); return view('themes.default1.client.kb.article-list.pages', compact('page'));
}else{ } else {
return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed')); return Redirect::back()->with('fails', Lang::get('lang.sorry_not_processed'));
} }
} }
public static function port() { public static function port()
{
$setting = Settings::whereId('1')->first(); $setting = Settings::whereId('1')->first();
Config::set('mail.port', $setting->port); Config::set('mail.port', $setting->port);
} }
public static function host() { public static function host()
{
$setting = Settings::whereId('1')->first(); $setting = Settings::whereId('1')->first();
Config::set('mail.host', $setting->host); Config::set('mail.host', $setting->host);
} }
public static function encryption() { public static function encryption()
{
$setting = Settings::whereId('1')->first(); $setting = Settings::whereId('1')->first();
Config::set(['mail.encryption' => $setting->encryption, 'mail.username' => $setting->email]); Config::set(['mail.encryption' => $setting->encryption, 'mail.username' => $setting->email]);
} }
public static function email() { public static function email()
{
$setting = Settings::whereId('1')->first(); $setting = Settings::whereId('1')->first();
Config::set(['mail.from' => ['address' => $setting->email, 'name' => 'asd']]); Config::set(['mail.from' => ['address' => $setting->email, 'name' => 'asd']]);
//dd(Config::get('mail')); //dd(Config::get('mail'));
} }
public static function password() { public static function password()
{
$setting = Settings::whereId('1')->first(); $setting = Settings::whereId('1')->first();
Config::set(['mail.password' => $setting->password, 'mail.sendmail' => $setting->email]); Config::set(['mail.password' => $setting->password, 'mail.sendmail' => $setting->email]);
} }
public function getCategoryList(Article $article, Category $category, Relationship $relation) { public function getCategoryList(Article $article, Category $category, Relationship $relation)
{
//$categorys = $category->get(); //$categorys = $category->get();
$categorys = $category->get(); $categorys = $category->get();
// $categorys->setPath('home'); // $categorys->setPath('home');
@@ -289,13 +309,15 @@ class UserController extends Controller {
// //return substr($date, 0, -6); // //return substr($date, 0, -6);
// } // }
public function clientProfile() { public function clientProfile()
{
$user = Auth::user(); $user = Auth::user();
return view('themes.default1.client.kb.article-list.profile', compact('user')); return view('themes.default1.client.kb.article-list.profile', compact('user'));
} }
public function postClientProfile($id, ProfileRequest $request) { public function postClientProfile($id, ProfileRequest $request)
{
$user = Auth::user(); $user = Auth::user();
$user->gender = $request->input('gender'); $user->gender = $request->input('gender');
$user->save(); $user->save();
@@ -314,7 +336,7 @@ class UserController extends Controller {
//$extension = Input::file('profile_pic')->getClientOriginalExtension(); //$extension = Input::file('profile_pic')->getClientOriginalExtension();
$name = Input::file('profile_pic')->getClientOriginalName(); $name = Input::file('profile_pic')->getClientOriginalName();
$destinationPath = 'lb-faveo/dist/img'; $destinationPath = 'lb-faveo/dist/img';
$fileName = rand(0000, 9999) . '.' . $name; $fileName = rand(0000, 9999).'.'.$name;
//echo $fileName; //echo $fileName;
Input::file('profile_pic')->move($destinationPath, $fileName); Input::file('profile_pic')->move($destinationPath, $fileName);
$user->profile_pic = $fileName; $user->profile_pic = $fileName;
@@ -328,7 +350,8 @@ class UserController extends Controller {
} }
} }
public function postClientProfilePassword($id, ProfilePassword $request) { public function postClientProfilePassword($id, ProfilePassword $request)
{
$user = Auth::user(); $user = Auth::user();
//echo $user->password; //echo $user->password;
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
@@ -340,5 +363,4 @@ class UserController extends Controller {
return redirect()->back()->with('fails', Lang::get('lang.password_was_not_updated')); return redirect()->back()->with('fails', Lang::get('lang.password_was_not_updated'));
} }
} }
} }

View File

@@ -2,23 +2,21 @@
namespace App\Http\Controllers\Common; namespace App\Http\Controllers\Common;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Excel; use Excel;
use Exception; use Exception;
class ExcelController extends Controller { class ExcelController extends Controller
{
public function export($filename, $data) { public function export($filename, $data)
if(count($data)==0){ {
if (count($data) == 0) {
throw new Exception('No data'); throw new Exception('No data');
} }
Excel::create($filename, function($excel) use($data){ Excel::create($filename, function ($excel) use ($data) {
$excel->sheet('sheet', function($sheet) use($data) { $excel->sheet('sheet', function ($sheet) use ($data) {
$sheet->fromArray($data); $sheet->fromArray($data);
}); });
})->export('xls'); })->export('xls');
} }
} }

View File

@@ -4,9 +4,10 @@ namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
class FileuploadController extends Controller { class FileuploadController extends Controller
{
public function __construct() { public function __construct()
{
// checking authentication // checking authentication
$this->middleware('auth'); $this->middleware('auth');
// checking if role is agent // checking if role is agent
@@ -15,7 +16,8 @@ class FileuploadController extends Controller {
// Returns a file size limit in bytes based on the PHP upload_max_filesize // Returns a file size limit in bytes based on the PHP upload_max_filesize
// and post_max_size // and post_max_size
function file_upload_max_size() { public function file_upload_max_size()
{
static $max_size = -1; static $max_size = -1;
if ($max_size < 0) { if ($max_size < 0) {
@@ -31,11 +33,13 @@ class FileuploadController extends Controller {
$max_size_in_actual = ini_get('upload_max_filesize'); $max_size_in_actual = ini_get('upload_max_filesize');
} }
} }
return ['0' => $max_size_in_bytes, '1' => $max_size_in_actual]; return ['0' => $max_size_in_bytes, '1' => $max_size_in_actual];
// return $max_size_in_bytes; // return $max_size_in_bytes;
} }
function parse_size($size) { public function parse_size($size)
{
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size. $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size. $size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
if ($unit) { if ($unit) {
@@ -45,5 +49,4 @@ class FileuploadController extends Controller {
return round($size); return round($size);
} }
} }
} }

View File

@@ -4,33 +4,32 @@ namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Model\helpdesk\Notification\Notification; use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Notification\NotificationType;
use App\Model\helpdesk\Notification\UserNotification; use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\User; use App\User;
use App\Model\helpdesk\Notification\NotificationType;
class NotificationController extends Controller {
class NotificationController extends Controller
{
/** /**
* ******************************************** * ********************************************
* Class Notification Controller * Class Notification Controller
* ******************************************** * ********************************************
* This controller is used to generate in app notification * This controller is used to generate in app notification
* under the folling occurrence * under the folling occurrence
* 1. Ticket Creation * 1. Ticket Creation
* 2. Ticket Reply * 2. Ticket Reply
* 3. User Creation * 3. User Creation.
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
public $user; public $user;
/** /**
* Constructor * Constructor.
*/ */
public function __construct() { public function __construct()
{
$user = new User(); $user = new User();
$this->user = $user; $this->user = $user;
// checking authentication // checking authentication
@@ -41,6 +40,7 @@ class NotificationController extends Controller {
/** /**
* This function is used to create in app notifications. * This function is used to create in app notifications.
*
* @param type $model_id * @param type $model_id
* @param type $userid_created * @param type $userid_created
* @param type $type_id * @param type $type_id
@@ -68,49 +68,62 @@ class NotificationController extends Controller {
} }
/** /**
* This function is to mark all ticket to read status * This function is to mark all ticket to read status.
*
* @param type $id * @param type $id
*
* @return int * @return int
*/ */
public function markAllRead($id) { public function markAllRead($id)
{
$markasread = UserNotification::where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get(); $markasread = UserNotification::where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get();
foreach ($markasread as $mark) { foreach ($markasread as $mark) {
$mark->is_read = '1'; $mark->is_read = '1';
$mark->save(); $mark->save();
} }
return 1; return 1;
} }
/** /**
* This function to mark read * This function to mark read.
*
* @param type $id * @param type $id
*
* @return int * @return int
*/ */
public function markRead($id) { public function markRead($id)
{
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get(); $markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get();
foreach ($markasread as $mark) { foreach ($markasread as $mark) {
$mark->is_read = '1'; $mark->is_read = '1';
$mark->save(); $mark->save();
} }
return 1; return 1;
} }
/** /**
* function to show all the notifications * function to show all the notifications.
*
* @return type * @return type
*/ */
public function show() { public function show()
{
$notifications = $this->getNotifications(); $notifications = $this->getNotifications();
//dd($notifications); //dd($notifications);
return view('notifications-all', compact('notifications')); return view('notifications-all', compact('notifications'));
} }
/** /**
* function to delete notifications * function to delete notifications.
*
* @param type $id * @param type $id
*
* @return int * @return int
*/ */
public function delete($id) { public function delete($id)
{
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->get(); $markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->get();
foreach ($markasread as $mark) { foreach ($markasread as $mark) {
$mark->delete(); $mark->delete();
@@ -119,36 +132,40 @@ class NotificationController extends Controller {
return 1; return 1;
} }
public function deleteAll() { public function deleteAll()
try{ {
$notifications = new Notification(); try {
if ($notifications->count()>0) { $notifications = new Notification();
foreach ($notifications->get() as $notification) { if ($notifications->count() > 0) {
$notification->delete(); foreach ($notifications->get() as $notification) {
$notification->delete();
}
} }
} $notifications->dummyDelete();
$notifications->dummyDelete();
return redirect()->back()->with('success', 'deleted'); return redirect()->back()->with('success', 'deleted');
} catch (\Exception $ex){ } catch (\Exception $ex) {
return redirect()->back()->with('fails',$ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
/** /**
* get the page to list the notifications. * get the page to list the notifications.
*
* @return response * @return response
*/ */
public static function getNotifications() { public static function getNotifications()
{
$notifications = UserNotification::with([ $notifications = UserNotification::with([
'notification.type' => function($query) { 'notification.type' => function ($query) {
$query->select('id', 'message', 'type'); $query->select('id', 'message', 'type');
}, 'users' => function($query) { }, 'users' => function ($query) {
$query->select('id', 'email', 'profile_pic'); $query->select('id', 'email', 'profile_pic');
}, 'notification.model' => function($query) { }, 'notification.model' => function ($query) {
$query->select('id', 'ticket_number'); $query->select('id', 'ticket_number');
}, },
]); ]);
return $notifications; return $notifications;
} }
} }

View File

@@ -10,14 +10,16 @@ use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email; use App\Model\helpdesk\Settings\Email;
use App\User; use App\User;
use Auth; use Auth;
use Mail;
use Exception; use Exception;
use Lang; use Lang;
use Mail;
class PhpMailController extends Controller { class PhpMailController extends Controller
{
public function fetch_smtp_details($id) { public function fetch_smtp_details($id)
{
$emails = Emails::where('id', '=', $id)->first(); $emails = Emails::where('id', '=', $id)->first();
return $emails; return $emails;
} }
@@ -26,7 +28,8 @@ class PhpMailController extends Controller {
* *
* @return type * @return type
*/ */
public function company() { public function company()
{
$company = Company::Where('id', '=', '1')->first(); $company = Company::Where('id', '=', '1')->first();
if ($company->company_name == null) { if ($company->company_name == null) {
$company = 'Support Center'; $company = 'Support Center';
@@ -45,8 +48,9 @@ class PhpMailController extends Controller {
* *
* @return type integer * @return type integer
*/ */
public function mailfrom($reg, $dept_id) { public function mailfrom($reg, $dept_id)
$email_id = ""; {
$email_id = '';
$emails = Emails::where('department', '=', $dept_id)->first(); $emails = Emails::where('department', '=', $dept_id)->first();
$email = Email::find(1); $email = Email::find(1);
@@ -55,17 +59,19 @@ class PhpMailController extends Controller {
} else { } else {
$email_id = $email->sys_email; $email_id = $email->sys_email;
} }
return $email_id; return $email_id;
} }
public function sendmail($from, $to, $message, $template_variables) { public function sendmail($from, $to, $message, $template_variables)
{
$this->setQueue(); $this->setQueue();
$job = new \App\Jobs\SendEmail($from, $to, $message, $template_variables); $job = new \App\Jobs\SendEmail($from, $to, $message, $template_variables);
$this->dispatch($job); $this->dispatch($job);
} }
public function sendEmail($from, $to, $message, $template_variables) { public function sendEmail($from, $to, $message, $template_variables)
{
$from_address = $this->fetch_smtp_details($from); $from_address = $this->fetch_smtp_details($from);
if ($from_address == null) { if ($from_address == null) {
throw new Exception(Lang::get('lang.system-email-not-configured')); throw new Exception(Lang::get('lang.system-email-not-configured'));
@@ -96,11 +102,11 @@ class PhpMailController extends Controller {
$ticket_link_with_number = $this->checkElement('ticket_link_with_number', $template_variables); $ticket_link_with_number = $this->checkElement('ticket_link_with_number', $template_variables);
$system_from = $this->checkElement('system_from', $template_variables); $system_from = $this->checkElement('system_from', $template_variables);
if ($system_from === "") { if ($system_from === '') {
$system_from = $this->company(); $system_from = $this->company();
} }
$system_link = $this->checkElement('system_link', $template_variables); $system_link = $this->checkElement('system_link', $template_variables);
if ($system_link === "") { if ($system_link === '') {
$system_link = \Config::get('app.url'); $system_link = \Config::get('app.url');
} }
$ticket_link = $this->checkElement('ticket_link', $template_variables); $ticket_link = $this->checkElement('ticket_link', $template_variables);
@@ -113,7 +119,6 @@ class PhpMailController extends Controller {
$email_address = $this->checkElement('email_address', $template_variables); $email_address = $this->checkElement('email_address', $template_variables);
$user = $this->checkElement('user', $template_variables); $user = $this->checkElement('user', $template_variables);
$status = \DB::table('settings_email')->first(); $status = \DB::table('settings_email')->first();
$template = TemplateType::where('name', '=', $template_type)->first(); $template = TemplateType::where('name', '=', $template_type)->first();
@@ -127,7 +132,7 @@ class PhpMailController extends Controller {
if ($template_data->subject) { if ($template_data->subject) {
$subject = $template_data->subject; $subject = $template_data->subject;
if ($ticket_number != null) { if ($ticket_number != null) {
$subject = $subject . ' [#' . $ticket_number . ']'; $subject = $subject.' [#'.$ticket_number.']';
} }
} else { } else {
$subject = $message['subject']; $subject = $message['subject'];
@@ -140,7 +145,6 @@ class PhpMailController extends Controller {
$subject = 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!!}', '{!!$ticket_link!!}']; $variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}', '{!!$ticket_link!!}'];
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link, $ticket_link]; $data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link, $ticket_link];
@@ -150,20 +154,20 @@ class PhpMailController extends Controller {
$contents = $messagebody; $contents = $messagebody;
} }
if ($template_type == 'ticket-reply-agent') { if ($template_type == 'ticket-reply-agent') {
$line = '---Reply above this line--- <br/><br/>'; $line = '---Reply above this line--- <br/><br/>';
$content = $line . $messagebody; $content = $line.$messagebody;
} else { } else {
$content = $messagebody; $content = $messagebody;
} }
} }
$send = $this->laravelMail($recipants, $recipantname, $subject, $content, $cc, $attachment); $send = $this->laravelMail($recipants, $recipantname, $subject, $content, $cc, $attachment);
return $send; return $send;
} }
public function setMailConfig($from_address) { public function setMailConfig($from_address)
{
$username = $from_address->email_address; $username = $from_address->email_address;
$fromname = $from_address->email_name; $fromname = $from_address->email_name;
$password = $from_address->password; $password = $from_address->password;
@@ -180,88 +184,94 @@ class PhpMailController extends Controller {
$port = ''; $port = '';
} }
$configs = [ $configs = [
'username' => $username, 'username' => $username,
'from' => ['address' => $username, 'name' => $fromname,], 'from' => ['address' => $username, 'name' => $fromname],
'password' => $password, 'password' => $password,
'encryption' => $smtpsecure, 'encryption' => $smtpsecure,
'host' => $host, 'host' => $host,
'port' => $port, 'port' => $port,
'driver' => $protocol, 'driver' => $protocol,
]; ];
foreach ($configs as $key => $config) { foreach ($configs as $key => $config) {
if (is_array($config)) { if (is_array($config)) {
foreach ($config as $from) { foreach ($config as $from) {
\Config::set('mail.' . $key, $config); \Config::set('mail.'.$key, $config);
} }
} else { } else {
\Config::set('mail.' . $key, $config); \Config::set('mail.'.$key, $config);
} }
} }
} }
public function setServices($emailid, $protocol) { public function setServices($emailid, $protocol)
{
$service = new \App\Model\MailJob\FaveoMail(); $service = new \App\Model\MailJob\FaveoMail();
$services = $service->where('email_id', $emailid)->lists('value', 'key')->toArray(); $services = $service->where('email_id', $emailid)->lists('value', 'key')->toArray();
$controller = new \App\Http\Controllers\Admin\helpdesk\EmailsController(); $controller = new \App\Http\Controllers\Admin\helpdesk\EmailsController();
$controller->setServiceConfig($protocol, $services); $controller->setServiceConfig($protocol, $services);
} }
public function checkElement($element, $array) { public function checkElement($element, $array)
$value = ""; {
$value = '';
if (is_array($array)) { if (is_array($array)) {
if (key_exists($element, $array)) { if (array_key_exists($element, $array)) {
$value = $array[$element]; $value = $array[$element];
} }
} }
return $value; return $value;
} }
public function laravelMail($to, $toname, $subject, $data, $cc, $attach) { public function laravelMail($to, $toname, $subject, $data, $cc, $attach)
{
//dd($to, $toname, $subject, $data, $cc, $attach); //dd($to, $toname, $subject, $data, $cc, $attach);
//dd(\Config::get('mail')); //dd(\Config::get('mail'));
//dd($attach); //dd($attach);
$mail = Mail::send('emails.mail', ['data' => $data], function ($m) use ($to, $subject, $toname, $cc, $attach) { $mail = Mail::send('emails.mail', ['data' => $data], function ($m) use ($to, $subject, $toname, $cc, $attach) {
$m->to($to, $toname)->subject($subject); $m->to($to, $toname)->subject($subject);
if ($cc != null) { if ($cc != null) {
foreach ($cc as $collaborator) { foreach ($cc as $collaborator) {
//mail to collaborators //mail to collaborators
$collab_user_id = $collaborator->user_id; $collab_user_id = $collaborator->user_id;
$user_id_collab = User::where('id', '=', $collab_user_id)->first(); $user_id_collab = User::where('id', '=', $collab_user_id)->first();
$collab_email = $user_id_collab->email; $collab_email = $user_id_collab->email;
$m->cc($collab_email); $m->cc($collab_email);
} }
} }
// $mail->addBCC($bc); // $mail->addBCC($bc);
$size = count($attach); $size = count($attach);
if ($size > 0) { if ($size > 0) {
for ($i = 0; $i < $size; $i++) { for ($i = 0; $i < $size; $i++) {
if (is_array($attach) && array_key_exists($i, $attach)) { if (is_array($attach) && array_key_exists($i, $attach)) {
$mode = 'normal'; $mode = 'normal';
if (is_array($attach[$i]) && array_key_exists('mode', $attach[$i])) { if (is_array($attach[$i]) && array_key_exists('mode', $attach[$i])) {
$mode = $attach[$i]['mode']; $mode = $attach[$i]['mode'];
}
$file = $attach[$i]['file_path'];
$name = $attach[$i]['file_name'];
$mime = $attach[$i]['mime'];
$this->attachmentMode($m, $file, $name, $mime, $mode);
}
} }
$file = $attach[$i]['file_path'];
$name = $attach[$i]['file_name'];
$mime = $attach[$i]['mime'];
$this->attachmentMode($m, $file, $name, $mime, $mode);
} }
}); }
}
});
if (is_object($mail) || (is_object($mail) && $mail->getStatusCode() == 200)) { if (is_object($mail) || (is_object($mail) && $mail->getStatusCode() == 200)) {
$mail = 1; $mail = 1;
} }
return $mail; return $mail;
} }
public function setQueue() { public function setQueue()
{
$short = 'database'; $short = 'database';
$field = [ $field = [
'driver' => 'database', 'driver' => 'database',
'table' => 'jobs', 'table' => 'jobs',
'queue' => 'default', 'queue' => 'default',
'expire' => 60, 'expire' => 60,
]; ];
$queue = new \App\Model\MailJob\QueueService(); $queue = new \App\Model\MailJob\QueueService();
@@ -274,18 +284,20 @@ class PhpMailController extends Controller {
$this->setQueueConfig($short, $field); $this->setQueueConfig($short, $field);
} }
public function setQueueConfig($short, $field) { public function setQueueConfig($short, $field)
{
\Config::set('queue.default', $short); \Config::set('queue.default', $short);
foreach ($field as $key => $value) { foreach ($field as $key => $value) {
\Config::set("queue.connections.$short.$key", $value); \Config::set("queue.connections.$short.$key", $value);
} }
} }
public function attachmentMode($message, $file, $name, $mime, $mode) { public function attachmentMode($message, $file, $name, $mime, $mode)
{
if ($mode == 'data') { if ($mode == 'data') {
return $message->attachData(base64_decode($file, true), $name, ['mime' => $mime]); return $message->attachData(base64_decode($file, true), $name, ['mime' => $mime]);
} }
return $message->attach($file, ['as' => $name, 'mime' => $mime]); return $message->attach($file, ['as' => $name, 'mime' => $mime]);
} }
} }

View File

@@ -11,7 +11,6 @@ use App\Model\helpdesk\Email\Smtp;
// models // models
use App\Model\helpdesk\Settings\Plugin; use App\Model\helpdesk\Settings\Plugin;
use App\Model\helpdesk\Theme\Widgets; use App\Model\helpdesk\Theme\Widgets;
use App\Model\helpdesk\Utility\Version_Check;
use Config; use Config;
// classes // classes
use Crypt; use Crypt;
@@ -27,14 +26,15 @@ use Lang;
* *************************** * ***************************
* Controller to keep smtp details and fetch where ever needed. * Controller to keep smtp details and fetch where ever needed.
*/ */
class SettingsController extends Controller { class SettingsController extends Controller
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* *
* @return type void * @return type void
*/ */
public function __construct() { public function __construct()
{
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
} }
@@ -44,7 +44,8 @@ class SettingsController extends Controller {
* *
* @return response * @return response
*/ */
public function widgets() { public function widgets()
{
return view('themes.default1.admin.helpdesk.theme.widgets'); return view('themes.default1.admin.helpdesk.theme.widgets');
} }
@@ -53,7 +54,8 @@ class SettingsController extends Controller {
* *
* @return response * @return response
*/ */
public function list_widget() { public function list_widget()
{
return \Datatable::collection(Widgets::where('id', '<', '7')->get()) return \Datatable::collection(Widgets::where('id', '<', '7')->get())
->searchColumns('name') ->searchColumns('name')
->orderColumns('name', 'title', 'value') ->orderColumns('name', 'title', 'value')
@@ -67,33 +69,33 @@ class SettingsController extends Controller {
return $model->value; return $model->value;
}) })
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span> return '<span data-toggle="modal" data-target="#edit_widget'.$model->id.'"><a class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a></span>
<div class="modal fade" id="edit_widget' . $model->id . '"> <div class="modal fade" id="edit_widget'.$model->id.'">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<form action="' . url('edit-widget/' . $model->id) . '" method="POST"> <form action="'.url('edit-widget/'.$model->id).'" method="POST">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">' . strtoupper($model->name) . ' </h4> <h4 class="modal-title">'.strtoupper($model->name).' </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>' . \Lang::get('lang.title') . '</label><br/> <label>'.\Lang::get('lang.title').'</label><br/>
<input type="text" name="title" value="' . $model->title . '" class="form-control" style="width:100%"> <input type="text" name="title" value="'.$model->title.'" class="form-control" style="width:100%">
</div> </div>
<br/> <br/>
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>' . \Lang::get('lang.content') . '</label><br/> <label>'.\Lang::get('lang.content').'</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content' . $model->id . '">' . $model->value . '</textarea> <textarea name="content" class="form-control" style="width:100%" id="Content'.$model->id.'">'.$model->value.'</textarea>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button>
<input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '"> <input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'">
</div> </div>
<script> <script>
$(function () { $(function () {
$("#Content' . $model->id . '").wysihtml5(); $("#Content'.$model->id.'").wysihtml5();
}); });
</script> </script>
</form> </form>
@@ -112,13 +114,15 @@ class SettingsController extends Controller {
* *
* @return type response * @return type response
*/ */
public function edit_widget($id, Widgets $widgets, Request $request) { public function edit_widget($id, Widgets $widgets, Request $request)
{
$widget = $widgets->where('id', '=', $id)->first(); $widget = $widgets->where('id', '=', $id)->first();
$widget->title = $request->title; $widget->title = $request->title;
$widget->value = $request->content; $widget->value = $request->content;
try { try {
$widget->save(); $widget->save();
return redirect()->back()->with('success', $widget->name . Lang::get('lang.saved_successfully'));
return redirect()->back()->with('success', $widget->name.Lang::get('lang.saved_successfully'));
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage()); return redirect()->back()->with('fails', $e->getMessage());
} }
@@ -129,7 +133,8 @@ class SettingsController extends Controller {
* *
* @return response * @return response
*/ */
public function social_buttons() { public function social_buttons()
{
return view('themes.default1.admin.helpdesk.theme.social'); return view('themes.default1.admin.helpdesk.theme.social');
} }
@@ -138,7 +143,8 @@ class SettingsController extends Controller {
* *
* @return response * @return response
*/ */
public function list_social_buttons() { public function list_social_buttons()
{
return \Datatable::collection(Widgets::where('id', '>', '6')->get()) return \Datatable::collection(Widgets::where('id', '>', '6')->get())
->searchColumns('name') ->searchColumns('name')
->orderColumns('name', 'value') ->orderColumns('name', 'value')
@@ -149,25 +155,25 @@ class SettingsController extends Controller {
return $model->value; return $model->value;
}) })
->addColumn('Actions', function ($model) { ->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span> return '<span data-toggle="modal" data-target="#edit_widget'.$model->id.'"><a class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a></span>
<div class="modal fade" id="edit_widget' . $model->id . '"> <div class="modal fade" id="edit_widget'.$model->id.'">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<form action="' . url('edit-widget/' . $model->id) . '" method="POST"> <form action="'.url('edit-widget/'.$model->id).'" method="POST">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">' . strtoupper($model->name) . ' </h4> <h4 class="modal-title">'.strtoupper($model->name).' </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<br/> <br/>
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>' . \Lang::get('lang.link') . '</label><br/> <label>'.\Lang::get('lang.link').'</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="' . $model->value . '"> <input type="url" name="content" class="form-control" style="width:100%" value="'.$model->value.'">
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button>
<input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '"> <input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'">
</div> </div>
</form> </form>
</div> </div>
@@ -185,14 +191,15 @@ class SettingsController extends Controller {
* *
* @return type response * @return type response
*/ */
public function edit_social_buttons($id, Widgets $widgets, Request $request) { public function edit_social_buttons($id, Widgets $widgets, Request $request)
{
$widget = $widgets->where('id', '=', $id)->first(); $widget = $widgets->where('id', '=', $id)->first();
$widget->title = $request->title; $widget->title = $request->title;
$widget->value = $request->content; $widget->value = $request->content;
try { try {
$widget->save(); $widget->save();
return redirect()->back()->with('success', $widget->name . ' Saved Successfully'); return redirect()->back()->with('success', $widget->name.' Saved Successfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
@@ -203,8 +210,10 @@ class SettingsController extends Controller {
* *
* @return type view * @return type view
*/ */
public function getsmtp() { public function getsmtp()
{
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
return view('themes.default1.admin.helpdesk.emails.smtp', compact('settings')); return view('themes.default1.admin.helpdesk.emails.smtp', compact('settings'));
} }
@@ -213,7 +222,8 @@ class SettingsController extends Controller {
* *
* @return type view * @return type view
*/ */
public function postsmtp(SmtpRequest $request) { public function postsmtp(SmtpRequest $request)
{
$data = Smtp::where('id', '=', 1)->first(); $data = Smtp::where('id', '=', 1)->first();
$data->driver = $request->input('driver'); $data->driver = $request->input('driver');
$data->host = $request->input('host'); $data->host = $request->input('host');
@@ -224,6 +234,7 @@ class SettingsController extends Controller {
$data->password = Crypt::encrypt($request->input('password')); $data->password = Crypt::encrypt($request->input('password'));
try { try {
$data->save(); $data->save();
return \Redirect::route('getsmtp')->with('success', 'success'); return \Redirect::route('getsmtp')->with('success', 'success');
} catch (Exception $e) { } catch (Exception $e) {
return \Redirect::route('getsmtp')->with('fails', $e->errorInfo[2]); return \Redirect::route('getsmtp')->with('fails', $e->errorInfo[2]);
@@ -238,7 +249,8 @@ class SettingsController extends Controller {
* *
* @return type view * @return type view
*/ */
public function PostSettings(Settings $set, Request $request) { public function PostSettings(Settings $set, Request $request)
{
$settings = $set->where('id', '1')->first(); $settings = $set->where('id', '1')->first();
$pass = $request->input('password'); $pass = $request->input('password');
$password = Crypt::encrypt($pass); $password = Crypt::encrypt($pass);
@@ -251,7 +263,7 @@ class SettingsController extends Controller {
if (Input::file('logo')) { if (Input::file('logo')) {
$name = Input::file('logo')->getClientOriginalName(); $name = Input::file('logo')->getClientOriginalName();
$destinationPath = 'dist/logo'; $destinationPath = 'dist/logo';
$fileName = rand(0000, 9999) . '.' . $name; $fileName = rand(0000, 9999).'.'.$name;
Input::file('logo')->move($destinationPath, $fileName); Input::file('logo')->move($destinationPath, $fileName);
$settings->logo = $fileName; $settings->logo = $fileName;
$settings->save(); $settings->save();
@@ -265,11 +277,13 @@ class SettingsController extends Controller {
} }
} }
public function Plugins() { public function Plugins()
{
return view('themes.default1.admin.helpdesk.settings.plugins'); return view('themes.default1.admin.helpdesk.settings.plugins');
} }
public function GetPlugin() { public function GetPlugin()
{
$plugins = $this->fetchConfig(); $plugins = $this->fetchConfig();
return \Datatable::collection(new Collection($plugins)) return \Datatable::collection(new Collection($plugins))
@@ -277,15 +291,15 @@ class SettingsController extends Controller {
->addColumn('name', function ($model) { ->addColumn('name', function ($model) {
if (array_has($model, 'path')) { if (array_has($model, 'path')) {
if ($model['status'] == 0) { if ($model['status'] == 0) {
$activate = '<a href=' . url('plugin/status/' . $model['path']) . '>Activate</a>'; $activate = '<a href='.url('plugin/status/'.$model['path']).'>Activate</a>';
$settings = ' '; $settings = ' ';
} else { } else {
$settings = '<a href=' . url($model['settings']) . '>Settings</a> | '; $settings = '<a href='.url($model['settings']).'>Settings</a> | ';
$activate = '<a href=' . url('plugin/status/' . $model['path']) . '>Deactivate</a>'; $activate = '<a href='.url('plugin/status/'.$model['path']).'>Deactivate</a>';
} }
$delete = '<a href="#" id=delete' . $model['path'] . ' data-toggle=modal data-target=#del' . $model['path'] . "><span style='color:red'>Delete</span></a>" $delete = '<a href="#" id=delete'.$model['path'].' data-toggle=modal data-target=#del'.$model['path']."><span style='color:red'>Delete</span></a>"
. "<div class='modal fade' id=del" . $model['path'] . "> ."<div class='modal fade' id=del".$model['path'].">
<div class='modal-dialog'> <div class='modal-dialog'>
<div class=modal-content> <div class=modal-content>
<div class=modal-header> <div class=modal-header>
@@ -294,8 +308,8 @@ class SettingsController extends Controller {
<div class=modal-body> <div class=modal-body>
<p>Are you Sure ?</p> <p>Are you Sure ?</p>
<div class=modal-footer> <div class=modal-footer>
<button type=button class='btn btn-default pull-left' data-dismiss=modal id=dismis>" . \Lang::get('lang.close') . '</button> <button type=button class='btn btn-default pull-left' data-dismiss=modal id=dismis>".\Lang::get('lang.close').'</button>
<a href=' . url('plugin/delete/' . $model['path']) . "><button class='btn btn-danger'>Delete</button></a> <a href='.url('plugin/delete/'.$model['path'])."><button class='btn btn-danger'>Delete</button></a>
</div> </div>
@@ -303,12 +317,12 @@ class SettingsController extends Controller {
</div> </div>
</div> </div>
</div>"; </div>";
$action = '<br><br>' . $delete . ' | ' . $settings . $activate; $action = '<br><br>'.$delete.' | '.$settings.$activate;
} else { } else {
$action = ''; $action = '';
} }
return ucfirst($model['name']) . $action; return ucfirst($model['name']).$action;
}) })
->addColumn('description', function ($model) { ->addColumn('description', function ($model) {
return ucfirst($model['description']); return ucfirst($model['description']);
@@ -317,7 +331,7 @@ class SettingsController extends Controller {
return ucfirst($model['author']); return ucfirst($model['author']);
}) })
->addColumn('website', function ($model) { ->addColumn('website', function ($model) {
return '<a href=' . $model['website'] . ' target=_blank>' . $model['website'] . '</a>'; return '<a href='.$model['website'].' target=_blank>'.$model['website'].'</a>';
}) })
->addColumn('version', function ($model) { ->addColumn('version', function ($model) {
return $model['version']; return $model['version'];
@@ -330,8 +344,9 @@ class SettingsController extends Controller {
* *
* @return type * @return type
*/ */
public function ReadPlugins() { public function ReadPlugins()
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins'; {
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins';
$plugins = array_diff(scandir($dir), ['.', '..']); $plugins = array_diff(scandir($dir), ['.', '..']);
return $plugins; return $plugins;
@@ -344,15 +359,16 @@ class SettingsController extends Controller {
* *
* @return type * @return type
*/ */
public function PostPlugins(Request $request) { public function PostPlugins(Request $request)
{
$this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']); $this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
try { try {
if (!extension_loaded('zip')){ if (!extension_loaded('zip')) {
throw new Exception('Please enable zip extension in your php'); throw new Exception('Please enable zip extension in your php');
} }
$plug = new Plugin(); $plug = new Plugin();
$file = $request->file('plugin'); $file = $request->file('plugin');
$destination = app_path() . DIRECTORY_SEPARATOR . 'Plugins'; $destination = app_path().DIRECTORY_SEPARATOR.'Plugins';
$zipfile = $file->getRealPath(); $zipfile = $file->getRealPath();
/* /*
* get the file name and remove .zip * get the file name and remove .zip
@@ -365,31 +381,31 @@ class SettingsController extends Controller {
if (in_array($filename, $dir_check)) { if (in_array($filename, $dir_check)) {
return redirect()->back()->with('fails', Lang::get('lang.plugin-exists')); return redirect()->back()->with('fails', Lang::get('lang.plugin-exists'));
} }
mkdir($destination . DIRECTORY_SEPARATOR . $filename); mkdir($destination.DIRECTORY_SEPARATOR.$filename);
/* /*
* extract the zip file using zipper * extract the zip file using zipper
*/ */
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination . DIRECTORY_SEPARATOR . $filename); \Zipper::make($zipfile)->folder($filename2)->extractTo($destination.DIRECTORY_SEPARATOR.$filename);
$file = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $filename; // Plugin file path $file = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR.$filename; // Plugin file path
if (file_exists($file)) { if (file_exists($file)) {
$seviceporvider = $file . DIRECTORY_SEPARATOR . 'ServiceProvider.php'; $seviceporvider = $file.DIRECTORY_SEPARATOR.'ServiceProvider.php';
$config = $file . DIRECTORY_SEPARATOR . 'config.php'; $config = $file.DIRECTORY_SEPARATOR.'config.php';
if (file_exists($seviceporvider) && file_exists($config)) { if (file_exists($seviceporvider) && file_exists($config)) {
/* /*
* move to faveo config * move to faveo config
*/ */
$faveoconfig = config_path() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $filename . '.php'; $faveoconfig = config_path().DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$filename.'.php';
if ($faveoconfig) { if ($faveoconfig) {
//copy($config, $faveoconfig); //copy($config, $faveoconfig);
/* /*
* write provider list in app.php line 128 * write provider list in app.php line 128
*/ */
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php'; $app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
chmod($app, 0644); chmod($app, 0644);
$str = "\n\n\t\t\t'App\\Plugins\\$filename" . "\\ServiceProvider',"; $str = "\n\n\t\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
$line_i_am_looking_for = 194; $line_i_am_looking_for = 194;
$lines = file($app, FILE_IGNORE_NEW_LINES); $lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str; $lines[$line_i_am_looking_for] = $str;
@@ -403,7 +419,7 @@ class SettingsController extends Controller {
*/ */
$this->deleteDirectory($file); $this->deleteDirectory($file);
return redirect()->back()->with('fails', Lang::get('no-plugin-file') . $file); return redirect()->back()->with('fails', Lang::get('no-plugin-file').$file);
} }
} else { } else {
/* /*
@@ -411,7 +427,7 @@ class SettingsController extends Controller {
*/ */
$this->deleteDirectory($file); $this->deleteDirectory($file);
return redirect()->back()->with('fails', Lang::get('plugin-config-missing') . $file); return redirect()->back()->with('fails', Lang::get('plugin-config-missing').$file);
} }
} else { } else {
/* /*
@@ -419,7 +435,7 @@ class SettingsController extends Controller {
*/ */
$this->deleteDirectory($file); $this->deleteDirectory($file);
return redirect()->back()->with('fails', '<b>' . Lang::get('lang.plugin-path-missing') . '</b> ' . $file); return redirect()->back()->with('fails', '<b>'.Lang::get('lang.plugin-path-missing').'</b> '.$file);
} }
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
@@ -433,7 +449,8 @@ class SettingsController extends Controller {
* *
* @return bool * @return bool
*/ */
public function deleteDirectory($dir) { public function deleteDirectory($dir)
{
if (!file_exists($dir)) { if (!file_exists($dir)) {
return true; return true;
} }
@@ -444,8 +461,8 @@ class SettingsController extends Controller {
if ($item == '.' || $item == '..') { if ($item == '.' || $item == '..') {
continue; continue;
} }
chmod($dir . DIRECTORY_SEPARATOR . $item, 0777); chmod($dir.DIRECTORY_SEPARATOR.$item, 0777);
if (!$this->deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) { if (!$this->deleteDirectory($dir.DIRECTORY_SEPARATOR.$item)) {
return false; return false;
} }
} }
@@ -454,8 +471,9 @@ class SettingsController extends Controller {
return rmdir($dir); return rmdir($dir);
} }
public function ReadConfigs() { public function ReadConfigs()
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR; {
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR;
$directories = scandir($dir); $directories = scandir($dir);
$files = []; $files = [];
foreach ($directories as $key => $file) { foreach ($directories as $key => $file) {
@@ -463,7 +481,7 @@ class SettingsController extends Controller {
continue; continue;
} }
if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) { if (is_dir($dir.DIRECTORY_SEPARATOR.$file)) {
$files[$key] = $file; $files[$key] = $file;
} }
} }
@@ -472,7 +490,7 @@ class SettingsController extends Controller {
$plugins = []; $plugins = [];
if (count($files) > 0) { if (count($files) > 0) {
foreach ($files as $key => $file) { foreach ($files as $key => $file) {
$plugin = $dir . $file; $plugin = $dir.$file;
$plugins[$key] = array_diff(scandir($plugin), ['.', '..', 'ServiceProvider.php']); $plugins[$key] = array_diff(scandir($plugin), ['.', '..', 'ServiceProvider.php']);
$plugins[$key]['file'] = $plugin; $plugins[$key]['file'] = $plugin;
} }
@@ -482,7 +500,7 @@ class SettingsController extends Controller {
if ($dh = opendir($dir)) { if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) { while (($file = readdir($dh)) !== false) {
if ($file == 'config.php') { if ($file == 'config.php') {
$config[] = $dir . DIRECTORY_SEPARATOR . $file; $config[] = $dir.DIRECTORY_SEPARATOR.$file;
} }
} }
closedir($dh); closedir($dh);
@@ -495,7 +513,8 @@ class SettingsController extends Controller {
} }
} }
public function fetchConfig() { public function fetchConfig()
{
$configs = $this->ReadConfigs(); $configs = $this->ReadConfigs();
//dd($configs); //dd($configs);
$plugs = new Plugin(); $plugs = new Plugin();
@@ -531,14 +550,15 @@ class SettingsController extends Controller {
return $attributes; return $attributes;
} }
public function DeletePlugin($slug) { public function DeletePlugin($slug)
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $slug; {
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR.$slug;
$this->deleteDirectory($dir); $this->deleteDirectory($dir);
/* /*
* remove service provider from app.php * remove service provider from app.php
*/ */
$str = "'App\\Plugins\\$slug" . "\\ServiceProvider',"; $str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
$path_to_file = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php'; $path_to_file = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$file_contents = file_get_contents($path_to_file); $file_contents = file_get_contents($path_to_file);
$file_contents = str_replace($str, '//', $file_contents); $file_contents = str_replace($str, '//', $file_contents);
file_put_contents($path_to_file, $file_contents); file_put_contents($path_to_file, $file_contents);
@@ -551,12 +571,13 @@ class SettingsController extends Controller {
return redirect()->back()->with('success', 'Deleted Successfully'); return redirect()->back()->with('success', 'Deleted Successfully');
} }
public function StatusPlugin($slug) { public function StatusPlugin($slug)
{
$plugs = new Plugin(); $plugs = new Plugin();
$plug = $plugs->where('name', $slug)->first(); $plug = $plugs->where('name', $slug)->first();
if (!$plug) { if (!$plug) {
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php'; $app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',"; $str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
$line_i_am_looking_for = 194; $line_i_am_looking_for = 194;
$lines = file($app, FILE_IGNORE_NEW_LINES); $lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str; $lines[$line_i_am_looking_for] = $str;
@@ -569,8 +590,8 @@ class SettingsController extends Controller {
if ($status == 0) { if ($status == 0) {
$plug->status = 1; $plug->status = 1;
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php'; $app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',"; $str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
$line_i_am_looking_for = 194; $line_i_am_looking_for = 194;
$lines = file($app, FILE_IGNORE_NEW_LINES); $lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str; $lines[$line_i_am_looking_for] = $str;
@@ -581,8 +602,8 @@ class SettingsController extends Controller {
/* /*
* remove service provider from app.php * remove service provider from app.php
*/ */
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',"; $str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
$path_to_file = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php'; $path_to_file = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$file_contents = file_get_contents($path_to_file); $file_contents = file_get_contents($path_to_file);
$file_contents = str_replace($str, '//', $file_contents); $file_contents = str_replace($str, '//', $file_contents);

View File

@@ -1,9 +1,9 @@
<?php <?php
namespace App\Http\Controllers\Common; namespace App\Http\Controllers\Common;
use Socialite; use Socialite;
class Socialite extends Socialite{ class Socialite extends Socialite
{
} }

View File

@@ -6,9 +6,9 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\helpdesk\TemplateSetRequest; use App\Http\Requests\helpdesk\TemplateSetRequest;
use App\Model\Common\Template; use App\Model\Common\Template;
use App\Model\Common\TemplateSet; use App\Model\Common\TemplateSet;
use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Lang; use Lang;
use Exception;
class TemplateSetController extends Controller class TemplateSetController extends Controller
{ {

View File

@@ -3,7 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Model\helpdesk\Ticket\Tickets; use App\Model\helpdesk\Ticket\Tickets;
use App\Http\Controllers\Controller;
class HomeController extends Controller class HomeController extends Controller
{ {
/* /*

View File

@@ -2,66 +2,72 @@
namespace App\Http\Controllers\Job; namespace App\Http\Controllers\Job;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Exception; use Exception;
use Form; use Form;
use Illuminate\Http\Request;
class MailController extends Controller class MailController extends Controller
{ {
public function serviceForm(Request $request){ public function serviceForm(Request $request)
{
$serviceid = $request->input('service'); $serviceid = $request->input('service');
$short_name = ""; $short_name = '';
$mail_services = new \App\Model\MailJob\MailService(); $mail_services = new \App\Model\MailJob\MailService();
$mail_service = $mail_services->find($serviceid); $mail_service = $mail_services->find($serviceid);
if($mail_service){ if ($mail_service) {
$short_name = $mail_service->short_name; $short_name = $mail_service->short_name;
} }
$form = $this->getServiceForm($short_name); $form = $this->getServiceForm($short_name);
return $form; return $form;
} }
public function form($label,$name,$class){ public function form($label, $name, $class)
{
$mailid = \Input::get('emailid'); $mailid = \Input::get('emailid');
if($mailid){ if ($mailid) {
$emails = new \App\Model\helpdesk\Email\Emails(); $emails = new \App\Model\helpdesk\Email\Emails();
$email = $emails->find($mailid); $email = $emails->find($mailid);
$form = "<div class='".$class."'>".Form::label($name, $label) ."<span class='text-red'> *</span>". $form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
Form::text($name, $email->getExtraField($name), ['class' => "form-control"])."</div>"; Form::text($name, $email->getExtraField($name), ['class' => 'form-control']).'</div>';
}else{ } else {
$form = "<div class='".$class."'>".Form::label($name, $label) ."<span class='text-red'> *</span>". $form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
Form::text($name, NULL, ['class' => "form-control"])."</div>"; Form::text($name, null, ['class' => 'form-control']).'</div>';
} }
return $form; return $form;
} }
public function getServiceForm($short_name){ public function getServiceForm($short_name)
$form = ""; {
try{ $form = '';
switch ($short_name){ try {
case "smtp": switch ($short_name) {
case 'smtp':
return $form; return $form;
case "mail": case 'mail':
return $form; return $form;
case "sendmail": case 'sendmail':
return $form; return $form;
case "mailgun": case 'mailgun':
$form .= "<div class='row'>".$this->form('Domain', 'domain','col-md-6 form-group'); $form .= "<div class='row'>".$this->form('Domain', 'domain', 'col-md-6 form-group');
$form .= $this->form('Secret Key', 'secret','col-md-6 form-group')."</div>"; $form .= $this->form('Secret Key', 'secret', 'col-md-6 form-group').'</div>';
return $form; return $form;
case "mandrill": case 'mandrill':
$form .= "<div class='row'>".$this->form('Secret Key', 'secret','col-md-6 form-group')."</div>"; $form .= "<div class='row'>".$this->form('Secret Key', 'secret', 'col-md-6 form-group').'</div>';
return $form; return $form;
case "log": case 'log':
return $form; return $form;
case "ses": case 'ses':
$form .= "<div class='row'>".$this->form('Key', 'key','col-md-6 form-group'); $form .= "<div class='row'>".$this->form('Key', 'key', 'col-md-6 form-group');
$form .= $this->form('Secret Key', 'secret','col-md-6 form-group').$this->form('Region', 'region','col-md-6 form-group')."</div>"; $form .= $this->form('Secret Key', 'secret', 'col-md-6 form-group').$this->form('Region', 'region', 'col-md-6 form-group').'</div>';
return $form; return $form;
default : default:
return $form; return $form;
} }
} catch (Exception $ex) { } catch (Exception $ex) {

View File

@@ -2,47 +2,51 @@
namespace App\Http\Controllers\Job; namespace App\Http\Controllers\Job;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Model\MailJob\QueueService; use App\Http\Requests\helpdesk\Queue\QueueRequest;
use App\Model\MailJob\FaveoQueue; use App\Model\MailJob\FaveoQueue;
use App\Model\MailJob\QueueService;
use Exception; use Exception;
use Form; use Form;
use App\Http\Requests\helpdesk\Queue\QueueRequest; use Illuminate\Http\Request;
class QueueController extends Controller { class QueueController extends Controller
{
public function index() { public function index()
{
try { try {
$queue = new QueueService(); $queue = new QueueService();
$queues = $queue->select('id', 'name', 'status')->get(); $queues = $queue->select('id', 'name', 'status')->get();
return view('themes.default1.admin.helpdesk.queue.index', compact('queues')); return view('themes.default1.admin.helpdesk.queue.index', compact('queues'));
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function edit($id) { public function edit($id)
{
try { try {
$queues = new QueueService(); $queues = new QueueService();
$queue = $queues->find($id); $queue = $queues->find($id);
if (!$queue) { if (!$queue) {
throw new Exception("Sorry we can not find your request"); throw new Exception('Sorry we can not find your request');
} }
return view('themes.default1.admin.helpdesk.queue.edit', compact('queue')); return view('themes.default1.admin.helpdesk.queue.edit', compact('queue'));
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function update($id, QueueRequest $request) { public function update($id, QueueRequest $request)
{
try { try {
$values = $request->except('_token'); $values = $request->except('_token');
$queues = new QueueService(); $queues = new QueueService();
$queue = $queues->find($id); $queue = $queues->find($id);
if (!$queue) { if (!$queue) {
throw new Exception("Sorry we can not find your request"); throw new Exception('Sorry we can not find your request');
} }
$setting = new FaveoQueue(); $setting = new FaveoQueue();
$settings = $setting->where('service_id', $id)->get(); $settings = $setting->where('service_id', $id)->get();
@@ -55,26 +59,28 @@ class QueueController extends Controller {
foreach ($values as $key => $value) { foreach ($values as $key => $value) {
$setting->create([ $setting->create([
'service_id' => $id, 'service_id' => $id,
'key' => $key, 'key' => $key,
'value' => $value, 'value' => $value,
]); ]);
} }
} }
return redirect()->back()->with('success', 'Updated'); return redirect()->back()->with('success', 'Updated');
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function activate($id) { public function activate($id)
{
try { try {
$queues = new QueueService(); $queues = new QueueService();
$queue = $queues->find($id); $queue = $queues->find($id);
$active_queue = $queues->where('status', 1)->first(); $active_queue = $queues->where('status', 1)->first();
if (!$queue) { if (!$queue) {
throw new Exception("Sorry we can not find your request"); throw new Exception('Sorry we can not find your request');
} }
if ($queue->isActivate()==false&&$id!=1&&$id!=2) { if ($queue->isActivate() == false && $id != 1 && $id != 2) {
throw new Exception("To activate $queue->name , Please configure it first"); throw new Exception("To activate $queue->name , Please configure it first");
} }
if ($active_queue) { if ($active_queue) {
@@ -83,89 +89,102 @@ class QueueController extends Controller {
} }
$queue->status = 1; $queue->status = 1;
$queue->save(); $queue->save();
return redirect()->back()->with('success', 'Activated'); return redirect()->back()->with('success', 'Activated');
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function getForm(Request $request){ public function getForm(Request $request)
{
$queueid = $request->input('queueid'); $queueid = $request->input('queueid');
$form = $this->getFormById($queueid); $form = $this->getFormById($queueid);
return $form; return $form;
} }
public function getShortNameById($queueid) { public function getShortNameById($queueid)
$short = ""; {
$short = '';
$queues = new QueueService(); $queues = new QueueService();
$queue = $queues->find($queueid); $queue = $queues->find($queueid);
if ($queue) { if ($queue) {
$short = $queue->short_name; $short = $queue->short_name;
} }
return $short; return $short;
} }
public function getIdByShortName($short) { public function getIdByShortName($short)
$id = ""; {
$id = '';
$queues = new QueueService(); $queues = new QueueService();
$queue = $queues->where('short_name', $short)->first(); $queue = $queues->where('short_name', $short)->first();
if ($queue) { if ($queue) {
$id = $queue->id; $id = $queue->id;
} }
return $id; return $id;
} }
public function getFormById($id) { public function getFormById($id)
{
$short = $this->getShortNameById($id); $short = $this->getShortNameById($id);
$form = ""; $form = '';
switch ($short) { switch ($short) {
case "beanstalkd": case 'beanstalkd':
$form .= "<div class='row'>"; $form .= "<div class='row'>";
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group','beanstalkd'); $form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'beanstalkd');
$form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group','localhost'); $form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group', 'localhost');
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'default'); $form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'default');
$form .= "</div>"; $form .= '</div>';
return $form; return $form;
case "sqs": case 'sqs':
$form .= "<div class='row'>"; $form .= "<div class='row'>";
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group','sqs'); $form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'sqs');
$form .= $this->form($short, 'Key', 'key', 'col-md-6 form-group','your-public-key'); $form .= $this->form($short, 'Key', 'key', 'col-md-6 form-group', 'your-public-key');
$form .= $this->form($short, 'Secret', 'secret', 'col-md-6 form-group', 'your-queue-url'); $form .= $this->form($short, 'Secret', 'secret', 'col-md-6 form-group', 'your-queue-url');
$form .= $this->form($short, 'Region', 'region', 'col-md-6 form-group', 'us-east-1'); $form .= $this->form($short, 'Region', 'region', 'col-md-6 form-group', 'us-east-1');
$form .= "</div>"; $form .= '</div>';
return $form; return $form;
case "iron": case 'iron':
$form .= "<div class='row'>"; $form .= "<div class='row'>";
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group','iron'); $form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'iron');
$form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group','mq-aws-us-east-1.iron.io'); $form .= $this->form($short, 'Host', 'host', 'col-md-6 form-group', 'mq-aws-us-east-1.iron.io');
$form .= $this->form($short, 'Token', 'token', 'col-md-6 form-group', 'your-token'); $form .= $this->form($short, 'Token', 'token', 'col-md-6 form-group', 'your-token');
$form .= $this->form($short, 'Project', 'project', 'col-md-6 form-group', 'your-project-id'); $form .= $this->form($short, 'Project', 'project', 'col-md-6 form-group', 'your-project-id');
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'your-queue-name'); $form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'your-queue-name');
$form .= "</div>"; $form .= '</div>';
return $form; return $form;
case "redis": case 'redis':
$form .= "<div class='row'>"; $form .= "<div class='row'>";
$form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group','redis'); $form .= $this->form($short, 'Driver', 'driver', 'col-md-6 form-group', 'redis');
$form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'default'); $form .= $this->form($short, 'Queue', 'queue', 'col-md-6 form-group', 'default');
$form .= "</div>"; $form .= '</div>';
return $form; return $form;
default : default:
return $form; return $form;
} }
} }
public function form($short, $label, $name, $class, $placeholder = '') { public function form($short, $label, $name, $class, $placeholder = '')
{
$queueid = $this->getIdByShortName($short); $queueid = $this->getIdByShortName($short);
$queues = new QueueService(); $queues = new QueueService();
$queue = $queues->find($queueid); $queue = $queues->find($queueid);
if ($queue) { if ($queue) {
$form = "<div class='" . $class . "'>" . Form::label($name, $label) . "<span class='text-red'> *</span>" . $form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
Form::text($name, $queue->getExtraField($name), ['class' => "form-control", 'placeholder' => $placeholder]) . "</div>"; Form::text($name, $queue->getExtraField($name), ['class' => 'form-control', 'placeholder' => $placeholder]).'</div>';
} else { } else {
$form = "<div class='" . $class . "'>" . Form::label($name, $label) . "<span class='text-red'> *</span>" . $form = "<div class='".$class."'>".Form::label($name, $label)."<span class='text-red'> *</span>".
Form::text($name, NULL, ['class' => "form-control", 'placeholder' => $placeholder]) . "</div>"; Form::text($name, null, ['class' => 'form-control', 'placeholder' => $placeholder]).'</div>';
} }
return $form; return $form;
} }
} }

View File

@@ -9,16 +9,18 @@ use Artisan;
use Exception; use Exception;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class UpgradeController extends Controller { class UpgradeController extends Controller
{
public $dir; public $dir;
public function __construct() { public function __construct()
{
$dir = base_path(); $dir = base_path();
$this->dir = $dir; $this->dir = $dir;
} }
public function getLatestVersion() { public function getLatestVersion()
{
try { try {
$name = \Config::get('app.name'); $name = \Config::get('app.name');
//dd($name); //dd($name);
@@ -28,17 +30,17 @@ class UpgradeController extends Controller {
$order_number = '44596328'; $order_number = '44596328';
$url = env('APP_URL'); $url = env('APP_URL');
$data = [ $data = [
'serial_key' => $serial_key, 'serial_key' => $serial_key,
'order_number' => $order_number, 'order_number' => $order_number,
'name' => $name, 'name' => $name,
'version' => Utility::getFileVersion(), 'version' => Utility::getFileVersion(),
'request_type' => 'check_update', 'request_type' => 'check_update',
'url' => $url, 'url' => $url,
]; ];
$data = Utility::encryptByFaveoPublicKey(json_encode($data)); $data = Utility::encryptByFaveoPublicKey(json_encode($data));
//dd($data); //dd($data);
$post_data = [ $post_data = [
'data' => $data 'data' => $data,
]; ];
$url = 'http://faveohelpdesk.com/billing/public/verification'; $url = 'http://faveohelpdesk.com/billing/public/verification';
if (str_contains($url, ' ')) { if (str_contains($url, ' ')) {
@@ -59,7 +61,8 @@ class UpgradeController extends Controller {
} }
} }
public function downloadLatestCode() { public function downloadLatestCode()
{
$name = \Config::get('app.name'); $name = \Config::get('app.name');
$durl = 'http://www.faveohelpdesk.com/billing/public/download-url'; $durl = 'http://www.faveohelpdesk.com/billing/public/download-url';
if (str_contains($durl, ' ')) { if (str_contains($durl, ' ')) {
@@ -75,7 +78,8 @@ class UpgradeController extends Controller {
return $download_url; return $download_url;
} }
public function saveLatestCodeAtTemp($download_url) { public function saveLatestCodeAtTemp($download_url)
{
echo '<p>Downloading New Update</p>'; echo '<p>Downloading New Update</p>';
$context = stream_context_create( $context = stream_context_create(
[ [
@@ -87,10 +91,10 @@ class UpgradeController extends Controller {
$newUpdate = file_get_contents($download_url, false, $context); $newUpdate = file_get_contents($download_url, false, $context);
if (!is_dir("$this->dir/UPDATES/")) { if (!is_dir("$this->dir/UPDATES/")) {
\File::makeDirectory($this->dir . '/UPDATES/', 0777); \File::makeDirectory($this->dir.'/UPDATES/', 0777);
} }
$dlHandler = fopen($this->dir . '/UPDATES/' . '/faveo-helpdesk-master.zip', 'w'); $dlHandler = fopen($this->dir.'/UPDATES/'.'/faveo-helpdesk-master.zip', 'w');
if (!fwrite($dlHandler, $newUpdate)) { if (!fwrite($dlHandler, $newUpdate)) {
echo '<p>Could not save new update. Operation aborted.</p>'; echo '<p>Could not save new update. Operation aborted.</p>';
exit(); exit();
@@ -99,25 +103,28 @@ class UpgradeController extends Controller {
echo '<p>Update Downloaded And Saved</p>'; echo '<p>Update Downloaded And Saved</p>';
} }
public function doUpdate() { public function doUpdate()
{
try { try {
$memory_limit = ini_get('memory_limit'); $memory_limit = ini_get('memory_limit');
if ($memory_limit < 256) { if ($memory_limit < 256) {
echo '<ul class=list-unstyled>'; echo '<ul class=list-unstyled>';
echo "<li style='color:red;'>Sorry we can not process your request because of limited memory! You have only $memory_limit. For this you need atleast 256 MB</li>"; echo "<li style='color:red;'>Sorry we can not process your request because of limited memory! You have only $memory_limit. For this you need atleast 256 MB</li>";
echo '</ul>'; echo '</ul>';
return 0; return 0;
} }
if (!extension_loaded('zip')) { if (!extension_loaded('zip')) {
echo '<ul class=list-unstyled>'; echo '<ul class=list-unstyled>';
echo "<li style='color:red;'>Sorry we can not process your request because you don't have ZIP extension contact your system admin</li>"; echo "<li style='color:red;'>Sorry we can not process your request because you don't have ZIP extension contact your system admin</li>";
echo '</ul>'; echo '</ul>';
return 0; return 0;
} }
//Artisan::call('down'); //Artisan::call('down');
$update = $this->dir . '/UPDATES'; $update = $this->dir.'/UPDATES';
//Open The File And Do Stuff //Open The File And Do Stuff
$zipHandle = zip_open($update . '/faveo-helpdesk-master.zip'); $zipHandle = zip_open($update.'/faveo-helpdesk-master.zip');
//dd($update . '/faveo-' . $aV . '.zip'); //dd($update . '/faveo-' . $aV . '.zip');
echo '<ul class=list-unstyled>'; echo '<ul class=list-unstyled>';
@@ -130,30 +137,29 @@ class UpgradeController extends Controller {
continue; continue;
} }
//Make the directory if we need to... //Make the directory if we need to...
if (!is_dir($update . '/' . $thisFileDir . '/')) { if (!is_dir($update.'/'.$thisFileDir.'/')) {
\File::makeDirectory($update . '/' . $thisFileDir, 0775, true, true); \File::makeDirectory($update.'/'.$thisFileDir, 0775, true, true);
// mkdir($update.'/'. $thisFileDir, 0775); // mkdir($update.'/'. $thisFileDir, 0775);
echo '<li style="color:white;">Created Directory ' . $thisFileDir . '</li>'; echo '<li style="color:white;">Created Directory '.$thisFileDir.'</li>';
} }
//Overwrite the file //Overwrite the file
if (!is_dir($update . '/' . $thisFileName)) { if (!is_dir($update.'/'.$thisFileName)) {
echo '<li style="color:white;">' . $thisFileName . '...........'; echo '<li style="color:white;">'.$thisFileName.'...........';
$contents = zip_entry_read($aF, zip_entry_filesize($aF)); $contents = zip_entry_read($aF, zip_entry_filesize($aF));
$contents = str_replace("\r\n", "\n", $contents); $contents = str_replace("\r\n", "\n", $contents);
$updateThis = ''; $updateThis = '';
//If we need to run commands, then do it. //If we need to run commands, then do it.
if ($thisFileName == $thisFileDir . '/.env') { if ($thisFileName == $thisFileDir.'/.env') {
if (is_file($update . '/' . $thisFileDir . '/.env')) { if (is_file($update.'/'.$thisFileDir.'/.env')) {
unlink($update . '/' . $thisFileDir . '/.env'); unlink($update.'/'.$thisFileDir.'/.env');
unlink($update . '/' . $thisFileDir . '/config/database.php'); unlink($update.'/'.$thisFileDir.'/config/database.php');
} }
echo' EXECUTED</li>'; echo' EXECUTED</li>';
} else { } else {
$updateThis = fopen($update . '/' . $thisFileName, 'w'); $updateThis = fopen($update.'/'.$thisFileName, 'w');
fwrite($updateThis, $contents); fwrite($updateThis, $contents);
fclose($updateThis); fclose($updateThis);
unset($contents); unset($contents);
@@ -166,12 +172,13 @@ class UpgradeController extends Controller {
return true; return true;
} catch (Exception $ex) { } catch (Exception $ex) {
echo '<ul class=list-unstyled>'; echo '<ul class=list-unstyled>';
echo "<li style='color:red;'>" . $ex->getMessage() . "</li>"; echo "<li style='color:red;'>".$ex->getMessage().'</li>';
echo '</ul>'; echo '</ul>';
} }
} }
public function copyToActualDirectory($latest_version) { public function copyToActualDirectory($latest_version)
{
try { try {
echo '<ul class=list-unstyled>'; echo '<ul class=list-unstyled>';
$directory = "$this->dir/UPDATES"; $directory = "$this->dir/UPDATES";
@@ -190,17 +197,18 @@ class UpgradeController extends Controller {
$this->deleteBarNotification('new-version'); $this->deleteBarNotification('new-version');
echo "<li style='color:green;'>&raquo; Faveo Updated to v" . Utility::getFileVersion() . "</li>"; echo "<li style='color:green;'>&raquo; Faveo Updated to v".Utility::getFileVersion().'</li>';
echo '</ul>'; echo '</ul>';
} catch (Exception $ex) { } catch (Exception $ex) {
echo '<ul class=list-unstyled>'; echo '<ul class=list-unstyled>';
echo "<li style='color:red;'>" . $ex->getMessage() . "</li>"; echo "<li style='color:red;'>".$ex->getMessage().'</li>';
echo '</ul>'; echo '</ul>';
} }
exit(); exit();
} }
public function deleteBarNotification($key) { public function deleteBarNotification($key)
{
try { try {
$noti = new BarNotification(); $noti = new BarNotification();
$notifications = $noti->where('key', $key)->get(); $notifications = $noti->where('key', $key)->get();
@@ -212,20 +220,24 @@ class UpgradeController extends Controller {
} }
} }
public function fileUpdate() { public function fileUpdate()
{
try { try {
$latest_version = $this->getLatestVersion(); $latest_version = $this->getLatestVersion();
if (Utility::getFileVersion() < $latest_version) { if (Utility::getFileVersion() < $latest_version) {
$url = url('file-upgrade'); $url = url('file-upgrade');
return view('themes.default1.update.file', compact('url')); return view('themes.default1.update.file', compact('url'));
} }
return redirect('dashboard')->with('fails', 'Could not find latest realeases from repository.'); return redirect('dashboard')->with('fails', 'Could not find latest realeases from repository.');
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function fileUpgrading(Request $request) { public function fileUpgrading(Request $request)
{
try { try {
// //
$latest_version = $this->getLatestVersion(); $latest_version = $this->getLatestVersion();
@@ -233,12 +245,11 @@ class UpgradeController extends Controller {
$current_version = Utility::getFileVersion(); $current_version = Utility::getFileVersion();
if ($latest_version != '') { if ($latest_version != '') {
if (Utility::getFileVersion() < $latest_version) { if (Utility::getFileVersion() < $latest_version) {
return view('themes.default1.update.update', compact('latest_version', 'current_version', 'request')); return view('themes.default1.update.update', compact('latest_version', 'current_version', 'request'));
} }
} }
return redirect('dashboard')->with('fails', 'Could not find latest realeases from repository.');
return redirect('dashboard')->with('fails', 'Could not find latest realeases from repository.');
// else { // else {
// return redirect()->back(); // return redirect()->back();
@@ -248,7 +259,8 @@ class UpgradeController extends Controller {
} }
} }
public function testScroll() { public function testScroll()
{
$ex = 1000; $ex = 1000;
echo '<ul style=list-unstyled>'; echo '<ul style=list-unstyled>';
for ($i = 0; $i < $ex; $i++) { for ($i = 0; $i < $ex; $i++) {
@@ -257,7 +269,8 @@ class UpgradeController extends Controller {
echo '</ul>'; echo '</ul>';
} }
public function fileUpgrading1(Request $request) { public function fileUpgrading1(Request $request)
{
if (Utility::getFileVersion() < Utility::getDatabaseVersion()) { if (Utility::getFileVersion() < Utility::getDatabaseVersion()) {
$latest_version = $this->getLatestVersion(); $latest_version = $this->getLatestVersion();
// dd($latest_version); // dd($latest_version);
@@ -267,7 +280,7 @@ class UpgradeController extends Controller {
echo "<p>CURRENT VERSION: $current_version</p>"; echo "<p>CURRENT VERSION: $current_version</p>";
echo '<p>Reading Current Releases List</p>'; echo '<p>Reading Current Releases List</p>';
if ($latest_version > $current_version) { if ($latest_version > $current_version) {
echo '<p>New Update Found: v' . $latest_version . '</p>'; echo '<p>New Update Found: v'.$latest_version.'</p>';
$found = true; $found = true;
if (!is_file("$this->dir/UPDATES/faveo-helpdesk-master.zip")) { if (!is_file("$this->dir/UPDATES/faveo-helpdesk-master.zip")) {
if ($request->get('dodownload') == true) { if ($request->get('dodownload') == true) {
@@ -278,7 +291,7 @@ class UpgradeController extends Controller {
echo '<p>Error in you network connection.</p>'; echo '<p>Error in you network connection.</p>';
} }
} else { } else {
echo '<p>Latest code found. <a href=' . url('file-upgrade?dodownload=true') . '>&raquo; Download Now?</a></p>'; echo '<p>Latest code found. <a href='.url('file-upgrade?dodownload=true').'>&raquo; Download Now?</a></p>';
exit(); exit();
} }
} else { } else {
@@ -287,7 +300,7 @@ class UpgradeController extends Controller {
if ($request->get('doUpdate') == true) { if ($request->get('doUpdate') == true) {
$updated = $this->doUpdate(); $updated = $this->doUpdate();
} else { } else {
echo '<p>Update ready. <a href=' . url('file-upgrade?doUpdate=true') . '>&raquo; Install Now?</a></p>'; echo '<p>Update ready. <a href='.url('file-upgrade?doUpdate=true').'>&raquo; Install Now?</a></p>';
exit(); exit();
} }
@@ -307,17 +320,18 @@ class UpgradeController extends Controller {
} }
} }
public function getCurl($url) { public function getCurl($url)
{
try { try {
$curl = Utility::_isCurl(); $curl = Utility::_isCurl();
if (!$curl) { if (!$curl) {
throw new Exception("Please enable your curl function to check latest update"); throw new Exception('Please enable your curl function to check latest update');
} }
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
if (curl_exec($ch) === false) { if (curl_exec($ch) === false) {
echo 'Curl error: ' . curl_error($ch); echo 'Curl error: '.curl_error($ch);
} }
$data = curl_exec($ch); $data = curl_exec($ch);
curl_close($ch); curl_close($ch);
@@ -328,11 +342,12 @@ class UpgradeController extends Controller {
} }
} }
public function postDownloadCurl($url, $data) { public function postDownloadCurl($url, $data)
{
try { try {
$curl = Utility::_isCurl(); $curl = Utility::_isCurl();
if (!$curl) { if (!$curl) {
throw new Exception("Please enable your curl function to check latest update"); throw new Exception('Please enable your curl function to check latest update');
} }
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
@@ -340,21 +355,23 @@ class UpgradeController extends Controller {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
if (curl_exec($ch) === false) { if (curl_exec($ch) === false) {
echo 'Curl error: ' . curl_error($ch); echo 'Curl error: '.curl_error($ch);
} }
$data = curl_exec($ch); $data = curl_exec($ch);
curl_close($ch); curl_close($ch);
return json_decode($data, true); return json_decode($data, true);
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function postCurl($url, $data) { public function postCurl($url, $data)
{
try { try {
$curl = Utility::_isCurl(); $curl = Utility::_isCurl();
if (!$curl) { if (!$curl) {
throw new Exception("Please enable your curl function to check latest update"); throw new Exception('Please enable your curl function to check latest update');
} }
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
@@ -362,18 +379,20 @@ class UpgradeController extends Controller {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
if (curl_exec($ch) === false) { if (curl_exec($ch) === false) {
echo 'Curl error: ' . curl_error($ch); echo 'Curl error: '.curl_error($ch);
} }
$data = curl_exec($ch); $data = curl_exec($ch);
curl_close($ch); curl_close($ch);
$data = Utility::decryptByFaveoPrivateKey($data); $data = Utility::decryptByFaveoPrivateKey($data);
return json_decode($data, true); return json_decode($data, true);
} catch (Exception $ex) { } catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
public function databaseUpdate() { public function databaseUpdate()
{
try { try {
if (Utility::getFileVersion() > Utility::getDatabaseVersion()) { if (Utility::getFileVersion() > Utility::getDatabaseVersion()) {
$url = url('database-upgrade'); $url = url('database-upgrade');
@@ -387,7 +406,8 @@ class UpgradeController extends Controller {
} }
} }
public function databaseUpgrade() { public function databaseUpgrade()
{
try { try {
if (Utility::getFileVersion() > Utility::getDatabaseVersion()) { if (Utility::getFileVersion() > Utility::getDatabaseVersion()) {
Artisan::call('migrate', ['--force' => true]); Artisan::call('migrate', ['--force' => true]);
@@ -400,5 +420,4 @@ class UpgradeController extends Controller {
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
} }
} }

View File

@@ -7,9 +7,10 @@ use Config;
use Exception; use Exception;
use Schema; use Schema;
class LibraryController extends Controller { class LibraryController extends Controller
{
public static function getFileVersion() { public static function getFileVersion()
{
try { try {
$app = Config::get('app.version'); $app = Config::get('app.version');
if ($app) { if ($app) {
@@ -22,7 +23,8 @@ class LibraryController extends Controller {
} }
} }
public static function getDatabaseVersion() { public static function getDatabaseVersion()
{
try { try {
$database = self::isDatabaseSetup(); $database = self::isDatabaseSetup();
if ($database == true) { if ($database == true) {
@@ -39,7 +41,8 @@ class LibraryController extends Controller {
} }
} }
public static function isDatabaseSetup() { public static function isDatabaseSetup()
{
try { try {
if (Schema::hasTable('settings_system')) { if (Schema::hasTable('settings_system')) {
return true; return true;
@@ -49,28 +52,30 @@ class LibraryController extends Controller {
} }
} }
public static function encryptByFaveoPublicKey($data) { public static function encryptByFaveoPublicKey($data)
{
try { try {
$path = storage_path() . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'public.key'; $path = storage_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'public.key';
//dd($path); //dd($path);
$key_content = file_get_contents($path); $key_content = file_get_contents($path);
$public_key = openssl_get_publickey($key_content); $public_key = openssl_get_publickey($key_content);
$encrypted = $e = NULL; $encrypted = $e = null;
openssl_seal($data, $encrypted, $e, array($public_key)); openssl_seal($data, $encrypted, $e, [$public_key]);
$sealed_data = base64_encode($encrypted); $sealed_data = base64_encode($encrypted);
$envelope = base64_encode($e[0]); $envelope = base64_encode($e[0]);
$result = ['seal' => $sealed_data, 'envelope' => $envelope]; $result = ['seal' => $sealed_data, 'envelope' => $envelope];
return json_encode($result); return json_encode($result);
} catch (Exception $ex) { } catch (Exception $ex) {
throw new Exception($ex->getMessage()); throw new Exception($ex->getMessage());
} }
} }
public static function decryptByFaveoPrivateKey($encrypted) { public static function decryptByFaveoPrivateKey($encrypted)
{
try { try {
$encrypted = json_decode($encrypted); $encrypted = json_decode($encrypted);
if ($encrypted) { if ($encrypted) {
@@ -78,11 +83,12 @@ class LibraryController extends Controller {
$envelope = $encrypted->envelope; $envelope = $encrypted->envelope;
$input = base64_decode($sealed_data); $input = base64_decode($sealed_data);
$einput = base64_decode($envelope); $einput = base64_decode($envelope);
$path = storage_path('app' . DIRECTORY_SEPARATOR . 'private.key'); $path = storage_path('app'.DIRECTORY_SEPARATOR.'private.key');
$key_content = file_get_contents($path); $key_content = file_get_contents($path);
$private_key = openssl_get_privatekey($key_content); $private_key = openssl_get_privatekey($key_content);
$plaintext = NULL; $plaintext = null;
openssl_open($input, $plaintext, $einput, $private_key); openssl_open($input, $plaintext, $einput, $private_key);
return $plaintext; return $plaintext;
} }
} catch (Exception $ex) { } catch (Exception $ex) {
@@ -90,8 +96,8 @@ class LibraryController extends Controller {
} }
} }
public static function _isCurl() { public static function _isCurl()
{
return function_exists('curl_version'); return function_exists('curl_version');
} }
} }

View File

@@ -44,6 +44,7 @@ class Authenticate
if ($this->auth->guest()) { if ($this->auth->guest()) {
if ($request->ajax()) { if ($request->ajax()) {
$result = ['fails' => 'Unauthorized! Please login again']; $result = ['fails' => 'Unauthorized! Please login again'];
return response()->json(compact('result')); return response()->json(compact('result'));
} else { } else {
return redirect()->guest('auth/login'); return redirect()->guest('auth/login');

View File

@@ -1,9 +1,9 @@
<?php <?php
namespace App\Http\Requests\helpdesk; namespace App\Http\Requests\helpdesk;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Model\helpdesk\Settings\CommonSettings;
/** /**
* AgentRequest. * AgentRequest.
@@ -29,10 +29,11 @@ class AgentRequest extends Request
*/ */
public function rules() public function rules()
{ {
$check = $this->check(new CommonSettings); $check = $this->check(new CommonSettings());
if ($check != 0) { if ($check != 0) {
return $check; return $check;
} }
return [ return [
'user_name' => 'required|unique:users|max:30', 'user_name' => 'required|unique:users|max:30',
'first_name' => 'required|max:30', 'first_name' => 'required|max:30',
@@ -45,15 +46,18 @@ class AgentRequest extends Request
'agent_time_zone' => 'required', 'agent_time_zone' => 'required',
// 'phone_number' => 'phone:IN', // 'phone_number' => 'phone:IN',
'mobile' => 'unique:users', 'mobile' => 'unique:users',
'team' => 'required', 'team' => 'required',
]; ];
} }
/** /**
*@category Funcion to set rule if send opt is enabled *@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings) *
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com *@author manish.verma@ladybirdweb.com
*@return array|int *
*@return array|int
*/ */
public function check($settings) public function check($settings)
{ {
@@ -72,8 +76,8 @@ class AgentRequest extends Request
// 'phone_number' => 'phone:IN', // 'phone_number' => 'phone:IN',
// 'mobile' => 'phone:IN', // 'mobile' => 'phone:IN',
'team' => 'required', 'team' => 'required',
'mobile' => 'required|unique:users', 'mobile' => 'required|unique:users',
'country_code' => 'required', 'country_code' => 'required',
]; ];
} else { } else {
return 0; return 0;

View File

@@ -29,7 +29,7 @@ class ChangepasswordRequest extends Request
public function rules() public function rules()
{ {
return [ return [
'change_password' => 'required', 'change_password' => 'required',
// 'message' => 'required', // 'message' => 'required',
]; ];

View File

@@ -5,7 +5,6 @@ namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Model\helpdesk\Settings\CommonSettings; use App\Model\helpdesk\Settings\CommonSettings;
/** /**
* CompanyRequest. * CompanyRequest.
* *
@@ -30,11 +29,12 @@ class ClientRequest extends Request
*/ */
public function rules() public function rules()
{ {
$check = $this->check(new CommonSettings); $check = $this->check(new CommonSettings());
if ($check != 0) { if ($check != 0) {
return $check; return $check;
$custom_rule = $this->getCustomRule(); $custom_rule = $this->getCustomRule();
$rules = array_merge($check, $custom_rule); $rules = array_merge($check, $custom_rule);
return $rules; return $rules;
} }
$current_rule = [ $current_rule = [
@@ -45,70 +45,83 @@ class ClientRequest extends Request
]; ];
$custom_rule = $this->getCustomRule(); $custom_rule = $this->getCustomRule();
$rules = array_merge($current_rule, $custom_rule); $rules = array_merge($current_rule, $custom_rule);
return $rules; return $rules;
} }
public function getHelpTopic(){ public function getHelpTopic()
{
$help_topics = new \App\Model\helpdesk\Manage\Help_topic(); $help_topics = new \App\Model\helpdesk\Manage\Help_topic();
$topic = $this->input('helptopic'); $topic = $this->input('helptopic');
$help_topic = $help_topics->where('id',$topic)->first(); $help_topic = $help_topics->where('id', $topic)->first();
return $help_topic; return $help_topic;
} }
public function getCustomRule(){ public function getCustomRule()
$custom_form = ""; {
$custom_form = '';
$help_topic = $this->getHelpTopic(); $help_topic = $this->getHelpTopic();
if($help_topic){ if ($help_topic) {
$custom_form = $help_topic->custom_form; $custom_form = $help_topic->custom_form;
} }
return $this->getForm($custom_form); return $this->getForm($custom_form);
} }
public function getForm($formid){ public function getForm($formid)
$id = ""; {
$id = '';
$forms = new \App\Model\helpdesk\Form\Forms(); $forms = new \App\Model\helpdesk\Form\Forms();
$form = $forms->where('id',$formid)->first(); $form = $forms->where('id', $formid)->first();
if($form){ if ($form) {
$id = $form->id; $id = $form->id;
} }
return $this->getFields($id); return $this->getFields($id);
} }
public function getFields($formid){ public function getFields($formid)
{
$rules = []; $rules = [];
$field = new \App\Model\helpdesk\Form\Fields(); $field = new \App\Model\helpdesk\Form\Fields();
$fields = $field->where('forms_id',$formid)->get(); $fields = $field->where('forms_id', $formid)->get();
if($fields->count()>0){ if ($fields->count() > 0) {
foreach($fields as $fd){ foreach ($fields as $fd) {
if($fd->required==='1'){ if ($fd->required === '1') {
$rules[str_replace(" ",'_',$fd->name)]="required"; $rules[str_replace(' ', '_', $fd->name)] = 'required';
} }
$rules = array_merge($rules,$this->getChild($fd->id)); $rules = array_merge($rules, $this->getChild($fd->id));
} }
} }
return $rules; return $rules;
} }
public function getChild($fieldid){ public function getChild($fieldid)
{
$children = new \App\Model\helpdesk\Form\FieldValue(); $children = new \App\Model\helpdesk\Form\FieldValue();
$childs = $children->where('field_id',$fieldid)->get(); $childs = $children->where('field_id', $fieldid)->get();
$rules = []; $rules = [];
if($childs->count()>0){ if ($childs->count() > 0) {
foreach($childs as $child){ foreach ($childs as $child) {
$child_formid = $child->child_id; $child_formid = $child->child_id;
return $this->getForm($child_formid); return $this->getForm($child_formid);
} }
} }
return []; return [];
} }
/** /**
*@category Funcion to set rule if send opt is enabled *@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings) *
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com *@author manish.verma@ladybirdweb.com
*@return array|int *
*@return array|int
*/ */
public function check($settings) public function check($settings)
{ {

View File

@@ -1,7 +1,10 @@
<?php <?php
namespace App\Http\Requests\helpdesk; namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Model\helpdesk\Settings\CommonSettings; use App\Model\helpdesk\Settings\CommonSettings;
/** /**
* CreateTicketRequest. * CreateTicketRequest.
* *
@@ -18,14 +21,16 @@ class CreateTicketRequest extends Request
{ {
return true; return true;
} }
public function wantsJson() public function wantsJson()
{ {
if(in_array('api',$this->segments())){ if (in_array('api', $this->segments())) {
return true; return true;
} }
return false; return false;
} }
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.
* *
@@ -33,14 +38,15 @@ class CreateTicketRequest extends Request
*/ */
public function rules() public function rules()
{ {
$check = $this->check(new CommonSettings); $check = $this->check(new CommonSettings());
if ($check != 0) { if ($check != 0) {
return $check; return $check;
} }
return [ return [
'email' => 'required|email|max:60', 'email' => 'required|email|max:60',
'first_name' => 'required|min:3|max:40', 'first_name' => 'required|min:3|max:40',
'helptopic' => 'required', 'helptopic' => 'required',
// 'dept' => 'required', // 'dept' => 'required',
'sla' => 'required', 'sla' => 'required',
'subject' => 'required|min:5', 'subject' => 'required|min:5',
@@ -48,11 +54,15 @@ class CreateTicketRequest extends Request
'priority' => 'required', 'priority' => 'required',
]; ];
} }
/** /**
*@category Funcion to set rule if send opt is enabled *@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings) *
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com *@author manish.verma@ladybirdweb.com
*@return array|int *
*@return array|int
*/ */
public function check($settings) public function check($settings)
{ {
@@ -61,9 +71,9 @@ class CreateTicketRequest extends Request
// dd($settings->status, $email_mandatory->status); // dd($settings->status, $email_mandatory->status);
if (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) { if (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
return [ return [
'email' => 'required|email|max:60', 'email' => 'required|email|max:60',
'first_name' => 'required|min:3|max:40', 'first_name' => 'required|min:3|max:40',
'helptopic' => 'required', 'helptopic' => 'required',
// 'dept' => 'required', // 'dept' => 'required',
'sla' => 'required', 'sla' => 'required',
'subject' => 'required|min:5', 'subject' => 'required|min:5',
@@ -76,9 +86,11 @@ class CreateTicketRequest extends Request
return 0; return 0;
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) { } elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
$rule = $this->onlyMobleRequired(); $rule = $this->onlyMobleRequired();
return $rule; return $rule;
} elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) { } elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
$rule = $this->onlyMobleRequired(); $rule = $this->onlyMobleRequired();
return $rule; return $rule;
} else { } else {
return 0; return 0;
@@ -87,15 +99,17 @@ class CreateTicketRequest extends Request
/** /**
*@category function to make only moble required rule *@category function to make only moble required rule
*
*@param null *@param null
*
*@return array *@return array
*/ */
public function onlyMobleRequired() public function onlyMobleRequired()
{ {
return [ return [
'email' => 'email|max:60', 'email' => 'email|max:60',
'first_name' => 'required|min:3|max:40', 'first_name' => 'required|min:3|max:40',
'helptopic' => 'required', 'helptopic' => 'required',
// 'dept' => 'required', // 'dept' => 'required',
'sla' => 'required', 'sla' => 'required',
'subject' => 'required|min:5', 'subject' => 'required|min:5',
@@ -105,4 +119,4 @@ class CreateTicketRequest extends Request
'mobile' => 'required', 'mobile' => 'required',
]; ];
} }
} }

View File

@@ -4,14 +4,15 @@ namespace App\Http\Requests\helpdesk\Job;
use App\Http\Requests\Request; use App\Http\Requests\Request;
class TaskRequest extends Request { class TaskRequest extends Request
{
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize()
{
return true; return true;
} }
@@ -20,27 +21,28 @@ class TaskRequest extends Request {
* *
* @return array * @return array
*/ */
public function rules() { public function rules()
{
return [ return [
'fetching-commands' => 'required_if:email_fetching,1', 'fetching-commands' => 'required_if:email_fetching,1',
'notification-commands' => 'required_if:notification_cron,1', 'notification-commands' => 'required_if:notification_cron,1',
'work-commands' => 'required_if:condition,1', 'work-commands' => 'required_if:condition,1',
'workflow-dailyAt' => 'required_if:work-commands,dailyAt', 'workflow-dailyAt' => 'required_if:work-commands,dailyAt',
'notification-dailyAt' => 'required_if:notification-commands,dailyAt', 'notification-dailyAt' => 'required_if:notification-commands,dailyAt',
'fetching-dailyAt' => 'required_if:fetching-commands,dailyAt', 'fetching-dailyAt' => 'required_if:fetching-commands,dailyAt',
]; ];
} }
public function messages() { public function messages()
{
return [ return [
'fetching-commands.required_if' => 'Please choose your Email Fetching timing', 'fetching-commands.required_if' => 'Please choose your Email Fetching timing',
'notification-commands.required_if'=>'Please choose your Email Notification timing', 'notification-commands.required_if'=> 'Please choose your Email Notification timing',
'work-commands.required_if'=>'Please choose your Auto-close Workflow timing', 'work-commands.required_if' => 'Please choose your Auto-close Workflow timing',
'workflow-dailyAt.required_if'=>'Please enter the time for Auto-close Workflow timing', 'workflow-dailyAt.required_if' => 'Please enter the time for Auto-close Workflow timing',
'notification-dailyAt.required_if'=>'Please enter the time for Email Notification timing', 'notification-dailyAt.required_if' => 'Please enter the time for Email Notification timing',
'fetching-dailyAt.required_if'=>'Please enter the time for Email Fetching timing', 'fetching-dailyAt.required_if' => 'Please enter the time for Email Fetching timing',
]; ];
} }
} }

View File

@@ -30,11 +30,12 @@ class LableUpdate extends Request
public function rules() public function rules()
{ {
$label_data = \Request::segments(); $label_data = \Request::segments();
$label = Label::find($label_data[1]); $label = Label::find($label_data[1]);
return [ return [
'title' => 'required|max:10|unique:labels,title,'.$label->id, 'title' => 'required|max:10|unique:labels,title,'.$label->id,
'color' => 'required|regex:/#([a-fA-F0-9]{3}){1,2}\b/', 'color' => 'required|regex:/#([a-fA-F0-9]{3}){1,2}\b/',
'order' => 'required|integer' 'order' => 'required|integer',
]; ];
} }
} }

View File

@@ -23,52 +23,56 @@ class MailRequest extends Request
*/ */
public function rules() public function rules()
{ {
$id = $this->segment(2); $id = $this->segment(2);
$email_address_rule = 'required|email|unique:emails'; $email_address_rule = 'required|email|unique:emails';
if($id){ if ($id) {
$email_address_rule = 'required|email|unique:emails,id,'.$id; $email_address_rule = 'required|email|unique:emails,id,'.$id;
} }
$rules = [
$rules = [ 'email_address' => $email_address_rule,
'email_address' => $email_address_rule, 'email_name' => 'required',
'email_name' => 'required', 'password' => 'required',
'password' => 'required', 'sending_protocol'=> 'required_if:sending_status,on',
'sending_protocol'=>'required_if:sending_status,on',
]; ];
$driver = $this->input('sending_protocol'); $driver = $this->input('sending_protocol');
$driver_rules = $this->getDriver($driver); $driver_rules = $this->getDriver($driver);
$rules = array_merge($rules,$driver_rules); $rules = array_merge($rules, $driver_rules);
return $rules; return $rules;
} }
public function getDriver($serviceid){ public function getDriver($serviceid)
{
$rules = []; $rules = [];
$mail_services = new \App\Model\MailJob\MailService(); $mail_services = new \App\Model\MailJob\MailService();
$mail_service = $mail_services->find($serviceid); $mail_service = $mail_services->find($serviceid);
if($mail_service){ if ($mail_service) {
$short = $mail_service->short_name; $short = $mail_service->short_name;
$rules = $this->getRules($short); $rules = $this->getRules($short);
} }
return $rules; return $rules;
} }
public function getRules($short){ public function getRules($short)
{
$rules = []; $rules = [];
switch ($short){ switch ($short) {
case "mailgun": case 'mailgun':
$rules = [ $rules = [
'domain'=>'required', 'domain'=> 'required',
'secret'=>'required', 'secret'=> 'required',
]; ];
return $rules; return $rules;
case "mandrill": case 'mandrill':
$rules = [ $rules = [
'secret'=>'required', 'secret'=> 'required',
]; ];
return $rules; return $rules;
default : default:
return $rules; return $rules;
} }
} }

View File

@@ -29,18 +29,14 @@ class PriorityRequest extends Request
public function rules() public function rules()
{ {
return [ return [
'priority' => 'required|max:10',
'status' => 'required',
'priority_desc' => 'required|max:255',
'priority_color' => 'required',
'ispublic' => 'required',
'priority_successfully_updated'=>'priority successfully updated',
'priority_successfully_created!!!'=>'priority successfully created',
'priority' => 'required|max:10',
'status' => 'required',
'priority_desc' => 'required|max:255',
'priority_color' => 'required',
'ispublic' => 'required',
'priority_successfully_updated' => 'priority successfully updated',
'priority_successfully_created!!!'=> 'priority successfully created',
]; ];
} }

View File

@@ -36,8 +36,8 @@ class ProfileRequest extends Request
} }
/** /**
*Check the mobile number is unique or not.
* *
*Check the mobile number is unique or not
*@return string *@return string
*/ */
public function checkMobile() public function checkMobile()

View File

@@ -25,16 +25,19 @@ class QueueRequest extends Request
{ {
$request = $this->except('_token'); $request = $this->except('_token');
$rules = $this->setRule($request); $rules = $this->setRule($request);
return $rules; return $rules;
} }
public function setRule($request){ public function setRule($request)
{
$rules = []; $rules = [];
if(count($request)>0){ if (count($request) > 0) {
foreach($request as $key=>$value){ foreach ($request as $key=>$value) {
$rules[$key]='required'; $rules[$key] = 'required';
} }
} }
return $rules; return $rules;
} }
} }

View File

@@ -29,10 +29,11 @@ class RegisterRequest extends Request
*/ */
public function rules() public function rules()
{ {
$check = $this->check(new CommonSettings); $check = $this->check(new CommonSettings());
if ($check != 0) { if ($check != 0) {
return $check; return $check;
} }
return [ return [
'email' => 'required|max:50|email|unique:users', 'email' => 'required|max:50|email|unique:users',
'full_name' => 'required', 'full_name' => 'required',
@@ -43,9 +44,12 @@ class RegisterRequest extends Request
/** /**
*@category Funcion to set rule if send opt is enabled *@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings) *
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com *@author manish.verma@ladybirdweb.com
*@return array|int *
*@return array|int
*/ */
public function check($settings) public function check($settings)
{ {

View File

@@ -1,9 +1,9 @@
<?php <?php
namespace App\Http\Requests\helpdesk; namespace App\Http\Requests\helpdesk;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Model\helpdesk\Settings\CommonSettings;
/** /**
* Sys_userRequest. * Sys_userRequest.
@@ -28,24 +28,28 @@ class Sys_userRequest extends Request
* @return array * @return array
*/ */
public function rules() public function rules()
{ {
$check = $this->check(new CommonSettings); $check = $this->check(new CommonSettings());
if ($check != 0) { if ($check != 0) {
return $check; return $check;
} }
return [ return [
'first_name' => 'required', 'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name', 'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'required|unique:users,email', 'email' => 'required|unique:users,email',
'mobile' => 'unique:users', 'mobile' => 'unique:users',
]; ];
} }
/** /**
*@category Funcion to set rule if send opt is enabled *@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings) *
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com *@author manish.verma@ladybirdweb.com
*@return array|int *
*@return array|int
*/ */
public function check($settings) public function check($settings)
{ {
@@ -53,19 +57,21 @@ class Sys_userRequest extends Request
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first(); $email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
if (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) { if (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
return [ return [
'first_name' => 'required', 'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name', 'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'required|unique:users,email', 'email' => 'required|unique:users,email',
'country_code' => 'required', 'country_code' => 'required',
'mobile' => 'required|unique:users', 'mobile' => 'required|unique:users',
]; ];
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) { } elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
return 0; return 0;
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) { } elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
$rule = $this->onlyMobleRequired(); $rule = $this->onlyMobleRequired();
return $rule; return $rule;
} elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) { } elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
$rule = $this->onlyMobleRequired(); $rule = $this->onlyMobleRequired();
return $rule; return $rule;
} else { } else {
return 0; return 0;
@@ -74,17 +80,19 @@ class Sys_userRequest extends Request
/** /**
*@category function to make only moble required rule *@category function to make only moble required rule
*
*@param null *@param null
*
*@return array *@return array
*/ */
public function onlyMobleRequired() public function onlyMobleRequired()
{ {
return [ return [
'first_name' => 'required', 'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name', 'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'unique:users,email', 'email' => 'unique:users,email',
'country_code' => 'required', 'country_code' => 'required',
'mobile' => 'required|unique:users', 'mobile' => 'required|unique:users',
]; ];
} }
} }

View File

@@ -3,6 +3,7 @@
namespace App\Http\Requests\helpdesk; namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request; use App\Http\Requests\Request;
//use Illuminate\Http\Request as Req; //use Illuminate\Http\Request as Req;
/** /**
* Sys_userUpdate. * Sys_userUpdate.
@@ -29,10 +30,10 @@ class Sys_userUpdate extends Request
public function rules() public function rules()
{ {
return [ return [
'first_name' => 'required', 'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name,'.$this->segment(2), 'user_name' => 'required|min:3|unique:users,user_name,'.$this->segment(2),
'email' => 'required|email|unique:users,email,'.$this->segment(2), 'email' => 'required|email|unique:users,email,'.$this->segment(2),
'mobile' => 'unique:users,mobile,'.$this->segment(2), 'mobile' => 'unique:users,mobile,'.$this->segment(2),
]; ];
} }
} }

View File

@@ -9,14 +9,15 @@ use App\Http\Requests\Request;
* *
* @author Ladybird <info@ladybirdweb.com> * @author Ladybird <info@ladybirdweb.com>
*/ */
class TicketRequest extends Request { class TicketRequest extends Request
{
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.
* *
* @return bool * @return bool
*/ */
public function authorize() { public function authorize()
{
return true; return true;
} }
@@ -25,39 +26,42 @@ class TicketRequest extends Request {
* *
* @return array * @return array
*/ */
public function rules() { public function rules()
$error = ""; {
$error = '';
try { try {
$size = $this->size(); $size = $this->size();
if ($size > 800 || $size==0) { if ($size > 800 || $size == 0) {
throw new \Exception("File size exceeded", 422); throw new \Exception('File size exceeded', 422);
} }
} catch (\Exception $ex) { } catch (\Exception $ex) {
dd($ex); dd($ex);
$error = $this->error($ex); $error = $this->error($ex);
} }
// return [ // return [
// 'attachment' => 'not_in:'.$error, // 'attachment' => 'not_in:'.$error,
// ]; // ];
} }
public function size() { public function size()
{
$files = $this->file('attachment'); $files = $this->file('attachment');
if (!$files) { if (!$files) {
throw new \Exception("exceeded", 422); throw new \Exception('exceeded', 422);
} }
$size = 0; $size = 0;
if (count($files) > 0) { if (count($files) > 0) {
foreach ($files as $file) { foreach ($files as $file) {
$size +=$file->getSize(); $size += $file->getSize();
} }
} }
return $size; return $size;
} }
public function error($e) { public function error($e)
{
if ($this->ajax() || $this->wantsJson()) { if ($this->ajax() || $this->wantsJson()) {
$message = $e->getMessage(); $message = $e->getMessage();
if (is_object($message)) { if (is_object($message)) {
$message = $message->toArray(); $message = $message->toArray();
@@ -66,5 +70,4 @@ class TicketRequest extends Request {
return $message; return $message;
} }
} }
} }

View File

@@ -24,6 +24,7 @@ class CategoryRequest extends Request
public function rules() public function rules()
{ {
$id = $this->segment(2); $id = $this->segment(2);
return [ return [
'name' => 'required|max:250|unique:kb_category,name,'.$id, 'name' => 'required|max:250|unique:kb_category,name,'.$id,
'description' => 'required', 'description' => 'required',

View File

@@ -24,8 +24,9 @@ class PageRequest extends Request
public function rules() public function rules()
{ {
$slug = $this->segment(2); $slug = $this->segment(2);
return [ return [
'name' => 'required|unique:kb_pages,slug,'.$slug 'name' => 'required|unique:kb_pages,slug,'.$slug,
]; ];
} }
} }

View File

@@ -2,15 +2,15 @@
namespace App\Http\ViewComposers; namespace App\Http\ViewComposers;
use Illuminate\View\View;
use App\Model\helpdesk\Settings\Company;
use Auth;
use App\User;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Ticket\Tickets;
use App\User;
use Auth;
use Illuminate\View\View;
class AgentLayout { class AgentLayout
{
/** /**
* The user repository implementation. * The user repository implementation.
* *
@@ -24,10 +24,12 @@ class AgentLayout {
/** /**
* Create a new profile composer. * Create a new profile composer.
* *
* @param * @param
*
* @return void * @return void
*/ */
public function __construct(Company $company, User $users, Tickets $tickets, Department $department) { public function __construct(Company $company, User $users, Tickets $tickets, Department $department)
{
$this->company = $company; $this->company = $company;
$this->auth = Auth::user(); $this->auth = Auth::user();
$this->users = $users; $this->users = $users;
@@ -38,34 +40,39 @@ class AgentLayout {
/** /**
* Bind data to the view. * Bind data to the view.
* *
* @param View $view * @param View $view
*
* @return void * @return void
*/ */
public function compose(View $view) { public function compose(View $view)
{
$notifications = \App\Http\Controllers\Common\NotificationController::getNotifications(); $notifications = \App\Http\Controllers\Common\NotificationController::getNotifications();
$view->with([ $view->with([
'company' => $this->company, 'company' => $this->company,
'notifications' => $notifications, 'notifications' => $notifications,
'myticket' => $this->myTicket(), 'myticket' => $this->myTicket(),
'unassigned' => $this->unassigned(), 'unassigned' => $this->unassigned(),
'followup_ticket' => $this->followupTicket(), 'followup_ticket' => $this->followupTicket(),
'deleted' => $this->deleted(), 'deleted' => $this->deleted(),
'tickets' => $this->inbox(), 'tickets' => $this->inbox(),
'department' => $this->departments(), 'department' => $this->departments(),
'overdues' => $this->overdues(), 'overdues' => $this->overdues(),
'due_today' => $this->getDueToday(), 'due_today' => $this->getDueToday(),
]); ]);
} }
public function users() { public function users()
{
return $this->users->select('id', 'profile_pic'); return $this->users->select('id', 'profile_pic');
} }
public function tickets() { public function tickets()
{
return $this->tickets->select('id', 'ticket_number'); return $this->tickets->select('id', 'ticket_number');
} }
public function departments() { public function departments()
{
$array = []; $array = [];
$tickets = $this->tickets; $tickets = $this->tickets;
if (\Auth::user()->role == 'agent') { if (\Auth::user()->role == 'agent') {
@@ -82,10 +89,12 @@ class AgentLayout {
foreach ($grouped as $key => $group) { foreach ($grouped as $key => $group) {
$status[$key] = $group->keyBy('status'); $status[$key] = $group->keyBy('status');
} }
return collect($status); return collect($status);
} }
public function myTicket() { public function myTicket()
{
$ticket = $this->tickets(); $ticket = $this->tickets();
if ($this->auth->role == 'admin') { if ($this->auth->role == 'admin') {
return $ticket->where('assigned_to', $this->auth->id) return $ticket->where('assigned_to', $this->auth->id)
@@ -96,7 +105,8 @@ class AgentLayout {
} }
} }
public function unassigned() { public function unassigned()
{
$ticket = $this->tickets(); $ticket = $this->tickets();
if ($this->auth->role == 'admin') { if ($this->auth->role == 'admin') {
return $ticket->where('assigned_to', '=', null) return $ticket->where('assigned_to', '=', null)
@@ -110,7 +120,8 @@ class AgentLayout {
} }
} }
public function followupTicket() { public function followupTicket()
{
$ticket = $this->tickets(); $ticket = $this->tickets();
if ($this->auth->role == 'admin') { if ($this->auth->role == 'admin') {
return $ticket->where('status', '1')->where('follow_up', '1')->select('id'); return $ticket->where('status', '1')->where('follow_up', '1')->select('id');
@@ -119,8 +130,8 @@ class AgentLayout {
} }
} }
public function deleted()
public function deleted() { {
$ticket = $this->tickets(); $ticket = $this->tickets();
if ($this->auth->role == 'admin') { if ($this->auth->role == 'admin') {
return $ticket->where('status', '5')->select('id'); return $ticket->where('status', '5')->select('id');
@@ -130,19 +141,21 @@ class AgentLayout {
} }
} }
public function inbox() { public function inbox()
{
$ticket = $this->tickets(); $ticket = $this->tickets();
if ($this->auth->role == 'admin') { if ($this->auth->role == 'admin') {
return $ticket->whereIn('status', array(1, 7))->select('id'); return $ticket->whereIn('status', [1, 7])->select('id');
} elseif ($this->auth->role == 'agent') { } elseif ($this->auth->role == 'agent') {
return $ticket->whereIn('status', array(1, 7)) return $ticket->whereIn('status', [1, 7])
->where('dept_id', '=', $this->auth->primary_dpt) ->where('dept_id', '=', $this->auth->primary_dpt)
->orWhere('assigned_to', '=', Auth::user()->id) ->orWhere('assigned_to', '=', Auth::user()->id)
->select('id'); ->select('id');
} }
} }
public function overdues() { public function overdues()
{
$ticket = $this->tickets(); $ticket = $this->tickets();
if ($this->auth->role == 'admin') { if ($this->auth->role == 'admin') {
return $ticket->where('status', '=', 1) return $ticket->where('status', '=', 1)
@@ -162,24 +175,22 @@ class AgentLayout {
} }
} }
public function getDueToday() public function getDueToday()
{ {
$ticket = $this->tickets(); $ticket = $this->tickets();
if ($this->auth->role == 'admin') { if ($this->auth->role == 'admin') {
return $ticket->where('status', '=', 1) return $ticket->where('status', '=', 1)
->where('status','=',1 ) ->where('status', '=', 1)
->where('isanswered', '=', 0) ->where('isanswered', '=', 0)
->whereNotNull('duedate') ->whereNotNull('duedate')
->whereRaw('date(duedate) = ?', [date('Y-m-d')]); ->whereRaw('date(duedate) = ?', [date('Y-m-d')]);
} elseif ($this->auth->role == 'agent') { } elseif ($this->auth->role == 'agent') {
return $ticket->where('status', '=', 1) return $ticket->where('status', '=', 1)
->where('status','=',1 ) ->where('status', '=', 1)
->where('isanswered', '=', 0) ->where('isanswered', '=', 0)
->whereNotNull('duedate') ->whereNotNull('duedate')
->where('dept_id', '=', $this->auth->primary_dpt) ->where('dept_id', '=', $this->auth->primary_dpt)
->whereRaw('date(duedate) = ?', [date('Y-m-d')]); ->whereRaw('date(duedate) = ?', [date('Y-m-d')]);
} }
} }
} }

View File

@@ -2,27 +2,28 @@
namespace App\Http\ViewComposers; namespace App\Http\ViewComposers;
use Illuminate\View\View;
use Auth; use Auth;
use Illuminate\View\View;
class AuthUser { class AuthUser
{
protected $user; protected $user;
public function __construct() { public function __construct()
{
$this->user = Auth::user(); $this->user = Auth::user();
} }
public function compose(View $view) { public function compose(View $view)
{
$view->with([ $view->with([
'auth_user_role' => $this->user->role, 'auth_user_role' => $this->user->role,
'auth_user_id'=>$this->user->id, 'auth_user_id' => $this->user->id,
'auth_user_profile_pic'=>$this->user->profile_pic, 'auth_user_profile_pic' => $this->user->profile_pic,
'auth_name'=>$this->user->name(), 'auth_name' => $this->user->name(),
'auth_user_active'=>$this->user->active, 'auth_user_active' => $this->user->active,
'auth_user_primary_dept'=> $this->user->primary_dept, 'auth_user_primary_dept'=> $this->user->primary_dept,
'auth_user_assign_group'=>$this->user->assign_group, 'auth_user_assign_group'=> $this->user->assign_group,
]); ]);
} }
} }

View File

@@ -2,20 +2,19 @@
namespace App\Http\ViewComposers; namespace App\Http\ViewComposers;
use Illuminate\View\View;
use App\Model\Update\BarNotification; use App\Model\Update\BarNotification;
use Illuminate\View\View;
class UpdateNotification { class UpdateNotification
{
public function __construct() { public function __construct()
{
} }
public function compose(View $view) { public function compose(View $view)
{
$notification = new BarNotification(); $notification = new BarNotification();
$notice = $notification->where('value', '!=', '')->select('value')->get(); $notice = $notification->where('value', '!=', '')->select('value')->get();
$view->with(['notification' => $notice]); $view->with(['notification' => $notice]);
} }
} }

View File

@@ -325,7 +325,7 @@ Breadcrumbs::register('user.show', function ($breadcrumbs) {
Breadcrumbs::register('user.export', function ($breadcrumbs) { Breadcrumbs::register('user.export', function ($breadcrumbs) {
$breadcrumbs->parent('user.index'); $breadcrumbs->parent('user.index');
$breadcrumbs->push("Export", url('user-export')); $breadcrumbs->push('Export', url('user-export'));
}); });
Breadcrumbs::register('organizations.index', function ($breadcrumbs) { Breadcrumbs::register('organizations.index', function ($breadcrumbs) {
@@ -368,58 +368,58 @@ Breadcrumbs::register('agent-profile-edit', function ($breadcrumbs) {
}); });
Breadcrumbs::register('inbox.ticket', function ($breadcrumbs) { Breadcrumbs::register('inbox.ticket', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.inbox'), route('inbox.ticket')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.inbox'), route('inbox.ticket'));
}); });
Breadcrumbs::register('open.ticket', function ($breadcrumbs) { Breadcrumbs::register('open.ticket', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.open'), route('open.ticket')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.open'), route('open.ticket'));
}); });
Breadcrumbs::register('answered.ticket', function ($breadcrumbs) { Breadcrumbs::register('answered.ticket', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.answered'), route('answered.ticket')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.answered'), route('answered.ticket'));
}); });
Breadcrumbs::register('myticket.ticket', function ($breadcrumbs) { Breadcrumbs::register('myticket.ticket', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.my_tickets'), route('myticket.ticket')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.my_tickets'), route('myticket.ticket'));
}); });
Breadcrumbs::register('overdue.ticket', function ($breadcrumbs) { Breadcrumbs::register('overdue.ticket', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.overdue'), route('overdue.ticket')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.overdue'), route('overdue.ticket'));
}); });
Breadcrumbs::register('closed.ticket', function ($breadcrumbs) { Breadcrumbs::register('closed.ticket', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.closed'), route('closed.ticket')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.closed'), route('closed.ticket'));
}); });
Breadcrumbs::register('assigned.ticket', function ($breadcrumbs) { Breadcrumbs::register('assigned.ticket', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.assigned'), route('assigned.ticket')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.assigned'), route('assigned.ticket'));
}); });
Breadcrumbs::register('newticket', function ($breadcrumbs) { Breadcrumbs::register('newticket', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.create'), route('newticket')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.create'), route('newticket'));
}); });
Breadcrumbs::register('ticket.thread', function ($breadcrumbs, $id) { Breadcrumbs::register('ticket.thread', function ($breadcrumbs, $id) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$ticket_number = App\Model\helpdesk\Ticket\Tickets::where('id', '=', $id)->first(); $ticket_number = App\Model\helpdesk\Ticket\Tickets::where('id', '=', $id)->first();
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . $ticket_number->ticket_number, url('/thread/{id}')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.$ticket_number->ticket_number, url('/thread/{id}'));
}); });
Breadcrumbs::register('get-trash', function ($breadcrumbs) { Breadcrumbs::register('get-trash', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.trash'), route('get-trash')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.trash'), route('get-trash'));
}); });
Breadcrumbs::register('unassigned', function ($breadcrumbs) { Breadcrumbs::register('unassigned', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.unassigned'), route('unassigned')); $breadcrumbs->push(Lang::get('lang.tickets').'&nbsp; > &nbsp;'.Lang::get('lang.unassigned'), route('unassigned'));
}); });
Breadcrumbs::register('dept.open.ticket', function ($breadcrumbs, $dept) { Breadcrumbs::register('dept.open.ticket', function ($breadcrumbs, $dept) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.department') . '&nbsp; > &nbsp;' . $dept . '&nbsp; > &nbsp;' . Lang::get('lang.open_tickets'), url('/{dept}/open')); $breadcrumbs->push(Lang::get('lang.department').'&nbsp; > &nbsp;'.$dept.'&nbsp; > &nbsp;'.Lang::get('lang.open_tickets'), url('/{dept}/open'));
}); });
Breadcrumbs::register('dept.closed.ticket', function ($breadcrumbs, $dept) { Breadcrumbs::register('dept.closed.ticket', function ($breadcrumbs, $dept) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.department') . '&nbsp; > &nbsp;' . $dept . '&nbsp; > &nbsp;' . Lang::get('lang.closed_tickets'), url('/{dept}/closed')); $breadcrumbs->push(Lang::get('lang.department').'&nbsp; > &nbsp;'.$dept.'&nbsp; > &nbsp;'.Lang::get('lang.closed_tickets'), url('/{dept}/closed'));
}); });
Breadcrumbs::register('report.index', function ($breadcrumbs) { Breadcrumbs::register('report.index', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
@@ -596,20 +596,20 @@ Breadcrumbs::register('priority.edit', function ($breadcrumbs) {
Breadcrumbs::register('dept.inprogress.ticket', function ($breadcrumbs, $dept) { Breadcrumbs::register('dept.inprogress.ticket', function ($breadcrumbs, $dept) {
$breadcrumbs->parent('dashboard'); $breadcrumbs->parent('dashboard');
$breadcrumbs->push(Lang::get('lang.department') . '&nbsp; > &nbsp;' . $dept . '&nbsp; > &nbsp;' . Lang::get('lang.assigned_tickets'), url('/{dept}/inprogress')); $breadcrumbs->push(Lang::get('lang.department').'&nbsp; > &nbsp;'.$dept.'&nbsp; > &nbsp;'.Lang::get('lang.assigned_tickets'), url('/{dept}/inprogress'));
}); });
Breadcrumbs::register('labels.index', function($breadcrumbs){ Breadcrumbs::register('labels.index', function ($breadcrumbs) {
$breadcrumbs->parent('setting'); $breadcrumbs->parent('setting');
$breadcrumbs->push(Lang::get('lang.label'), 'labels.index'); $breadcrumbs->push(Lang::get('lang.label'), 'labels.index');
}); });
Breadcrumbs::register('labels.create', function($breadcrumbs){ Breadcrumbs::register('labels.create', function ($breadcrumbs) {
$breadcrumbs->parent('labels.index'); $breadcrumbs->parent('labels.index');
$breadcrumbs->push(Lang::get('lang.create'), 'labels.create'); $breadcrumbs->push(Lang::get('lang.create'), 'labels.create');
}); });
Breadcrumbs::register('labels.edit', function($breadcrumbs){ Breadcrumbs::register('labels.edit', function ($breadcrumbs) {
$breadcrumbs->parent('labels.index'); $breadcrumbs->parent('labels.index');
$breadcrumbs->push(Lang::get('lang.edit'), 'labels.edit'); $breadcrumbs->push(Lang::get('lang.edit'), 'labels.edit');
}); });

View File

@@ -1,19 +1,22 @@
<?php <?php
function loging($context, $message, $level = 'error', $array = []) { function loging($context, $message, $level = 'error', $array = [])
{
\Log::$level($message . ":-:-:-" . $context, $array); \Log::$level($message.':-:-:-'.$context, $array);
} }
function checkArray($key, $array) { function checkArray($key, $array)
$value = ""; {
$value = '';
if (array_key_exists($key, $array)) { if (array_key_exists($key, $array)) {
$value = $array[$key]; $value = $array[$key];
} }
return $value; return $value;
} }
function mime($type) { function mime($type)
{
if ($type == 'jpg' || if ($type == 'jpg' ||
$type == 'png' || $type == 'png' ||
$type == 'PNG' || $type == 'PNG' ||
@@ -26,36 +29,43 @@ function mime($type) {
$type == 'image/jpg' || $type == 'image/jpg' ||
$type == 'image/gif' || $type == 'image/gif' ||
// $type == "application/octet-stream" || // $type == "application/octet-stream" ||
$type == "image/png" || $type == 'image/png' ||
starts_with($type, 'image')) { starts_with($type, 'image')) {
return "image"; return 'image';
} }
} }
function removeUnderscore($string) { function removeUnderscore($string)
{
if (str_contains($string, '_') === true) { if (str_contains($string, '_') === true) {
$string = str_replace('_', ' ', $string); $string = str_replace('_', ' ', $string);
} }
return ucfirst($string); return ucfirst($string);
} }
function isItil() { function isItil()
{
$check = false; $check = false;
if (\Schema::hasTable('sd_releases') && \Schema::hasTable('sd_changes') && \Schema::hasTable('sd_problem')) { if (\Schema::hasTable('sd_releases') && \Schema::hasTable('sd_changes') && \Schema::hasTable('sd_problem')) {
$check = true; $check = true;
} }
return $check; return $check;
} }
function isAsset() { function isAsset()
{
$check = false; $check = false;
if (\Schema::hasTable('sd_assets')) { if (\Schema::hasTable('sd_assets')) {
$check = true; $check = true;
} }
return $check; return $check;
} }
function itilEnabled() { function itilEnabled()
{
$check = false; $check = false;
if (\Schema::hasTable('common_settings')) { if (\Schema::hasTable('common_settings')) {
$settings = \DB::table('common_settings')->where('option_name', 'itil')->first(); $settings = \DB::table('common_settings')->where('option_name', 'itil')->first();
@@ -63,10 +73,12 @@ function itilEnabled() {
$check = true; $check = true;
} }
} }
return $check; return $check;
} }
function isBill() { function isBill()
{
$check = false; $check = false;
if (\Schema::hasTable('common_settings')) { if (\Schema::hasTable('common_settings')) {
$settings = \DB::table('common_settings')->where('option_name', 'bill')->first(); $settings = \DB::table('common_settings')->where('option_name', 'bill')->first();
@@ -74,20 +86,23 @@ function isBill() {
$check = true; $check = true;
} }
} }
return $check; return $check;
} }
function deletePopUp($id, $url, $title = "Delete", $class = "btn btn-sm btn-danger", $btn_name = "Delete", $button_check = true) { function deletePopUp($id, $url, $title = 'Delete', $class = 'btn btn-sm btn-danger', $btn_name = 'Delete', $button_check = true)
$button = ""; {
$button = '';
if ($button_check == true) { if ($button_check == true) {
$button = '<a href="#delete" class="' . $class . '" data-toggle="modal" data-target="#delete' . $id . '">' . $btn_name . '</a>'; $button = '<a href="#delete" class="'.$class.'" data-toggle="modal" data-target="#delete'.$id.'">'.$btn_name.'</a>';
} }
return $button . '<div class="modal fade" id="delete' . $id . '">
return $button.'<div class="modal fade" id="delete'.$id.'">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">' . $title . '</h4> <h4 class="modal-title">'.$title.'</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="row"> <div class="row">
@@ -98,23 +113,26 @@ function deletePopUp($id, $url, $title = "Delete", $class = "btn btn-sm btn-dang
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" id="close" class="btn btn-default pull-left" data-dismiss="modal">Close</button> <button type="button" id="close" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
<a href="' . $url . '" class="btn btn-danger">Delete</a> <a href="'.$url.'" class="btn btn-danger">Delete</a>
</div> </div>
</div> </div>
</div> </div>
</div>'; </div>';
} }
function isInstall() { function isInstall()
{
$check = false; $check = false;
$env = base_path('.env'); $env = base_path('.env');
if (\File::exists($env) && env('DB_INSTALL') == 1) { if (\File::exists($env) && env('DB_INSTALL') == 1) {
$check = true; $check = true;
} }
return $check; return $check;
} }
function faveotime($date, $hour = 0, $min = 0, $sec = 0) { function faveotime($date, $hour = 0, $min = 0, $sec = 0)
{
if (is_bool($hour) && $hour == true) { if (is_bool($hour) && $hour == true) {
$hour = $date->hour; $hour = $date->hour;
} }
@@ -125,5 +143,6 @@ function faveotime($date, $hour = 0, $min = 0, $sec = 0) {
$sec = $date->second; $sec = $date->second;
} }
$date1 = \Carbon\Carbon::create($date->year, $date->month, $date->day, $hour, $min, $sec); $date1 = \Carbon\Carbon::create($date->year, $date->month, $date->day, $hour, $min, $sec);
return $date1->hour($hour)->minute($min)->second($sec); return $date1->hour($hour)->minute($min)->second($sec);
} }

View File

@@ -11,15 +11,14 @@
| |
*/ */
Route::group(['middleware' => ['web']], function () { Route::group(['middleware' => ['web']], function () {
Route::group(['middleware' => 'update', 'middleware' => 'install'], function () { Route::group(['middleware' => 'update', 'middleware' => 'install'], function () {
Route::controllers([ Route::controllers([
'auth' => 'Auth\AuthController', 'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController', 'password' => 'Auth\PasswordController',
]); ]);
Route::get('social/login/redirect/{provider}/{redirect?}', ['uses' => 'Auth\AuthController@redirectToProvider', 'as' => 'social.login']); Route::get('social/login/redirect/{provider}/{redirect?}', ['uses' => 'Auth\AuthController@redirectToProvider', 'as' => 'social.login']);
Route::get('social/login/{provider}', ['as'=>'social.login.callback','uses'=>'Auth\AuthController@handleProviderCallback']); Route::get('social/login/{provider}', ['as'=>'social.login.callback', 'uses'=>'Auth\AuthController@handleProviderCallback']);
Route::get('social-sync', ['as'=>'social.sync','uses'=>'Client\helpdesk\GuestController@sync']); Route::get('social-sync', ['as'=>'social.sync', 'uses'=>'Client\helpdesk\GuestController@sync']);
}); });
/* /*
@@ -29,44 +28,29 @@ Route::group(['middleware' => ['web']], function () {
| Here is defining entire routes for the Admin Panel | Here is defining entire routes for the Admin Panel
| |
*/ */
Route::get('password/email/{one?}/{two?}/{three?}/{four?}/{five?}',['as' => 'password.email', 'uses' => 'Auth\PasswordController@getEmail']); Route::get('password/email/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'password.email', 'uses' => 'Auth\PasswordController@getEmail']);
Breadcrumbs::register('password.email', function ($breadcrumbs) { Breadcrumbs::register('password.email', function ($breadcrumbs) {
$breadcrumbs->parent('/'); $breadcrumbs->parent('/');
$breadcrumbs->push('Login', url('auth/login')); $breadcrumbs->push('Login', url('auth/login'));
$breadcrumbs->push('Forgot Password', url('password/email')); $breadcrumbs->push('Forgot Password', url('password/email'));
}); });
// register page // register page
Route::get('auth/register/{one?}/{two?}/{three?}/{four?}/{five?}',['as' => 'auth.register', 'uses' => 'Auth\AuthController@getRegister']); Route::get('auth/register/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@getRegister']);
Breadcrumbs::register('auth.register', function ($breadcrumbs) { Breadcrumbs::register('auth.register', function ($breadcrumbs) {
$breadcrumbs->parent('/'); $breadcrumbs->parent('/');
$breadcrumbs->push('Login', url('auth/login')); $breadcrumbs->push('Login', url('auth/login'));
$breadcrumbs->push('Create Account', url('auth/register')); $breadcrumbs->push('Create Account', url('auth/register'));
}); });
// Auth login // Auth login
Route::get('auth/login/{one?}/{two?}/{three?}/{four?}/{five?}',['as' => 'auth.login', 'uses' => 'Auth\AuthController@getLogin']); Route::get('auth/login/{one?}/{two?}/{three?}/{four?}/{five?}', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@getLogin']);
Breadcrumbs::register('auth.login', function ($breadcrumbs) { Breadcrumbs::register('auth.login', function ($breadcrumbs) {
$breadcrumbs->parent('/'); $breadcrumbs->parent('/');
$breadcrumbs->push('Create Account', url('auth/register')); $breadcrumbs->push('Create Account', url('auth/register'));
$breadcrumbs->push('Login', url('auth/login')); $breadcrumbs->push('Login', url('auth/login'));
});
});
Route::get('account/activate/{token}', ['as' => 'account.activate', 'uses' => 'Auth\AuthController@accountActivate']); Route::get('account/activate/{token}', ['as' => 'account.activate', 'uses' => 'Auth\AuthController@accountActivate']);
Route::get('getmail/{token}', 'Auth\AuthController@getMail'); Route::get('getmail/{token}', 'Auth\AuthController@getMail');
Route::get('verify-otp', ['as' => 'otp-verification', 'uses' => 'Auth\AuthController@getVerifyOTP']); Route::get('verify-otp', ['as' => 'otp-verification', 'uses' => 'Auth\AuthController@getVerifyOTP']);
@@ -84,7 +68,7 @@ Route::group(['middleware' => ['web']], function () {
//Notification marking //Notification marking
Route::post('mark-read/{id}', 'Common\NotificationController@markRead'); Route::post('mark-read/{id}', 'Common\NotificationController@markRead');
Route::post('mark-all-read/{id}', 'Common\NotificationController@markAllRead'); Route::post('mark-all-read/{id}', 'Common\NotificationController@markAllRead');
Route::get('notifications-list', ['as' => 'notification.list', 'uses' => 'Common\NotificationController@show']); Route::get('notifications-list', ['as' => 'notification.list', 'uses' => 'Common\NotificationController@show']);
Route::post('notification-delete/{id}', ['as' => 'notification.delete', 'uses' => 'Common\NotificationController@delete']); Route::post('notification-delete/{id}', ['as' => 'notification.delete', 'uses' => 'Common\NotificationController@delete']);
Route::get('notifications-list/delete', ['as' => 'notification.delete.all', 'uses' => 'Common\NotificationController@deleteAll']); Route::get('notifications-list/delete', ['as' => 'notification.delete.all', 'uses' => 'Common\NotificationController@deleteAll']);
@@ -94,27 +78,27 @@ Route::group(['middleware' => ['web']], function () {
Route::post('delete-notification-log', 'Admin\helpdesk\SettingsController@deleteNotificationLog'); Route::post('delete-notification-log', 'Admin\helpdesk\SettingsController@deleteNotificationLog');
// resource is a function to process create,edit,read and delete // resource is a function to process create,edit,read and delete
Route::resource('groups', 'Admin\helpdesk\GroupController'); // for group module, for CRUD Route::resource('groups', 'Admin\helpdesk\GroupController'); // for group module, for CRUD
Route::resource('departments', 'Admin\helpdesk\DepartmentController'); // for departments module, for CRUD Route::resource('departments', 'Admin\helpdesk\DepartmentController'); // for departments module, for CRUD
Route::resource('teams', 'Admin\helpdesk\TeamController'); // in teams module, for CRUD Route::resource('teams', 'Admin\helpdesk\TeamController'); // in teams module, for CRUD
Route::get('/teams/show/{id}', ['as' => 'teams.show', 'uses' => 'Admin\helpdesk\TeamController@show']); /* Get Team View */ Route::get('/teams/show/{id}', ['as' => 'teams.show', 'uses' => 'Admin\helpdesk\TeamController@show']); /* Get Team View */
Breadcrumbs::register('teams.show', function ($breadcrumbs) { Breadcrumbs::register('teams.show', function ($breadcrumbs) {
$breadcrumbs->parent('teams.index'); $breadcrumbs->parent('teams.index');
$breadcrumbs->push(Lang::get('lang.show'), url('teams/{teams}/show')); $breadcrumbs->push(Lang::get('lang.show'), url('teams/{teams}/show'));
}); });
Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpdesk\TeamController@getshow']); Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpdesk\TeamController@getshow']);
Route::resource('agents', 'Admin\helpdesk\AgentController'); // in agents module, for CRUD Route::resource('agents', 'Admin\helpdesk\AgentController'); // in agents module, for CRUD
Route::resource('emails', 'Admin\helpdesk\EmailsController'); // in emails module, for CRUD Route::resource('emails', 'Admin\helpdesk\EmailsController'); // in emails module, for CRUD
Route::resource('banlist', 'Admin\helpdesk\BanlistController'); // in banlist module, for CRUD Route::resource('banlist', 'Admin\helpdesk\BanlistController'); // in banlist module, for CRUD
Route::get('banlist/delete/{id}', ['as' => 'banlist.delete', 'uses' => 'Admin\helpdesk\BanlistController@delete']); // in banlist module, for CRUD Route::get('banlist/delete/{id}', ['as' => 'banlist.delete', 'uses' => 'Admin\helpdesk\BanlistController@delete']); // in banlist module, for CRUD
/* /*
* Templates * Templates
*/ */
Route::resource('templates', 'Common\TemplateController'); Route::resource('templates', 'Common\TemplateController');
Route::get('get-templates', 'Common\TemplateController@GetTemplates'); Route::get('get-templates', 'Common\TemplateController@GetTemplates');
Route::get('templates-delete', 'Common\TemplateController@destroy'); Route::get('templates-delete', 'Common\TemplateController@destroy');
@@ -132,96 +116,96 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
Route::post('create-templates', ['as' => 'template.createnew', 'uses' => 'Admin\helpdesk\TemplateController@createtemplate']); Route::post('create-templates', ['as' => 'template.createnew', 'uses' => 'Admin\helpdesk\TemplateController@createtemplate']);
Route::get('delete-template/{template}/{path}', ['as' => 'templates.delete', 'uses' => 'Admin\helpdesk\TemplateController@deletetemplate']); Route::get('delete-template/{template}/{path}', ['as' => 'templates.delete', 'uses' => 'Admin\helpdesk\TemplateController@deletetemplate']);
Route::get('getdiagno', ['as' => 'getdiagno', 'uses' => 'Admin\helpdesk\TemplateController@formDiagno']); // for getting form for diagnostic Route::get('getdiagno', ['as' => 'getdiagno', 'uses' => 'Admin\helpdesk\TemplateController@formDiagno']); // for getting form for diagnostic
Route::post('postdiagno', ['as' => 'postdiagno', 'uses' => 'Admin\helpdesk\TemplateController@postDiagno']); // for getting form for diagnostic Route::post('postdiagno', ['as' => 'postdiagno', 'uses' => 'Admin\helpdesk\TemplateController@postDiagno']); // for getting form for diagnostic
Route::resource('helptopic', 'Admin\helpdesk\HelptopicController'); // in helptopics module, for CRUD Route::resource('helptopic', 'Admin\helpdesk\HelptopicController'); // in helptopics module, for CRUD
Route::resource('sla', 'Admin\helpdesk\SlaController'); // in SLA Plan module, for CRUD Route::resource('sla', 'Admin\helpdesk\SlaController'); // in SLA Plan module, for CRUD
Route::resource('forms', 'Admin\helpdesk\FormController'); Route::resource('forms', 'Admin\helpdesk\FormController');
Route::get('forms/add-child/{formid}', ['as' => 'forms.add.child', 'uses' => 'Admin\helpdesk\FormController@addChildForm']); Route::get('forms/add-child/{formid}', ['as' => 'forms.add.child', 'uses' => 'Admin\helpdesk\FormController@addChildForm']);
Route::post('forms/field/{fieldid}/child', [ Route::post('forms/field/{fieldid}/child', [
'as' => 'forms.field.child', 'as' => 'forms.field.child',
'uses' => 'Admin\helpdesk\FormController@addChild', 'uses' => 'Admin\helpdesk\FormController@addChild',
]); ]);
Route::get('forms/render/child', [ Route::get('forms/render/child', [
'as' => 'forms.field.child', 'as' => 'forms.field.child',
'uses' => 'Admin\helpdesk\FormController@renderChild', 'uses' => 'Admin\helpdesk\FormController@renderChild',
]); ]);
Route::get('delete-forms/{id}', ['as' => 'forms.delete', 'uses' => 'Admin\helpdesk\FormController@delete']); Route::get('delete-forms/{id}', ['as' => 'forms.delete', 'uses' => 'Admin\helpdesk\FormController@delete']);
//$router->model('id','getcompany'); //$router->model('id','getcompany');
Route::get('job-scheduler', ['as' => 'get.job.scheder', 'uses' => 'Admin\helpdesk\SettingsController@getSchedular']); //to get ob scheduler form page Route::get('job-scheduler', ['as' => 'get.job.scheder', 'uses' => 'Admin\helpdesk\SettingsController@getSchedular']); //to get ob scheduler form page
Route::patch('post-scheduler', ['as' => 'post.job.scheduler', 'uses' => 'Admin\helpdesk\SettingsController@postSchedular']); //to update job scheduler Route::patch('post-scheduler', ['as' => 'post.job.scheduler', 'uses' => 'Admin\helpdesk\SettingsController@postSchedular']); //to update job scheduler
Route::get('agent-profile-page/{id}', ['as' => 'agent.profile.page', 'uses' => 'Admin\helpdesk\AgentController@agent_profile']); Route::get('agent-profile-page/{id}', ['as' => 'agent.profile.page', 'uses' => 'Admin\helpdesk\AgentController@agent_profile']);
Route::get('getcompany', ['as' => 'getcompany', 'uses' => 'Admin\helpdesk\SettingsController@getcompany']); // direct to company setting page Route::get('getcompany', ['as' => 'getcompany', 'uses' => 'Admin\helpdesk\SettingsController@getcompany']); // direct to company setting page
Route::patch('postcompany/{id}', 'Admin\helpdesk\SettingsController@postcompany'); // Updating the Company table with requests Route::patch('postcompany/{id}', 'Admin\helpdesk\SettingsController@postcompany'); // Updating the Company table with requests
Route::get('delete-logo', ['as' => 'delete.logo', 'uses' => 'Admin\helpdesk\SettingsController@deleteLogo']); // deleting a logo Route::get('delete-logo', ['as' => 'delete.logo', 'uses' => 'Admin\helpdesk\SettingsController@deleteLogo']); // deleting a logo
Route::get('getsystem', ['as' => 'getsystem', 'uses' => 'Admin\helpdesk\SettingsController@getsystem']); // direct to system setting page Route::get('getsystem', ['as' => 'getsystem', 'uses' => 'Admin\helpdesk\SettingsController@getsystem']); // direct to system setting page
Route::patch('postsystem/{id}', 'Admin\helpdesk\SettingsController@postsystem'); // Updating the System table with requests Route::patch('postsystem/{id}', 'Admin\helpdesk\SettingsController@postsystem'); // Updating the System table with requests
Route::get('getticket', ['as' => 'getticket', 'uses' => 'Admin\helpdesk\SettingsController@getticket']); // direct to ticket setting page Route::get('getticket', ['as' => 'getticket', 'uses' => 'Admin\helpdesk\SettingsController@getticket']); // direct to ticket setting page
Route::patch('postticket/{id}', 'Admin\helpdesk\SettingsController@postticket'); // Updating the Ticket table with requests Route::patch('postticket/{id}', 'Admin\helpdesk\SettingsController@postticket'); // Updating the Ticket table with requests
Route::get('getemail', ['as' => 'getemail', 'uses' => 'Admin\helpdesk\SettingsController@getemail']); // direct to email setting page Route::get('getemail', ['as' => 'getemail', 'uses' => 'Admin\helpdesk\SettingsController@getemail']); // direct to email setting page
Route::get('ticket/tooltip',['as'=>'ticket.tooltip','uses'=>'Agent\helpdesk\TicketController@getTooltip']); Route::get('ticket/tooltip', ['as'=>'ticket.tooltip', 'uses'=>'Agent\helpdesk\TicketController@getTooltip']);
Route::patch('postemail/{id}', 'Admin\helpdesk\SettingsController@postemail'); // Updating the Email table with requests Route::patch('postemail/{id}', 'Admin\helpdesk\SettingsController@postemail'); // Updating the Email table with requests
// Route::get('getaccess', 'Admin\helpdesk\SettingsController@getaccess'); // direct to access setting page // Route::get('getaccess', 'Admin\helpdesk\SettingsController@getaccess'); // direct to access setting page
// Route::patch('postaccess/{id}', 'Admin\helpdesk\SettingsController@postaccess'); // Updating the Access table with requests // Route::patch('postaccess/{id}', 'Admin\helpdesk\SettingsController@postaccess'); // Updating the Access table with requests
Route::get('getresponder', ['as' => 'getresponder', 'uses' => 'Admin\helpdesk\SettingsController@getresponder']); // direct to responder setting page Route::get('getresponder', ['as' => 'getresponder', 'uses' => 'Admin\helpdesk\SettingsController@getresponder']); // direct to responder setting page
Route::patch('postresponder/{id}', 'Admin\helpdesk\SettingsController@postresponder'); // Updating the Responder table with requests Route::patch('postresponder/{id}', 'Admin\helpdesk\SettingsController@postresponder'); // Updating the Responder table with requests
Route::get('getalert', ['as' => 'getalert', 'uses' => 'Admin\helpdesk\SettingsController@getalert']); // direct to alert setting page Route::get('getalert', ['as' => 'getalert', 'uses' => 'Admin\helpdesk\SettingsController@getalert']); // direct to alert setting page
Route::patch('postalert/{id}', 'Admin\helpdesk\SettingsController@postalert'); // Updating the Alert table with requests Route::patch('postalert/{id}', 'Admin\helpdesk\SettingsController@postalert'); // Updating the Alert table with requests
// Templates // Templates
Route::get('security', ['as' => 'security.index', 'uses' => 'Admin\helpdesk\SecurityController@index']); // direct to security setting page Route::get('security', ['as' => 'security.index', 'uses' => 'Admin\helpdesk\SecurityController@index']); // direct to security setting page
Route::resource('close-workflow', 'Admin\helpdesk\CloseWrokflowController'); // direct to security setting page Route::resource('close-workflow', 'Admin\helpdesk\CloseWrokflowController'); // direct to security setting page
Route::resource('close-workflow', 'Admin\helpdesk\CloseWrokflowController'); // direct to security setting page Route::resource('close-workflow', 'Admin\helpdesk\CloseWrokflowController'); // direct to security setting page
Route::patch('security/{id}', ['as' => 'securitys.update', 'uses' => 'Admin\helpdesk\SecurityController@update']); // direct to security setting page Route::patch('security/{id}', ['as' => 'securitys.update', 'uses' => 'Admin\helpdesk\SecurityController@update']); // direct to security setting page
Route::get('setting-status', ['as' => 'statuss.index', 'uses' => 'Admin\helpdesk\SettingsController@getStatuses']); // direct to status setting page Route::get('setting-status', ['as' => 'statuss.index', 'uses' => 'Admin\helpdesk\SettingsController@getStatuses']); // direct to status setting page
Route::patch('status-update/{id}', ['as' => 'statuss.update', 'uses' => 'Admin\helpdesk\SettingsController@editStatuses']); Route::patch('status-update/{id}', ['as' => 'statuss.update', 'uses' => 'Admin\helpdesk\SettingsController@editStatuses']);
Route::get('status/edit/{id}', ['as' => 'status.edit', 'uses' => 'Admin\helpdesk\SettingsController@getEditStatuses']); Route::get('status/edit/{id}', ['as' => 'status.edit', 'uses' => 'Admin\helpdesk\SettingsController@getEditStatuses']);
Route::post('status-create', ['as' => 'statuss.create', 'uses' => 'Admin\helpdesk\SettingsController@createStatuses']); Route::post('status-create', ['as' => 'statuss.create', 'uses' => 'Admin\helpdesk\SettingsController@createStatuses']);
Route::get('status-delete/{id}', ['as' => 'statuss.delete', 'uses' => 'Admin\helpdesk\SettingsController@deleteStatuses']); Route::get('status-delete/{id}', ['as' => 'statuss.delete', 'uses' => 'Admin\helpdesk\SettingsController@deleteStatuses']);
Route::get('ticket/status/{id}/{state}', ['as' => 'statuss.state', 'uses' => 'Agent\helpdesk\TicketController@updateStatuses']); Route::get('ticket/status/{id}/{state}', ['as' => 'statuss.state', 'uses' => 'Agent\helpdesk\TicketController@updateStatuses']);
Route::get('getratings', ['as' => 'ratings.index', 'uses' => 'Admin\helpdesk\SettingsController@RatingSettings']); Route::get('getratings', ['as' => 'ratings.index', 'uses' => 'Admin\helpdesk\SettingsController@RatingSettings']);
Route::get('deleter/{rating}', ['as' => 'ratings.delete', 'uses' => 'Admin\helpdesk\SettingsController@RatingDelete']); Route::get('deleter/{rating}', ['as' => 'ratings.delete', 'uses' => 'Admin\helpdesk\SettingsController@RatingDelete']);
Route::get('create-ratings', ['as' => 'rating.create', 'uses' => 'Admin\helpdesk\SettingsController@createRating']); Route::get('create-ratings', ['as' => 'rating.create', 'uses' => 'Admin\helpdesk\SettingsController@createRating']);
Route::post('store-ratings', ['as' => 'rating.store', 'uses' => 'Admin\helpdesk\SettingsController@storeRating']); Route::post('store-ratings', ['as' => 'rating.store', 'uses' => 'Admin\helpdesk\SettingsController@storeRating']);
Route::get('editratings/{slug}', ['as' => 'rating.edit', 'uses' => 'Admin\helpdesk\SettingsController@editRatingSettings']); Route::get('editratings/{slug}', ['as' => 'rating.edit', 'uses' => 'Admin\helpdesk\SettingsController@editRatingSettings']);
Route::patch('postratings/{slug}', ['as' => 'settings.rating', 'uses' => 'Admin\helpdesk\SettingsController@PostRatingSettings']); Route::patch('postratings/{slug}', ['as' => 'settings.rating', 'uses' => 'Admin\helpdesk\SettingsController@PostRatingSettings']);
Route::get('remove-user-org/{id}', ['as' => 'removeuser.org', 'uses' => 'Agent\helpdesk\UserController@removeUserOrg']); Route::get('remove-user-org/{id}', ['as' => 'removeuser.org', 'uses' => 'Agent\helpdesk\UserController@removeUserOrg']);
Route::get('admin-profile', ['as' => 'admin-profile', 'uses' => 'Admin\helpdesk\ProfileController@getProfile']); /* User profile edit get */ Route::get('admin-profile', ['as' => 'admin-profile', 'uses' => 'Admin\helpdesk\ProfileController@getProfile']); /* User profile edit get */
Route::get('admin-profile-edit', 'Admin\helpdesk\ProfileController@getProfileedit'); /* Admin profile get */ Route::get('admin-profile-edit', 'Admin\helpdesk\ProfileController@getProfileedit'); /* Admin profile get */
Route::patch('admin-profile', 'Admin\helpdesk\ProfileController@postProfileedit'); /* Admin Profile Post */ Route::patch('admin-profile', 'Admin\helpdesk\ProfileController@postProfileedit'); /* Admin Profile Post */
Route::patch('admin-profile-password', 'Admin\helpdesk\ProfileController@postProfilePassword'); /* Admin Profile Password Post */ Route::patch('admin-profile-password', 'Admin\helpdesk\ProfileController@postProfilePassword'); /* Admin Profile Password Post */
Route::get('widgets', ['as' => 'widgets', 'uses' => 'Common\SettingsController@widgets']); /* get the create footer page for admin */ Route::get('widgets', ['as' => 'widgets', 'uses' => 'Common\SettingsController@widgets']); /* get the create footer page for admin */
Route::get('list-widget', 'Common\SettingsController@list_widget'); /* get the list widget page for admin */ Route::get('list-widget', 'Common\SettingsController@list_widget'); /* get the list widget page for admin */
Route::post('edit-widget/{id}', 'Common\SettingsController@edit_widget'); /* get the create footer page for admin */ Route::post('edit-widget/{id}', 'Common\SettingsController@edit_widget'); /* get the create footer page for admin */
Route::get('social-buttons', ['as' => 'social.buttons', 'uses' => 'Common\SettingsController@social_buttons']); /* get the create footer page for admin */ Route::get('social-buttons', ['as' => 'social.buttons', 'uses' => 'Common\SettingsController@social_buttons']); /* get the create footer page for admin */
Route::get('list-social-buttons', ['as' => 'list.social.buttons', 'uses' => 'Common\SettingsController@list_social_buttons']); /* get the list widget page for admin */ Route::get('list-social-buttons', ['as' => 'list.social.buttons', 'uses' => 'Common\SettingsController@list_social_buttons']); /* get the list widget page for admin */
Route::post('edit-widget/{id}', 'Common\SettingsController@edit_social_buttons'); /* get the create footer page for admin */ Route::post('edit-widget/{id}', 'Common\SettingsController@edit_social_buttons'); /* get the create footer page for admin */
Route::get('version-check', ['as' => 'version-check', 'uses' => 'Common\SettingsController@version_check']); /* Check version */ Route::get('version-check', ['as' => 'version-check', 'uses' => 'Common\SettingsController@version_check']); /* Check version */
Route::post('post-version-check', ['as' => 'post-version-check', 'uses' => 'Common\SettingsController@post_version_check']); /* post Check version */ Route::post('post-version-check', ['as' => 'post-version-check', 'uses' => 'Common\SettingsController@post_version_check']); /* post Check version */
Route::get('admin', ['as' => 'setting', 'uses' => 'Admin\helpdesk\SettingsController@settings']); Route::get('admin', ['as' => 'setting', 'uses' => 'Admin\helpdesk\SettingsController@settings']);
Route::get('plugins', ['as' => 'plugins', 'uses' => 'Common\SettingsController@Plugins']); Route::get('plugins', ['as' => 'plugins', 'uses' => 'Common\SettingsController@Plugins']);
Route::get('getplugin', ['as' => 'get.plugin', 'uses' => 'Common\SettingsController@GetPlugin']); Route::get('getplugin', ['as' => 'get.plugin', 'uses' => 'Common\SettingsController@GetPlugin']);
Route::post('post-plugin', ['as' => 'post.plugin', 'uses' => 'Common\SettingsController@PostPlugins']); Route::post('post-plugin', ['as' => 'post.plugin', 'uses' => 'Common\SettingsController@PostPlugins']);
Route::get('getconfig', ['as' => 'get.config', 'uses' => 'Common\SettingsController@fetchConfig']); Route::get('getconfig', ['as' => 'get.config', 'uses' => 'Common\SettingsController@fetchConfig']);
@@ -229,7 +213,7 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
Route::get('plugin/status/{slug}', ['as' => 'status.plugin', 'uses' => 'Common\SettingsController@StatusPlugin']); Route::get('plugin/status/{slug}', ['as' => 'status.plugin', 'uses' => 'Common\SettingsController@StatusPlugin']);
//Routes for showing language table and switching language //Routes for showing language table and switching language
Route::get('languages', ['as' => 'LanguageController', 'uses' => 'Admin\helpdesk\LanguageController@index']); Route::get('languages', ['as' => 'LanguageController', 'uses' => 'Admin\helpdesk\LanguageController@index']);
Route::get('get-languages', ['as' => 'getAllLanguages', 'uses' => 'Admin\helpdesk\LanguageController@getLanguages']); Route::get('get-languages', ['as' => 'getAllLanguages', 'uses' => 'Admin\helpdesk\LanguageController@getLanguages']);
Route::get('change-language/{lang}', ['as' => 'lang.switch', 'uses' => 'Admin\helpdesk\LanguageController@switchLanguage']); Route::get('change-language/{lang}', ['as' => 'lang.switch', 'uses' => 'Admin\helpdesk\LanguageController@switchLanguage']);
//Route for download language template package //Route for download language template package
@@ -237,20 +221,20 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
//Routes for language file upload form-----------You may want to use csrf protection for these route-------------- //Routes for language file upload form-----------You may want to use csrf protection for these route--------------
Route::post('language/add', 'Admin\helpdesk\LanguageController@postForm'); Route::post('language/add', 'Admin\helpdesk\LanguageController@postForm');
Route::get('language/add', ['as' => 'add-language', 'uses' => 'Admin\helpdesk\LanguageController@getForm']); Route::get('language/add', ['as' => 'add-language', 'uses' => 'Admin\helpdesk\LanguageController@getForm']);
//Routes for delete language package //Routes for delete language package
Route::get('delete-language/{lang}', ['as' => 'lang.delete', 'uses' => 'Admin\helpdesk\LanguageController@deleteLanguage']); Route::get('delete-language/{lang}', ['as' => 'lang.delete', 'uses' => 'Admin\helpdesk\LanguageController@deleteLanguage']);
Route::get('generate-api-key', 'Admin\helpdesk\SettingsController@GenerateApiKey'); // route to generate api key Route::get('generate-api-key', 'Admin\helpdesk\SettingsController@GenerateApiKey'); // route to generate api key
Route::post('validating-email-settings', ['as' => 'validating.email.settings', 'uses' => 'Admin\helpdesk\EmailsController@validatingEmailSettings']); // route to check email input validation Route::post('validating-email-settings', ['as' => 'validating.email.settings', 'uses' => 'Admin\helpdesk\EmailsController@validatingEmailSettings']); // route to check email input validation
Route::post('validating-email-settings-on-update/{id}', ['as' => 'validating.email.settings.update', 'uses' => 'Admin\helpdesk\EmailsController@validatingEmailSettingsUpdate']); // route to check email input validation Route::post('validating-email-settings-on-update/{id}', ['as' => 'validating.email.settings.update', 'uses' => 'Admin\helpdesk\EmailsController@validatingEmailSettingsUpdate']); // route to check email input validation
Route::get('workflow', ['as' => 'workflow', 'uses' => 'Admin\helpdesk\WorkflowController@index']); Route::get('workflow', ['as' => 'workflow', 'uses' => 'Admin\helpdesk\WorkflowController@index']);
Route::get('workflow-list', ['as' => 'workflow.list', 'uses' => 'Admin\helpdesk\WorkflowController@workFlowList']); Route::get('workflow-list', ['as' => 'workflow.list', 'uses' => 'Admin\helpdesk\WorkflowController@workFlowList']);
Route::get('workflow/create', ['as' => 'workflow.create', 'uses' => 'Admin\helpdesk\WorkflowController@create']); Route::get('workflow/create', ['as' => 'workflow.create', 'uses' => 'Admin\helpdesk\WorkflowController@create']);
Route::post('workflow/store', ['as' => 'workflow.store', 'uses' => 'Admin\helpdesk\WorkflowController@store']); Route::post('workflow/store', ['as' => 'workflow.store', 'uses' => 'Admin\helpdesk\WorkflowController@store']);
Route::get('workflow/edit/{id}', ['as' => 'workflow.edit', 'uses' => 'Admin\helpdesk\WorkflowController@edit']); Route::get('workflow/edit/{id}', ['as' => 'workflow.edit', 'uses' => 'Admin\helpdesk\WorkflowController@edit']);
Route::post('workflow/update/{id}', ['as' => 'workflow.update', 'uses' => 'Admin\helpdesk\WorkflowController@update']); Route::post('workflow/update/{id}', ['as' => 'workflow.update', 'uses' => 'Admin\helpdesk\WorkflowController@update']);
Route::get('workflow/action-rule/{id}', ['as' => 'workflow.dept', 'uses' => 'Admin\helpdesk\WorkflowController@selectAction']); Route::get('workflow/action-rule/{id}', ['as' => 'workflow.dept', 'uses' => 'Admin\helpdesk\WorkflowController@selectAction']);
Route::get('workflow/delete/{id}', ['as' => 'workflow.delete', 'uses' => 'Admin\helpdesk\WorkflowController@destroy']); Route::get('workflow/delete/{id}', ['as' => 'workflow.delete', 'uses' => 'Admin\helpdesk\WorkflowController@destroy']);
@@ -258,23 +242,23 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
* Api Settings * Api Settings
*/ */
Route::get('api', ['as' => 'api.settings.get', 'uses' => 'Common\ApiSettings@show']); Route::get('api', ['as' => 'api.settings.get', 'uses' => 'Common\ApiSettings@show']);
Route::post('api', ['as' => 'api.settings.post', 'uses' => 'Common\ApiSettings@postSettings']); Route::post('api', ['as' => 'api.settings.post', 'uses' => 'Common\ApiSettings@postSettings']);
/* /*
* Error and debugging * Error and debugging
*/ */
//route for showing error and debugging setting form page //route for showing error and debugging setting form page
Route::get('error-and-debugging-options', ['as' => 'err.debug.settings', 'uses' => 'Admin\helpdesk\ErrorAndDebuggingController@showSettings']); Route::get('error-and-debugging-options', ['as' => 'err.debug.settings', 'uses' => 'Admin\helpdesk\ErrorAndDebuggingController@showSettings']);
//route for submit error and debugging setting form page //route for submit error and debugging setting form page
Route::post('post-settings', ['as' => 'post.error.debug.settings', Route::post('post-settings', ['as' => 'post.error.debug.settings',
'uses' => 'Admin\helpdesk\ErrorAndDebuggingController@postSettings',]); 'uses' => 'Admin\helpdesk\ErrorAndDebuggingController@postSettings', ]);
//route to error logs table page //route to error logs table page
Route::get('show-error-logs', [ Route::get('show-error-logs', [
'as' => 'error.logs', 'as' => 'error.logs',
'uses' => 'Admin\helpdesk\ErrorAndDebuggingController@showErrorLogs', 'uses' => 'Admin\helpdesk\ErrorAndDebuggingController@showErrorLogs',
]); ]);
/* /*
* Approval * Approval
*/ */
@@ -282,18 +266,17 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
Route::post('settingsUpdateApproval/settings', ['as' => 'settingsUpdateApproval.settings', 'uses' => 'Agent\helpdesk\TicketController@settingsUpdateApproval']); Route::post('settingsUpdateApproval/settings', ['as' => 'settingsUpdateApproval.settings', 'uses' => 'Agent\helpdesk\TicketController@settingsUpdateApproval']);
Route::get('/ticket/approval/closed', ['as' => 'closed.approvel.ticket', 'uses' => 'Agent\helpdesk\TicketController@approverClosedTicketList']); /* Get Closed Ticket */ Route::get('/ticket/approval/closed', ['as' => 'closed.approvel.ticket', 'uses' => 'Agent\helpdesk\TicketController@approverClosedTicketList']); /* Get Closed Ticket */
Route::get('/ticket/get-approval', ['as' => 'get.approval.ticket', 'uses' => 'Agent\helpdesk\TicketController@getApproval']); /* Get tickets in datatable */ Route::get('/ticket/get-approval', ['as' => 'get.approval.ticket', 'uses' => 'Agent\helpdesk\TicketController@getApproval']); /* Get tickets in datatable */
Route::get('/ticket/close/get-approval/{id}', ['as' => 'get.close.approval.ticket', 'uses' => 'Agent\helpdesk\TicketController@getCloseapproval']); /* Get tickets in datatable */ Route::get('/ticket/close/get-approval/{id}', ['as' => 'get.close.approval.ticket', 'uses' => 'Agent\helpdesk\TicketController@getCloseapproval']); /* Get tickets in datatable */
/** /*
* Labels * Labels
*/ */
Route::resource('labels','Admin\helpdesk\Label\LabelController'); Route::resource('labels', 'Admin\helpdesk\Label\LabelController');
Route::get('labels-ajax',['as'=>'labels.ajax','uses'=>'Admin\helpdesk\Label\LabelController@ajaxTable']); Route::get('labels-ajax', ['as'=>'labels.ajax', 'uses'=>'Admin\helpdesk\Label\LabelController@ajaxTable']);
Route::get('labels/delete/{id}', ['as' => 'labels.destroy', 'uses' => 'Admin\helpdesk\Label\LabelController@destroy']); Route::get('labels/delete/{id}', ['as' => 'labels.destroy', 'uses' => 'Admin\helpdesk\Label\LabelController@destroy']);
}); });
/* /*
|------------------------------------------------------------------ |------------------------------------------------------------------
@@ -315,15 +298,12 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
Route::get('user-export', ['as' => 'user.export', 'uses' => 'Agent\helpdesk\UserController@getExportUser']); /* User router is used to control the CRUD of user */ Route::get('user-export', ['as' => 'user.export', 'uses' => 'Agent\helpdesk\UserController@getExportUser']); /* User router is used to control the CRUD of user */
Route::post('user-export', ['as' => 'user.export.post', 'uses' => 'Agent\helpdesk\UserController@exportUser']); /* User router is used to control the CRUD of user */ Route::post('user-export', ['as' => 'user.export.post', 'uses' => 'Agent\helpdesk\UserController@exportUser']); /* User router is used to control the CRUD of user */
Route::get('user-list', ['as' => 'user.list', 'uses' => 'Agent\helpdesk\UserController@user_list']); Route::get('user-list', ['as' => 'user.list', 'uses' => 'Agent\helpdesk\UserController@user_list']);
// Route::get('user/delete/{id}', ['as' => 'user.delete' , 'uses' => 'Agent\helpdesk\UserController@destroy']); // Route::get('user/delete/{id}', ['as' => 'user.delete' , 'uses' => 'Agent\helpdesk\UserController@destroy']);
Route::resource('organizations', 'Agent\helpdesk\OrganizationController'); /* organization router used to deal CRUD function of organization */ Route::resource('organizations', 'Agent\helpdesk\OrganizationController'); /* organization router used to deal CRUD function of organization */
Route::get('get-organization', ['as' => 'org.get.ajax', 'uses' => 'Agent\helpdesk\OrganizationController@getOrgAjax']); Route::get('get-organization', ['as' => 'org.get.ajax', 'uses' => 'Agent\helpdesk\OrganizationController@getOrgAjax']);
Route::get('org-list', ['as' => 'org.list', 'uses' => 'Agent\helpdesk\OrganizationController@org_list']); Route::get('org-list', ['as' => 'org.list', 'uses' => 'Agent\helpdesk\OrganizationController@org_list']);
Route::get('organization-autofill', ['as' => 'post.organization.autofill', 'uses' => 'Agent\helpdesk\OrganizationController@organizationAutofill']); //auto fill organization name Route::get('organization-autofill', ['as' => 'post.organization.autofill', 'uses' => 'Agent\helpdesk\OrganizationController@organizationAutofill']); //auto fill organization name
Route::get('org/delete/{id}', ['as' => 'org.delete', 'uses' => 'Agent\helpdesk\OrganizationController@destroy']); Route::get('org/delete/{id}', ['as' => 'org.delete', 'uses' => 'Agent\helpdesk\OrganizationController@destroy']);
@@ -331,9 +311,8 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
// Route::post('org-chart-range', ['as' => 'post.org.chart', 'uses' => 'Agent\helpdesk\OrganizationController@orgChartData']); // Route::post('org-chart-range', ['as' => 'post.org.chart', 'uses' => 'Agent\helpdesk\OrganizationController@orgChartData']);
Route::post('org-chart-range/{id}/{date1}/{date2}', ['as' => 'post.org.chart', 'uses' => 'Agent\helpdesk\OrganizationController@orgChartData']); Route::post('org-chart-range/{id}/{date1}/{date2}', ['as' => 'post.org.chart', 'uses' => 'Agent\helpdesk\OrganizationController@orgChartData']);
Route::get('profile', ['as' => 'profile', 'uses' => 'Agent\helpdesk\UserController@getProfile']); /* User profile get */ Route::get('profile', ['as' => 'profile', 'uses' => 'Agent\helpdesk\UserController@getProfile']); /* User profile get */
Route::get('profile-edit', ['as' => 'agent-profile-edit', 'uses' => 'Agent\helpdesk\UserController@getProfileedit']); /* User profile edit get */ Route::get('profile-edit', ['as' => 'agent-profile-edit', 'uses' => 'Agent\helpdesk\UserController@getProfileedit']); /* User profile edit get */
Route::post('verify-number', ['as' => 'agent-verify-number', 'uses' => 'Agent\helpdesk\UserController@resendOTP']); Route::post('verify-number', ['as' => 'agent-verify-number', 'uses' => 'Agent\helpdesk\UserController@resendOTP']);
Route::post('verify-number2', ['as' => 'post-agent-verify-number', 'uses' => 'Agent\helpdesk\UserController@verifyOTP']); Route::post('verify-number2', ['as' => 'post-agent-verify-number', 'uses' => 'Agent\helpdesk\UserController@verifyOTP']);
@@ -341,45 +320,45 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
Route::patch('agent-profile', ['as' => 'agent-profile', 'uses' => 'Agent\helpdesk\UserController@postProfileedit']); /* User Profile Post */ Route::patch('agent-profile', ['as' => 'agent-profile', 'uses' => 'Agent\helpdesk\UserController@postProfileedit']); /* User Profile Post */
Route::patch('agent-profile-password/{id}', 'Agent\helpdesk\UserController@postProfilePassword'); /* Profile Password Post */ Route::patch('agent-profile-password/{id}', 'Agent\helpdesk\UserController@postProfilePassword'); /* Profile Password Post */
Route::get('canned/list', ['as' => 'canned.list', 'uses' => 'Agent\helpdesk\CannedController@index']); /* Canned list */ Route::get('canned/list', ['as' => 'canned.list', 'uses' => 'Agent\helpdesk\CannedController@index']); /* Canned list */
Route::get('canned/create', ['as' => 'canned.create', 'uses' => 'Agent\helpdesk\CannedController@create']); /* Canned create */ Route::get('canned/create', ['as' => 'canned.create', 'uses' => 'Agent\helpdesk\CannedController@create']); /* Canned create */
Route::patch('canned/store', ['as' => 'canned.store', 'uses' => 'Agent\helpdesk\CannedController@store']); /* Canned store */ Route::patch('canned/store', ['as' => 'canned.store', 'uses' => 'Agent\helpdesk\CannedController@store']); /* Canned store */
Route::get('canned/edit/{id}', ['as' => 'canned.edit', 'uses' => 'Agent\helpdesk\CannedController@edit']); /* Canned edit */ Route::get('canned/edit/{id}', ['as' => 'canned.edit', 'uses' => 'Agent\helpdesk\CannedController@edit']); /* Canned edit */
Route::patch('canned/update/{id}', ['as' => 'canned.update', 'uses' => 'Agent\helpdesk\CannedController@update']); /* Canned update */ Route::patch('canned/update/{id}', ['as' => 'canned.update', 'uses' => 'Agent\helpdesk\CannedController@update']); /* Canned update */
Route::get('canned/show/{id}', ['as' => 'canned.show', 'uses' => 'Agent\helpdesk\CannedController@show']); /* Canned show */ Route::get('canned/show/{id}', ['as' => 'canned.show', 'uses' => 'Agent\helpdesk\CannedController@show']); /* Canned show */
Route::delete('canned/destroy/{id}', ['as' => 'canned.destroy', 'uses' => 'Agent\helpdesk\CannedController@destroy']); /* Canned delete */ Route::delete('canned/destroy/{id}', ['as' => 'canned.destroy', 'uses' => 'Agent\helpdesk\CannedController@destroy']); /* Canned delete */
Route::get('/test', ['as' => 'thr', 'uses' => 'Agent\helpdesk\MailController@fetchdata']); /* Fetch Emails */ Route::get('/test', ['as' => 'thr', 'uses' => 'Agent\helpdesk\MailController@fetchdata']); /* Fetch Emails */
Route::get('/ticket', ['as' => 'ticket', 'uses' => 'Agent\helpdesk\TicketController@ticket_list']); /* Get Ticket */ Route::get('/ticket', ['as' => 'ticket', 'uses' => 'Agent\helpdesk\TicketController@ticket_list']); /* Get Ticket */
Route::get('/ticket/inbox', ['as' => 'inbox.ticket', 'uses' => 'Agent\helpdesk\TicketController@inbox_ticket_list']); /* Get Inbox Ticket */ Route::get('/ticket/inbox', ['as' => 'inbox.ticket', 'uses' => 'Agent\helpdesk\TicketController@inbox_ticket_list']); /* Get Inbox Ticket */
Route::get('/ticket/get-inbox', ['as' => 'get.inbox.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_inbox']); /* Get tickets in datatable */ Route::get('/ticket/get-inbox', ['as' => 'get.inbox.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_inbox']); /* Get tickets in datatable */
Route::get('/ticket/open', ['as' => 'open.ticket', 'uses' => 'Agent\helpdesk\TicketController@open_ticket_list']); /* Get Open Ticket */ Route::get('/ticket/open', ['as' => 'open.ticket', 'uses' => 'Agent\helpdesk\TicketController@open_ticket_list']); /* Get Open Ticket */
Route::get('/ticket/get-open', ['as' => 'get.open.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_open']); /* Get tickets in datatable */ Route::get('/ticket/get-open', ['as' => 'get.open.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_open']); /* Get tickets in datatable */
Route::get('/ticket/answered', ['as' => 'answered.ticket', 'uses' => 'Agent\helpdesk\TicketController@answered_ticket_list']); /* Get Answered Ticket */ Route::get('/ticket/answered', ['as' => 'answered.ticket', 'uses' => 'Agent\helpdesk\TicketController@answered_ticket_list']); /* Get Answered Ticket */
Route::get('/ticket/get-answered', ['as' => 'get.answered.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_answered']); /* Get tickets in datatable */ Route::get('/ticket/get-answered', ['as' => 'get.answered.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_answered']); /* Get tickets in datatable */
Route::get('/ticket/myticket', ['as' => 'myticket.ticket', 'uses' => 'Agent\helpdesk\TicketController@myticket_ticket_list']); /* Get Tickets Assigned to logged user */ Route::get('/ticket/myticket', ['as' => 'myticket.ticket', 'uses' => 'Agent\helpdesk\TicketController@myticket_ticket_list']); /* Get Tickets Assigned to logged user */
Route::get('/ticket/get-myticket', ['as' => 'get.myticket.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_myticket']); /* Get tickets in datatable */ Route::get('/ticket/get-myticket', ['as' => 'get.myticket.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_myticket']); /* Get tickets in datatable */
Route::get('/ticket/overdue', ['as' => 'overdue.ticket', 'uses' => 'Agent\helpdesk\TicketController@overdue_ticket_list']); /* Get Overdue Ticket */ Route::get('/ticket/overdue', ['as' => 'overdue.ticket', 'uses' => 'Agent\helpdesk\TicketController@overdue_ticket_list']); /* Get Overdue Ticket */
Route::get('/ticket/get-overdue', ['as' => 'get.overdue.ticket', 'uses' => 'Agent\helpdesk\TicketController@getOverdueTickets']); /* Get Overdue Ticket */ Route::get('/ticket/get-overdue', ['as' => 'get.overdue.ticket', 'uses' => 'Agent\helpdesk\TicketController@getOverdueTickets']); /* Get Overdue Ticket */
Route::get('/ticket/closed', ['as' => 'closed.ticket', 'uses' => 'Agent\helpdesk\TicketController@closed_ticket_list']); /* Get Closed Ticket */ Route::get('/ticket/closed', ['as' => 'closed.ticket', 'uses' => 'Agent\helpdesk\TicketController@closed_ticket_list']); /* Get Closed Ticket */
Route::get('/ticket/get-closed', ['as' => 'get.closed.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_closed']); /* Get tickets in datatable */ Route::get('/ticket/get-closed', ['as' => 'get.closed.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_closed']); /* Get tickets in datatable */
Route::get('/ticket/assigned', ['as' => 'assigned.ticket', 'uses' => 'Agent\helpdesk\TicketController@assigned_ticket_list']); /* Get Assigned Ticket */ Route::get('/ticket/assigned', ['as' => 'assigned.ticket', 'uses' => 'Agent\helpdesk\TicketController@assigned_ticket_list']); /* Get Assigned Ticket */
Route::get('/ticket/get-assigned', ['as' => 'get.assigned.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_assigned']); /* Get tickets in datatable */ Route::get('/ticket/get-assigned', ['as' => 'get.assigned.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_assigned']); /* Get tickets in datatable */
Route::get('/newticket', ['as' => 'newticket', 'uses' => 'Agent\helpdesk\TicketController@newticket']); /* Get Create New Ticket */ Route::get('/newticket', ['as' => 'newticket', 'uses' => 'Agent\helpdesk\TicketController@newticket']); /* Get Create New Ticket */
Route::get('/newticket/autofill', ['as' => 'post.newticket.autofill', 'uses' => 'Agent\helpdesk\TicketController@autofill']); Route::get('/newticket/autofill', ['as' => 'post.newticket.autofill', 'uses' => 'Agent\helpdesk\TicketController@autofill']);
Route::post('/newticket/post', ['as' => 'post.newticket', 'uses' => 'Agent\helpdesk\TicketController@post_newticket']); /* Post Create New Ticket */ Route::post('/newticket/post', ['as' => 'post.newticket', 'uses' => 'Agent\helpdesk\TicketController@post_newticket']); /* Post Create New Ticket */
Route::get('/thread/{id}', ['as' => 'ticket.thread', 'uses' => 'Agent\helpdesk\TicketController@thread']); /* Get Thread by ID */ Route::get('/thread/{id}', ['as' => 'ticket.thread', 'uses' => 'Agent\helpdesk\TicketController@thread']); /* Get Thread by ID */
Route::post('/thread/reply/{id}', ['as' => 'ticket.reply', 'uses' => 'Agent\helpdesk\TicketController@reply']); /* Patch Thread Reply */ Route::post('/thread/reply/{id}', ['as' => 'ticket.reply', 'uses' => 'Agent\helpdesk\TicketController@reply']); /* Patch Thread Reply */
Route::patch('/internal/note/{id}', ['as' => 'Internal.note', 'uses' => 'Agent\helpdesk\TicketController@InternalNote']); /* Patch Internal Note */ Route::patch('/internal/note/{id}', ['as' => 'Internal.note', 'uses' => 'Agent\helpdesk\TicketController@InternalNote']); /* Patch Internal Note */
Route::patch('/ticket/assign/{id}', ['as' => 'assign.ticket', 'uses' => 'Agent\helpdesk\TicketController@assign']); /* Patch Ticket assigned to whom */ Route::patch('/ticket/assign/{id}', ['as' => 'assign.ticket', 'uses' => 'Agent\helpdesk\TicketController@assign']); /* Patch Ticket assigned to whom */
@@ -393,13 +372,13 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
Route::get('/ticket/surrender/{id}', ['as' => 'ticket.surrender', 'uses' => 'Agent\helpdesk\TicketController@surrender']); /* Get Ticket Surrender */ Route::get('/ticket/surrender/{id}', ['as' => 'ticket.surrender', 'uses' => 'Agent\helpdesk\TicketController@surrender']); /* Get Ticket Surrender */
Route::get('/aaaa', 'Client\helpdesk\GuestController@ticket_number'); Route::get('/aaaa', 'Client\helpdesk\GuestController@ticket_number');
Route::get('trash', ['as' => 'get-trash', 'uses' => 'Agent\helpdesk\TicketController@trash']); /* To show Deleted Tickets */ Route::get('trash', ['as' => 'get-trash', 'uses' => 'Agent\helpdesk\TicketController@trash']); /* To show Deleted Tickets */
Route::get('/ticket/trash', ['as' => 'get.trash.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_trash']); /* Get tickets in datatable */ Route::get('/ticket/trash', ['as' => 'get.trash.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_trash']); /* Get tickets in datatable */
Route::get('unassigned', ['as' => 'unassigned', 'uses' => 'Agent\helpdesk\TicketController@unassigned']); /* To show Unassigned Tickets */ Route::get('unassigned', ['as' => 'unassigned', 'uses' => 'Agent\helpdesk\TicketController@unassigned']); /* To show Unassigned Tickets */
Route::get('/ticket/unassigned', ['as' => 'get.unassigned.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_unassigned']); /* Get tickets in datatable */ Route::get('/ticket/unassigned', ['as' => 'get.unassigned.ticket', 'uses' => 'Agent\helpdesk\TicketController@get_unassigned']); /* Get tickets in datatable */
Route::get('dashboard', ['as' => 'dashboard', 'uses' => 'Agent\helpdesk\DashboardController@index']); /* To show dashboard pages */ Route::get('dashboard', ['as' => 'dashboard', 'uses' => 'Agent\helpdesk\DashboardController@index']); /* To show dashboard pages */
Route::get('agen', 'Agent\helpdesk\DashboardController@ChartData'); Route::get('agen', 'Agent\helpdesk\DashboardController@ChartData');
Route::get('image/{id}', ['as' => 'image', 'uses' => 'Agent\helpdesk\MailController@get_data']); /* get image */ Route::get('image/{id}', ['as' => 'image', 'uses' => 'Agent\helpdesk\MailController@get_data']); /* get image */
Route::get('thread/auto/{id}', 'Agent\helpdesk\TicketController@autosearch'); Route::get('thread/auto/{id}', 'Agent\helpdesk\TicketController@autosearch');
@@ -412,17 +391,17 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
// Route::get('message' , 'MessageController@show'); // Route::get('message' , 'MessageController@show');
Route::post('lock', ['as' => 'lock', 'uses' => 'Agent\helpdesk\TicketController@lock']); Route::post('lock', ['as' => 'lock', 'uses' => 'Agent\helpdesk\TicketController@lock']);
Route::patch('user-org-assign/{id}', ['as' => 'user.assign.org', 'uses' => 'Agent\helpdesk\UserController@UserAssignOrg']); Route::patch('user-org-assign/{id}', ['as' => 'user.assign.org', 'uses' => 'Agent\helpdesk\UserController@UserAssignOrg']);
Route::patch('user-org-edit-assign/{id}', ['as' => 'user.editassign.org', 'uses' => 'Agent\helpdesk\UserController@UsereditAssignOrg']); Route::patch('user-org-edit-assign/{id}', ['as' => 'user.editassign.org', 'uses' => 'Agent\helpdesk\UserController@UsereditAssignOrg']);
Route::patch('/user-org/{id}', 'Agent\helpdesk\UserController@User_Create_Org'); Route::patch('/user-org/{id}', 'Agent\helpdesk\UserController@User_Create_Org');
Route::patch('/head-org/{id}', 'Agent\helpdesk\OrganizationController@Head_Org'); Route::patch('/head-org/{id}', 'Agent\helpdesk\OrganizationController@Head_Org');
// Department ticket // Department ticket
Route::get('/{dept}/open', ['as' => 'dept.open.ticket', 'uses' => 'Agent\helpdesk\TicketController@deptopen']); // Open Route::get('/{dept}/open', ['as' => 'dept.open.ticket', 'uses' => 'Agent\helpdesk\TicketController@deptopen']); // Open
Route::get('tickets/{dept}/{status}', ['as' => 'dept.ticket', 'uses' => 'Agent\helpdesk\TicketController@deptTicket']); // Open Route::get('tickets/{dept}/{status}', ['as' => 'dept.ticket', 'uses' => 'Agent\helpdesk\TicketController@deptTicket']); // Open
Route::get('/{dept}/assigned', ['as' => 'dept.inprogress.ticket', 'uses' => 'Agent\helpdesk\TicketController@deptinprogress']); // Inprogress Route::get('/{dept}/assigned', ['as' => 'dept.inprogress.ticket', 'uses' => 'Agent\helpdesk\TicketController@deptinprogress']); // Inprogress
Route::get('/{dept}/closed', ['as' => 'dept.closed.ticket', 'uses' => 'Agent\helpdesk\TicketController@deptclose']); // Closed Route::get('/{dept}/closed', ['as' => 'dept.closed.ticket', 'uses' => 'Agent\helpdesk\TicketController@deptclose']); // Closed
Route::post('rating/{id}', ['as' => 'ticket.rating', 'uses' => 'Agent\helpdesk\TicketController@rating']); /* Get overall Ratings */ Route::post('rating/{id}', ['as' => 'ticket.rating', 'uses' => 'Agent\helpdesk\TicketController@rating']); /* Get overall Ratings */
Route::post('rating2/{id}', ['as' => 'ticket.rating2', 'uses' => 'Agent\helpdesk\TicketController@ratingReply']); /* Get reply Ratings */ Route::post('rating2/{id}', ['as' => 'ticket.rating2', 'uses' => 'Agent\helpdesk\TicketController@ratingReply']); /* Get reply Ratings */
// To check and lock tickets // To check and lock tickets
@@ -443,29 +422,28 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
// route for graphical reporting // route for graphical reporting
Route::get('report', ['as' => 'report.index', 'uses' => 'Agent\helpdesk\ReportController@index']); /* To show dashboard pages */ Route::get('report', ['as' => 'report.index', 'uses' => 'Agent\helpdesk\ReportController@index']); /* To show dashboard pages */
// default route to get the data for the first time // default route to get the data for the first time
Route::get('help-topic-report', 'Agent\helpdesk\ReportController@chartdataHelptopic'); Route::get('help-topic-report', 'Agent\helpdesk\ReportController@chartdataHelptopic');
// route to get the data on change // route to get the data on change
Route::post('help-topic-report/{date1}/{date2}/{id}', ['as' => 'report.helptopic', 'uses' => 'Agent\helpdesk\ReportController@chartdataHelptopic']); /* To show dashboard pages */ Route::post('help-topic-report/{date1}/{date2}/{id}', ['as' => 'report.helptopic', 'uses' => 'Agent\helpdesk\ReportController@chartdataHelptopic']); /* To show dashboard pages */
Route::post('help-topic-pdf', ['as' => 'help.topic.pdf', 'uses' => 'Agent\helpdesk\ReportController@helptopicPdf']); Route::post('help-topic-pdf', ['as' => 'help.topic.pdf', 'uses' => 'Agent\helpdesk\ReportController@helptopicPdf']);
// Route to get details of agents // Route to get details of agents
Route::post('get-agents', ['as' => 'get-agents', 'uses' => 'Agent\helpdesk\UserController@getAgentDetails']); Route::post('get-agents', ['as' => 'get-agents', 'uses' => 'Agent\helpdesk\UserController@getAgentDetails']);
/** /*
* Label * Label
*/ */
Route::get('labels-ticket',['as'=>'labels.ticket','uses'=>'Admin\helpdesk\Label\LabelController@attachTicket']); Route::get('labels-ticket', ['as'=>'labels.ticket', 'uses'=>'Admin\helpdesk\Label\LabelController@attachTicket']);
Route::get('json-labels',['as'=>'labels.json','uses'=>'Admin\helpdesk\Label\LabelController@getLabel']); Route::get('json-labels', ['as'=>'labels.json', 'uses'=>'Admin\helpdesk\Label\LabelController@getLabel']);
Route::get('filter',['as'=>'filter','uses'=>'Agent\helpdesk\Filter\FilterController@getFilter']); Route::get('filter', ['as'=>'filter', 'uses'=>'Agent\helpdesk\Filter\FilterController@getFilter']);
/** /*
* Tags * Tags
*/ */
Route::get('add-tag',['as'=>'tag.add','uses'=>'Agent\helpdesk\Filter\TagController@addToFilter']); Route::get('add-tag', ['as'=>'tag.add', 'uses'=>'Agent\helpdesk\Filter\TagController@addToFilter']);
Route::get('get-tag',['as'=>'tag.get','uses'=>'Agent\helpdesk\Filter\TagController@getTag']); Route::get('get-tag', ['as'=>'tag.get', 'uses'=>'Agent\helpdesk\Filter\TagController@getTag']);
}); });
/* /*
@@ -492,7 +470,7 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
// }); // });
Route::any('getdata', function () { Route::any('getdata', function () {
$term = Illuminate\Support\Str::lower(Input::get('term')); $term = Illuminate\Support\Str::lower(Input::get('term'));
$data = Illuminate\Support\Facades\DB::table('tickets')->distinct()->select('ticket_number')->where('ticket_number', 'LIKE', $term . '%')->groupBy('ticket_number')->take(10)->get(); $data = Illuminate\Support\Facades\DB::table('tickets')->distinct()->select('ticket_number')->where('ticket_number', 'LIKE', $term.'%')->groupBy('ticket_number')->take(10)->get();
foreach ($data as $v) { foreach ($data as $v) {
return [ return [
'value' => $v->ticket_number, 'value' => $v->ticket_number,
@@ -501,38 +479,37 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
}); });
Route::post('postform/{id}', 'Client\helpdesk\FormController@postForm'); /* post the AJAX form for create a ticket by guest user */ Route::post('postform/{id}', 'Client\helpdesk\FormController@postForm'); /* post the AJAX form for create a ticket by guest user */
Route::post('postedform', ['as'=>'client.form.post','uses'=>'Client\helpdesk\FormController@postedForm']); /* post the form to store the value */ Route::post('postedform', ['as'=>'client.form.post', 'uses'=>'Client\helpdesk\FormController@postedForm']); /* post the form to store the value */
//Route::get('check', 'CheckController@getcheck'); //testing checkbox auto-populate //Route::get('check', 'CheckController@getcheck'); //testing checkbox auto-populate
//Route::post('postcheck/{id}', 'CheckController@postcheck'); //Route::post('postcheck/{id}', 'CheckController@postcheck');
Route::get('get-helptopic-form', 'Client\helpdesk\FormController@getCustomForm'); Route::get('get-helptopic-form', 'Client\helpdesk\FormController@getCustomForm');
Route::get('home', ['as' => 'home', 'uses' => 'Client\helpdesk\WelcomepageController@index']); //guest layout Route::get('home', ['as' => 'home', 'uses' => 'Client\helpdesk\WelcomepageController@index']); //guest layout
Route::get('/', ['as' => '/', 'uses' => 'Client\helpdesk\WelcomepageController@index']); Route::get('/', ['as' => '/', 'uses' => 'Client\helpdesk\WelcomepageController@index']);
Route::get('create-ticket', ['as' => 'form', 'uses' => 'Client\helpdesk\FormController@getForm']); //getform Route::get('create-ticket', ['as' => 'form', 'uses' => 'Client\helpdesk\FormController@getForm']); //getform
Route::get('mytickets/{id}', ['as' => 'ticketinfo', 'uses' => 'Client\helpdesk\GuestController@singleThread']); //detail ticket information Route::get('mytickets/{id}', ['as' => 'ticketinfo', 'uses' => 'Client\helpdesk\GuestController@singleThread']); //detail ticket information
Route::post('checkmyticket', 'Client\helpdesk\UnAuthController@PostCheckTicket'); //ticket ckeck Route::post('checkmyticket', 'Client\helpdesk\UnAuthController@PostCheckTicket'); //ticket ckeck
Route::get('check_ticket/{id}', ['as' => 'check_ticket', 'uses' => 'Client\helpdesk\GuestController@get_ticket_email']); //detail ticket information Route::get('check_ticket/{id}', ['as' => 'check_ticket', 'uses' => 'Client\helpdesk\GuestController@get_ticket_email']); //detail ticket information
// show ticket via have a ticket // show ticket via have a ticket
Route::get('show-ticket/{id}/{code}', ['as' => 'show.ticket', 'uses' => 'Client\helpdesk\UnAuthController@showTicketCode']); //detail ticket information Route::get('show-ticket/{id}/{code}', ['as' => 'show.ticket', 'uses' => 'Client\helpdesk\UnAuthController@showTicketCode']); //detail ticket information
//testing ckeditor //testing ckeditor
//=================================================================================== //===================================================================================
Route::group(['middleware' => 'role.user', 'middleware' => 'auth'], function () { Route::group(['middleware' => 'role.user', 'middleware' => 'auth'], function () {
Route::get('client-profile', ['as' => 'client.profile', 'uses' => 'Client\helpdesk\GuestController@getProfile']); /* User profile get */ Route::get('client-profile', ['as' => 'client.profile', 'uses' => 'Client\helpdesk\GuestController@getProfile']); /* User profile get */
Route::get('mytickets', ['as' => 'ticket2', 'uses' => 'Client\helpdesk\GuestController@getMyticket']); Route::get('mytickets', ['as' => 'ticket2', 'uses' => 'Client\helpdesk\GuestController@getMyticket']);
Route::get('myticket/{id}', ['as' => 'ticket', 'uses' => 'Client\helpdesk\GuestController@thread']); /* Get my tickets */ Route::get('myticket/{id}', ['as' => 'ticket', 'uses' => 'Client\helpdesk\GuestController@thread']); /* Get my tickets */
Route::patch('client-profile-edit', 'Client\helpdesk\GuestController@postProfile'); /* User Profile Post */ Route::patch('client-profile-edit', 'Client\helpdesk\GuestController@postProfile'); /* User Profile Post */
Route::patch('client-profile-password', 'Client\helpdesk\GuestController@postProfilePassword'); /* Profile Password Post */ Route::patch('client-profile-password', 'Client\helpdesk\GuestController@postProfilePassword'); /* Profile Password Post */
Route::post('post/reply/{id}', ['as' => 'client.reply', 'uses' => 'Client\helpdesk\ClientTicketController@reply']); Route::post('post/reply/{id}', ['as' => 'client.reply', 'uses' => 'Client\helpdesk\ClientTicketController@reply']);
Route::post('verify-client-number', ['as' => 'client-verify-number', 'uses' => 'Client\helpdesk\GuestController@resendOTP']); Route::post('verify-client-number', ['as' => 'client-verify-number', 'uses' => 'Client\helpdesk\GuestController@resendOTP']);
Route::post('verify-client-number2', ['as' => 'post-client-verify-number', 'uses' => 'Client\helpdesk\GuestController@verifyOTP']); Route::post('verify-client-number2', ['as' => 'post-client-verify-number', 'uses' => 'Client\helpdesk\GuestController@verifyOTP']);
}); });
//==================================================================================== //====================================================================================
Route::get('checkticket', 'Client\helpdesk\ClientTicketController@getCheckTicket'); /* Check your Ticket */ Route::get('checkticket', 'Client\helpdesk\ClientTicketController@getCheckTicket'); /* Check your Ticket */
@@ -593,10 +570,10 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
echo '</tr>'; echo '</tr>';
foreach ($routeCollection as $value) { foreach ($routeCollection as $value) {
echo '<tr>'; echo '<tr>';
echo '<td>' . $value->getMethods()[0] . '</td>'; echo '<td>'.$value->getMethods()[0].'</td>';
echo '<td>' . $value->getName() . '</td>'; echo '<td>'.$value->getName().'</td>';
echo '<td>' . $value->getPath() . '</td>'; echo '<td>'.$value->getPath().'</td>';
echo '<td>' . $value->getActionName() . '</td>'; echo '<td>'.$value->getActionName().'</td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table>'; echo '</table>';
@@ -607,29 +584,25 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
|============================================================= |=============================================================
*/ */
Route::get('500', ['as' => 'error500', function () { Route::get('500', ['as' => 'error500', function () {
return view('errors.500'); return view('errors.500');
}]); }]);
Route::get('404', ['as' => 'error404', function () { Route::get('404', ['as' => 'error404', function () {
return view('errors.404'); return view('errors.404');
}]); }]);
Route::get('error-in-database-connection', ['as' => 'errordb', function() { Route::get('error-in-database-connection', ['as' => 'errordb', function () {
return view('errors.db'); return view('errors.db');
}]); }]);
Route::get('unauthorized', ['as' => 'unauth', function () {
return view('errors.unauth');
}]);
Route::get('unauthorized', ['as' => 'unauth', function() {
return view('errors.unauth');
}]);
Route::get('board-offline', ['as' => 'board.offline', function () { Route::get('board-offline', ['as' => 'board.offline', function () {
return view('errors.offline'); return view('errors.offline');
}]); }]);
/* /*
|============================================================= |=============================================================
| Test mail Routes | Test mail Routes
@@ -644,20 +617,20 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
// }); // });
/* For the crud of catogory */ /* For the crud of catogory */
Route::resource('category', 'Agent\kb\CategoryController'); Route::resource('category', 'Agent\kb\CategoryController');
Route::get('category/delete/{id}', 'Agent\kb\CategoryController@destroy'); Route::get('category/delete/{id}', 'Agent\kb\CategoryController@destroy');
/* For the crud of article */ /* For the crud of article */
Route::resource('article', 'Agent\kb\ArticleController'); Route::resource('article', 'Agent\kb\ArticleController');
Route::get('article/delete/{id}', 'Agent\kb\ArticleController@destroy'); Route::get('article/delete/{id}', 'Agent\kb\ArticleController@destroy');
/* get settings */ /* get settings */
Route::get('kb/settings', ['as' => 'settings', 'uses' => 'Agent\kb\SettingsController@settings']); Route::get('kb/settings', ['as' => 'settings', 'uses' => 'Agent\kb\SettingsController@settings']);
/* post settings */ /* post settings */
Route::patch('postsettings/{id}', 'Agent\kb\SettingsController@postSettings'); Route::patch('postsettings/{id}', 'Agent\kb\SettingsController@postSettings');
//Route for administrater to access the comment //Route for administrater to access the comment
Route::get('comment', ['as' => 'comment', 'uses' => 'Agent\kb\SettingsController@comment']); Route::get('comment', ['as' => 'comment', 'uses' => 'Agent\kb\SettingsController@comment']);
/* Route to define the comment should Published */ /* Route to define the comment should Published */
Route::get('published/{id}', ['as' => 'published', 'uses' => 'Agent\kb\SettingsController@publish']); Route::get('published/{id}', ['as' => 'published', 'uses' => 'Agent\kb\SettingsController@publish']);
/* Route for deleting comments */ /* Route for deleting comments */
@@ -673,8 +646,7 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
/* delete Background */ /* delete Background */
Route::get('delete-background/{id}', ['as' => 'delete-background', 'uses' => 'Agent\kb\SettingsController@deleteBackground']); Route::get('delete-background/{id}', ['as' => 'delete-background', 'uses' => 'Agent\kb\SettingsController@deleteBackground']);
Route::resource('page', 'Agent\kb\PageController'); Route::resource('page', 'Agent\kb\PageController');
Route::get('get-pages', ['as' => 'api.page', 'uses' => 'Agent\kb\PageController@getData']); Route::get('get-pages', ['as' => 'api.page', 'uses' => 'Agent\kb\PageController@getData']);
Route::get('page/delete/{id}', ['as' => 'pagedelete', 'uses' => 'Agent\kb\PageController@destroy']); Route::get('page/delete/{id}', ['as' => 'pagedelete', 'uses' => 'Agent\kb\PageController@destroy']);
Route::get('comment/delete/{id}', ['as' => 'commentdelete', 'uses' => 'Agent\kb\SettingsController@delete']); Route::get('comment/delete/{id}', ['as' => 'commentdelete', 'uses' => 'Agent\kb\SettingsController@delete']);
@@ -690,19 +662,19 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
/* post the comment from show page */ /* post the comment from show page */
Route::post('postcomment/{slug}', ['as' => 'postcomment', 'uses' => 'Client\kb\UserController@postComment']); Route::post('postcomment/{slug}', ['as' => 'postcomment', 'uses' => 'Client\kb\UserController@postComment']);
/* get the article list */ /* get the article list */
Route::get('article-list', ['as' => 'article-list', 'uses' => 'Client\kb\UserController@getArticle']); Route::get('article-list', ['as' => 'article-list', 'uses' => 'Client\kb\UserController@getArticle']);
// /* get search values */ // /* get search values */
Route::get('search', ['as' => 'search', 'uses' => 'Client\kb\UserController@search']); Route::get('search', ['as' => 'search', 'uses' => 'Client\kb\UserController@search']);
/* get the selected article */ /* get the selected article */
Route::get('show/{slug}', ['as' => 'show', 'uses' => 'Client\kb\UserController@show']); Route::get('show/{slug}', ['as' => 'show', 'uses' => 'Client\kb\UserController@show']);
Route::get('category-list', ['as' => 'category-list', 'uses' => 'Client\kb\UserController@getCategoryList']); Route::get('category-list', ['as' => 'category-list', 'uses' => 'Client\kb\UserController@getCategoryList']);
/* get the categories with article */ /* get the categories with article */
Route::get('category-list/{id}', ['as' => 'categorylist', 'uses' => 'Client\kb\UserController@getCategory']); Route::get('category-list/{id}', ['as' => 'categorylist', 'uses' => 'Client\kb\UserController@getCategory']);
Route::post('show/rating/{id}', ['as' => 'show.rating', 'uses' => 'Client\helpdesk\UnAuthController@rating']); /* Get overall Ratings */ Route::post('show/rating/{id}', ['as' => 'show.rating', 'uses' => 'Client\helpdesk\UnAuthController@rating']); /* Get overall Ratings */
Route::post('show/rating2/{id}', ['as' => 'show.rating2', 'uses' => 'Client\helpdesk\UnAuthController@ratingReply']); /* Get reply Ratings */ Route::post('show/rating2/{id}', ['as' => 'show.rating2', 'uses' => 'Client\helpdesk\UnAuthController@ratingReply']); /* Get reply Ratings */
Route::get('show/change-status/{status}/{id}', ['as' => 'show.change.status', 'uses' => 'Client\helpdesk\UnAuthController@changeStatus']); /* Get reply Ratings */ Route::get('show/change-status/{status}/{id}', ['as' => 'show.change.status', 'uses' => 'Client\helpdesk\UnAuthController@changeStatus']); /* Get reply Ratings */
@@ -712,12 +684,12 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
// $router->get('faq',['as'=>'faq' , 'uses'=>'Client\kb\UserController@Faq'] ); // $router->get('faq',['as'=>'faq' , 'uses'=>'Client\kb\UserController@Faq'] );
/* get the cantact page to user */ /* get the cantact page to user */
Route::get('contact', ['as' => 'contact', 'uses' => 'Client\kb\UserController@contact']); Route::get('contact', ['as' => 'contact', 'uses' => 'Client\kb\UserController@contact']);
/* post the cantact page to controller */ /* post the cantact page to controller */
Route::post('post-contact', ['as' => 'post-contact', 'uses' => 'Client\kb\UserController@postContact']); Route::post('post-contact', ['as' => 'post-contact', 'uses' => 'Client\kb\UserController@postContact']);
//to get the value for page content //to get the value for page content
Route::get('pages/{name}', ['as' => 'pages', 'uses' => 'Client\kb\UserController@getPage']); Route::get('pages/{name}', ['as' => 'pages', 'uses' => 'Client\kb\UserController@getPage']);
//profile //profile
// $router->get('client-profile',['as' => 'client-profile', 'uses' => 'Client\kb\UserController@clientProfile']); // $router->get('client-profile',['as' => 'client-profile', 'uses' => 'Client\kb\UserController@clientProfile']);
// Route::patch('client-profile-edit',['as' => 'client-profile-edit', 'uses' => 'Client\kb\UserController@postClientProfile']); // Route::patch('client-profile-edit',['as' => 'client-profile-edit', 'uses' => 'Client\kb\UserController@postClientProfile']);
@@ -802,44 +774,42 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
$api_control->ticketDetailEvent($details); $api_control->ticketDetailEvent($details);
}); });
Route::get('test', ['as' => 'test', 'uses' => 'Common\PushNotificationController@response']); Route::get('test', ['as' => 'test', 'uses' => 'Common\PushNotificationController@response']);
Route::get('mail/config/service', ['as' => 'mail.config.service', 'uses' => 'Job\MailController@serviceForm']); Route::get('mail/config/service', ['as' => 'mail.config.service', 'uses' => 'Job\MailController@serviceForm']);
/** /*
* Queue * Queue
*/ */
Route::get('queue', ['as' => 'queue', 'uses' => 'Job\QueueController@index']); Route::get('queue', ['as' => 'queue', 'uses' => 'Job\QueueController@index']);
Route::get('form/queue', ['as' => 'queue.form', 'uses' => 'Job\QueueController@getForm']); Route::get('form/queue', ['as' => 'queue.form', 'uses' => 'Job\QueueController@getForm']);
Route::get('queue/{id}', ['as' => 'queue.edit', 'uses' => 'Job\QueueController@edit']); Route::get('queue/{id}', ['as' => 'queue.edit', 'uses' => 'Job\QueueController@edit']);
Route::post('queue/{id}', ['as' => 'queue.update', 'uses' => 'Job\QueueController@update']); Route::post('queue/{id}', ['as' => 'queue.update', 'uses' => 'Job\QueueController@update']);
Route::get('queue/{id}/activate', ['as' => 'queue.activate', 'uses' => 'Job\QueueController@activate']); Route::get('queue/{id}/activate', ['as' => 'queue.activate', 'uses' => 'Job\QueueController@activate']);
Route::get('get-ticket-number', ['as' => 'get.ticket.number', 'uses' => 'Admin\helpdesk\SettingsController@getTicketNumber']); Route::get('get-ticket-number', ['as' => 'get.ticket.number', 'uses' => 'Admin\helpdesk\SettingsController@getTicketNumber']);
Route::get('genereate-pdf/{threadid}', ['as' => 'thread.pdf', 'uses' => 'Agent\helpdesk\TicketController@pdfThread']); Route::get('genereate-pdf/{threadid}', ['as' => 'thread.pdf', 'uses' => 'Agent\helpdesk\TicketController@pdfThread']);
/** /*
* Url Settings * Url Settings
*/ */
Route::get('url/settings', ['as' => 'url.settings', 'uses' => 'Admin\helpdesk\UrlSettingController@settings']); Route::get('url/settings', ['as' => 'url.settings', 'uses' => 'Admin\helpdesk\UrlSettingController@settings']);
Route::patch('url/settings', ['as' => 'url.settings.post', 'uses' => 'Admin\helpdesk\UrlSettingController@postSettings']); Route::patch('url/settings', ['as' => 'url.settings.post', 'uses' => 'Admin\helpdesk\UrlSettingController@postSettings']);
/** /*
* Social media settings * Social media settings
*/ */
Route::get('social/media',['as'=>'social','uses'=>'Admin\helpdesk\SocialMedia\SocialMediaController@index']); Route::get('social/media', ['as'=>'social', 'uses'=>'Admin\helpdesk\SocialMedia\SocialMediaController@index']);
Route::get('social/media/{provider}',['as'=>'social.media','uses'=>'Admin\helpdesk\SocialMedia\SocialMediaController@settings']); Route::get('social/media/{provider}', ['as'=>'social.media', 'uses'=>'Admin\helpdesk\SocialMedia\SocialMediaController@settings']);
Route::post('social/media/{provider}',['as'=>'social.media.post','uses'=>'Admin\helpdesk\SocialMedia\SocialMediaController@postSettings']); Route::post('social/media/{provider}', ['as'=>'social.media.post', 'uses'=>'Admin\helpdesk\SocialMedia\SocialMediaController@postSettings']);
/* /*
* Ticket_Priority Settings * Ticket_Priority Settings
*/ */
Route::get('ticket/priority', ['as' => 'priority.index', 'uses' => 'Admin\helpdesk\PriorityController@priorityIndex']); Route::get('ticket/priority', ['as' => 'priority.index', 'uses' => 'Admin\helpdesk\PriorityController@priorityIndex']);
Route::post('user/ticket/priority', ['as' => 'user.priority.index', 'uses' => 'Admin\helpdesk\PriorityController@userPriorityIndex']); Route::post('user/ticket/priority', ['as' => 'user.priority.index', 'uses' => 'Admin\helpdesk\PriorityController@userPriorityIndex']);
Route::get('get_index', ['as' => 'priority.index1', 'uses' => 'Admin\helpdesk\PriorityController@priorityIndex1']); Route::get('get_index', ['as' => 'priority.index1', 'uses' => 'Admin\helpdesk\PriorityController@priorityIndex1']);
Route::get('ticket/priority/create', ['as' => 'priority.create', 'uses' => 'Admin\helpdesk\PriorityController@priorityCreate']); Route::get('ticket/priority/create', ['as' => 'priority.create', 'uses' => 'Admin\helpdesk\PriorityController@priorityCreate']);
Route::post('ticket/priority/create1', ['as' => 'priority.create1', 'uses' => 'Admin\helpdesk\PriorityController@priorityCreate1']); Route::post('ticket/priority/create1', ['as' => 'priority.create1', 'uses' => 'Admin\helpdesk\PriorityController@priorityCreate1']);
@@ -848,20 +818,20 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
Route::get('ticket/priority/{ticket_priority}/destroy', ['as' => 'priority.destroy', 'uses' => 'Admin\helpdesk\PriorityController@destroy']); Route::get('ticket/priority/{ticket_priority}/destroy', ['as' => 'priority.destroy', 'uses' => 'Admin\helpdesk\PriorityController@destroy']);
// user---arindam // user---arindam
Route::post('rolechangeadmin/{id}', ['as' => 'user.post.rolechangeadmin', 'uses' =>'Agent\helpdesk\UserController@changeRoleAdmin']); Route::post('rolechangeadmin/{id}', ['as' => 'user.post.rolechangeadmin', 'uses' =>'Agent\helpdesk\UserController@changeRoleAdmin']);
Route::post('rolechangeagent/{id}', ['as' => 'user.post.rolechangeagent', 'uses' =>'Agent\helpdesk\UserController@changeRoleAgent']); Route::post('rolechangeagent/{id}', ['as' => 'user.post.rolechangeagent', 'uses' =>'Agent\helpdesk\UserController@changeRoleAgent']);
Route::post('rolechangeuser/{id}', ['as' => 'user.post.rolechangeuser', 'uses' =>'Agent\helpdesk\UserController@changeRoleUser']); Route::post('rolechangeuser/{id}', ['as' => 'user.post.rolechangeuser', 'uses' =>'Agent\helpdesk\UserController@changeRoleUser']);
Route::get('password', ['as' => 'user.changepassword', 'uses' =>'Agent\helpdesk\UserController@randomPassword']); Route::get('password', ['as' => 'user.changepassword', 'uses' =>'Agent\helpdesk\UserController@randomPassword']);
Route::post('changepassword/{id}', ['as' => 'user.post.changepassword', 'uses' =>'Agent\helpdesk\UserController@randomPostPassword']); Route::post('changepassword/{id}', ['as' => 'user.post.changepassword', 'uses' =>'Agent\helpdesk\UserController@randomPostPassword']);
Route::post('delete/{id}', ['as' => 'user.post.delete', 'uses' =>'Agent\helpdesk\UserController@deleteAgent']); Route::post('delete/{id}', ['as' => 'user.post.delete', 'uses' =>'Agent\helpdesk\UserController@deleteAgent']);
// deleted user list // deleted user list
Route::get('deleted/user', ['as' => 'user.deleted', 'uses' => 'Agent\helpdesk\UserController@deletedUser']); Route::get('deleted/user', ['as' => 'user.deleted', 'uses' => 'Agent\helpdesk\UserController@deletedUser']);
Route::post('restore/{id}', ['as' => 'user.restore', 'uses' => 'Agent\helpdesk\UserController@restoreUser']); Route::post('restore/{id}', ['as' => 'user.restore', 'uses' => 'Agent\helpdesk\UserController@restoreUser']);
//due today ticket //due today ticket
Route::get('duetoday', ['as' => 'ticket.duetoday', 'uses' =>'Agent\helpdesk\TicketController@dueTodayTicketlist']); Route::get('duetoday', ['as' => 'ticket.duetoday', 'uses' =>'Agent\helpdesk\TicketController@dueTodayTicketlist']);
// Route::post('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']); // Route::post('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']);
Route::get('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']); /* Get Open Ticket */ Route::get('duetoday/list/ticket', ['as' => 'ticket.post.duetoday', 'uses' =>'Agent\helpdesk\TicketController@getDueToday']); /* Get Open Ticket */
// Breadcrumbs::register('open.ticket', function ($breadcrumbs) { // Breadcrumbs::register('open.ticket', function ($breadcrumbs) {
@@ -869,4 +839,3 @@ Route::get('getshow/{id}', ['as' => 'teams.getshow.list', 'uses' => 'Admin\helpd
// $breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.open'), route('open.ticket')); // $breadcrumbs->push(Lang::get('lang.tickets') . '&nbsp; > &nbsp;' . Lang::get('lang.open'), route('open.ticket'));
// }); // });
}); });

View File

@@ -2,28 +2,27 @@
namespace App\Jobs; namespace App\Jobs;
use App\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Common\PhpMailController;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SendEmail extends Job implements SelfHandling,ShouldQueue class SendEmail extends Job implements SelfHandling, ShouldQueue
{ {
use InteractsWithQueue,SerializesModels; use InteractsWithQueue,SerializesModels;
protected $from; protected $from;
protected $to; protected $to;
protected $message; protected $message;
protected $template; protected $template;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @return void * @return void
*/ */
public function __construct($from, $to, $message,$template_variables='') public function __construct($from, $to, $message, $template_variables = '')
{ {
$this->from = $from; $this->from = $from;
$this->to = $to; $this->to = $to;
@@ -38,10 +37,8 @@ class SendEmail extends Job implements SelfHandling,ShouldQueue
*/ */
public function handle(PhpMailController $PhpMailController) public function handle(PhpMailController $PhpMailController)
{ {
$p = $PhpMailController->sendEmail($this->from, $this->to, $this->message,$this->template); $p = $PhpMailController->sendEmail($this->from, $this->to, $this->message, $this->template);
return $p; return $p;
} }
} }

View File

@@ -4,12 +4,13 @@ namespace App\Model\MailJob;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Condition extends Model { class Condition extends Model
{
protected $table = "conditions"; protected $table = 'conditions';
protected $fillable = ['job', 'value']; protected $fillable = ['job', 'value'];
public function getConditionValue($job) { public function getConditionValue($job)
{
$value = ['condition' => '', 'at' => '']; $value = ['condition' => '', 'at' => ''];
$condition = $this->where('job', $job)->first(); $condition = $this->where('job', $job)->first();
if ($condition) { if ($condition) {
@@ -19,21 +20,24 @@ class Condition extends Model {
$value = ['condition' => $this->checkArray(0, $condition_value), 'at' => $this->checkArray(1, $condition_value)]; $value = ['condition' => $this->checkArray(0, $condition_value), 'at' => $this->checkArray(1, $condition_value)];
} }
} }
return $value; return $value;
} }
public function checkArray($key,$array){ public function checkArray($key, $array)
$value = ""; {
if(is_array($array)){ $value = '';
if(array_key_exists($key, $array)){ if (is_array($array)) {
if (array_key_exists($key, $array)) {
$value = $array[$key]; $value = $array[$key];
} }
} }
return $value; return $value;
} }
public function checkActiveJob() { public function checkActiveJob()
{
$result = ['fetching' => '', 'notification' => '', 'work' => '', 'message' => '', 'remind' => '']; $result = ['fetching' => '', 'notification' => '', 'work' => '', 'message' => '', 'remind' => ''];
$emails = new \App\Model\helpdesk\Settings\Email(); $emails = new \App\Model\helpdesk\Settings\Email();
$email = $emails->find(1); $email = $emails->find(1);
@@ -41,19 +45,19 @@ class Condition extends Model {
if ($email->email_fetching == 1) { if ($email->email_fetching == 1) {
$result['fetching'] = true; $result['fetching'] = true;
} }
if($email->notification_cron==1){ if ($email->notification_cron == 1) {
$result['notification'] = true; $result['notification'] = true;
} }
} }
$works = new \App\Model\helpdesk\Workflow\WorkflowClose(); $works = new \App\Model\helpdesk\Workflow\WorkflowClose();
$work = $works->find(1); $work = $works->find(1);
//dd($work); //dd($work);
if($work){ if ($work) {
if($work->condition==1){ if ($work->condition == 1) {
$result['work'] = true; $result['work'] = true;
} }
} }
return $result; return $result;
} }
} }

View File

@@ -4,9 +4,8 @@ namespace App\Model\MailJob;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class FaveoMail extends Model { class FaveoMail extends Model
{
protected $table = "faveo_mails"; protected $table = 'faveo_mails';
protected $fillable = ["drive", "key", "value","email_id"]; protected $fillable = ['drive', 'key', 'value', 'email_id'];
} }

View File

@@ -4,9 +4,8 @@ namespace App\Model\MailJob;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class FaveoQueue extends Model { class FaveoQueue extends Model
{
protected $table = "faveo_queues"; protected $table = 'faveo_queues';
protected $fillable = ["key", "value","service_id"]; protected $fillable = ['key', 'value', 'service_id'];
} }

View File

@@ -6,6 +6,6 @@ use Illuminate\Database\Eloquent\Model;
class MailService extends Model class MailService extends Model
{ {
protected $table = "mail_services"; protected $table = 'mail_services';
protected $fillable = ["name","short_name"]; protected $fillable = ['name', 'short_name'];
} }

View File

@@ -7,55 +7,67 @@ use Lang;
class QueueService extends Model class QueueService extends Model
{ {
protected $table = "queue_services"; protected $table = 'queue_services';
protected $fillable = ["name","short_name","status"]; protected $fillable = ['name', 'short_name', 'status'];
public function extraFieldRelation(){ public function extraFieldRelation()
{
$related = "App\Model\MailJob\FaveoQueue"; $related = "App\Model\MailJob\FaveoQueue";
return $this->hasMany($related,'service_id');
return $this->hasMany($related, 'service_id');
} }
public function getExtraField($key){ public function getExtraField($key)
$value = ""; {
$setting = $this->extraFieldRelation()->where('key',$key)->first(); $value = '';
if($setting){ $setting = $this->extraFieldRelation()->where('key', $key)->first();
if ($setting) {
$value = $setting->value; $value = $setting->value;
} }
return $value; return $value;
} }
public function getName(){ public function getName()
$name = $this->attributes['name']; {
$name = $this->attributes['name'];
$id = $this->attributes['id']; $id = $this->attributes['id'];
$html = "<a href=".url('queue/'.$id).">".$name."</a>"; $html = '<a href='.url('queue/'.$id).'>'.$name.'</a>';
return $html; return $html;
} }
public function getStatus(){ public function getStatus()
{
$status = $this->attributes['status']; $status = $this->attributes['status'];
$html = "<span style='color:red'>".Lang::get('lang.inactive')."</span>"; $html = "<span style='color:red'>".Lang::get('lang.inactive').'</span>';
if($status==1){ if ($status == 1) {
$html = "<span style='color:green'>".Lang::get('lang.active')."</span>"; $html = "<span style='color:green'>".Lang::get('lang.active').'</span>';
} }
return $html; return $html;
} }
public function getAction(){ public function getAction()
{
$id = $this->attributes['id']; $id = $this->attributes['id'];
$status = $this->attributes['status']; $status = $this->attributes['status'];
$html = "<a href=".url('queue/'.$id.'/activate')." class='btn btn-primary'>".Lang::get('lang.activate')."</a>"; $html = '<a href='.url('queue/'.$id.'/activate')." class='btn btn-primary'>".Lang::get('lang.activate').'</a>';
if($status==1){ if ($status == 1) {
$html = "<a href='#' class='btn btn-primary' disabled>".Lang::get('lang.activate')."</a>"; $html = "<a href='#' class='btn btn-primary' disabled>".Lang::get('lang.activate').'</a>';
} }
return $html; return $html;
} }
public function isActivate(){ public function isActivate()
{
$check = true; $check = true;
$settings = $this->extraFieldRelation()->get(); $settings = $this->extraFieldRelation()->get();
if($settings->count()==0){ if ($settings->count() == 0) {
$check = false; $check = false;
} }
return $check; return $check;
} }
} }

View File

@@ -7,5 +7,5 @@ use App\BaseModel;
class Assign_team_agent extends BaseModel class Assign_team_agent extends BaseModel
{ {
protected $table = 'team_assign_agent'; protected $table = 'team_assign_agent';
protected $fillable = ['id', 'team_id', 'agent_id','updated_at', 'created_at']; protected $fillable = ['id', 'team_id', 'agent_id', 'updated_at', 'created_at'];
} }

View File

@@ -12,22 +12,27 @@ class Organization extends BaseModel
/* Define the fillable fields */ /* Define the fillable fields */
protected $fillable = ['id', 'name', 'phone', 'website', 'address', 'head', 'internal_notes']; protected $fillable = ['id', 'name', 'phone', 'website', 'address', 'head', 'internal_notes'];
public function userRelation()
public function userRelation(){ {
$related = "App\Model\helpdesk\Agent_panel\User_org"; $related = "App\Model\helpdesk\Agent_panel\User_org";
return $this->hasMany($related,'org_id');
return $this->hasMany($related, 'org_id');
} }
public function getUserIds(){ public function getUserIds()
{
$user_relations = $this->userRelation()->lists('user_id')->toArray(); $user_relations = $this->userRelation()->lists('user_id')->toArray();
return $user_relations; return $user_relations;
} }
public function users(){ public function users()
{
$user = new \App\User(); $user = new \App\User();
$user_ids = $this->getUserIds(); $user_ids = $this->getUserIds();
$users = $user->whereIn('id',$user_ids); $users = $user->whereIn('id', $user_ids);
return $users; return $users;
} }
} }

View File

@@ -13,10 +13,11 @@ class User_org extends BaseModel
/* define fillable fields */ /* define fillable fields */
protected $fillable = ['id', 'org_id', 'user_id']; protected $fillable = ['id', 'org_id', 'user_id'];
public function setOrgIdAttribute($value){ public function setOrgIdAttribute($value)
if($value==""){ {
if ($value == '') {
$this->attributes['org_id'] = null; $this->attributes['org_id'] = null;
}else{ } else {
$this->attributes['org_id'] = $value; $this->attributes['org_id'] = $value;
} }
} }

View File

@@ -14,53 +14,61 @@ class Emails extends BaseModel
'fetching_status', 'move_to_folder', 'delete_email', 'do_nothing', 'fetching_status', 'move_to_folder', 'delete_email', 'do_nothing',
'sending_status', 'authentication', 'header_spoofing', 'imap_config', 'sending_status', 'authentication', 'header_spoofing', 'imap_config',
]; ];
public function getCurrentDrive(){ public function getCurrentDrive()
$drive = $this->attributes['sending_protocol']; {
$drive = $this->attributes['sending_protocol'];
$mailServices = new \App\Model\MailJob\MailService(); $mailServices = new \App\Model\MailJob\MailService();
$id = ""; $id = '';
$mailService = $mailServices->where('short_name',$drive)->first(); $mailService = $mailServices->where('short_name', $drive)->first();
if($mailService){ if ($mailService) {
$id = $mailService->id; $id = $mailService->id;
} }
return $id; return $id;
} }
public function getExtraField($key){ public function getExtraField($key)
$value = ""; {
$value = '';
$id = $this->attributes['id']; $id = $this->attributes['id'];
$services = new \App\Model\MailJob\FaveoMail(); $services = new \App\Model\MailJob\FaveoMail();
$service = $services->where('email_id',$id)->where('key',$key)->first(); $service = $services->where('email_id', $id)->where('key', $key)->first();
if($service){ if ($service) {
$value = $service->value; $value = $service->value;
} }
return $value; return $value;
} }
public function extraFieldRelation(){ public function extraFieldRelation()
{
$related = "App\Model\MailJob\FaveoMail"; $related = "App\Model\MailJob\FaveoMail";
return $this->hasMany($related,'email_id');
return $this->hasMany($related, 'email_id');
} }
public function deleteExtraFields(){ public function deleteExtraFields()
{
$fields = $this->extraFieldRelation()->get(); $fields = $this->extraFieldRelation()->get();
if($fields->count()>0){ if ($fields->count() > 0) {
foreach ($fields as $field){ foreach ($fields as $field) {
$field->delete(); $field->delete();
} }
} }
} }
public function getPasswordAttribute($value){ public function getPasswordAttribute($value)
if($value){ {
if ($value) {
return \Crypt::decrypt($value); return \Crypt::decrypt($value);
} }
return $value; return $value;
} }
public function delete() { public function delete()
{
$this->deleteExtraFields(); $this->deleteExtraFields();
parent::delete(); parent::delete();
} }

View File

@@ -7,28 +7,30 @@ use Illuminate\Database\Eloquent\Model;
class Filter extends Model class Filter extends Model
{ {
protected $table = 'filters'; protected $table = 'filters';
protected $fillable = ['ticket_id','key','value']; protected $fillable = ['ticket_id', 'key', 'value'];
public function getLabelTitle($ticketid){ public function getLabelTitle($ticketid)
$filter = $this->where('ticket_id',$ticketid)->where('key','label')->first(); {
$output = []; $filter = $this->where('ticket_id', $ticketid)->where('key', 'label')->first();
if($filter && $filter->value){ $output = [];
$labelids = explode(',', $filter->value); if ($filter && $filter->value) {
$labels = new Label(); $labelids = explode(',', $filter->value);
$label = $labels->whereIn('title',$labelids)->get(); $labels = new Label();
if($label->count()>0){ $label = $labels->whereIn('title', $labelids)->get();
foreach($label as $key=>$l){ if ($label->count() > 0) {
$output[$key] = $l->titleWithColor(); foreach ($label as $key=>$l) {
} $output[$key] = $l->titleWithColor();
} }
} }
return $output; }
return $output;
}
public function getTagsByTicketId($ticketid)
{
$filter = $this->where('key', 'tag')->where('ticket_id', $ticketid)->lists('value')->toArray();
return $filter;
} }
public function getTagsByTicketId($ticketid){
$filter = $this->where('key','tag')->where('ticket_id',$ticketid)->lists('value')->toArray();
return $filter;
}
} }

View File

@@ -5,33 +5,37 @@ namespace App\Model\helpdesk\Filters;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Lang; use Lang;
class Label extends Model { class Label extends Model
{
protected $table = 'labels'; protected $table = 'labels';
protected $fillable = ['title', 'color', 'order', 'status']; protected $fillable = ['title', 'color', 'order', 'status'];
public function titleWithColor() { public function titleWithColor()
{
$title = $this->title; $title = $this->title;
$color = $this->color; $color = $this->color;
if ($title && $color) { if ($title && $color) {
return "<span class='label' style='background-color:" . $color . "; color: #FFF;'>" . $title . "</span>"; return "<span class='label' style='background-color:".$color."; color: #FFF;'>".$title.'</span>';
} else { } else {
return "--"; return '--';
} }
} }
public function status() { public function status()
{
$status = $this->status; $status = $this->status;
$output = Lang::get('lang.disabled'); $output = Lang::get('lang.disabled');
if ($status == 1) { if ($status == 1) {
$output = Lang::get('lang.enabled'); $output = Lang::get('lang.enabled');
} }
return $output; return $output;
} }
public function isChecked($ticketid) { public function isChecked($ticketid)
{
$title = $this->attributes['title']; $title = $this->attributes['title'];
$output = ""; $output = '';
$filters = new Filter(); $filters = new Filter();
$filter = $filters $filter = $filters
->where('ticket_id', $ticketid) ->where('ticket_id', $ticketid)
@@ -39,24 +43,26 @@ class Label extends Model {
->where('value', $title) ->where('value', $title)
->first(); ->first();
if ($filter && $filter->value) { if ($filter && $filter->value) {
$output = "checked"; $output = 'checked';
} }
return $output; return $output;
} }
public function assignedLabels($ticketid) { public function assignedLabels($ticketid)
$output = ""; {
$output = '';
$filters = new Filter(); $filters = new Filter();
$filter = $filters->where('ticket_id', $ticketid)->where('key', 'label')->select('value')->get(); $filter = $filters->where('ticket_id', $ticketid)->where('key', 'label')->select('value')->get();
if (count($filter) > 0) { if (count($filter) > 0) {
foreach ($filter as $fil) { foreach ($filter as $fil) {
$label = $this->where('title',$fil->value)->select('title','color')->first(); $label = $this->where('title', $fil->value)->select('title', 'color')->first();
if($label){ if ($label) {
$output .="&nbsp;&nbsp;".$label->titleWithColor()."&nbsp;&nbsp;"; $output .= '&nbsp;&nbsp;'.$label->titleWithColor().'&nbsp;&nbsp;';
} }
} }
} }
return $output; return $output;
} }
} }

Some files were not shown because too many files have changed in this diff Show More