update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Console\Commands;
use App\Http\Controllers\Client\helpdesk\UnAuthController;
use Illuminate\Console\Command;
class CloseWork extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ticket:close';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Ticket will close according to workflow';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (env('DB_INSTALL') == 1) {
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$controller = new UnAuthController($PhpMailController);
$controller->autoCloseTickets();
loging('ticket-close-workflow', 'Close ticket workflow executed', 'info');
//\Log::info('Close ticket workflow executed');
$this->info('Close ticket workflow executed');
}
}
}

View File

@@ -22,8 +22,6 @@ class SendReport extends Command
* @var string
*/
protected $description = 'Sending the report mail ';
protected $report;
protected $mail;
/**
* Create a new command instance.
@@ -32,9 +30,6 @@ class SendReport extends Command
*/
public function __construct()
{
$mail = new PhpMailController();
$report = new NotificationController($mail);
$this->report = $report;
parent::__construct();
}
@@ -46,11 +41,23 @@ class SendReport extends Command
public function handle()
{
try {
$this->report->send_notification();
\Log::info('Report has send');
$this->info('Report has send');
if (env('DB_INSTALL') == 1) {
$mail = new PhpMailController();
$mail->setQueue();
$this_report = new NotificationController($mail);
$report = $this_report->send_notification();
if ($report !== 0) {
loging('sending-mail-report', 'Report has send', 'info');
//\Log::info("Report has send");
$this->info('Report has send');
} else {
loging('sending-mail-report', 'Nothing to send', 'info');
$this->info('Nothing to send');
}
}
} catch (Exception $ex) {
dd($ex);
//dd($ex);
$this->error($ex->getMessage());
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Console\Commands;
use App\Http\Controllers\Agent\helpdesk\MailController;
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
use Event;
use Illuminate\Console\Command;
class TicketFetch extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ticket:fetch';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fetching the tickets from service provider';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (env('DB_INSTALL') == 1) {
$controller = $this->mailController();
$emails = new \App\Model\helpdesk\Email\Emails();
$settings_email = new \App\Model\helpdesk\Settings\Email();
$system = new \App\Model\helpdesk\Settings\System();
$ticket = new \App\Model\helpdesk\Settings\Ticket();
$controller->readmails($emails, $settings_email, $system, $ticket);
Event::fire('ticket.fetch', ['event' => '']);
loging('fetching-ticket', 'Ticket has read', 'info');
//\Log::info('Ticket has read');
$this->info('Ticket has read');
}
}
public function mailController()
{
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
$ticket = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
$work = new TicketWorkflowController($ticket);
$controller = new MailController($work);
return $controller;
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Console;
use App\Model\MailJob\Condition;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@@ -14,6 +15,9 @@ class Kernel extends ConsoleKernel
*/
protected $commands = [
'App\Console\Commands\Inspire',
'App\Console\Commands\SendReport',
'App\Console\Commands\CloseWork',
'App\Console\Commands\TicketFetch',
];
/**
@@ -25,12 +29,97 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
if (env('DB_INSTALL') == 1) {
$queue = $this->getCurrentQueue();
$schedule->command('queue:listen '.$queue, ['--tries' => 1])->everyMinute()->withoutOverlapping();
$this->execute($schedule, 'fetching');
$this->execute($schedule, 'notification');
$this->execute($schedule, 'work');
$this->execute($schedule, 'followup');
$this->execute($schedule, 'message');
loging('cron', 'executed successfully', 'info');
}
}
$schedule->call(function () {
$user = new User();
$user->save();
})->everyFiveMinutes();
public function execute($schedule, $task)
{
$condition = new Condition();
$command = $condition->getConditionValue($task);
switch ($task) {
case 'fetching':
$this->getCondition($schedule->command('ticket:fetch'), $command);
break;
case 'notification':
$this->getCondition($schedule->command('report:send'), $command);
break;
case 'work':
$this->getCondition($schedule->command('ticket:close'), $command);
break;
case 'followup':
$this->getCondition($schedule->command('users:followup'), $command);
break;
case 'message':
$this->getCondition($schedule->command('message:send'), $command);
break;
}
}
public function getCondition($schedule, $command)
{
$condition = $command['condition'];
$at = $command['at'];
switch ($condition) {
case 'everyMinute':
$schedule->everyMinute()->withoutOverlapping();
break;
case 'everyFiveMinutes':
$schedule->everyFiveMinutes()->withoutOverlapping();
break;
case 'everyTenMinutes':
$schedule->everyTenMinutes()->withoutOverlapping();
break;
case 'everyThirtyMinutes':
$schedule->everyThirtyMinutes()->withoutOverlapping();
break;
case 'hourly':
$schedule->hourly()->withoutOverlapping();
break;
case 'daily':
$schedule->daily()->withoutOverlapping();
break;
case 'dailyAt':
$this->getConditionWithOption($schedule, $condition, $at);
break;
case 'weekly':
$schedule->weekly()->withoutOverlapping();
break;
case 'monthly':
$schedule->monthly()->withoutOverlapping();
break;
case 'yearly':
$schedule->yearly()->withoutOverlapping();
break;
}
}
public function getConditionWithOption($schedule, $command, $at)
{
switch ($command) {
case 'dailyAt':
$schedule->dailyAt($at)->withoutOverlapping();
break;
}
}
public function getCurrentQueue()
{
$queue = 'database';
$services = new \App\Model\MailJob\QueueService();
$current = $services->where('status', 1)->first();
if ($current) {
$queue = $current->short_name;
}
return $queue;
}
}